Matej Klemen
commited on
Commit
•
b2bdc31
1
Parent(s):
d7406d5
Multiple fixes:
Browse files* Fix indices inside corrections pointing to out-of-bounds tokens due to some sentences not being marked in the 'corresp' field of the correction group tag
* Write the correct version of the dataset (3.0 instead of 1.0)
* Correct the statistic of manually annotated documents
* Remove idx_par, idx_sent for source and target sentences
- README.md +5 -11
- dataset_infos.json +1 -1
- solar3.py +55 -31
README.md
CHANGED
@@ -34,7 +34,7 @@ task_ids:
|
|
34 |
|
35 |
Šolar* is a developmental corpus of 5485 school texts (e.g., essays), written by students in Slovenian secondary schools
|
36 |
(age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade.
|
37 |
-
Part of the corpus (
|
38 |
document available at https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Smernice-za-oznacevanje-korpusa-Solar_V1.1.pdf (in Slovenian).
|
39 |
|
40 |
\(*) pronounce "š" as "sh" in "shoe".
|
@@ -88,11 +88,9 @@ A sample instance from the dataset:
|
|
88 |
{
|
89 |
'id_doc': 'solar1',
|
90 |
'doc_title': 'KUS-G-slo-1-GO-E-2009-10001',
|
91 |
-
'is_manually_validated': True,
|
92 |
-
'idx_src_par': 2, 'idx_src_sent': 0,
|
93 |
'id_src_tokens': ['solar1s.3.1.1', 'solar1s.3.1.2', 'solar1s.3.1.3', 'solar1s.3.1.4', 'solar1s.3.1.5', 'solar1s.3.1.6', 'solar1s.3.1.7', 'solar1s.3.1.8', 'solar1s.3.1.9', 'solar1s.3.1.10', 'solar1s.3.1.11', 'solar1s.3.1.12', 'solar1s.3.1.13', 'solar1s.3.1.14', 'solar1s.3.1.15', 'solar1s.3.1.16', 'solar1s.3.1.17', 'solar1s.3.1.18', 'solar1s.3.1.19', 'solar1s.3.1.20', 'solar1s.3.1.21', 'solar1s.3.1.22', 'solar1s.3.1.23', 'solar1s.3.1.24', 'solar1s.3.1.25'],
|
94 |
'src_tokens': ['”', 'Ne', 'da', 'sovražim', ',', 'da', 'ljubim', 'sem', 'na', 'svetu', '”', ',', 'izreče', 'Antigona', 'v', 'bran', 'kralju', 'Kreonu', 'za', 'svoje', 'nasprotno', 'mišljenje', 'pred', 'smrtjo', '.'],
|
95 |
-
'idx_tgt_par': 2, 'idx_tgt_sent': 0,
|
96 |
'id_tgt_tokens': ['solar1t.3.1.1', 'solar1t.3.1.2', 'solar1t.3.1.3', 'solar1t.3.1.4', 'solar1t.3.1.5', 'solar1t.3.1.6', 'solar1t.3.1.7', 'solar1t.3.1.8', 'solar1t.3.1.9', 'solar1t.3.1.10', 'solar1t.3.1.11', 'solar1t.3.1.12', 'solar1t.3.1.13', 'solar1t.3.1.14', 'solar1t.3.1.15', 'solar1t.3.1.16', 'solar1t.3.1.17', 'solar1t.3.1.18', 'solar1t.3.1.19', 'solar1t.3.1.20', 'solar1t.3.1.21', 'solar1t.3.1.22', 'solar1t.3.1.23', 'solar1t.3.1.24', 'solar1t.3.1.25', 'solar1t.3.1.26'],
|
97 |
'tgt_tokens': ['„', 'Ne', 'da', 'sovražim', ',', 'da', 'ljubim', 'sem', 'na', 'svetu', ',', '”', 'izreče', 'Antigona', 'sebi', 'v', 'bran', 'kralju', 'Kreonu', 'za', 'svoje', 'nasprotno', 'mišljenje', 'pred', 'smrtjo', '.'],
|
98 |
'corrections': [
|
@@ -112,13 +110,9 @@ The instance represents a correction in the document 'solar1' (`id_doc`), which
|
|
112 |
|
113 |
- `id_doc`: a string containing the identifying name of the document in which the sentence appears;
|
114 |
- `doc_title`: a string containing the assigned document title;
|
115 |
-
- `is_manually_validated`: a bool indicating whether the document in which the sentence appears was reviewed by a teacher;
|
116 |
-
- `idx_src_par`: a uint32 containing the index of the paragraph in which the source sentence appears (`-1` if there is no source sentence);
|
117 |
-
- `idx_src_sent`: a uint32 containing the index of the source sentence inside its paragraph (`-1` if there is no source sentence);
|
118 |
- `id_src_tokens`: identifiers of words in the source sentence (`[]` if there is no source sentence);
|
119 |
-
- `src_tokens`: words in the source sentence (`[]` if there is no source sentence);
|
120 |
-
- `idx_tgt_par`: a uint32 containing the index of the paragraph in which the target sentence appears (`-1` if there is no target sentence);
|
121 |
-
- `idx_tgt_sent`: a uint32 containing the index of the target sentence inside its paragraph (`-1` if there is no target sentence);
|
122 |
- `id_tgt_tokens`: identifiers of words in the target sentence (`[]` if there is no target sentence);
|
123 |
- `tgt_tokens`: words in the target sentence (`[]` if there is no target sentence);
|
124 |
- `corrections`: a list of the corrections, with each correction represented with a dictionary, containing the indices of the source tokens involved (`idx_src`), target tokens involved (`idx_tgt`), and the categories of the corrections made (`corr_types`). Please note that there can be multiple assigned categories for one annotated correction, in which case `len(corr_types) > 1`.
|
@@ -130,7 +124,7 @@ Note: `idx_src_par`, `idx_src_sent`, `idx_tgt_par`, `idx_tgt_sent` can be used t
|
|
130 |
|
131 |
The Developmental corpus Šolar consists of 5,485 texts written by students in Slovenian secondary schools (age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade. The information on school (elementary or secondary), subject, level (grade or year), type of text, region, and date of production is provided for each text. School essays form the majority of the corpus while other material includes texts created during lessons, such as text recapitulations or descriptions, examples of formal applications, etc.
|
132 |
|
133 |
-
Part of the corpus (
|
134 |
|
135 |
|
136 |
## Additional Information
|
|
|
34 |
|
35 |
Šolar* is a developmental corpus of 5485 school texts (e.g., essays), written by students in Slovenian secondary schools
|
36 |
(age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade.
|
37 |
+
Part of the corpus (1516 texts) is annotated with teachers' corrections using a system of labels described in the
|
38 |
document available at https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1589/Smernice-za-oznacevanje-korpusa-Solar_V1.1.pdf (in Slovenian).
|
39 |
|
40 |
\(*) pronounce "š" as "sh" in "shoe".
|
|
|
88 |
{
|
89 |
'id_doc': 'solar1',
|
90 |
'doc_title': 'KUS-G-slo-1-GO-E-2009-10001',
|
91 |
+
'is_manually_validated': True,
|
|
|
92 |
'id_src_tokens': ['solar1s.3.1.1', 'solar1s.3.1.2', 'solar1s.3.1.3', 'solar1s.3.1.4', 'solar1s.3.1.5', 'solar1s.3.1.6', 'solar1s.3.1.7', 'solar1s.3.1.8', 'solar1s.3.1.9', 'solar1s.3.1.10', 'solar1s.3.1.11', 'solar1s.3.1.12', 'solar1s.3.1.13', 'solar1s.3.1.14', 'solar1s.3.1.15', 'solar1s.3.1.16', 'solar1s.3.1.17', 'solar1s.3.1.18', 'solar1s.3.1.19', 'solar1s.3.1.20', 'solar1s.3.1.21', 'solar1s.3.1.22', 'solar1s.3.1.23', 'solar1s.3.1.24', 'solar1s.3.1.25'],
|
93 |
'src_tokens': ['”', 'Ne', 'da', 'sovražim', ',', 'da', 'ljubim', 'sem', 'na', 'svetu', '”', ',', 'izreče', 'Antigona', 'v', 'bran', 'kralju', 'Kreonu', 'za', 'svoje', 'nasprotno', 'mišljenje', 'pred', 'smrtjo', '.'],
|
|
|
94 |
'id_tgt_tokens': ['solar1t.3.1.1', 'solar1t.3.1.2', 'solar1t.3.1.3', 'solar1t.3.1.4', 'solar1t.3.1.5', 'solar1t.3.1.6', 'solar1t.3.1.7', 'solar1t.3.1.8', 'solar1t.3.1.9', 'solar1t.3.1.10', 'solar1t.3.1.11', 'solar1t.3.1.12', 'solar1t.3.1.13', 'solar1t.3.1.14', 'solar1t.3.1.15', 'solar1t.3.1.16', 'solar1t.3.1.17', 'solar1t.3.1.18', 'solar1t.3.1.19', 'solar1t.3.1.20', 'solar1t.3.1.21', 'solar1t.3.1.22', 'solar1t.3.1.23', 'solar1t.3.1.24', 'solar1t.3.1.25', 'solar1t.3.1.26'],
|
95 |
'tgt_tokens': ['„', 'Ne', 'da', 'sovražim', ',', 'da', 'ljubim', 'sem', 'na', 'svetu', ',', '”', 'izreče', 'Antigona', 'sebi', 'v', 'bran', 'kralju', 'Kreonu', 'za', 'svoje', 'nasprotno', 'mišljenje', 'pred', 'smrtjo', '.'],
|
96 |
'corrections': [
|
|
|
110 |
|
111 |
- `id_doc`: a string containing the identifying name of the document in which the sentence appears;
|
112 |
- `doc_title`: a string containing the assigned document title;
|
113 |
+
- `is_manually_validated`: a bool indicating whether the document in which the sentence appears was reviewed by a teacher;
|
|
|
|
|
114 |
- `id_src_tokens`: identifiers of words in the source sentence (`[]` if there is no source sentence);
|
115 |
+
- `src_tokens`: words in the source sentence (`[]` if there is no source sentence);
|
|
|
|
|
116 |
- `id_tgt_tokens`: identifiers of words in the target sentence (`[]` if there is no target sentence);
|
117 |
- `tgt_tokens`: words in the target sentence (`[]` if there is no target sentence);
|
118 |
- `corrections`: a list of the corrections, with each correction represented with a dictionary, containing the indices of the source tokens involved (`idx_src`), target tokens involved (`idx_tgt`), and the categories of the corrections made (`corr_types`). Please note that there can be multiple assigned categories for one annotated correction, in which case `len(corr_types) > 1`.
|
|
|
124 |
|
125 |
The Developmental corpus Šolar consists of 5,485 texts written by students in Slovenian secondary schools (age 15-19) and pupils in the 7th-9th grade of primary school (13-15), with a small percentage also from the 6th grade. The information on school (elementary or secondary), subject, level (grade or year), type of text, region, and date of production is provided for each text. School essays form the majority of the corpus while other material includes texts created during lessons, such as text recapitulations or descriptions, examples of formal applications, etc.
|
126 |
|
127 |
+
Part of the corpus (1516 texts) is annotated with teachers' corrections using a system of labels described in the attached document (in Slovenian). Teacher corrections were part of the original files and reflect real classroom situations of essay marking. Corrections were then inserted into texts by annotators and subsequently categorized.
|
128 |
|
129 |
|
130 |
## Additional Information
|
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"}, "
|
|
|
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}}
|
solar3.py
CHANGED
@@ -63,6 +63,28 @@ def resolve_element(tag_el, ne_tag: Optional[str] = "O"):
|
|
63 |
return anns
|
64 |
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
def read_data(data_path):
|
67 |
data = {} # ID_sent -> sentence_metadata
|
68 |
tree = ET.parse(data_path)
|
@@ -98,8 +120,6 @@ def read_data(data_path):
|
|
98 |
data[id_sent] = {
|
99 |
"id_doc": id_text,
|
100 |
"doc_title": text_title,
|
101 |
-
"idx_par": idx_par,
|
102 |
-
"idx_sent": idx_sent,
|
103 |
"id_token": ids, "form": forms, "lemma": lemmas, "msd": msds, "ne_tag": nes,
|
104 |
"is_manually_validated": is_manually_validated
|
105 |
}
|
@@ -111,7 +131,7 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
111 |
"""Šolar is a developmental corpus of school texts (e.g., essays), annotated with metadata and (partially)
|
112 |
with teachers' corrections. """
|
113 |
|
114 |
-
VERSION = datasets.Version("
|
115 |
|
116 |
def _info(self):
|
117 |
features = datasets.Features(
|
@@ -119,12 +139,8 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
119 |
"id_doc": datasets.Value("string"),
|
120 |
"doc_title": datasets.Value("string"),
|
121 |
"is_manually_validated": datasets.Value("bool"),
|
122 |
-
"idx_src_par": datasets.Value("int32"),
|
123 |
-
"idx_src_sent": datasets.Value("int32"),
|
124 |
"id_src_tokens": datasets.Sequence(datasets.Value("string")),
|
125 |
"src_tokens": datasets.Sequence(datasets.Value("string")),
|
126 |
-
"idx_tgt_par": datasets.Value("int32"),
|
127 |
-
"idx_tgt_sent": datasets.Value("int32"),
|
128 |
"id_tgt_tokens": datasets.Sequence(datasets.Value("string")),
|
129 |
"tgt_tokens": datasets.Sequence(datasets.Value("string")),
|
130 |
"corrections": [
|
@@ -171,34 +187,46 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
171 |
|
172 |
for idx_corr, corrected_sent in enumerate(root.iterfind(f"{NAMESPACE}linkGrp")):
|
173 |
involved_sents = corrected_sent.attrib["corresp"].split(" ")
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
# not always ordered <source> <target>, sometimes reversed
|
178 |
-
if "t" in involved_sents[0]:
|
179 |
-
id_src_sent, id_tgt_sent = list(map(lambda _s: _s[1:], involved_sents[::-1]))
|
180 |
-
else:
|
181 |
-
id_src_sent, id_tgt_sent = list(map(lambda _s: _s[1:], involved_sents))
|
182 |
-
else: # one sentence: only source or only target (usually a sentence marked as redundant or as missing)
|
183 |
-
id_src_sent, id_tgt_sent = None, None
|
184 |
-
if "t" in involved_sents[0]:
|
185 |
-
id_tgt_sent = involved_sents[0][1:]
|
186 |
-
else:
|
187 |
-
id_src_sent = involved_sents[0][1:]
|
188 |
|
189 |
id_doc, doc_title, is_manually_validated = None, None, False
|
190 |
src_sent_data, tgt_sent_data = {}, {}
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
id_doc = src_sent_data["id_doc"]
|
195 |
doc_title = src_sent_data["doc_title"]
|
196 |
is_manually_validated |= src_sent_data["is_manually_validated"]
|
197 |
-
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
id_doc = tgt_sent_data["id_doc"]
|
200 |
doc_title = tgt_sent_data["doc_title"]
|
201 |
is_manually_validated |= tgt_sent_data["is_manually_validated"]
|
|
|
|
|
202 |
|
203 |
corr_data = []
|
204 |
for token_info in corrected_sent.findall(f"{NAMESPACE}link"):
|
@@ -215,7 +243,7 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
215 |
|
216 |
for curr_tok in connections:
|
217 |
# Token IDs have an index at the end, but it is 1-based; convert it to 0-based
|
218 |
-
idx_tok =
|
219 |
if "t" in curr_tok: # target token
|
220 |
tgt_inds.append(idx_tok)
|
221 |
else: # source token
|
@@ -227,12 +255,8 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
227 |
"id_doc": id_doc[:-1], # doc ID without the "s" or "t" info
|
228 |
"doc_title": doc_title,
|
229 |
"is_manually_validated": is_manually_validated,
|
230 |
-
"idx_src_par": src_sent_data.get("idx_par", -1),
|
231 |
-
"idx_src_sent": src_sent_data.get("idx_sent", -1),
|
232 |
"id_src_tokens": src_sent_data.get("id_token", []),
|
233 |
"src_tokens": src_sent_data.get("form", []),
|
234 |
-
"idx_tgt_par": tgt_sent_data.get("idx_par", -1),
|
235 |
-
"idx_tgt_sent": tgt_sent_data.get("idx_sent", -1),
|
236 |
"id_tgt_tokens": tgt_sent_data.get("id_token", []),
|
237 |
"tgt_tokens": tgt_sent_data.get("form", []),
|
238 |
"corrections": corr_data
|
|
|
63 |
return anns
|
64 |
|
65 |
|
66 |
+
def extract_sent_id(tok_id):
|
67 |
+
# e.g., `extract_sent_id("#solar1s.3.2.44") == "solar1s.3.2"` or `extract_sent_id("solar1s.3.2.44") == "solar1s.3.2"`
|
68 |
+
_tok_id = tok_id[1:] if tok_id.startswith("#") else tok_id
|
69 |
+
return ".".join(_tok_id.split(".")[: -1])
|
70 |
+
|
71 |
+
|
72 |
+
def find_involved_sents(correction_group_el):
|
73 |
+
src_sent_ids = set()
|
74 |
+
tgt_sent_ids = set()
|
75 |
+
for _curr_corr in correction_group_el:
|
76 |
+
sent_ids = list(map(lambda _tok_id: extract_sent_id(_tok_id),
|
77 |
+
_curr_corr.attrib["target"].split(" ")))
|
78 |
+
|
79 |
+
for _s_id in sent_ids:
|
80 |
+
if "t" in _s_id:
|
81 |
+
tgt_sent_ids.add(_s_id)
|
82 |
+
else:
|
83 |
+
src_sent_ids.add(_s_id)
|
84 |
+
|
85 |
+
return sorted(list(src_sent_ids)), sorted(list(tgt_sent_ids))
|
86 |
+
|
87 |
+
|
88 |
def read_data(data_path):
|
89 |
data = {} # ID_sent -> sentence_metadata
|
90 |
tree = ET.parse(data_path)
|
|
|
120 |
data[id_sent] = {
|
121 |
"id_doc": id_text,
|
122 |
"doc_title": text_title,
|
|
|
|
|
123 |
"id_token": ids, "form": forms, "lemma": lemmas, "msd": msds, "ne_tag": nes,
|
124 |
"is_manually_validated": is_manually_validated
|
125 |
}
|
|
|
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.0")
|
135 |
|
136 |
def _info(self):
|
137 |
features = datasets.Features(
|
|
|
139 |
"id_doc": datasets.Value("string"),
|
140 |
"doc_title": datasets.Value("string"),
|
141 |
"is_manually_validated": datasets.Value("bool"),
|
|
|
|
|
142 |
"id_src_tokens": datasets.Sequence(datasets.Value("string")),
|
143 |
"src_tokens": datasets.Sequence(datasets.Value("string")),
|
|
|
|
|
144 |
"id_tgt_tokens": datasets.Sequence(datasets.Value("string")),
|
145 |
"tgt_tokens": datasets.Sequence(datasets.Value("string")),
|
146 |
"corrections": [
|
|
|
187 |
|
188 |
for idx_corr, corrected_sent in enumerate(root.iterfind(f"{NAMESPACE}linkGrp")):
|
189 |
involved_sents = corrected_sent.attrib["corresp"].split(" ")
|
190 |
+
# Involved sentences according to the IDs of token mappings - 'corresp' does not list all of them!
|
191 |
+
# (possible bug in data)
|
192 |
+
involved_src_sents, involved_tgt_sents = find_involved_sents(corrected_sent)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
|
194 |
id_doc, doc_title, is_manually_validated = None, None, False
|
195 |
src_sent_data, tgt_sent_data = {}, {}
|
196 |
+
tok2position = {}
|
197 |
+
assert len(involved_src_sents) > 0 or len(involved_tgt_sents) > 0
|
198 |
+
|
199 |
+
if len(involved_src_sents) > 0:
|
200 |
+
src_sent_data = source_data[involved_src_sents[0]]
|
201 |
+
for src_sent_id in involved_src_sents[1:]:
|
202 |
+
curr_sent_data = source_data[src_sent_id]
|
203 |
+
src_sent_data["id_token"].extend(curr_sent_data["id_token"])
|
204 |
+
src_sent_data["form"].extend(curr_sent_data["form"])
|
205 |
+
src_sent_data["lemma"].extend(curr_sent_data["lemma"])
|
206 |
+
src_sent_data["msd"].extend(curr_sent_data["msd"])
|
207 |
+
src_sent_data["ne_tag"].extend(curr_sent_data["ne_tag"])
|
208 |
+
|
209 |
id_doc = src_sent_data["id_doc"]
|
210 |
doc_title = src_sent_data["doc_title"]
|
211 |
is_manually_validated |= src_sent_data["is_manually_validated"]
|
212 |
+
for _pos, _tok in enumerate(src_sent_data["id_token"]):
|
213 |
+
tok2position[_tok] = _pos
|
214 |
+
|
215 |
+
if len(involved_tgt_sents) > 0:
|
216 |
+
tgt_sent_data = target_data[involved_tgt_sents[0]]
|
217 |
+
for tgt_sent_id in involved_tgt_sents[1:]:
|
218 |
+
curr_sent_data = target_data[tgt_sent_id]
|
219 |
+
tgt_sent_data["id_token"].extend(curr_sent_data["id_token"])
|
220 |
+
tgt_sent_data["form"].extend(curr_sent_data["form"])
|
221 |
+
tgt_sent_data["lemma"].extend(curr_sent_data["lemma"])
|
222 |
+
tgt_sent_data["msd"].extend(curr_sent_data["msd"])
|
223 |
+
tgt_sent_data["ne_tag"].extend(curr_sent_data["ne_tag"])
|
224 |
+
|
225 |
id_doc = tgt_sent_data["id_doc"]
|
226 |
doc_title = tgt_sent_data["doc_title"]
|
227 |
is_manually_validated |= tgt_sent_data["is_manually_validated"]
|
228 |
+
for _pos, _tok in enumerate(tgt_sent_data["id_token"]):
|
229 |
+
tok2position[_tok] = _pos
|
230 |
|
231 |
corr_data = []
|
232 |
for token_info in corrected_sent.findall(f"{NAMESPACE}link"):
|
|
|
243 |
|
244 |
for curr_tok in connections:
|
245 |
# Token IDs have an index at the end, but it is 1-based; convert it to 0-based
|
246 |
+
idx_tok = tok2position[curr_tok[1:]]
|
247 |
if "t" in curr_tok: # target token
|
248 |
tgt_inds.append(idx_tok)
|
249 |
else: # source token
|
|
|
255 |
"id_doc": id_doc[:-1], # doc ID without the "s" or "t" info
|
256 |
"doc_title": doc_title,
|
257 |
"is_manually_validated": is_manually_validated,
|
|
|
|
|
258 |
"id_src_tokens": src_sent_data.get("id_token", []),
|
259 |
"src_tokens": src_sent_data.get("form", []),
|
|
|
|
|
260 |
"id_tgt_tokens": tgt_sent_data.get("id_token", []),
|
261 |
"tgt_tokens": tgt_sent_data.get("form", []),
|
262 |
"corrections": corr_data
|