Matej Klemen
commited on
Commit
·
5786d54
1
Parent(s):
c232a0a
Expose (predicted) linguistic annotations for src and tgt tokens; remove a leftover debug assert
Browse files- dataset_infos.json +1 -1
- solar3.py +54 -19
dataset_infos.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"default": {"description": "\u0160olar is a developmental corpus of 5485 school texts (e.g., essays), written by students in Slovenian secondary schools \n(age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade. \nPart of the corpus (2,094 texts) is annotated with teachers' corrections using a system of labels described in the \ndocument available at https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Smernice-za-oznacevanje-korpusa-Solar_V1.1.pdf (in Slovenian).\n", "citation": "@misc{solar3.0,\n title = {Developmental corpus {\u000b S}olar 3.0},\n author = {Arhar Holdt, {\u000b S}pela and Rozman, Tadeja and Stritar Ku{\u000b c}uk, Mojca and Krek, Simon and Krap{\u000b s} Vodopivec, Irena and Stabej, Marko and Pori, Eva and Goli, Teja and Lavri{\u000b c}, Polona and Laskowski, Cyprian and Kocjan{\u000b c}i{\u000b c}, Polonca and Klemenc, Bojan and Krsnik, Luka and Kosem, Iztok},\n url = {http://hdl.handle.net/11356/1589},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1589", "license": "Creative Commons - Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)", "features": {"id_doc": {"dtype": "string", "id": null, "_type": "Value"}, "doc_title": {"dtype": "string", "id": null, "_type": "Value"}, "is_manually_validated": {"dtype": "bool", "id": null, "_type": "Value"}, "id_src_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "src_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "id_tgt_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tgt_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corrections": [{"idx_src": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "idx_tgt": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corr_types": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "solar3", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 120154479, "num_examples": 125867, "dataset_name": "solar3"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Solar.TEI.zip": {"num_bytes": 99287852, "checksum": "188945c90c663cc34c77c6aefd40357b60b88436b3d9fd53f24304c927ac1cbf"}}, "download_size": 99287852, "post_processing_size": null, "dataset_size": 120154479, "size_in_bytes": 219442331}, "sentence_level": {"description": "\u0160olar is a developmental corpus of 5485 school texts (e.g., essays), written by students in Slovenian secondary schools \n(age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade. \nPart of the corpus (1516 texts) is annotated with teachers' corrections using a system of labels described in the \ndocument available at https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Smernice-za-oznacevanje-korpusa-Solar_V1.1.pdf (in Slovenian).\n", "citation": "@misc{solar3.0,\n title = {Developmental corpus {\u000b S}olar 3.0},\n author = {Arhar Holdt, {\u000b S}pela and Rozman, Tadeja and Stritar Ku{\u000b c}uk, Mojca and Krek, Simon and Krap{\u000b s} Vodopivec, Irena and Stabej, Marko and Pori, Eva and Goli, Teja and Lavri{\u000b c}, Polona and Laskowski, Cyprian and Kocjan{\u000b c}i{\u000b c}, Polonca and Klemenc, Bojan and Krsnik, Luka and Kosem, Iztok},\n url = {http://hdl.handle.net/11356/1589},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1589", "license": "Creative Commons - Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)", "features": {"id_doc": {"dtype": "string", "id": null, "_type": "Value"}, "doc_title": {"dtype": "string", "id": null, "_type": "Value"}, "is_manually_validated": {"dtype": "bool", "id": null, "_type": "Value"}, "src_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tgt_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corrections": [{"idx_src": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "idx_tgt": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corr_types": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "solar3", "config_name": "sentence_level", "version": {"version_str": "3.0.1", "description": null, "major": 3, "minor": 0, "patch": 1}, "splits": {"train": {"name": "train", "num_bytes": 41032273, "num_examples": 125867, "dataset_name": "solar3"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Solar.TEI.zip": {"num_bytes": 99287852, "checksum": "188945c90c663cc34c77c6aefd40357b60b88436b3d9fd53f24304c927ac1cbf"}}, "download_size": 99287852, "post_processing_size": null, "dataset_size": 41032273, "size_in_bytes": 140320125}, "document_level": {"description": "\u0160olar is a developmental corpus of 5485 school texts (e.g., essays), written by students in Slovenian secondary schools \n(age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade. \nPart of the corpus (1516 texts) is annotated with teachers' corrections using a system of labels described in the \ndocument available at https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Smernice-za-oznacevanje-korpusa-Solar_V1.1.pdf (in Slovenian).\n", "citation": "@misc{solar3.0,\n title = {Developmental corpus {\u000b S}olar 3.0},\n author = {Arhar Holdt, {\u000b S}pela and Rozman, Tadeja and Stritar Ku{\u000b c}uk, Mojca and Krek, Simon and Krap{\u000b s} Vodopivec, Irena and Stabej, Marko and Pori, Eva and Goli, Teja and Lavri{\u000b c}, Polona and Laskowski, Cyprian and Kocjan{\u000b c}i{\u000b c}, Polonca and Klemenc, Bojan and Krsnik, Luka and Kosem, Iztok},\n url = {http://hdl.handle.net/11356/1589},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1589", "license": "Creative Commons - Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)", "features": {"id_doc": {"dtype": "string", "id": null, "_type": "Value"}, "doc_title": {"dtype": "string", "id": null, "_type": "Value"}, "is_manually_validated": {"dtype": "bool", "id": null, "_type": "Value"}, "src_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tgt_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corrections": [{"idx_src": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "idx_tgt": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corr_types": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "solar3", "config_name": "document_level", "version": {"version_str": "3.0.1", "description": null, "major": 3, "minor": 0, "patch": 1}, "splits": {"train": {"name": "train", "num_bytes": 33456666, "num_examples": 5485, "dataset_name": "solar3"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Solar.TEI.zip": {"num_bytes": 99287852, "checksum": "188945c90c663cc34c77c6aefd40357b60b88436b3d9fd53f24304c927ac1cbf"}}, "download_size": 99287852, "post_processing_size": null, "dataset_size": 33456666, "size_in_bytes": 132744518}}
|
|
|
1 |
+
{"default": {"description": "\u0160olar is a developmental corpus of 5485 school texts (e.g., essays), written by students in Slovenian secondary schools \n(age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade. \nPart of the corpus (2,094 texts) is annotated with teachers' corrections using a system of labels described in the \ndocument available at https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Smernice-za-oznacevanje-korpusa-Solar_V1.1.pdf (in Slovenian).\n", "citation": "@misc{solar3.0,\n title = {Developmental corpus {\u000b S}olar 3.0},\n author = {Arhar Holdt, {\u000b S}pela and Rozman, Tadeja and Stritar Ku{\u000b c}uk, Mojca and Krek, Simon and Krap{\u000b s} Vodopivec, Irena and Stabej, Marko and Pori, Eva and Goli, Teja and Lavri{\u000b c}, Polona and Laskowski, Cyprian and Kocjan{\u000b c}i{\u000b c}, Polonca and Klemenc, Bojan and Krsnik, Luka and Kosem, Iztok},\n url = {http://hdl.handle.net/11356/1589},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1589", "license": "Creative Commons - Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)", "features": {"id_doc": {"dtype": "string", "id": null, "_type": "Value"}, "doc_title": {"dtype": "string", "id": null, "_type": "Value"}, "is_manually_validated": {"dtype": "bool", "id": null, "_type": "Value"}, "id_src_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "src_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "id_tgt_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tgt_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corrections": [{"idx_src": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "idx_tgt": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corr_types": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "solar3", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 120154479, "num_examples": 125867, "dataset_name": "solar3"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Solar.TEI.zip": {"num_bytes": 99287852, "checksum": "188945c90c663cc34c77c6aefd40357b60b88436b3d9fd53f24304c927ac1cbf"}}, "download_size": 99287852, "post_processing_size": null, "dataset_size": 120154479, "size_in_bytes": 219442331}, "sentence_level": {"description": "\u0160olar is a developmental corpus of 5485 school texts (e.g., essays), written by students in Slovenian secondary schools \n(age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade. \nPart of the corpus (1516 texts) is annotated with teachers' corrections using a system of labels described in the \ndocument available at https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Smernice-za-oznacevanje-korpusa-Solar_V1.1.pdf (in Slovenian).\n", "citation": "@misc{solar3.0,\n title = {Developmental corpus {\u000b S}olar 3.0},\n author = {Arhar Holdt, {\u000b S}pela and Rozman, Tadeja and Stritar Ku{\u000b c}uk, Mojca and Krek, Simon and Krap{\u000b s} Vodopivec, Irena and Stabej, Marko and Pori, Eva and Goli, Teja and Lavri{\u000b c}, Polona and Laskowski, Cyprian and Kocjan{\u000b c}i{\u000b c}, Polonca and Klemenc, Bojan and Krsnik, Luka and Kosem, Iztok},\n url = {http://hdl.handle.net/11356/1589},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1589", "license": "Creative Commons - Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)", "features": {"id_doc": {"dtype": "string", "id": null, "_type": "Value"}, "doc_title": {"dtype": "string", "id": null, "_type": "Value"}, "is_manually_validated": {"dtype": "bool", "id": null, "_type": "Value"}, "src_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "src_ling_annotations": {"lemma": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ana": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "msd": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ne_tag": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "tgt_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tgt_ling_annotations": {"lemma": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ana": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "msd": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ne_tag": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "corrections": [{"idx_src": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "idx_tgt": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corr_types": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "solar3", "config_name": "sentence_level", "version": {"version_str": "3.0.2", "description": null, "major": 3, "minor": 0, "patch": 2}, "splits": {"train": {"name": "train", "num_bytes": 317733578, "num_examples": 125867, "dataset_name": "solar3"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Solar.TEI.zip": {"num_bytes": 99287852, "checksum": "188945c90c663cc34c77c6aefd40357b60b88436b3d9fd53f24304c927ac1cbf"}}, "download_size": 99287852, "post_processing_size": null, "dataset_size": 317733578, "size_in_bytes": 417021430}, "document_level": {"description": "\u0160olar is a developmental corpus of 5485 school texts (e.g., essays), written by students in Slovenian secondary schools \n(age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade. \nPart of the corpus (1516 texts) is annotated with teachers' corrections using a system of labels described in the \ndocument available at https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Smernice-za-oznacevanje-korpusa-Solar_V1.1.pdf (in Slovenian).\n", "citation": "@misc{solar3.0,\n title = {Developmental corpus {\u000b S}olar 3.0},\n author = {Arhar Holdt, {\u000b S}pela and Rozman, Tadeja and Stritar Ku{\u000b c}uk, Mojca and Krek, Simon and Krap{\u000b s} Vodopivec, Irena and Stabej, Marko and Pori, Eva and Goli, Teja and Lavri{\u000b c}, Polona and Laskowski, Cyprian and Kocjan{\u000b c}i{\u000b c}, Polonca and Klemenc, Bojan and Krsnik, Luka and Kosem, Iztok},\n url = {http://hdl.handle.net/11356/1589},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1589", "license": "Creative Commons - Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)", "features": {"id_doc": {"dtype": "string", "id": null, "_type": "Value"}, "doc_title": {"dtype": "string", "id": null, "_type": "Value"}, "is_manually_validated": {"dtype": "bool", "id": null, "_type": "Value"}, "src_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "src_ling_annotations": {"lemma": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ana": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "msd": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ne_tag": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "tgt_tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tgt_ling_annotations": {"lemma": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ana": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "msd": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ne_tag": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "corrections": [{"idx_src": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "idx_tgt": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "corr_types": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "solar3", "config_name": "document_level", "version": {"version_str": "3.0.2", "description": null, "major": 3, "minor": 0, "patch": 2}, "splits": {"train": {"name": "train", "num_bytes": 305646012, "num_examples": 5485, "dataset_name": "solar3"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Solar.TEI.zip": {"num_bytes": 99287852, "checksum": "188945c90c663cc34c77c6aefd40357b60b88436b3d9fd53f24304c927ac1cbf"}}, "download_size": 99287852, "post_processing_size": null, "dataset_size": 305646012, "size_in_bytes": 404933864}}
|
solar3.py
CHANGED
@@ -48,17 +48,18 @@ def resolve_element(tag_el, ne_tag: Optional[str] = "O"):
|
|
48 |
if tag_el.tag.endswith(("w", "pc")):
|
49 |
form = tag_el.text.strip()
|
50 |
lemma = tag_el.text.strip() if tag_el.tag.endswith("pc") else tag_el.attrib["lemma"]
|
51 |
-
|
|
|
52 |
ret_ne_tag = ne_tag
|
53 |
id_tag = tag_el.attrib[f"{XML_NAMESPACE}id"]
|
54 |
|
55 |
-
return [(id_tag, form, lemma, msd, ret_ne_tag)]
|
56 |
# Named entities: words and punctuation nested directly below current element
|
57 |
elif tag_el.tag.endswith("seg"):
|
58 |
anns = []
|
59 |
ret_ne_tag = tag_el.attrib["subtype"].upper()
|
60 |
-
for curr_child in tag_el:
|
61 |
-
anns.extend(resolve_element(curr_child, ne_tag=ret_ne_tag))
|
62 |
|
63 |
return anns
|
64 |
|
@@ -108,19 +109,21 @@ def read_data(data_path):
|
|
108 |
for idx_sent, curr_sent in enumerate(curr_par.iterfind(f".//{NAMESPACE}s")):
|
109 |
id_sent = curr_sent.attrib[f"{XML_NAMESPACE}id"]
|
110 |
ids, forms, lemmas, msds, nes = [], [], [], [], []
|
|
|
111 |
for curr_el in curr_sent:
|
112 |
curr_annotations = resolve_element(curr_el)
|
113 |
for curr_ann in curr_annotations:
|
114 |
ids.append(curr_ann[0])
|
115 |
forms.append(curr_ann[1])
|
116 |
lemmas.append(curr_ann[2])
|
117 |
-
|
118 |
-
|
|
|
119 |
|
120 |
data[id_sent] = {
|
121 |
"id_doc": id_text,
|
122 |
"doc_title": text_title,
|
123 |
-
"id_token": ids, "form": forms, "lemma": lemmas, "msd":
|
124 |
"is_manually_validated": is_manually_validated
|
125 |
}
|
126 |
|
@@ -131,7 +134,7 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
131 |
"""Šolar is a developmental corpus of school texts (e.g., essays), annotated with metadata and (partially)
|
132 |
with teachers' corrections. """
|
133 |
|
134 |
-
VERSION = datasets.Version("3.0.
|
135 |
|
136 |
BUILDER_CONFIGS = [
|
137 |
datasets.BuilderConfig(name="sentence_level", version=VERSION,
|
@@ -149,7 +152,19 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
149 |
"doc_title": datasets.Value("string"),
|
150 |
"is_manually_validated": datasets.Value("bool"),
|
151 |
"src_tokens": datasets.Sequence(datasets.Value("string")),
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
"tgt_tokens": datasets.Sequence(datasets.Value("string")),
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
"corrections": [
|
154 |
{
|
155 |
"idx_src": datasets.Sequence(datasets.Value("int32")),
|
@@ -210,6 +225,7 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
210 |
src_sent_data["id_token"].extend(curr_sent_data["id_token"])
|
211 |
src_sent_data["form"].extend(curr_sent_data["form"])
|
212 |
src_sent_data["lemma"].extend(curr_sent_data["lemma"])
|
|
|
213 |
src_sent_data["msd"].extend(curr_sent_data["msd"])
|
214 |
src_sent_data["ne_tag"].extend(curr_sent_data["ne_tag"])
|
215 |
|
@@ -226,6 +242,7 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
226 |
tgt_sent_data["id_token"].extend(curr_sent_data["id_token"])
|
227 |
tgt_sent_data["form"].extend(curr_sent_data["form"])
|
228 |
tgt_sent_data["lemma"].extend(curr_sent_data["lemma"])
|
|
|
229 |
tgt_sent_data["msd"].extend(curr_sent_data["msd"])
|
230 |
tgt_sent_data["ne_tag"].extend(curr_sent_data["ne_tag"])
|
231 |
|
@@ -264,8 +281,20 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
264 |
"is_manually_validated": is_manually_validated,
|
265 |
"id_src_tokens": src_sent_data.get("id_token", []),
|
266 |
"src_tokens": src_sent_data.get("form", []),
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
"id_tgt_tokens": tgt_sent_data.get("id_token", []),
|
268 |
"tgt_tokens": tgt_sent_data.get("form", []),
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
"corrections": corr_data
|
270 |
}
|
271 |
|
@@ -276,6 +305,8 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
276 |
curr_instances = map(lambda tup: tup[1], curr_group) # remove the redundant index info from datasets
|
277 |
|
278 |
src_tokens, tgt_tokens, mapped_corrections = [], [], []
|
|
|
|
|
279 |
seen_src_tokens, seen_tgt_tokens = {}, {}
|
280 |
# Need to keep the current base position of source and target tokens AND previous base position:
|
281 |
# A source may map into multiple targets (or vice versa), but we do not want to write it twice in a doc.
|
@@ -290,18 +321,29 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
290 |
|
291 |
id_src_toks, id_tgt_toks = curr_inst["id_src_tokens"], curr_inst["id_tgt_tokens"]
|
292 |
curr_src_toks, curr_tgt_toks = curr_inst["src_tokens"], curr_inst["tgt_tokens"]
|
|
|
293 |
curr_corrs = curr_inst["corrections"]
|
294 |
|
295 |
num_added_src, num_added_tgt = 0, 0
|
296 |
-
for id_tok, tok in zip(id_src_toks, curr_src_toks):
|
297 |
if id_tok not in seen_src_tokens:
|
298 |
src_tokens.append(tok)
|
|
|
|
|
|
|
|
|
|
|
299 |
seen_src_tokens[id_tok] = tok
|
300 |
num_added_src += 1
|
301 |
|
302 |
-
for id_tok, tok in zip(id_tgt_toks, curr_tgt_toks):
|
303 |
if id_tok not in seen_tgt_tokens:
|
304 |
tgt_tokens.append(tok)
|
|
|
|
|
|
|
|
|
|
|
305 |
seen_tgt_tokens[id_tok] = tok
|
306 |
num_added_tgt += 1
|
307 |
|
@@ -318,15 +360,6 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
318 |
"corr_types": corr["corr_types"]
|
319 |
})
|
320 |
|
321 |
-
# TODO: sanity check
|
322 |
-
for _idx_src in mapped_corrections[-1]["idx_src"]:
|
323 |
-
if _idx_src >= len(src_tokens):
|
324 |
-
raise ValueError
|
325 |
-
|
326 |
-
for _idx_tgt in mapped_corrections[-1]["idx_tgt"]:
|
327 |
-
if _idx_tgt >= len(tgt_tokens):
|
328 |
-
raise ValueError
|
329 |
-
|
330 |
src_base += num_added_src
|
331 |
tgt_base += num_added_tgt
|
332 |
|
@@ -341,7 +374,9 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
341 |
"doc_title": doc_title,
|
342 |
"is_manually_validated": is_validated,
|
343 |
"src_tokens": src_tokens,
|
|
|
344 |
"tgt_tokens": tgt_tokens,
|
|
|
345 |
"corrections": mapped_corrections
|
346 |
}
|
347 |
|
|
|
48 |
if tag_el.tag.endswith(("w", "pc")):
|
49 |
form = tag_el.text.strip()
|
50 |
lemma = tag_el.text.strip() if tag_el.tag.endswith("pc") else tag_el.attrib["lemma"]
|
51 |
+
ana = tag_el.attrib["ana"] # JOS/MTE specifications
|
52 |
+
msd = tag_el.attrib["msd"] # UD specifications
|
53 |
ret_ne_tag = ne_tag
|
54 |
id_tag = tag_el.attrib[f"{XML_NAMESPACE}id"]
|
55 |
|
56 |
+
return [(id_tag, form, lemma, ana, msd, ret_ne_tag)]
|
57 |
# Named entities: words and punctuation nested directly below current element
|
58 |
elif tag_el.tag.endswith("seg"):
|
59 |
anns = []
|
60 |
ret_ne_tag = tag_el.attrib["subtype"].upper()
|
61 |
+
for idx_child, curr_child in enumerate(tag_el):
|
62 |
+
anns.extend(resolve_element(curr_child, ne_tag=f"B-{ret_ne_tag}" if idx_child == 0 else f"I-{ret_ne_tag}"))
|
63 |
|
64 |
return anns
|
65 |
|
|
|
109 |
for idx_sent, curr_sent in enumerate(curr_par.iterfind(f".//{NAMESPACE}s")):
|
110 |
id_sent = curr_sent.attrib[f"{XML_NAMESPACE}id"]
|
111 |
ids, forms, lemmas, msds, nes = [], [], [], [], []
|
112 |
+
msds_jos, msds_ud = [], []
|
113 |
for curr_el in curr_sent:
|
114 |
curr_annotations = resolve_element(curr_el)
|
115 |
for curr_ann in curr_annotations:
|
116 |
ids.append(curr_ann[0])
|
117 |
forms.append(curr_ann[1])
|
118 |
lemmas.append(curr_ann[2])
|
119 |
+
msds_jos.append(curr_ann[3])
|
120 |
+
msds_ud.append(curr_ann[4])
|
121 |
+
nes.append(curr_ann[5])
|
122 |
|
123 |
data[id_sent] = {
|
124 |
"id_doc": id_text,
|
125 |
"doc_title": text_title,
|
126 |
+
"id_token": ids, "form": forms, "lemma": lemmas, "ana": msds_jos, "msd": msds_ud, "ne_tag": nes,
|
127 |
"is_manually_validated": is_manually_validated
|
128 |
}
|
129 |
|
|
|
134 |
"""Šolar is a developmental corpus of school texts (e.g., essays), annotated with metadata and (partially)
|
135 |
with teachers' corrections. """
|
136 |
|
137 |
+
VERSION = datasets.Version("3.0.2")
|
138 |
|
139 |
BUILDER_CONFIGS = [
|
140 |
datasets.BuilderConfig(name="sentence_level", version=VERSION,
|
|
|
152 |
"doc_title": datasets.Value("string"),
|
153 |
"is_manually_validated": datasets.Value("bool"),
|
154 |
"src_tokens": datasets.Sequence(datasets.Value("string")),
|
155 |
+
"src_ling_annotations": {
|
156 |
+
"lemma": datasets.Sequence(datasets.Value("string")),
|
157 |
+
"ana": datasets.Sequence(datasets.Value("string")),
|
158 |
+
"msd": datasets.Sequence(datasets.Value("string")),
|
159 |
+
"ne_tag": datasets.Sequence(datasets.Value("string"))
|
160 |
+
},
|
161 |
"tgt_tokens": datasets.Sequence(datasets.Value("string")),
|
162 |
+
"tgt_ling_annotations": {
|
163 |
+
"lemma": datasets.Sequence(datasets.Value("string")),
|
164 |
+
"ana": datasets.Sequence(datasets.Value("string")),
|
165 |
+
"msd": datasets.Sequence(datasets.Value("string")),
|
166 |
+
"ne_tag": datasets.Sequence(datasets.Value("string"))
|
167 |
+
},
|
168 |
"corrections": [
|
169 |
{
|
170 |
"idx_src": datasets.Sequence(datasets.Value("int32")),
|
|
|
225 |
src_sent_data["id_token"].extend(curr_sent_data["id_token"])
|
226 |
src_sent_data["form"].extend(curr_sent_data["form"])
|
227 |
src_sent_data["lemma"].extend(curr_sent_data["lemma"])
|
228 |
+
src_sent_data["ana"].extend(curr_sent_data["ana"])
|
229 |
src_sent_data["msd"].extend(curr_sent_data["msd"])
|
230 |
src_sent_data["ne_tag"].extend(curr_sent_data["ne_tag"])
|
231 |
|
|
|
242 |
tgt_sent_data["id_token"].extend(curr_sent_data["id_token"])
|
243 |
tgt_sent_data["form"].extend(curr_sent_data["form"])
|
244 |
tgt_sent_data["lemma"].extend(curr_sent_data["lemma"])
|
245 |
+
tgt_sent_data["ana"].extend(curr_sent_data["ana"])
|
246 |
tgt_sent_data["msd"].extend(curr_sent_data["msd"])
|
247 |
tgt_sent_data["ne_tag"].extend(curr_sent_data["ne_tag"])
|
248 |
|
|
|
281 |
"is_manually_validated": is_manually_validated,
|
282 |
"id_src_tokens": src_sent_data.get("id_token", []),
|
283 |
"src_tokens": src_sent_data.get("form", []),
|
284 |
+
"src_ling_annotations": {
|
285 |
+
"lemma": src_sent_data.get("lemma", []),
|
286 |
+
"ana": src_sent_data.get("ana", []),
|
287 |
+
"msd": src_sent_data.get("msd", []),
|
288 |
+
"ne_tag": src_sent_data.get("ne_tag", [])
|
289 |
+
},
|
290 |
"id_tgt_tokens": tgt_sent_data.get("id_token", []),
|
291 |
"tgt_tokens": tgt_sent_data.get("form", []),
|
292 |
+
"tgt_ling_annotations": {
|
293 |
+
"lemma": tgt_sent_data.get("lemma", []),
|
294 |
+
"ana": tgt_sent_data.get("ana", []),
|
295 |
+
"msd": tgt_sent_data.get("msd", []),
|
296 |
+
"ne_tag": tgt_sent_data.get("ne_tag", [])
|
297 |
+
},
|
298 |
"corrections": corr_data
|
299 |
}
|
300 |
|
|
|
305 |
curr_instances = map(lambda tup: tup[1], curr_group) # remove the redundant index info from datasets
|
306 |
|
307 |
src_tokens, tgt_tokens, mapped_corrections = [], [], []
|
308 |
+
src_ling_anns = {"lemma": [], "ana": [], "msd": [], "ne_tag": []}
|
309 |
+
tgt_ling_anns = {"lemma": [], "ana": [], "msd": [], "ne_tag": []}
|
310 |
seen_src_tokens, seen_tgt_tokens = {}, {}
|
311 |
# Need to keep the current base position of source and target tokens AND previous base position:
|
312 |
# A source may map into multiple targets (or vice versa), but we do not want to write it twice in a doc.
|
|
|
321 |
|
322 |
id_src_toks, id_tgt_toks = curr_inst["id_src_tokens"], curr_inst["id_tgt_tokens"]
|
323 |
curr_src_toks, curr_tgt_toks = curr_inst["src_tokens"], curr_inst["tgt_tokens"]
|
324 |
+
curr_src_anns, curr_tgt_anns = curr_inst["src_ling_annotations"], curr_inst["tgt_ling_annotations"]
|
325 |
curr_corrs = curr_inst["corrections"]
|
326 |
|
327 |
num_added_src, num_added_tgt = 0, 0
|
328 |
+
for idx_position, (id_tok, tok) in enumerate(zip(id_src_toks, curr_src_toks)):
|
329 |
if id_tok not in seen_src_tokens:
|
330 |
src_tokens.append(tok)
|
331 |
+
src_ling_anns["lemma"].append(curr_src_anns["lemma"][idx_position])
|
332 |
+
src_ling_anns["ana"].append(curr_src_anns["ana"][idx_position])
|
333 |
+
src_ling_anns["msd"].append(curr_src_anns["msd"][idx_position])
|
334 |
+
src_ling_anns["ne_tag"].append(curr_src_anns["ne_tag"][idx_position])
|
335 |
+
|
336 |
seen_src_tokens[id_tok] = tok
|
337 |
num_added_src += 1
|
338 |
|
339 |
+
for idx_position, (id_tok, tok) in enumerate(zip(id_tgt_toks, curr_tgt_toks)):
|
340 |
if id_tok not in seen_tgt_tokens:
|
341 |
tgt_tokens.append(tok)
|
342 |
+
tgt_ling_anns["lemma"].append(curr_tgt_anns["lemma"][idx_position])
|
343 |
+
tgt_ling_anns["ana"].append(curr_tgt_anns["ana"][idx_position])
|
344 |
+
tgt_ling_anns["msd"].append(curr_tgt_anns["msd"][idx_position])
|
345 |
+
tgt_ling_anns["ne_tag"].append(curr_tgt_anns["ne_tag"][idx_position])
|
346 |
+
|
347 |
seen_tgt_tokens[id_tok] = tok
|
348 |
num_added_tgt += 1
|
349 |
|
|
|
360 |
"corr_types": corr["corr_types"]
|
361 |
})
|
362 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
src_base += num_added_src
|
364 |
tgt_base += num_added_tgt
|
365 |
|
|
|
374 |
"doc_title": doc_title,
|
375 |
"is_manually_validated": is_validated,
|
376 |
"src_tokens": src_tokens,
|
377 |
+
"src_ling_annotations": src_ling_anns,
|
378 |
"tgt_tokens": tgt_tokens,
|
379 |
+
"tgt_ling_annotations": tgt_ling_anns,
|
380 |
"corrections": mapped_corrections
|
381 |
}
|
382 |
|