-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathevaluate.sh
executable file
·60 lines (51 loc) · 1.56 KB
/
evaluate.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
model=$1
source=$2
target=$3
OPENNMT=/mnt/disk/afm/OpenNMT-py
SCRIPTS="`cd $(dirname $0);pwd`"
gpu=0
dump_attention=true #false
# Set use_fertility_type=true to try out the predicted fertilities
# on a model trained with actual fertilities.
use_fertility_type=false #true
fertility_type=predicted
use_attn_transform=false
attn_transform=constrained_softmax
c_attn=0.2
beam=10
srclang=ro
tgtlang=en
langpair=${srclang}-${tgtlang}
align=data/${langpair}/corpus.bpe.${langpair}.forward.align
train_src=data/${langpair}/corpus.bpe.${srclang}
extra_flags=""
if ${dump_attention}
then
extra_flags="${extra_flags} -tgt ${target} -dump_attn"
fi
if ${use_fertility_type}
then
extra_flags="${extra_flags} -fertility_type ${fertility_type}"
fi
if ${use_attn_transform}
then
extra_flags="${extra_flags} -attn_transform ${attn_transform} -c_attn ${c_attn}"
fi
for alpha in 0 # 0.2 0.4 0.6 0.8 1
do
for beta in 0 # 0.2 0.4 0.6 0.8 1
do
cd ${OPENNMT}
python -u translate.py -model $model -src $source -output $target.pred \
-beam_size $beam -batch_size 1 -coverage_penalty wu -length_penalty wu \
-alpha ${alpha} -beta ${beta} -min_attention 0.1 ${extra_flags} \
-replace_unk -verbose -gpu $gpu
sed -r 's/(@@ )|(@@ ?$)//g' $target.pred > $target.pred.merged
sed -r 's/(@@ )|(@@ ?$)//g' $target > $target.merged
echo ""
echo "alpha = $alpha, beta = $beta"
cd ${SCRIPTS}
perl multi-bleu.perl -lc $target.merged < $target.pred.merged
java -Xmx2G -jar meteor-1.5/meteor-1.5.jar $target.pred.merged $target.merged -l $tgtlang | tail -1
done
done