Created
June 23, 2018 21:08
-
-
Save felipessalvatore/ea5be8069c48c817bae675b31cd0c76b to your computer and use it in GitHub Desktop.
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
from nltk.translate.bleu_score import sentence_bleu, brevity_penalty, SmoothingFunction | |
reference = [ "In the farm's afternoons there is too much blue".split(" ") ] | |
candidate = "In the afternoons of the farm there is too much blue".split(" ") | |
score = sentence_bleu(reference, candidate) | |
print("candidate1") | |
print(score) | |
print(len(reference[0]), len(candidate)) | |
print("BP = {}".format(brevity_penalty(len(reference[0]), len(candidate)))) | |
candidate = "In the farm's afternoons there is a lot of blue".split(" ") | |
score = sentence_bleu(reference, candidate) | |
print("candidate2") | |
print(score) | |
print(len(reference[0]), len(candidate)) | |
print("BP = {}".format(brevity_penalty(len(reference[0]), len(candidate)))) | |
candidate = "The farm's afternoons are blue".split(" ") | |
score = sentence_bleu(reference, candidate) | |
print("candidate3") | |
print(score) | |
print(len(reference[0]), len(candidate)) | |
print("BP = {}".format(brevity_penalty(len(reference[0]), len(candidate)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment