Spaces:
Runtime error
Runtime error
Create utils.py
Browse files
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)
|