student2222333051 commited on
Commit
98c81b1
·
verified ·
1 Parent(s): 8e796c0

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +7 -0
utils.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction
2
+
3
+ def compute_bleu(reference, hypothesis):
4
+ smoothie = SmoothingFunction().method4
5
+ ref = [reference.split()]
6
+ hyp = hypothesis.split()
7
+ return sentence_bleu(ref, hyp, smoothing_function=smoothie)