Add test sets
Browse files- .gitignore +1 -0
- HIPE2020_sent-split.py +39 -32
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
venv/
|
HIPE2020_sent-split.py
CHANGED
@@ -30,23 +30,23 @@ _DESCRIPTION = """\
|
|
30 |
TODO
|
31 |
"""
|
32 |
|
33 |
-
_BASE_URL_TRAIN_DEV_TEST = "https://
|
34 |
|
35 |
|
36 |
_URLs = {
|
37 |
"EN": {
|
38 |
-
"dev": _BASE_URL_TRAIN_DEV_TEST + "en/HIPE-data-v1.4-dev-en.tsv
|
39 |
-
"test": _BASE_URL_TRAIN_DEV_TEST + "en/HIPE-data-v1.4-test-en.tsv
|
40 |
}, # English only no train
|
41 |
"DE": {
|
42 |
-
"dev": _BASE_URL_TRAIN_DEV_TEST + "de/HIPE-data-v1.4-dev-de.tsv
|
43 |
-
"train": _BASE_URL_TRAIN_DEV_TEST + "de/HIPE-data-v1.4-train-de.tsv
|
44 |
-
"test": _BASE_URL_TRAIN_DEV_TEST + "de/HIPE-data-v1.4-test-de.tsv
|
45 |
},
|
46 |
"FR": {
|
47 |
-
"dev": _BASE_URL_TRAIN_DEV_TEST + "fr/HIPE-data-v1.4-dev-fr.tsv
|
48 |
-
"train": _BASE_URL_TRAIN_DEV_TEST + "fr/HIPE-data-v1.4-train-fr.tsv
|
49 |
-
"test": _BASE_URL_TRAIN_DEV_TEST + "fr/HIPE-data-v1.4-test-fr.tsv
|
50 |
},
|
51 |
}
|
52 |
|
@@ -121,6 +121,7 @@ class HIPE2020(datasets.GeneratorBasedBuilder):
|
|
121 |
"B-org",
|
122 |
"B-pers",
|
123 |
"B-prod",
|
|
|
124 |
"I-loc",
|
125 |
"I-org",
|
126 |
"I-pers",
|
@@ -168,6 +169,7 @@ class HIPE2020(datasets.GeneratorBasedBuilder):
|
|
168 |
"I-loc.adm.town",
|
169 |
"I-loc.fac",
|
170 |
"I-loc.oro",
|
|
|
171 |
"I-loc.phys.geo",
|
172 |
"I-loc.phys.hydro",
|
173 |
"I-loc.unk",
|
@@ -193,6 +195,7 @@ class HIPE2020(datasets.GeneratorBasedBuilder):
|
|
193 |
names=[
|
194 |
"O",
|
195 |
"B-loc",
|
|
|
196 |
"B-loc.adm.reg",
|
197 |
"B-loc.adm.town",
|
198 |
"B-loc.fac",
|
@@ -203,7 +206,9 @@ class HIPE2020(datasets.GeneratorBasedBuilder):
|
|
203 |
"B-pers.coll",
|
204 |
"B-pers.ind",
|
205 |
"B-prod.media",
|
|
|
206 |
"I-loc",
|
|
|
207 |
"I-loc.adm.reg",
|
208 |
"I-loc.fac",
|
209 |
"I-loc.oro",
|
@@ -258,14 +263,17 @@ class HIPE2020(datasets.GeneratorBasedBuilder):
|
|
258 |
"I-loc.adm.nat",
|
259 |
"I-loc.adm.reg",
|
260 |
"I-loc.adm.town",
|
|
|
261 |
"I-loc.fac",
|
262 |
"I-loc.oro",
|
|
|
263 |
"I-loc.phys.geo",
|
264 |
"I-loc.phys.hydro",
|
265 |
"I-org",
|
266 |
"I-org.adm",
|
267 |
"I-org.ent",
|
268 |
"I-pers.ind",
|
|
|
269 |
"_",
|
270 |
]
|
271 |
)
|
@@ -286,35 +294,33 @@ class HIPE2020(datasets.GeneratorBasedBuilder):
|
|
286 |
)
|
287 |
|
288 |
def _split_generators(self, dl_manager):
|
289 |
-
"""Returns SplitGenerators."""
|
290 |
downloaded_files = dl_manager.download_and_extract(self.config.data_urls)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
if self.config.name != "en":
|
292 |
-
data_files
|
293 |
"train": downloaded_files["train"],
|
294 |
-
|
295 |
-
|
296 |
-
else:
|
297 |
-
data_files = {"dev": downloaded_files["dev"]}
|
298 |
-
if self.config.name == "en":
|
299 |
-
return [
|
300 |
-
datasets.SplitGenerator(
|
301 |
-
name=datasets.Split.VALIDATION,
|
302 |
-
gen_kwargs={"filepath": data_files["dev"]},
|
303 |
-
),
|
304 |
-
# datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_files["test"]}), # TODO add test splits
|
305 |
-
]
|
306 |
-
|
307 |
-
else:
|
308 |
-
return [
|
309 |
datasets.SplitGenerator(
|
310 |
name=datasets.Split.TRAIN,
|
311 |
gen_kwargs={"filepath": data_files["train"]},
|
312 |
),
|
313 |
-
datasets.SplitGenerator(
|
314 |
-
name=datasets.Split.VALIDATION,
|
315 |
-
gen_kwargs={"filepath": data_files["dev"]},
|
316 |
-
),
|
317 |
]
|
|
|
318 |
|
319 |
def _generate_examples(self, filepath):
|
320 |
date_re = re.compile(r"# date = (\d{4}-\d{2}-\d{02})")
|
@@ -338,6 +344,7 @@ class HIPE2020(datasets.GeneratorBasedBuilder):
|
|
338 |
new_sentence = False
|
339 |
|
340 |
for line in f:
|
|
|
341 |
if line.startswith(
|
342 |
"TOKEN NE-COARSE-LIT NE-COARSE-METO NE-FINE-LIT NE-FINE-METO NE-FINE-COMP NE-NESTED NEL-LIT NEL-METO MISC"
|
343 |
):
|
@@ -419,7 +426,7 @@ class HIPE2020(datasets.GeneratorBasedBuilder):
|
|
419 |
no_space_after = []
|
420 |
end_of_line = []
|
421 |
pysdbsegment = []
|
422 |
-
|
423 |
# HIPE 2020 tokens are tab separated
|
424 |
splits = line.split(
|
425 |
"\t"
|
@@ -461,4 +468,4 @@ class HIPE2020(datasets.GeneratorBasedBuilder):
|
|
461 |
"date": date,
|
462 |
"title": title,
|
463 |
"document_id": document_id,
|
464 |
-
}
|
|
|
30 |
TODO
|
31 |
"""
|
32 |
|
33 |
+
_BASE_URL_TRAIN_DEV_TEST = "https://raw.githubusercontent.com/impresso/CLEF-HIPE-2020/master/data/v1.4/"
|
34 |
|
35 |
|
36 |
_URLs = {
|
37 |
"EN": {
|
38 |
+
"dev": _BASE_URL_TRAIN_DEV_TEST + "en/HIPE-data-v1.4-dev-en.tsv",
|
39 |
+
"test": _BASE_URL_TRAIN_DEV_TEST + "en/HIPE-data-v1.4-test-en.tsv"
|
40 |
}, # English only no train
|
41 |
"DE": {
|
42 |
+
"dev": _BASE_URL_TRAIN_DEV_TEST + "de/HIPE-data-v1.4-dev-de.tsv",
|
43 |
+
"train": _BASE_URL_TRAIN_DEV_TEST + "de/HIPE-data-v1.4-train-de.tsv",
|
44 |
+
"test": _BASE_URL_TRAIN_DEV_TEST + "de/HIPE-data-v1.4-test-de.tsv"
|
45 |
},
|
46 |
"FR": {
|
47 |
+
"dev": _BASE_URL_TRAIN_DEV_TEST + "fr/HIPE-data-v1.4-dev-fr.tsv",
|
48 |
+
"train": _BASE_URL_TRAIN_DEV_TEST + "fr/HIPE-data-v1.4-train-fr.tsv",
|
49 |
+
"test": _BASE_URL_TRAIN_DEV_TEST + "fr/HIPE-data-v1.4-test-fr.tsv"
|
50 |
},
|
51 |
}
|
52 |
|
|
|
121 |
"B-org",
|
122 |
"B-pers",
|
123 |
"B-prod",
|
124 |
+
"B-time",
|
125 |
"I-loc",
|
126 |
"I-org",
|
127 |
"I-pers",
|
|
|
169 |
"I-loc.adm.town",
|
170 |
"I-loc.fac",
|
171 |
"I-loc.oro",
|
172 |
+
"I-loc.phys.astro",
|
173 |
"I-loc.phys.geo",
|
174 |
"I-loc.phys.hydro",
|
175 |
"I-loc.unk",
|
|
|
195 |
names=[
|
196 |
"O",
|
197 |
"B-loc",
|
198 |
+
"B-loc.adm.nat",
|
199 |
"B-loc.adm.reg",
|
200 |
"B-loc.adm.town",
|
201 |
"B-loc.fac",
|
|
|
206 |
"B-pers.coll",
|
207 |
"B-pers.ind",
|
208 |
"B-prod.media",
|
209 |
+
"B-time.date.abs",
|
210 |
"I-loc",
|
211 |
+
"I-loc.adm.nat",
|
212 |
"I-loc.adm.reg",
|
213 |
"I-loc.fac",
|
214 |
"I-loc.oro",
|
|
|
263 |
"I-loc.adm.nat",
|
264 |
"I-loc.adm.reg",
|
265 |
"I-loc.adm.town",
|
266 |
+
"I-loc.adm.sup",
|
267 |
"I-loc.fac",
|
268 |
"I-loc.oro",
|
269 |
+
"I-loc.phys.astro",
|
270 |
"I-loc.phys.geo",
|
271 |
"I-loc.phys.hydro",
|
272 |
"I-org",
|
273 |
"I-org.adm",
|
274 |
"I-org.ent",
|
275 |
"I-pers.ind",
|
276 |
+
"I-prod.media",
|
277 |
"_",
|
278 |
]
|
279 |
)
|
|
|
294 |
)
|
295 |
|
296 |
def _split_generators(self, dl_manager):
|
297 |
+
"""Returns SplitGenerators."""
|
298 |
downloaded_files = dl_manager.download_and_extract(self.config.data_urls)
|
299 |
+
data_files = {
|
300 |
+
"dev": downloaded_files["dev"],
|
301 |
+
"test": downloaded_files["test"],
|
302 |
+
}
|
303 |
+
splits = [
|
304 |
+
datasets.SplitGenerator(
|
305 |
+
name=datasets.Split.VALIDATION,
|
306 |
+
gen_kwargs={"filepath": data_files["dev"]},
|
307 |
+
),
|
308 |
+
datasets.SplitGenerator(
|
309 |
+
name=datasets.Split.TEST,
|
310 |
+
gen_kwargs={"filepath": data_files["test"]},
|
311 |
+
),
|
312 |
+
]
|
313 |
if self.config.name != "en":
|
314 |
+
data_files.update({
|
315 |
"train": downloaded_files["train"],
|
316 |
+
})
|
317 |
+
splits += [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
datasets.SplitGenerator(
|
319 |
name=datasets.Split.TRAIN,
|
320 |
gen_kwargs={"filepath": data_files["train"]},
|
321 |
),
|
|
|
|
|
|
|
|
|
322 |
]
|
323 |
+
return splits
|
324 |
|
325 |
def _generate_examples(self, filepath):
|
326 |
date_re = re.compile(r"# date = (\d{4}-\d{2}-\d{02})")
|
|
|
344 |
new_sentence = False
|
345 |
|
346 |
for line in f:
|
347 |
+
print(line)
|
348 |
if line.startswith(
|
349 |
"TOKEN NE-COARSE-LIT NE-COARSE-METO NE-FINE-LIT NE-FINE-METO NE-FINE-COMP NE-NESTED NEL-LIT NEL-METO MISC"
|
350 |
):
|
|
|
426 |
no_space_after = []
|
427 |
end_of_line = []
|
428 |
pysdbsegment = []
|
429 |
+
|
430 |
# HIPE 2020 tokens are tab separated
|
431 |
splits = line.split(
|
432 |
"\t"
|
|
|
468 |
"date": date,
|
469 |
"title": title,
|
470 |
"document_id": document_id,
|
471 |
+
}
|