summaryrefslogtreecommitdiff
path: root/python/psb.py
blob: 9d963f1a05572c2c213fe5bd936d8227b6f8472f (plain)
1
2
3
4
5
6
7
8
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.split()], hypothesis.split(), smoothing_function=smoothing.method2)
print("%f"%(score*100))