diff options
author | Patrick Simianer <p@simianer.de> | 2017-07-04 21:09:02 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2017-07-04 21:09:02 +0200 |
commit | f4fca383b61034ea7b0432d3ef1c2c00174658d4 (patch) | |
tree | 3acf1c405f29bedb4396424cb96038ee5efd67fc /python | |
parent | 266d81d50413863ab80cc3328b2548d36c3a1298 (diff) |
nltk per-sentence BLEU
Diffstat (limited to 'python')
-rw-r--r-- | python/psb.py | 9 |
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)) + |