Created
March 24, 2017 08:35
-
-
Save rmeertens/fcd35f62696172aefcfd28094d9afabc to your computer and use it in GitHub Desktop.
I wanted to know more about the BLEU score, so did this experiment:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nltk | |
reference = "today I go cycling".split() | |
references = [reference] | |
hypothesis_strings = ["today I go cycling", | |
"today I go biking", | |
"today , I go cycling", | |
"today I go ride my bike", | |
"today I go bicycles", | |
"today I go fietsen", | |
"today I go refrigerator"] | |
longest_sentence_length = max([len(s) for s in hypothesis_strings]) | |
for hypothesis in hypothesis_strings: | |
bluescore = nltk.translate.bleu_score.sentence_bleu(references,hypothesis.split()) | |
print("%s %f" % (hypothesis.ljust(longest_sentence_length), bluescore)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment