yuvalkirstain commited on
Commit
959d23e
·
1 Parent(s): 277a6f4

bug fix - add unique idx per question

Browse files
Files changed (1) hide show
  1. mrqa.py +5 -4
mrqa.py CHANGED
@@ -201,8 +201,8 @@ class MRQA(datasets.GeneratorBasedBuilder):
201
  with open(filepath, encoding="utf-8") as f:
202
  header = next(f)
203
  subset = json.loads(header)["header"]["dataset"]
204
-
205
- for i, row in enumerate(f):
206
  paragraph = json.loads(row)
207
  context = paragraph["context"].strip()
208
  if subset == "HotpotQA":
@@ -229,17 +229,18 @@ class MRQA(datasets.GeneratorBasedBuilder):
229
  "context": context,
230
  # "context_tokens": context_tokens,
231
  "qid": qid,
232
- "idx": i,
233
  "question": question,
234
  # "question_tokens": question_tokens,
235
  # "detected_answers": detected_answers,
236
  "answers": answers,
237
  "answer": answers[0]
238
  }
 
239
  yield f"{source}_{qid}", final_row
240
 
241
 
242
  if __name__ == '__main__':
243
  from datasets import load_dataset
244
- ssfd_debug = load_dataset("/Users/yuvalkirstain/repos/mrqa", name="newsqa")
245
  x = 5
 
201
  with open(filepath, encoding="utf-8") as f:
202
  header = next(f)
203
  subset = json.loads(header)["header"]["dataset"]
204
+ idx = 0
205
+ for row in enumerate(f):
206
  paragraph = json.loads(row)
207
  context = paragraph["context"].strip()
208
  if subset == "HotpotQA":
 
229
  "context": context,
230
  # "context_tokens": context_tokens,
231
  "qid": qid,
232
+ "idx": idx,
233
  "question": question,
234
  # "question_tokens": question_tokens,
235
  # "detected_answers": detected_answers,
236
  "answers": answers,
237
  "answer": answers[0]
238
  }
239
+ idx += 1
240
  yield f"{source}_{qid}", final_row
241
 
242
 
243
  if __name__ == '__main__':
244
  from datasets import load_dataset
245
+ ssfd_debug = load_dataset("mrqa.py", name="newsqa")
246
  x = 5