sbarham commited on
Commit
9f097cf
·
1 Parent(s): 813d8b8

Update megawika-test.py

Browse files
Files changed (1) hide show
  1. megawika-test.py +37 -37
megawika-test.py CHANGED
@@ -138,26 +138,26 @@ class MegaWika(datasets.GeneratorBasedBuilder):
138
  "source_text": datasets.Value("string"),
139
 
140
  # Question/answer pairs
141
- # "qa_pairs": datasets.Sequence(
142
- # {
143
- # "question": datasets.Value("string"),
144
- # "en_answer": datasets.Value("string"),
145
- # "lang_answer": datasets.Value("string"),
146
- # "frames": datasets.Sequence(
147
- # {
148
- # "frame": datasets.Value("string"),
149
- # "argument": datasets.Value("string")
150
- # }
151
- # ),
152
- # "en_matches_in_source": [[datasets.Value("int32")]], # list of pair of int indices
153
- # "en_match_in_passage": [datasets.Value("int32")], # pair of int indices
154
- # "lang_matches_in_source": [[datasets.Value("int32")]], # list of pair of int indices
155
- # "lang_match_in_passage": [datasets.Value("int32")], # pair of int indices
156
- # "passage": [datasets.Value("string")],
157
- # "en_answer_tokens": [datasets.Value("string")],
158
- # "match_disambiguated_question": datasets.Value("string"),
159
- # }
160
- # )
161
  }
162
  )
163
  }
@@ -236,23 +236,23 @@ class MegaWika(datasets.GeneratorBasedBuilder):
236
  "source_lang": entry.get("source_lang", ""),
237
  "source_url": entry.get("source_url", ""),
238
  "source_text": entry.get("source_text", ""),
239
- # "qa_pairs": [
240
- # {
241
- # "question": qa_pair.get('question', ""),
242
- # "en_answer": qa_pair.get('en_answer', qa_pair.get('answer', "")),
243
- # 'lang_answer': qa_pair.get('lang_answer', ''),
244
- # 'frames': qa_pair.get('frames', []),
245
- # "en_matches_in_source": self._get_qa_pair_list_features(qa_pair, "en_matches_in_source"),
246
- # "en_match_in_passage": self._get_qa_pair_list_features(qa_pair, "en_match_in_passage"),
247
- # "lang_matches_in_source": self._get_qa_pair_list_features(qa_pair, "lang_matches_in_source"),
248
- # "lang_match_in_passage": self._get_qa_pair_list_features(qa_pair, "lang_match_in_passage"),
249
- # "passage": qa_pair.get('passage', []),
250
- # "en_answer_tokens": qa_pair.get('en_answer_tokens', qa_pair.get('answer_tokens', [])),
251
- # "match_disambiguated_question": qa_pair.get('match_disambiguated_question', ""),
252
- # }
253
- # for qa_pair
254
- # in entry.get('qa_pairs', [])
255
- # ]
256
  }
257
  for entry
258
  in example.get("entries", [])
 
138
  "source_text": datasets.Value("string"),
139
 
140
  # Question/answer pairs
141
+ "qa_pairs": datasets.Sequence(
142
+ {
143
+ "question": datasets.Value("string"),
144
+ "en_answer": datasets.Value("string"),
145
+ "lang_answer": datasets.Value("string"),
146
+ "frames": datasets.Sequence(
147
+ {
148
+ "frame": datasets.Value("string"),
149
+ "argument": datasets.Value("string")
150
+ }
151
+ ),
152
+ "en_matches_in_source": [[datasets.Value("int32")]], # list of pair of int indices
153
+ "en_match_in_passage": [datasets.Value("int32")], # pair of int indices
154
+ "lang_matches_in_source": [[datasets.Value("int32")]], # list of pair of int indices
155
+ "lang_match_in_passage": [datasets.Value("int32")], # pair of int indices
156
+ "passage": [datasets.Value("string")],
157
+ "en_answer_tokens": [datasets.Value("string")],
158
+ "match_disambiguated_question": datasets.Value("string"),
159
+ }
160
+ )
161
  }
162
  )
163
  }
 
236
  "source_lang": entry.get("source_lang", ""),
237
  "source_url": entry.get("source_url", ""),
238
  "source_text": entry.get("source_text", ""),
239
+ "qa_pairs": [
240
+ {
241
+ "question": qa_pair.get('question', ""),
242
+ "en_answer": qa_pair.get('en_answer', qa_pair.get('answer', "")),
243
+ 'lang_answer': qa_pair.get('lang_answer', ''),
244
+ 'frames': qa_pair.get('frames', []),
245
+ "en_matches_in_source": self._get_qa_pair_list_features(qa_pair, "en_matches_in_source"),
246
+ "en_match_in_passage": self._get_qa_pair_list_features(qa_pair, "en_match_in_passage"),
247
+ "lang_matches_in_source": self._get_qa_pair_list_features(qa_pair, "lang_matches_in_source"),
248
+ "lang_match_in_passage": self._get_qa_pair_list_features(qa_pair, "lang_match_in_passage"),
249
+ "passage": qa_pair.get('passage', []),
250
+ "en_answer_tokens": qa_pair.get('en_answer_tokens', qa_pair.get('answer_tokens', [])),
251
+ "match_disambiguated_question": qa_pair.get('match_disambiguated_question', ""),
252
+ }
253
+ for qa_pair
254
+ in entry.get('qa_pairs', [])
255
+ ]
256
  }
257
  for entry
258
  in example.get("entries", [])