tensorflow / nmt

TensorFlow Neural Machine Translation Tutorial
Apache License 2.0
6.36k stars 1.96k forks source link

How to get the BLEU value of the test corpus #361

Closed yapingzhao closed 5 years ago

yapingzhao commented 6 years ago

Hi, python -m nmt.nmt \ --out_dir=/tmp/nmt_model \ --inference_input_file=/tmp/my_infer_file.vi \ --inference_output_file=/tmp/nmt_model/output_infer --vocab_prefix=/tmp/vocab Run the above command to get the translated translation, but there is no BLEU value, how to get the BLEU value, what is the command?

Looking forward to your advice or answers. Best regards, Thank you very much!

durson commented 6 years ago

Hello, in my project I did it in a following way:

  1. Create script named nmt/eval_bleu.py from .utils import evaluation_utils import sys ref = sys.argv[1] hyp = sys.argv[2] print(evaluation_utils.evaluate(ref, hyp, 'bleu'))

  2. Run it python3 -m nmt.eval_bleu <reference file> <translation file>

yapingzhao commented 6 years ago

@durson Thank you very much.