summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2017-07-04 21:09:02 +0200
committerPatrick Simianer <p@simianer.de>2017-07-04 21:09:02 +0200
commitf4fca383b61034ea7b0432d3ef1c2c00174658d4 (patch)
tree3acf1c405f29bedb4396424cb96038ee5efd67fc
parent266d81d50413863ab80cc3328b2548d36c3a1298 (diff)
nltk per-sentence BLEU
-rw-r--r--python/psb.py9
1 files changed, 9 insertions, 0 deletions
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))
+