-
Notifications
You must be signed in to change notification settings - Fork 1
/
distributional.sh
executable file
·70 lines (63 loc) · 1.64 KB
/
distributional.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
if [ "$#" -lt 5 ]; then
echo "Usage: distributional.sh <corpus> <vocab> <pairs> <ppmi-rep-base> <svd-rep-base> (extra args)"
echo ""
echo "Corpus must already exists, the rest of the files are generated by this script."
echo
echo "This will generate: "
echo ""
echo "<vocab>"
echo "<pairs>"
echo
echo "<ppmi-rep-base>.contexts.vocab"
echo "<ppmi-rep-base>.words.vocab"
echo "<ppmi-rep-base>.npz"
echo
echo "<svd-rep-base>.contexts.vocab"
echo "<svd-rep-base>.words.vocab"
echo "<svd-rep-base>.vt.npy"
echo "<svd-rep-base>.ut.npy"
echo "<svd-rep-base>.s.npy"
echo
echo "These can be used by hyperword"
echo
echo
echo "Extra arguments are similar to hyperword:"
echo
echo "--thr (default: 100)"
echo "--rank (default: 500)"
echo "--win (default: 2)"
echo "--sub (default: 0)"
echo "--cds (default: 0.75f)"
echo "--pos (default: false)"
echo "--dyn (default: false)"
echo "--del (default: false)"
echo "--neg (default: 0)"
exit 0
fi
corpus=$1
vocab=$2
pairs=$3
ppmi=$4
svd=$5
echo $corpus
echo $@
shift 5
./build/default/test/count $corpus $vocab $pairs $ppmi.mm $svd $@
if [ $? -eq 0 ]; then
echo "Done with calculation, massaging files for hyperword"
else
echo "Something went wrong"
exit 1
fi
python convertTXT.py $svd.ut.txt $svd.ut.npy
rm $svd.ut.txt
python convertTXT.py $svd.vt.txt $svd.vt.npy
rm $svd.vt.txt
python convertTXT.py $svd.s.txt $svd.s.npy
rm $svd.s.txt
python convertMM.py $ppmi.mm $ppmi.npz
#rm $ppmi.mm
cp $vocab $svd.contexts.vocab
cp $vocab $svd.words.vocab
cp $vocab $ppmi.contexts.vocab
cp $vocab $ppmi.words.vocab