-
Notifications
You must be signed in to change notification settings - Fork 391
/
eval_wmt_ende.sh
executable file
·42 lines (33 loc) · 1.15 KB
/
eval_wmt_ende.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
#!/bin/bash
if [ $# -eq 0 ]
then
echo "usage: $0 <data_dir>"
exit 1
fi
DATA_PATH=$1
SP_PATH=/usr/local/bin
runconfig=wmt_ende_transformer
testset=newstest2017-ende
sl=en
tl=de
export PATH=$SP_PATH:$PATH
export CUDA_VISIBLE_DEVICES=0
wget -nc https://raw.githubusercontent.com/OpenNMT/OpenNMT-tf/master/third_party/input-from-sgm.perl
wget -nc https://raw.githubusercontent.com/OpenNMT/OpenNMT-tf/master/third_party/multi-bleu-detok.perl
perl input-from-sgm.perl < $DATA_PATH/test/$testset-src.$sl.sgm \
| spm_encode --model=data/wmt$sl$tl.model > data/$testset-src.$sl
perl input-from-sgm.perl < $DATA_PATH/test/$testset-ref.$tl.sgm > data/$testset-ref.$tl
if true; then
onmt-main \
--config config/wmt_ende.yml --auto_config \
--checkpoint_path=$runconfig/avg \
infer \
--features_file data/$testset-src.$sl \
> data/$testset-src.hyp.$tl
fi
if true; then
spm_decode --model=data/wmt$sl$tl.model --input_format=piece \
< data/$testset-src.hyp.$tl \
> data/$testset-src.hyp.detok.$tl
perl multi-bleu-detok.perl data/$testset-ref.$tl < data/$testset-src.hyp.detok.$tl
fi