PiC commited on
Commit
8541359
1 Parent(s): 44ed974

Update phrase_retrieval.py

Browse files
Files changed (1) hide show
  1. phrase_retrieval.py +9 -6
phrase_retrieval.py CHANGED
@@ -85,11 +85,11 @@ class PhraseRetrieval(datasets.GeneratorBasedBuilder):
85
  "title": datasets.Value("string"),
86
  "context": datasets.Value("string"),
87
  "question": datasets.Value("string"),
88
- "answers": datasets.features.Dict(
89
  {
90
- "text": datasets.Sequence(datasets.Value("string")),
91
- "answer_start": datasets.Sequence(datasets.Value("int32")),
92
- }
93
  ),
94
  }
95
  ),
@@ -129,6 +129,9 @@ class PhraseRetrieval(datasets.GeneratorBasedBuilder):
129
  for example in pic_pr["data"]:
130
  title = example.get("title", "")
131
 
 
 
 
132
  # Features currently used are "context", "question", and "answers".
133
  # Others are extracted here for the ease of future expansions.
134
  yield key, {
@@ -137,8 +140,8 @@ class PhraseRetrieval(datasets.GeneratorBasedBuilder):
137
  "question": example["question"],
138
  "id": example["id"],
139
  "answers": {
140
- "answer_start": example["answers"]["answer_start"],
141
- "text": example["answers"]["text"],
142
  },
143
  }
144
  key += 1
 
85
  "title": datasets.Value("string"),
86
  "context": datasets.Value("string"),
87
  "question": datasets.Value("string"),
88
+ "answers": datasets.Sequence(
89
  {
90
+ "text": datasets.Value("string"),
91
+ "answer_start": datasets.Value("int32"),
92
+ },
93
  ),
94
  }
95
  ),
 
129
  for example in pic_pr["data"]:
130
  title = example.get("title", "")
131
 
132
+ answer_starts = [answer["answer_start"] for answer in example["answers"]]
133
+ answers = [answer["text"] for answer in example["answers"]]
134
+
135
  # Features currently used are "context", "question", and "answers".
136
  # Others are extracted here for the ease of future expansions.
137
  yield key, {
 
140
  "question": example["question"],
141
  "id": example["id"],
142
  "answers": {
143
+ "answer_start": answer_starts,
144
+ "text": answers,
145
  },
146
  }
147
  key += 1