Spaces:
Runtime error
Runtime error
ted
commited on
Commit
•
97d2fe4
1
Parent(s):
bd803d5
[fix] fix bugs
Browse files- metric-codebleu.py +13 -0
metric-codebleu.py
CHANGED
@@ -104,6 +104,19 @@ class codebleu(evaluate.Metric):
|
|
104 |
):
|
105 |
"""Returns the scores"""
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
return calc_codebleu(
|
108 |
references=references,
|
109 |
predictions=predictions,
|
|
|
104 |
):
|
105 |
"""Returns the scores"""
|
106 |
|
107 |
+
if isinstance(references, str):
|
108 |
+
references = [references]
|
109 |
+
|
110 |
+
if isinstance(references[0], str):
|
111 |
+
references = [[ref] for ref in references]
|
112 |
+
|
113 |
+
if isinstance(predictions, str):
|
114 |
+
predictions = [predictions]
|
115 |
+
|
116 |
+
assert isinstance(references, list)
|
117 |
+
assert isinstance(predictions, list)
|
118 |
+
assert len(references) == len(predictions), "The number of predictions and references must be the same."
|
119 |
+
|
120 |
return calc_codebleu(
|
121 |
references=references,
|
122 |
predictions=predictions,
|