Update tydiqa-goldp.py
Browse files- tydiqa-goldp.py +4 -24
tydiqa-goldp.py
CHANGED
@@ -105,27 +105,7 @@ class tydiqa_GoldP(datasets.GeneratorBasedBuilder):
|
|
105 |
# TODO(tydiqa): Yields (key, example) tuples from the dataset
|
106 |
|
107 |
with open(filepath, encoding="utf-8") as f:
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
context = paragraph["context"].strip()
|
113 |
-
for qa in paragraph["qas"]:
|
114 |
-
question = qa["question"].strip()
|
115 |
-
id_ = qa["id"]
|
116 |
-
|
117 |
-
answer_starts = [answer["answer_start"] for answer in qa["answers"]]
|
118 |
-
answers = [answer["text"].strip() for answer in qa["answers"]]
|
119 |
-
|
120 |
-
# Features currently used are "context", "question", and "answers".
|
121 |
-
# Others are extracted here for the ease of future expansions.
|
122 |
-
yield id_, {
|
123 |
-
"title": title,
|
124 |
-
"context": context,
|
125 |
-
"question": question,
|
126 |
-
"id": id_,
|
127 |
-
"answers": {
|
128 |
-
"answer_start": answer_starts,
|
129 |
-
"text": answers,
|
130 |
-
},
|
131 |
-
}
|
|
|
105 |
# TODO(tydiqa): Yields (key, example) tuples from the dataset
|
106 |
|
107 |
with open(filepath, encoding="utf-8") as f:
|
108 |
+
for row in f:
|
109 |
+
data = json.loads(row)
|
110 |
+
idx = data['id']
|
111 |
+
yield idx, data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|