File size: 978 Bytes
158b61b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
BASE="output-translation/flores"

# Path to Input file
INP="input-files/flores/hin.devtest"
# INP=$BASE"/input.txt"
LOW=$BASE"/test-low.hi"
TOK=$BASE"/test-tok.hi"
BPEI=$BASE"/test-hyp-i.hi"
BPE=$BASE"/test-hyp.hi"
TRANS=$BASE"/test.en"

# Path to Output file
OUT=$BASE"/test-flores.en"

MODEL="hi-en/model.pt"
CODES="hi-en/bpe-codes/bpe-codes.hi"

python3 tools/indic_nlp_library/indicnlp/normalize/indic_normalize.py $INP $LOW hi

python3 tools/indic_nlp_library/indicnlp/tokenize/indic_tokenize.py $LOW $TOK hi

python3 apply_bpe.py -c $CODES < $TOK > $BPEI

python3 merge_bpe_word.py $BPEI $TOK $BPE

CUDA_VISIBLE_DEVICES=0 python3 /home/development/akashb/web-service/OpenNMT-py/translate.py --gpu 0 --model $MODEL --src $BPE --output $TRANS

# onmt_translate -model $MODEL -src $BPE -output $TRANS -gpu 0

sed -r -i 's/(@@ )|(@@ ?$)//g; s/ ▁//g' $TRANS

tools/mosesdecoder/scripts/tokenizer/detokenizer.perl < $TRANS > $OUT

rm $LOW
# rm $TOK
rm $BPE
rm $BPEI
rm $TRANS