-
Notifications
You must be signed in to change notification settings - Fork 26
/
run_mono.sh
executable file
·62 lines (52 loc) · 1.23 KB
/
run_mono.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
#!/bin/bash
if [[ $# -lt 8 || $# -gt 9 ]]; then
echo "`basename $0` remake outputDir trainFile lang dim numIters numThreads neg [otherOpts]"
echo "remake=1: to re-make the code again"
echo "neg=0: use hierarchical softmax"
exit
fi
remake=$1
outputDir=$2
trainFile=$3
lang=$4
dim=$5
numIter=$6
numThreads=$7
neg=$8
otherOpts=""
if [ $# -ge 9 ]; then
otherOpts=${9}
fi
if [ $neg -gt 0 ]; then
negStr="-negative $neg -hs 0"
else
negStr="-negative 0 -hs 1"
fi
echo "negStr=$negStr"
VERBOSE=1
function execute_check {
file=$1
cmd=$2
if [[ -f $file || -d $file ]]; then
echo ""
echo "! File/directory $file exists. Skip."
else
echo ""
if [ $VERBOSE -eq 1 ]; then
echo "# Executing: $cmd"
fi
eval $cmd
fi
}
# check outDir exists
echo "# outputDir=$outputDir"
execute_check $outputDir "mkdir -p $outputDir"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "# Script dir = $SCRIPT_DIR"
execute_check "" "cd $SCRIPT_DIR"
if [ $remake -eq 1 ]
then
make clean
make
fi
execute_check "" "time $SCRIPT_DIR/bivec -src-train $trainFile -src-lang $lang -output $outputDir/model -cbow 0 -size $dim -window 5 $negStr -sample 1e-5 -threads $numThreads -binary 0 -iter $numIter $otherOpts"