Last active
December 25, 2017 08:13
-
-
Save prakhar21/bbfc1e08b4cfc62329a77e719ae920c9 to your computer and use it in GitHub Desktop.
BLEU Score calculation
This file contains 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
#!/usr/bin/env python | |
from nltk.translate.bleu_score import sentence_bleu | |
def perfect(): | |
machine_translation = "this blog talks about scoring machine translated text" | |
machine_trans = machine_translation.split() | |
reference_translation = "this blog talks about scoring machine translated text" | |
reference_trans = [reference_translation.split()] | |
score = sentence_bleu(reference_trans,machine_trans) | |
return score | |
def imperfect(): | |
machine_translation = "the quick brown fox" | |
machine_trans = machine_translation.split() | |
reference_translation = "this blog talks about scoring machine translated text" | |
reference_trans = [reference_translation.split()] | |
score = sentence_bleu(reference_trans,machine_trans) | |
return score | |
if __name__ == '__main__': | |
print perfect() | |
print imperfect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment