djstrong commited on
Commit
0ad3cc2
1 Parent(s): dd1cdf8

Update poquad.py

Browse files
Files changed (1) hide show
  1. poquad.py +12 -6
poquad.py CHANGED
@@ -107,13 +107,19 @@ class SquadV2(datasets.GeneratorBasedBuilder):
107
  context = paragraph["context"] # do not strip leading blank spaces GH-2585
108
  for qa in paragraph["qas"]:
109
  question = qa["question"]
110
-
111
- if "answers" not in qa:
112
- continue
113
- answer_starts = [answer["answer_start"] for answer in qa["answers"]]
 
 
 
 
 
 
114
  #answer_ends = [answer["answer_end"] for answer in qa["answers"]]
115
- answers = [answer["text"] for answer in qa["answers"]]
116
- generative_answers = [answer["generative_answer"] for answer in qa["answers"]]
117
  is_impossible = qa["is_impossible"]
118
  # Features currently used are "context", "question", and "answers".
119
  # Others are extracted here for the ease of future expansions.
 
107
  context = paragraph["context"] # do not strip leading blank spaces GH-2585
108
  for qa in paragraph["qas"]:
109
  question = qa["question"]
110
+
111
+
112
+ if "answers" in qa:
113
+ answers_key="answers"
114
+ elif "plausible_answers" in qa:
115
+ answers_key="plausible_answers"
116
+ else:
117
+ raise ValueError
118
+
119
+ answer_starts = [answer["answer_start"] for answer in qa[answers_key]]
120
  #answer_ends = [answer["answer_end"] for answer in qa["answers"]]
121
+ answers = [answer["text"] for answer in qa[answers_key]]
122
+ generative_answers = [answer["generative_answer"] for answer in qa[answers_key]]
123
  is_impossible = qa["is_impossible"]
124
  # Features currently used are "context", "question", and "answers".
125
  # Others are extracted here for the ease of future expansions.