-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrunLocal_DLV2_SHACL.sh
92 lines (75 loc) · 2.05 KB
/
runLocal_DLV2_SHACL.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
#!/bin/bash
ROOT_PATH=$(pwd)
DLV2_PATH="DLV2"
SHACL_PATH="SHACL/SHACL_files"
EXE_PATH=$DLV2_PATH
CORPUS_PATH="CORPUS"
CMD="/usr/bin/time -v ./dlv2 ./dlv2SparqlABoxEndpoint.asp ./rules.asp"
DEBUG=1
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
if [ -z "$1" ]; then
echo "No argument supplied"
echo "USAGE: sh runLocal_DLV2_SHACL.sh [dlv2|shacl] [debug]"
echo "EXAMPLE: sh runLocal_DLV2_SHACL.sh dlv2"
exit 1
elif [ $1 = "shacl" ]; then
EXE_PATH=$SHACL_PATH
cd $EXE_PATH
javac -cp .:./lib/* DetectViolationsOnCorpus.java
cd $ROOT_PATH
CMD="/usr/bin/time -v java -cp .:./lib/* -Dfile.encoding=utf-8 DetectViolationsOnCorpus licenceusecaseTBox.owl riolOntology.owl regulativerules.ttl compliancerules.ttl"
elif [ $1 = "dlv2" ]; then
CMD="/usr/bin/time -v ./dlv2 ./rules_local.asp"
else
echo "Argument not valid"
exit 1
fi
if [ -z "$2" ]; then
DEBUG=0
RED=''
GREEN=''
NC=''
elif [ "$2" = "csv" ]; then
DEBUG=2
RED=''
GREEN=''
NC=''
elif [ "$2" = "first" ]; then
DEBUG=3
RED=''
GREEN=''
NC=''
echo "OK " $DEBUG
fi
RESULT_FILE="results_$1_local.txt"
files=$(ls -v $CORPUS_PATH)
rm $RESULT_FILE
total_time=0
if [ $DEBUG -ne 2 ]; then
echo "Instance,Reasoner,Type,Time"
fi
for F in $files; do
cd $ROOT_PATH
cd $EXE_PATH
if [ $DEBUG -eq 1 ]; then
>&2 echo "EXECUTING $1 WITH $F"
pwd
>&2 echo $CMD "$ROOT_PATH/$CORPUS_PATH/$F >> $ROOT_PATH/$RESULT_FILE 2>&1"
fi
# START REASONER LOCALLY AND COMPUTE EXECUTION TIME
start=`date +%s.%N`
$CMD $ROOT_PATH/$CORPUS_PATH/$F >> $ROOT_PATH/$RESULT_FILE 2>&1
end=`date +%s.%N`
current_time=`echo "$end - $start" | bc | sed 's/^\./0./'`
total_time=`echo "$current_time + $total_time" | bc | sed 's/^\./0./'`
if [ $DEBUG -eq 1 ]; then
>&2 echo "Execution Time: END:" $end " START " $start " CURRENT: " $current_time
fi
echo "${RED}$F,$1,local,${GREEN}$current_time${NC}"
cd $ROOT_PATH
done
if [ $DEBUG -lt 2 ]; then
echo 'Total Time:' $total_time
fi