Datasets:
Commit
·
26d699d
1
Parent(s):
e0e4fb3
Update SpaCE2021.py
Browse files- SpaCE2021.py +15 -8
SpaCE2021.py
CHANGED
@@ -116,11 +116,10 @@ _split_name_map = {
|
|
116 |
class SpaCE2021Config(datasets.BuilderConfig):
|
117 |
"""BuilderConfig for SpaCE2021."""
|
118 |
|
119 |
-
def __init__(self,
|
120 |
# Version history:
|
121 |
# 1.0518.0: final version used in SpaCE2021 Eval.
|
122 |
super().__init__(version=datasets.Version("1.0518.0"), **kwargs)
|
123 |
-
self.features = features
|
124 |
self.splits = splits
|
125 |
|
126 |
|
@@ -145,7 +144,7 @@ class SpaCE2021(datasets.GeneratorBasedBuilder):
|
|
145 |
def _info(self):
|
146 |
return datasets.DatasetInfo(
|
147 |
description=_DESCRIPTION_DICT[self.config.name],
|
148 |
-
features=_FEATURES_DICT[self.config.name],
|
149 |
homepage="http://ccl.pku.edu.cn:8084/SpaCE2021/",
|
150 |
citation=_CITATION,
|
151 |
license=_LICENSE,
|
@@ -157,19 +156,27 @@ class SpaCE2021(datasets.GeneratorBasedBuilder):
|
|
157 |
|
158 |
split_things = []
|
159 |
for split_name in self.config.splits:
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
split_thing = datasets.SplitGenerator(
|
161 |
name=_split_name_map[split_name],
|
162 |
gen_kwargs={
|
163 |
-
"
|
164 |
"split": split_name,
|
165 |
}
|
166 |
)
|
167 |
split_things.append(split_thing)
|
168 |
return split_things
|
169 |
|
170 |
-
def _generate_examples(self, filepath):
|
171 |
-
with open(filepath, encoding="utf-8") as
|
172 |
-
for idx, line in enumerate(
|
173 |
example = json.loads(line.strip())
|
174 |
-
|
|
|
|
|
175 |
|
|
|
116 |
class SpaCE2021Config(datasets.BuilderConfig):
|
117 |
"""BuilderConfig for SpaCE2021."""
|
118 |
|
119 |
+
def __init__(self, splits, **kwargs):
|
120 |
# Version history:
|
121 |
# 1.0518.0: final version used in SpaCE2021 Eval.
|
122 |
super().__init__(version=datasets.Version("1.0518.0"), **kwargs)
|
|
|
123 |
self.splits = splits
|
124 |
|
125 |
|
|
|
144 |
def _info(self):
|
145 |
return datasets.DatasetInfo(
|
146 |
description=_DESCRIPTION_DICT[self.config.name],
|
147 |
+
features=datasets.Features(_FEATURES_DICT[self.config.name]),
|
148 |
homepage="http://ccl.pku.edu.cn:8084/SpaCE2021/",
|
149 |
citation=_CITATION,
|
150 |
license=_LICENSE,
|
|
|
156 |
|
157 |
split_things = []
|
158 |
for split_name in self.config.splits:
|
159 |
+
# print('')
|
160 |
+
split_data_path = _URLS_DICT[self.config.name][split_name]
|
161 |
+
# print(split_data_path)
|
162 |
+
filepath = dl_manager.download(split_data_path)
|
163 |
+
# print(filepath)
|
164 |
+
# print('')
|
165 |
split_thing = datasets.SplitGenerator(
|
166 |
name=_split_name_map[split_name],
|
167 |
gen_kwargs={
|
168 |
+
"filepath": filepath,
|
169 |
"split": split_name,
|
170 |
}
|
171 |
)
|
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 |
+
if split == qid.split("-")[2]:
|
181 |
+
yield example.get("qID"), example
|
182 |
|