luozhouyang commited on
Commit
33297f1
1 Parent(s): 17278ac

Fixed answers key

Browse files
Files changed (1) hide show
  1. dureader.py +12 -2
dureader.py CHANGED
@@ -140,11 +140,16 @@ class DuReader(datasets.GeneratorBasedBuilder):
140
  for p in d["paragraphs"]:
141
  context = p["context"]
142
  for qa in p["qas"]:
 
 
143
  example = {
144
  "id": qa["id"],
145
  "context": context,
146
  "question": qa["question"],
147
- "answers": qa["answers"],
 
 
 
148
  }
149
  yield example["id"], example
150
 
@@ -170,13 +175,18 @@ class DuReader(datasets.GeneratorBasedBuilder):
170
  title = p["title"]
171
  context = p["context"]
172
  for qa in p["qas"]:
 
 
173
  example = {
174
  "id": qa["id"],
175
  "title": title,
176
  "context": context,
177
  "question": qa["question"],
178
  "is_impossible": qa["is_impossible"],
179
- "answers": qa["answers"],
 
 
 
180
  "type": qa["type"],
181
  }
182
  yield example["id"], example
 
140
  for p in d["paragraphs"]:
141
  context = p["context"]
142
  for qa in p["qas"]:
143
+ starts = [x["answer_start"] for x in qa["answers"]]
144
+ answers = [x["text"] for x in qa["answers"]]
145
  example = {
146
  "id": qa["id"],
147
  "context": context,
148
  "question": qa["question"],
149
+ "answers": {
150
+ "text": answers,
151
+ "answer_start": starts,
152
+ },
153
  }
154
  yield example["id"], example
155
 
 
175
  title = p["title"]
176
  context = p["context"]
177
  for qa in p["qas"]:
178
+ starts = [x["answer_start"] for x in qa["answers"]]
179
+ answers = [x["text"] for x in qa["answers"]]
180
  example = {
181
  "id": qa["id"],
182
  "title": title,
183
  "context": context,
184
  "question": qa["question"],
185
  "is_impossible": qa["is_impossible"],
186
+ "answers": {
187
+ "text": answers,
188
+ "answer_start": starts,
189
+ },
190
  "type": qa["type"],
191
  }
192
  yield example["id"], example