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