eladsegal commited on
Commit
eb3a90a
1 Parent(s): 59eebb1

Update metrics/bleu.py

Browse files
Files changed (1) hide show
  1. metrics/bleu.py +2 -0
metrics/bleu.py CHANGED
@@ -1,5 +1,6 @@
1
  # Copied from https://github.com/huggingface/datasets/blob/76bb45964df1e62d1411b0a9e9fc673e9a791c9a/metrics/sacrebleu/sacrebleu.py
2
 
 
3
  from sacrebleu.metrics import BLEU
4
 
5
 
@@ -15,6 +16,7 @@ def compute_bleu(
15
  ):
16
  references_per_prediction = len(references[0])
17
  if any(len(refs) != references_per_prediction for refs in references):
 
18
  max_references_per_prediction = max(len(refs) for refs in references)
19
  for refs in references:
20
  refs.extend([None] * (max_references_per_prediction - len(refs)))
 
1
  # Copied from https://github.com/huggingface/datasets/blob/76bb45964df1e62d1411b0a9e9fc673e9a791c9a/metrics/sacrebleu/sacrebleu.py
2
 
3
+ from copy import deepcopy
4
  from sacrebleu.metrics import BLEU
5
 
6
 
 
16
  ):
17
  references_per_prediction = len(references[0])
18
  if any(len(refs) != references_per_prediction for refs in references):
19
+ references = deepcopy(references)
20
  max_references_per_prediction = max(len(refs) for refs in references)
21
  for refs in references:
22
  refs.extend([None] * (max_references_per_prediction - len(refs)))