Datasets:
hugforziio
commited on
Commit
·
bd651cb
1
Parent(s):
10f7567
Update SpaCE2021.py
Browse files- SpaCE2021.py +10 -3
SpaCE2021.py
CHANGED
@@ -165,6 +165,7 @@ class SpaCE2021(datasets.GeneratorBasedBuilder):
|
|
165 |
split_thing = datasets.SplitGenerator(
|
166 |
name=_split_name_map[split_name],
|
167 |
gen_kwargs={
|
|
|
168 |
"filepath": filepath,
|
169 |
"split": split_name,
|
170 |
}
|
@@ -172,11 +173,17 @@ class SpaCE2021(datasets.GeneratorBasedBuilder):
|
|
172 |
split_things.append(split_thing)
|
173 |
return split_things
|
174 |
|
175 |
-
def _generate_examples(self, filepath, split):
|
176 |
with open(filepath, encoding="utf-8") as ff:
|
|
|
177 |
for idx, line in enumerate(ff):
|
178 |
example = json.loads(line.strip())
|
|
|
|
|
179 |
qid = example.get("qID")
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
182 |
|
|
|
165 |
split_thing = datasets.SplitGenerator(
|
166 |
name=_split_name_map[split_name],
|
167 |
gen_kwargs={
|
168 |
+
"task": self.config.name,
|
169 |
"filepath": filepath,
|
170 |
"split": split_name,
|
171 |
}
|
|
|
173 |
split_things.append(split_thing)
|
174 |
return split_things
|
175 |
|
176 |
+
def _generate_examples(self, task, filepath, split):
|
177 |
with open(filepath, encoding="utf-8") as ff:
|
178 |
+
keys = _FEATURES_DICT[task].keys()
|
179 |
for idx, line in enumerate(ff):
|
180 |
example = json.loads(line.strip())
|
181 |
+
example = {kk: example[kk] for kk in keys if kk in example}
|
182 |
+
# print(example)
|
183 |
qid = example.get("qID")
|
184 |
+
# print(qid)
|
185 |
+
jj = (split == qid.split("-")[1])
|
186 |
+
# print(jj)
|
187 |
+
if jj:
|
188 |
+
yield qid, example
|
189 |
|