-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathspotlight.sh
executable file
·55 lines (48 loc) · 2 KB
/
spotlight.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
#!/bin/sh
LANG=$1
MODELFOLDER=/opt/spotlight
cd $MODELFOLDER
DIRECTORY=/opt/spotlight/models/$LANG
echo "Selected language: $LANG"
if [ -d "$DIRECTORY" ]
then
echo "/opt/spotlight/$LANG http://0.0.0.0:80/rest/"
if [[ $LANG == "en" ]]
then
java -Dfile.encoding=UTF-8 -Xmx15G -jar /opt/spotlight/dbpedia-spotlight.jar /opt/spotlight/models/$LANG http://0.0.0.0:80/rest
else
java -Dfile.encoding=UTF-8 -Xmx10G -jar /opt/spotlight/dbpedia-spotlight.jar /opt/spotlight/models/$LANG http://0.0.0.0:80/rest
fi
else
QUERY="PREFIX dataid: <https://dataid.dbpedia.org/databus#>
PREFIX dataid-cv: <https://dataid.dbpedia.org/databus-cv#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX dcat: <http://www.w3.org/ns/dcat#>
SELECT DISTINCT ?file WHERE {
?dataset dataid:artifact <https://databus.dbpedia.org/dbpedia/spotlight/spotlight-model> .
?dataset dcat:distribution ?distribution .
{
?distribution dct:hasVersion ?latestVersion
{
SELECT (?version as ?latestVersion) WHERE {
?dataset dataid:artifact <https://databus.dbpedia.org/dbpedia/spotlight/spotlight-model> .
?dataset dct:hasVersion ?version .
} ORDER BY DESC (?version) LIMIT 1
}
?distribution dataid-cv:lang '$LANG' .
}
?distribution dcat:downloadURL ?file .
}"
RESULT=`curl --data-urlencode query="$QUERY" -H 'accept:text/tab-separated-values' https://databus.dbpedia.org/sparql | sed 's/"//g' | grep -v "^file$" | head -n 1`
echo $RESULT
curl -LO $RESULT
tar -C /opt/spotlight/models -xvf spotlight-model_lang=$LANG.tar.gz
rm spotlight-model_lang=$LANG.tar.gz
echo "/opt/spotlight/models/$LANG http://0.0.0.0:80/rest/"
if [[ $LANG == "en" ]]
then
java -Dfile.encoding=UTF-8 -Xmx15G -jar /opt/spotlight/dbpedia-spotlight.jar /opt/spotlight/models/$LANG http://0.0.0.0:80/rest
else
java -Dfile.encoding=UTF-8 -Xmx10G -jar /opt/spotlight/dbpedia-spotlight.jar /opt/spotlight/models/$LANG http://0.0.0.0:80/rest
fi
fi