From f4fca383b61034ea7b0432d3ef1c2c00174658d4 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 4 Jul 2017 21:09:02 +0200 Subject: nltk per-sentence BLEU --- python/psb.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 python/psb.py (limited to 'python') diff --git a/python/psb.py b/python/psb.py new file mode 100644 index 0000000..2d575fa --- /dev/null +++ b/python/psb.py @@ -0,0 +1,9 @@ +import nltk +from nltk.translate.bleu_score import SmoothingFunction +smoothing = SmoothingFunction() + +hypothesis = open('in').read().strip() +reference = open('ref').read().strip() +score = nltk.translate.bleu_score.sentence_bleu([reference], hypothesis, smoothing_function=smoothing.method0) +print("%f"%(score*100)) + -- cgit v1.2.3