mathiascreutz
commited on
Commit
•
465cc03
1
Parent(s):
d7d532b
Data loader produces full test and validation split as well
Browse files- opusparcus.py +32 -9
opusparcus.py
CHANGED
@@ -47,7 +47,8 @@ _LICENSE = ""
|
|
47 |
_URLs = {
|
48 |
"validation": "validation.jsonl",
|
49 |
"test": "test.jsonl"
|
50 |
-
|
|
|
51 |
# NB: the "train" split file is defined dynamically inside the `_split_generators` method
|
52 |
}
|
53 |
|
@@ -169,6 +170,26 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
169 |
"filepath": data_dir["validation"],
|
170 |
"split": "validation",
|
171 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
)
|
173 |
]
|
174 |
|
@@ -215,16 +236,18 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
215 |
"quality": data["quality"],
|
216 |
}
|
217 |
else:
|
|
|
218 |
with open(filepath, encoding="utf-8") as f:
|
219 |
for id_, row in enumerate(f):
|
220 |
data = json.loads(row)
|
221 |
if data["lang"] == lang:
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
230 |
|
|
|
47 |
_URLs = {
|
48 |
"validation": "validation.jsonl",
|
49 |
"test": "test.jsonl"
|
50 |
+
"full-validation": "validation.jsonl",
|
51 |
+
"full-test": "test.jsonl"
|
52 |
# NB: the "train" split file is defined dynamically inside the `_split_generators` method
|
53 |
}
|
54 |
|
|
|
170 |
"filepath": data_dir["validation"],
|
171 |
"split": "validation",
|
172 |
},
|
173 |
+
),
|
174 |
+
datasets.SplitGenerator(
|
175 |
+
name="full-test",
|
176 |
+
# These kwargs will be passed to _generate_examples
|
177 |
+
gen_kwargs={
|
178 |
+
"lang": self.config.lang,
|
179 |
+
"quality": 100,
|
180 |
+
"filepath": data_dir["test"],
|
181 |
+
"split": "test"
|
182 |
+
},
|
183 |
+
),
|
184 |
+
datasets.SplitGenerator(
|
185 |
+
name="full-validation",
|
186 |
+
# These kwargs will be passed to _generate_examples
|
187 |
+
gen_kwargs={
|
188 |
+
"lang": self.config.lang,
|
189 |
+
"quality": 100,
|
190 |
+
"filepath": data_dir["validation"],
|
191 |
+
"split": "validation",
|
192 |
+
},
|
193 |
)
|
194 |
]
|
195 |
|
|
|
236 |
"quality": data["quality"],
|
237 |
}
|
238 |
else:
|
239 |
+
keep_all = (split == "full-validation" || split == "full-test")
|
240 |
with open(filepath, encoding="utf-8") as f:
|
241 |
for id_, row in enumerate(f):
|
242 |
data = json.loads(row)
|
243 |
if data["lang"] == lang:
|
244 |
+
if keep_all or data["annot_score"] >= 3.0:
|
245 |
+
yield id_, {
|
246 |
+
"lang": data["lang"],
|
247 |
+
"sent1": data["sent1"],
|
248 |
+
"sent2": data["sent2"],
|
249 |
+
"annot_score": data["annot_score"],
|
250 |
+
"gem_id": data["gem_id"],
|
251 |
+
"quality": 100,
|
252 |
+
}
|
253 |
|