Update seq2seq_utils.py (#51)

Found a mistake with calculation of BLEU Score.
This commit is contained in:
Hamel Husain 2018-03-18 12:25:58 -07:00 committed by k8s-ci-robot
parent 45255b52e3
commit 2ec3b03ed4
1 changed files with 5 additions and 1 deletions

View File

@ -419,7 +419,11 @@ class Seq2Seq_Inference(object):
actual.append(self.pp_title.process_text([holdout_titles[i]])[0])
predicted.append(self.pp_title.process_text([yhat])[0])
# calculate BLEU score
logging.warning('Calculating BLEU.')
bleu = corpus_bleu(actual, predicted)
#must be careful with nltk api for corpus_bleu!,
# expects List[List[List[str]]] for ground truth, using List[List[str]] will give you
# erroneous results.
bleu = corpus_bleu([[a] for a in actual], predicted)
return bleu