-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanhalytics.sh
executable file
·205 lines (188 loc) · 6.03 KB
/
anhalytics.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/bin/bash
# OPTIONS:
# -help print command line options
# -harvestDaily harvest the publications of the yesterday
# -harvest harvest the publications, if no date limitation process all repository content
# -grobid extract TEIs from the downladed binaries buildTei
# -buildTei build the corpus tei containing the mtds and the fulltext tei
# -annotate process named entities using the NERD service
# -index {tei|annotation} index either the full tei or annotation into ES
# -dFromDate "yyyy-mm-dd" set/filter records to process by starting date
# -dUntilDate "yyyy-mm-dd" set/filter records to process by ending date
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=`which java`
fi
if [ ! -x "$JAVA" ]; then
echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
exit 1
fi
# Print command line usage / help
usage() {
echo "Usage: $0 [-action] [args]"
echo " -help print command line options"
echo " -harvestDaily harvest the publications of the yesterday"
echo " -harvest harvest the publications, if no date limitation process all repository content"
echo " -grobid extract TEIs from the downladed binaries buildTei"
echo " -mineData extract data from teis and insert them into DB"
echo " -generateTei build the corpus tei containing the mtds and the fulltext tei"
echo " -annotate process named entities using the NERD service"
echo " -index {tei|annotation} index either the full tei or annotation into ES"
echo " -dFromDate yyyy-mm-dd set/filter records to process by starting date"
echo " -dUntilDate yyyy-mm-dd set/filter records to process by ending date"
}
array_contains2 () {
local in=1
local array="$1[@]"
local seeking=$2
for element in "${!array}"; do
if [[ $element == $seeking ]]; then
in=0
break
fi
done
return $in
}
check_dates_option(){
dates=("-dFromDate" "-dUntilDate")
if array_contains2 dates "$1" || [ -z "$1" ]
then return 0
else return 1
fi
}
for p in ./anhalytics-*/build/libs/
do
if [ "$(ls -A $p)" ]; then
continue;
else
echo "Make sur the project is compiled."
exit 0
fi
done
for m in ./anhalytics-*/build/libs/*-onejar.jar
do
if [[ $m == *"harvest"* ]]
then
modules[0]=$m
elif [[ $m == *"annotate"* ]]
then
modules[1]=$m
elif [[ $m == *"index"* ]]
then
modules[2]=$m
elif [[ $m == *"commons"* ]]
then
modules[3]=$m
elif [[ $m == *"kb"* ]]
then
modules[4]=$m
fi
done
while true;
do
case $1 in
-help)
usage
exit 0
;;
--configure)
"$JAVA" -Xmx2048m -jar "${modules[3]}" --configure
exit 0
;;
--prepare)
"$JAVA" -Xmx2048m -jar "${modules[3]}" --prepare
exit 0
;;
--harvestDaily)
"$JAVA" -Xmx2048m -jar "${modules[0]}" -exe harvestDaily
exit 0
;;
--harvest)
if check_dates_option "$2" || check_dates_option "$4"
then
"$JAVA" -Xmx2048m -jar "${modules[0]}" -exe harvestAll $2 $3 $4 $5
else usage
fi
exit 0
;;
--processGrobid)
if check_dates_option "$2" || check_dates_option "$4"
then
"$JAVA" -Xmx2048m -jar "${modules[0]}" -exe processGrobid $2 $3 $4 $5
else usage
fi
exit 0
;;
--harvestDOI)
if check_dates_option "$2" || check_dates_option "$4"
then
"$JAVA" -Xmx2048m -jar "${modules[0]}" -exe harvestDOI $2 $3 $4 $5
else usage
fi
exit 0
;;
--generateTei)
if check_dates_option "$2" || check_dates_option "$4"
then
"$JAVA" -Xmx2048m -jar "${modules[0]}" -exe generateTei $2 $3 $4 $5
else usage
fi
exit 0
;;
--annotate)
if check_dates_option "$2" || check_dates_option "$4"
then
"$JAVA" -Xmx2048m -jar "${modules[1]}" -exe annotateAll -multiThread $2 $3 $4 $5
else usage
fi
exit 0
;;
--annotateNerd)
if check_dates_option "$2" || check_dates_option "$4"
then
"$JAVA" -Xmx2048m -jar "${modules[1]}" -exe annotateAllNerd -multiThread $2 $3 $4 $5
else usage
fi
exit 0
;;
--annotateKeyterm)
if check_dates_option "$2" || check_dates_option "$4"
then
"$JAVA" -Xmx2048m -jar "${modules[1]}" -exe annotateAllKeyTerm -multiThread $2 $3 $4 $5
else usage
fi
exit 0
;;
--buildKb)
if check_dates_option "$2" || check_dates_option "$4"
then
"$JAVA" -Xmx2048m -jar "${modules[4]}" -exe initKnowledgeBase $2 $3 $4 $5
else usage
fi
exit 0
;;
--buildBiblioKb)
if check_dates_option "$2" || check_dates_option "$4"
then
"$JAVA" -Xmx2048m -jar "${modules[4]}" -exe initCitationKnowledgeBase $2 $3 $4 $5
else usage
fi
exit 0
;;
--index)
arr=("Metadata" "Fulltext" "Annotations" "KB")
if array_contains2 arr "$2"
then
"$JAVA" -Xmx2048m -jar "${modules[2]}" -exe index$2
else usage
fi
exit 0
;;
*)
echo "Error parsing argument $1!" >&2
usage
exit 1
;;
esac
done