lvwerra HF staff commited on
Commit
b5bab25
1 Parent(s): 87bf795

Update Space (evaluate main: dfdd0cc0)

Browse files
Files changed (1) hide show
  1. sacrebleu.py +18 -6
sacrebleu.py CHANGED
@@ -115,12 +115,20 @@ class Sacrebleu(evaluate.EvaluationModule):
115
  citation=_CITATION,
116
  homepage="https://github.com/mjpost/sacreBLEU",
117
  inputs_description=_KWARGS_DESCRIPTION,
118
- features=datasets.Features(
119
- {
120
- "predictions": datasets.Value("string", id="sequence"),
121
- "references": datasets.Sequence(datasets.Value("string", id="sequence"), id="references"),
122
- }
123
- ),
 
 
 
 
 
 
 
 
124
  codebase_urls=["https://github.com/mjpost/sacreBLEU"],
125
  reference_urls=[
126
  "https://github.com/mjpost/sacreBLEU",
@@ -140,6 +148,10 @@ class Sacrebleu(evaluate.EvaluationModule):
140
  tokenize=None,
141
  use_effective_order=False,
142
  ):
 
 
 
 
143
  references_per_prediction = len(references[0])
144
  if any(len(refs) != references_per_prediction for refs in references):
145
  raise ValueError("Sacrebleu requires the same number of references for each prediction")
 
115
  citation=_CITATION,
116
  homepage="https://github.com/mjpost/sacreBLEU",
117
  inputs_description=_KWARGS_DESCRIPTION,
118
+ features=[
119
+ datasets.Features(
120
+ {
121
+ "predictions": datasets.Value("string", id="sequence"),
122
+ "references": datasets.Sequence(datasets.Value("string", id="sequence"), id="references"),
123
+ }
124
+ ),
125
+ datasets.Features(
126
+ {
127
+ "predictions": datasets.Value("string", id="sequence"),
128
+ "references": datasets.Value("string", id="sequence"),
129
+ }
130
+ ),
131
+ ],
132
  codebase_urls=["https://github.com/mjpost/sacreBLEU"],
133
  reference_urls=[
134
  "https://github.com/mjpost/sacreBLEU",
 
148
  tokenize=None,
149
  use_effective_order=False,
150
  ):
151
+ # if only one reference is provided make sure we still use list of lists
152
+ if isinstance(references[0], str):
153
+ references = [[ref] for ref in references]
154
+
155
  references_per_prediction = len(references[0])
156
  if any(len(refs) != references_per_prediction for refs in references):
157
  raise ValueError("Sacrebleu requires the same number of references for each prediction")