forked from kba/infolis-dbminer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-on-all.sh
executable file
·68 lines (61 loc) · 1.96 KB
/
run-on-all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
DATASETS_ROOT=${DATASETS_ROOT:-$HOME/infolis-datasets/datasets}
declare -A dataset_names=(
[replication-wiki]="$DATASETS_ROOT/replication-wiki/text/all"
[ssoar]="$DATASETS_ROOT/ssoar/text/all"
[mpra]="$DATASETS_ROOT/mpra/text/all"
[econstor]="$DATASETS_ROOT/econstor/text/all"
[econstor2000]="$DATASETS_ROOT/econstor/text/first2000"
)
declare -A filemeta=(
[$DATASETS_ROOT/replication-wiki/text/all]="$DATASETS_ROOT/replication-wiki/meta"
[$DATASETS_ROOT/ssoar/text/all]="$DATASETS_ROOT/ssoar/meta"
[$DATASETS_ROOT/mpra/text/all]="$DATASETS_ROOT/mpra/meta"
[$DATASETS_ROOT/econstor/text/all]="$DATASETS_ROOT/econstor/meta"
[$DATASETS_ROOT/econstor/text/first2000]="$DATASETS_ROOT/econstor/meta"
)
declare -A patternsets=(
[dara]="import/dara-solr.json"
[db]="import/databases.json"
[icpsr]="import/icpsr-studies.json"
)
timestamp() {
date -Iseconds | sed 's/[^0-9]\+/-/g'
}
usage () {
echo "$(basename $0) <patternset> [dataset...]
Patternsets: ${!patternsets[*]}
Datasets: ${!dataset_names[*]}
DATASETS_ROOT: $DATASETS_ROOT
"
}
main () {
declare -a datasets
patternset="$1"; shift;
if [[ -z "$patternset" || -z "${patternsets[$patternset]}" ]];then
echo "no such patternset '$patternset'"
usage
exit 1
fi
if [[ -z "$1" ]];then
datasets=("${!dataset_names[@]}")
else
datasets=("$@")
fi
local fm
for fm in "${datasets[@]}";do
if [[ -z "${dataset_names[$fm]}" ]];then
echo "No such dataset '${fm}'"
usage
exit 2
fi
done
local dataset textdir metadir outfile
for dataset in "${datasets[@]}";do
textdir="${dataset_names[$dataset]}"
metadir="${filemeta[$textdir]}"
outfile="output-${dataset}-${patternset}-$(timestamp).json"
./dbminer.py search-patterns "${patternsets[$patternset]}" "$textdir" "$metadir" "$outfile"
done
}
main "$@"