Datasets:
Commit
·
d3614db
1
Parent(s):
3f2caa4
feat: Change the output format of the dataset to be in line with SQuAD
Browse files- scandiqa.py +23 -5
scandiqa.py
CHANGED
@@ -114,11 +114,15 @@ class ScandiQA(GeneratorBasedBuilder):
|
|
114 |
{
|
115 |
"example_id": Value("int64"),
|
116 |
"question": Value("string"),
|
117 |
-
"answer":
|
118 |
-
|
|
|
|
|
119 |
"context": Value("string"),
|
120 |
-
"answer_en":
|
121 |
-
|
|
|
|
|
122 |
"context_en": Value("string"),
|
123 |
"title_en": Value("string"),
|
124 |
}
|
@@ -159,4 +163,18 @@ class ScandiQA(GeneratorBasedBuilder):
|
|
159 |
with Path(filepath).open(encoding="utf-8") as f:
|
160 |
for key, row in enumerate(f):
|
161 |
data = json.loads(row)
|
162 |
-
yield key,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
{
|
115 |
"example_id": Value("int64"),
|
116 |
"question": Value("string"),
|
117 |
+
"answer": {
|
118 |
+
"text": Value("string"),
|
119 |
+
"answer_start": Value("int64"),
|
120 |
+
},
|
121 |
"context": Value("string"),
|
122 |
+
"answer_en": {
|
123 |
+
"text": Value("string"),
|
124 |
+
"answer_start_en": Value("int64"),
|
125 |
+
},
|
126 |
"context_en": Value("string"),
|
127 |
"title_en": Value("string"),
|
128 |
}
|
|
|
163 |
with Path(filepath).open(encoding="utf-8") as f:
|
164 |
for key, row in enumerate(f):
|
165 |
data = json.loads(row)
|
166 |
+
yield key, {
|
167 |
+
"example_id": data["example_id"],
|
168 |
+
"question": data["question"],
|
169 |
+
"answer": {
|
170 |
+
"text": data["answer"],
|
171 |
+
"answer_start": data["answer_start"],
|
172 |
+
},
|
173 |
+
"context": data["context"],
|
174 |
+
"answer_en": {
|
175 |
+
"text": data["answer_en"],
|
176 |
+
"answer_start": data["answer_start_en"],
|
177 |
+
},
|
178 |
+
"context_en": data["context_en"],
|
179 |
+
"title_en": data["title_en"],
|
180 |
+
}
|