forked from thunlp/OpenKE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-subgraphs.sh
executable file
·80 lines (71 loc) · 1.94 KB
/
test-subgraphs.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
#!/bin/sh
if [ "$#" -lt 4 ];
then
echo "usage: $0 -m model -d db -r RecordsToTest -k [-1, -2, 10]. Found $#"
exit
fi
for (( i=1; i<=$#; i++ ))
do
arg=${@:$i:1} # Gets the string i
val=${@:$i+1:1} # Gets the string i+1
case $arg in
-m)
E=$val
((i++))
;;
--model=*)
# Split at = char and remove the shortest match from beginning
E=${arg#*=}
;;
-d)
DB=$val
((i++))
;;
--db=*)
DB=${arg#*=}
;;
-r)
R=$val
((i++))
;;
--record-test=*)
R=${arg#*=}
;;
-k)
K=$val
((i++))
;;
-s)
S=$val
((i++))
;;
--score-func=*)
S=${arg#*=}
;;
*)
echo "Unknown argument number $i: '$arg'"
;;
esac
done
# Result Directory
RD="/var/scratch/dvs254/OpenKE-results/"
#for E in "transe" "rotate" "complex"
#do
#for DB in "fb15k237" "dbpedia50"
#do
RDB=$RD"$DB/"
RDE=$RDB"embeddings/" # contains file in the name format : db-model.json
RDD=$RDB"data/" # contains files in the name format fb15k237-transe-training-topk-10.pkl (embedding features) or .json (raw answers)
RDM=$RDB"models/"
RDS=$RDB"subgraphs/"
#for K in -2 #10 -1 # is for dynamic K, -2 is for dynamic threshold
#do
emb_file=$RDE"$DB-$E.json"
sub_file=$RDS"$DB-$E-subgraphs-tau-10.pkl"
sub_emb_dir=$RDS
test_file="./benchmarks/$DB/test2id.txt"
train_file="./benchmarks/$DB/train2id.txt"
edict_file="/var/scratch/dvs254/OpenKE-results/$DB/misc/$DB-id-to-entity.pkl"
rdict_file="/var/scratch/dvs254/OpenKE-results/$DB/misc/$DB-id-to-relation.pkl"
echo "Calling Python script"
python test_subgraphs.py --testfile $test_file --embfile $emb_file --subfile $sub_file --subembdir $sub_emb_dir --topk $K --db $DB --trainfile $train_file --model $E -stp 0.01 --entdict $edict_file --reldict $rdict_file --testonly $R --score $S