-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevaluate-wiki.sh
executable file
·86 lines (74 loc) · 1.75 KB
/
evaluate-wiki.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
#!/bin/bash
DIR="/data/data_hellrich/tmp/emnlp2018/"
FREQUENT="$DIR/wiki_1000_most_frequent"
CORPUS="wiki"
function eval_pmi {
for x in $DIR/pmi/$CORPUS
do
for y in $x/*v0 #assumes everything ready
do
base=${y::-2}
normal=$(./evaluate-variant.sh $FREQUENT SVD svd_pmi "$base"v*)
bootstrapped=$(./evaluate-variant.sh $FREQUENT SVD svd_pmi "$base"b*)
labels=${base/*\//};
label1=${labels::-4}
label2=${labels:3:-1}
echo "SVD $CORPUS $label1 $label2 n $normal"
echo "SVD $CORPUS $label1 $label2 b $bootstrapped"
done
done
}
function eval_sgns {
for x in $DIR/sgns/$CORPUS
do
for y in $x/*v0 #assumes everything ready
do
base=${y::-2}
normal=$(./evaluate-variant.sh $FREQUENT SGNS sgns "$base"v*)
bootstrapped=$(./evaluate-variant.sh $FREQUENT SGNS sgns "$base"b*)
labels=${base/*\//};
label1=${labels::-4}
label2=${labels:3:-1}
echo "SGNS $CORPUS $label1 $label2 n $normal"
echo "SGNS $CORPUS $label1 $label2 b $bootstrapped"
done
done
}
function correct_names {
for y in $@
do
mv $y/vectors.txt.npy $y/vectors.words.npy 2>/dev/null
mv $y/vectors.txt.vocab $y/vectors.words.vocab 2>/dev/null
done
}
function eval_glove {
for x in $DIR/glove/$CORPUS
do
for y in $x/*v0 #assumes everything ready
do
base=${y::-2}
correct_names "$base"v*
correct_names "$base"b*
normal=$(./evaluate-variant.sh $FREQUENT SGNS vectors "$base"v*)
bootstrapped=$(./evaluate-variant.sh $FREQUENT SGNS vectors "$base"b*)
label1=ws
label2=ww
echo "GloVe $CORPUS $label1 $label2 n $normal"
echo "GloVe $CORPUS $label1 $label2 b $bootstrapped"
done
done
}
case $1 in
pmi)
eval_pmi
;;
glove)
eval_glove
;;
sgns)
eval_sgns
;;
*)
echo "ERROR, choose pmi, glove or sgns"
exit 1
esac