Spaces:
Running
Running
Update Space (evaluate main: dfdd0cc0)
Browse files- google_bleu.py +18 -6
google_bleu.py
CHANGED
@@ -131,12 +131,20 @@ class GoogleBleu(evaluate.EvaluationModule):
|
|
131 |
description=_DESCRIPTION,
|
132 |
citation=_CITATION,
|
133 |
inputs_description=_KWARGS_DESCRIPTION,
|
134 |
-
features=
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
)
|
141 |
|
142 |
def _compute(
|
@@ -147,6 +155,10 @@ class GoogleBleu(evaluate.EvaluationModule):
|
|
147 |
min_len: int = 1,
|
148 |
max_len: int = 4,
|
149 |
) -> Dict[str, float]:
|
|
|
|
|
|
|
|
|
150 |
references = [[tokenizer(r) for r in ref] for ref in references]
|
151 |
predictions = [tokenizer(p) for p in predictions]
|
152 |
return {
|
|
|
131 |
description=_DESCRIPTION,
|
132 |
citation=_CITATION,
|
133 |
inputs_description=_KWARGS_DESCRIPTION,
|
134 |
+
features=[
|
135 |
+
datasets.Features(
|
136 |
+
{
|
137 |
+
"predictions": datasets.Value("string", id="sequence"),
|
138 |
+
"references": datasets.Sequence(datasets.Value("string", id="sequence"), id="references"),
|
139 |
+
}
|
140 |
+
),
|
141 |
+
datasets.Features(
|
142 |
+
{
|
143 |
+
"predictions": datasets.Value("string", id="sequence"),
|
144 |
+
"references": datasets.Value("string", id="sequence"),
|
145 |
+
}
|
146 |
+
),
|
147 |
+
],
|
148 |
)
|
149 |
|
150 |
def _compute(
|
|
|
155 |
min_len: int = 1,
|
156 |
max_len: int = 4,
|
157 |
) -> Dict[str, float]:
|
158 |
+
# if only one reference is provided make sure we still use list of lists
|
159 |
+
if isinstance(references[0], str):
|
160 |
+
references = [[ref] for ref in references]
|
161 |
+
|
162 |
references = [[tokenizer(r) for r in ref] for ref in references]
|
163 |
predictions = [tokenizer(p) for p in predictions]
|
164 |
return {
|