Abinaya Mahendiran
commited on
Commit
·
8b9563a
1
Parent(s):
a43fa96
Updated data loader script
Browse files- squad_v2.py +8 -8
squad_v2.py
CHANGED
@@ -127,15 +127,15 @@ class SquadV2(datasets.GeneratorBasedBuilder):
|
|
127 |
"""Yields examples."""
|
128 |
# TODO(squad_v2): Yields (key, example) tuples from the dataset
|
129 |
with open(filepath, encoding="utf-8") as f:
|
130 |
-
|
131 |
-
|
132 |
# Features currently used are "context", "question", and "answers".
|
133 |
# Others are extracted here for the ease of future expansions.
|
134 |
yield id_, {
|
135 |
-
"id":
|
136 |
-
"gem_id":
|
137 |
-
"title":
|
138 |
-
"context":
|
139 |
-
"question":
|
140 |
-
"answers":
|
141 |
}
|
|
|
127 |
"""Yields examples."""
|
128 |
# TODO(squad_v2): Yields (key, example) tuples from the dataset
|
129 |
with open(filepath, encoding="utf-8") as f:
|
130 |
+
data = json.loads(f)
|
131 |
+
for id_, row in enumerate(data["data"]):
|
132 |
# Features currently used are "context", "question", and "answers".
|
133 |
# Others are extracted here for the ease of future expansions.
|
134 |
yield id_, {
|
135 |
+
"id": row["id"],
|
136 |
+
"gem_id": row["gem_id"],
|
137 |
+
"title": row["title"],
|
138 |
+
"context": row["context"],
|
139 |
+
"question": row["question"],
|
140 |
+
"answers": row["answers"],
|
141 |
}
|