venkatasg commited on
Commit
214f071
·
1 Parent(s): 8c5256a

missing iter_stats initialization

Browse files
Files changed (1) hide show
  1. gleu.py +5 -2
gleu.py CHANGED
@@ -183,6 +183,7 @@ class gleu(evaluate.Metric):
183
  {
184
  "predictions": datasets.Value("string", id="sequence"),
185
  "references": datasets.Value("string", id="sequence"),
 
186
  }
187
  ),
188
  codebase_urls=["https://github.com/cnap/gec-ranking/"],
@@ -193,7 +194,7 @@ class gleu(evaluate.Metric):
193
  # TODO: Download external resources if needed
194
  pass
195
 
196
- def _compute(self, references, predictions):
197
  """Returns the scores"""
198
 
199
  num_iterations = 500
@@ -201,7 +202,7 @@ class gleu(evaluate.Metric):
201
  if len(references)==1:
202
  num_iterations = 1
203
 
204
- gleu_calculator = GLEU(order=4)
205
 
206
  # if sources:
207
  # gleu_calculator.load_sources(sources)
@@ -217,6 +218,8 @@ class gleu(evaluate.Metric):
217
  seed(j*101)
218
  indices.append([randint(0,len(references)-1) for i in range(len(predictions))])
219
 
 
 
220
  for i,h in enumerate(predictions) :
221
  gleu_calculator.load_hypothesis_sentence(h)
222
 
 
183
  {
184
  "predictions": datasets.Value("string", id="sequence"),
185
  "references": datasets.Value("string", id="sequence"),
186
+ "order": datasets.Value("Int32"),
187
  }
188
  ),
189
  codebase_urls=["https://github.com/cnap/gec-ranking/"],
 
194
  # TODO: Download external resources if needed
195
  pass
196
 
197
+ def _compute(self, references, predictions, order=4):
198
  """Returns the scores"""
199
 
200
  num_iterations = 500
 
202
  if len(references)==1:
203
  num_iterations = 1
204
 
205
+ gleu_calculator = GLEU(order=order)
206
 
207
  # if sources:
208
  # gleu_calculator.load_sources(sources)
 
218
  seed(j*101)
219
  indices.append([randint(0,len(references)-1) for i in range(len(predictions))])
220
 
221
+ iter_stats = [[0 for i in range(2*order+2)] for j in range(num_iterations) ]
222
+
223
  for i,h in enumerate(predictions) :
224
  gleu_calculator.load_hypothesis_sentence(h)
225