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))