lvwerra HF staff commited on
Commit
9f2195a
1 Parent(s): d852794

Update Space (evaluate main: dfdd0cc0)

Browse files
Files changed (1) hide show
  1. chrf.py +18 -6
chrf.py CHANGED
@@ -136,12 +136,20 @@ class ChrF(evaluate.EvaluationModule):
136
  citation=_CITATION,
137
  homepage="https://github.com/mjpost/sacreBLEU#chrf--chrf",
138
  inputs_description=_KWARGS_DESCRIPTION,
139
- features=datasets.Features(
140
- {
141
- "predictions": datasets.Value("string", id="sequence"),
142
- "references": datasets.Sequence(datasets.Value("string", id="sequence"), id="references"),
143
- }
144
- ),
 
 
 
 
 
 
 
 
145
  codebase_urls=["https://github.com/mjpost/sacreBLEU#chrf--chrf"],
146
  reference_urls=[
147
  "https://github.com/m-popovic/chrF",
@@ -159,6 +167,10 @@ class ChrF(evaluate.EvaluationModule):
159
  whitespace: bool = False,
160
  eps_smoothing: bool = False,
161
  ):
 
 
 
 
162
  references_per_prediction = len(references[0])
163
  if any(len(refs) != references_per_prediction for refs in references):
164
  raise ValueError("Sacrebleu requires the same number of references for each prediction")
 
136
  citation=_CITATION,
137
  homepage="https://github.com/mjpost/sacreBLEU#chrf--chrf",
138
  inputs_description=_KWARGS_DESCRIPTION,
139
+ features=[
140
+ datasets.Features(
141
+ {
142
+ "predictions": datasets.Value("string", id="sequence"),
143
+ "references": datasets.Sequence(datasets.Value("string", id="sequence"), id="references"),
144
+ }
145
+ ),
146
+ datasets.Features(
147
+ {
148
+ "predictions": datasets.Value("string", id="sequence"),
149
+ "references": datasets.Value("string", id="sequence"),
150
+ }
151
+ ),
152
+ ],
153
  codebase_urls=["https://github.com/mjpost/sacreBLEU#chrf--chrf"],
154
  reference_urls=[
155
  "https://github.com/m-popovic/chrF",
 
167
  whitespace: bool = False,
168
  eps_smoothing: bool = False,
169
  ):
170
+ # if only one reference is provided make sure we still use list of lists
171
+ if isinstance(references[0], str):
172
+ references = [[ref] for ref in references]
173
+
174
  references_per_prediction = len(references[0])
175
  if any(len(refs) != references_per_prediction for refs in references):
176
  raise ValueError("Sacrebleu requires the same number of references for each prediction")