-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_aksw.sh
49 lines (36 loc) · 1.59 KB
/
import_aksw.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
#!/bin/bash
# Variables to hold URLs and filenames
NT_FILE_URL="https://raw.githubusercontent.com/AKSW/aksw.org-model/main/aksw.org.nt"
GRAPH_FILE_URL="https://raw.githubusercontent.com/AKSW/aksw.org-model/main/aksw.org.nt.graph"
NT_FILE="aksw.nt"
GRAPH_FILE="aksw.graph"
TDB_DIRECTORY="./db_storage/databases/1/"
TEMP_SPARQL_FILE="drop_graph.sparql"
docker stop semantic-toolstack-library-db-1
sleep 1s
# Download the .nt and .graph files
echo "Downloading .nt file..."
curl -o $NT_FILE $NT_FILE_URL
echo "Downloading .graph file..."
curl -o $GRAPH_FILE $GRAPH_FILE_URL
# Extract the named graph URI from the .graph file
NAMED_GRAPH_URI=$(head -n 1 $GRAPH_FILE)
# Check if the named graph URI was found
if [ -z "$NAMED_GRAPH_URI" ]; then
echo "Error: No named graph URI found in the .graph file."
exit 1
fi
echo "Named Graph URI found: $NAMED_GRAPH_URI"
# Create a temporary SPARQL file to drop the existing named graph
echo "Creating SPARQL file to drop the existing named graph..."
echo "DROP GRAPH <$NAMED_GRAPH_URI>;" > $TEMP_SPARQL_FILE
# Drop the existing named graph (if it exists)
echo "Dropping the existing named graph..."
sudo ~/Documents/apache-jena-5.1.0/bin/tdb2.tdbupdate --loc=$TDB_DIRECTORY --update=$TEMP_SPARQL_FILE
# Import the converted .nt file into TDB with the specified named graph
echo "Importing the converted .nt file into TDB..."
sudo ~/Documents/apache-jena-5.1.0/bin/tdb2.tdbloader --graph=$NAMED_GRAPH_URI --loc=$TDB_DIRECTORY $NT_FILE
echo "Import completed."
# Clean up temporary files
rm $NT_FILE $GRAPH_FILE $TEMP_SPARQL_FILE
docker start semantic-toolstack-library-db-1