Datasets:
Matej Klemen
commited on
Commit
•
2a252da
1
Parent(s):
61a3f98
Expose document lemmas and MSDs
Browse files- cc_gigafida.py +15 -0
- dataset_infos.json +1 -1
cc_gigafida.py
CHANGED
@@ -62,6 +62,8 @@ class CcGigafida(datasets.GeneratorBasedBuilder):
|
|
62 |
"publisher": datasets.Value("string"),
|
63 |
"genres": datasets.Sequence(datasets.Value("string")),
|
64 |
"doc_tokenized": datasets.Sequence(datasets.Sequence(datasets.Sequence(datasets.Value("string")))),
|
|
|
|
|
65 |
"doc_string": datasets.Sequence(datasets.Sequence(datasets.Value("string"))),
|
66 |
"id_sents": datasets.Sequence(datasets.Sequence(datasets.Value("string")))
|
67 |
}
|
@@ -136,10 +138,12 @@ class CcGigafida(datasets.GeneratorBasedBuilder):
|
|
136 |
body_tag = root.find(f".//{NAMESPACE}body")
|
137 |
tokenized_doc, doc_str = [], []
|
138 |
doc_sent_ids = []
|
|
|
139 |
|
140 |
for para_tag in body_tag.findall(f".//{NAMESPACE}p"):
|
141 |
id_para = para_tag.attrib[f"{XML_NAMESPACE}id"]
|
142 |
tokenized_para, para_str = [], []
|
|
|
143 |
para_sent_ids = []
|
144 |
|
145 |
for _idx_sent, sent_tag in enumerate(para_tag.findall(f".//{NAMESPACE}s")):
|
@@ -150,6 +154,7 @@ class CcGigafida(datasets.GeneratorBasedBuilder):
|
|
150 |
id_sent = f"{id_para}.{_idx_sent}"
|
151 |
|
152 |
tokenized_sent, str_sent = [], []
|
|
|
153 |
for child_tag in sent_tag:
|
154 |
tag_str = child_tag.tag[len(NAMESPACE):]
|
155 |
if tag_str not in {"w", "S", "c", "pc"}:
|
@@ -167,20 +172,28 @@ class CcGigafida(datasets.GeneratorBasedBuilder):
|
|
167 |
str_sent.append(child_tag.text)
|
168 |
if child_tag.text != " ":
|
169 |
tokenized_sent.append(child_tag.text)
|
|
|
|
|
170 |
|
171 |
# word or punctuation character
|
172 |
else:
|
173 |
str_sent.append(child_tag.text)
|
174 |
tokenized_sent.append(child_tag.text)
|
|
|
|
|
175 |
|
176 |
str_sent = "".join(str_sent)
|
177 |
tokenized_para.append(tokenized_sent)
|
178 |
para_str.append(str_sent)
|
179 |
para_sent_ids.append(id_sent)
|
|
|
|
|
180 |
|
181 |
tokenized_doc.append(tokenized_para)
|
182 |
doc_str.append(para_str)
|
183 |
doc_sent_ids.append(para_sent_ids)
|
|
|
|
|
184 |
|
185 |
yield _idx_file, {
|
186 |
"id_doc": id_doc,
|
@@ -190,6 +203,8 @@ class CcGigafida(datasets.GeneratorBasedBuilder):
|
|
190 |
"publisher": publisher,
|
191 |
"genres": genres,
|
192 |
"doc_tokenized": tokenized_doc,
|
|
|
|
|
193 |
"doc_string": doc_str,
|
194 |
"id_sents": doc_sent_ids
|
195 |
}
|
|
|
62 |
"publisher": datasets.Value("string"),
|
63 |
"genres": datasets.Sequence(datasets.Value("string")),
|
64 |
"doc_tokenized": datasets.Sequence(datasets.Sequence(datasets.Sequence(datasets.Value("string")))),
|
65 |
+
"doc_lemmas": datasets.Sequence(datasets.Sequence(datasets.Sequence(datasets.Value("string")))),
|
66 |
+
"doc_msds": datasets.Sequence(datasets.Sequence(datasets.Sequence(datasets.Value("string")))),
|
67 |
"doc_string": datasets.Sequence(datasets.Sequence(datasets.Value("string"))),
|
68 |
"id_sents": datasets.Sequence(datasets.Sequence(datasets.Value("string")))
|
69 |
}
|
|
|
138 |
body_tag = root.find(f".//{NAMESPACE}body")
|
139 |
tokenized_doc, doc_str = [], []
|
140 |
doc_sent_ids = []
|
141 |
+
doc_msds, doc_lemmas = [], []
|
142 |
|
143 |
for para_tag in body_tag.findall(f".//{NAMESPACE}p"):
|
144 |
id_para = para_tag.attrib[f"{XML_NAMESPACE}id"]
|
145 |
tokenized_para, para_str = [], []
|
146 |
+
para_msds, para_lemmas = [], []
|
147 |
para_sent_ids = []
|
148 |
|
149 |
for _idx_sent, sent_tag in enumerate(para_tag.findall(f".//{NAMESPACE}s")):
|
|
|
154 |
id_sent = f"{id_para}.{_idx_sent}"
|
155 |
|
156 |
tokenized_sent, str_sent = [], []
|
157 |
+
msd_tags, lemmas = [], []
|
158 |
for child_tag in sent_tag:
|
159 |
tag_str = child_tag.tag[len(NAMESPACE):]
|
160 |
if tag_str not in {"w", "S", "c", "pc"}:
|
|
|
172 |
str_sent.append(child_tag.text)
|
173 |
if child_tag.text != " ":
|
174 |
tokenized_sent.append(child_tag.text)
|
175 |
+
msd_tags.append(child_tag.attrib["ana"][len("mte:"):] if "ana" in child_tag.attrib else "")
|
176 |
+
lemmas.append(child_tag.text)
|
177 |
|
178 |
# word or punctuation character
|
179 |
else:
|
180 |
str_sent.append(child_tag.text)
|
181 |
tokenized_sent.append(child_tag.text)
|
182 |
+
msd_tags.append(child_tag.attrib["ana"][len("mte:"):] if "ana" in child_tag.attrib else child_tag.attrib["msd"])
|
183 |
+
lemmas.append(child_tag.attrib["lemma"] if "lemma" in child_tag.attrib else child_tag.text)
|
184 |
|
185 |
str_sent = "".join(str_sent)
|
186 |
tokenized_para.append(tokenized_sent)
|
187 |
para_str.append(str_sent)
|
188 |
para_sent_ids.append(id_sent)
|
189 |
+
para_msds.append(msd_tags)
|
190 |
+
para_lemmas.append(lemmas)
|
191 |
|
192 |
tokenized_doc.append(tokenized_para)
|
193 |
doc_str.append(para_str)
|
194 |
doc_sent_ids.append(para_sent_ids)
|
195 |
+
doc_msds.append(para_msds)
|
196 |
+
doc_lemmas.append(para_lemmas)
|
197 |
|
198 |
yield _idx_file, {
|
199 |
"id_doc": id_doc,
|
|
|
203 |
"publisher": publisher,
|
204 |
"genres": genres,
|
205 |
"doc_tokenized": tokenized_doc,
|
206 |
+
"doc_lemmas": doc_lemmas,
|
207 |
+
"doc_msds": doc_msds,
|
208 |
"doc_string": doc_str,
|
209 |
"id_sents": doc_sent_ids
|
210 |
}
|
dataset_infos.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"default": {"description": "The ccGigafida corpus contains a subsample of the Gigafida corpus. The Gigafida corpus is an extensive collection of \nSlovene text of various genres, from daily newspapers, magazines, all kinds of books (fiction, non-fiction, textbooks), \nweb pages, transcriptions of parliamentary debates and similar.\n", "citation": "@misc{ccGigafida,\n title = {Written corpus {ccGigafida} 1.0},\n author = {Logar, Nata{\u000b s}a and Erjavec, Toma{\u000b z} and Krek, Simon and Gr{\u000b c}ar, Miha and Holozan, Peter},\n url = {http://hdl.handle.net/11356/1035},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n copyright = {Creative Commons - Attribution-{NonCommercial}-{ShareAlike} 4.0 International ({CC} {BY}-{NC}-{SA} 4.0)},\n issn = {2820-4042},\n year = {2013}\n}\n", "homepage": "http://eng.slovenscina.eu/korpusi/proste-zbirke", "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"}, "authors": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "publish_date": {"dtype": "string", "id": null, "_type": "Value"}, "publisher": {"dtype": "string", "id": null, "_type": "Value"}, "genres": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "doc_tokenized": {"feature": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "doc_string": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "id_sents": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "cc_gigafida", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes":
|
|
|
1 |
+
{"default": {"description": "The ccGigafida corpus contains a subsample of the Gigafida corpus. The Gigafida corpus is an extensive collection of \nSlovene text of various genres, from daily newspapers, magazines, all kinds of books (fiction, non-fiction, textbooks), \nweb pages, transcriptions of parliamentary debates and similar.\n", "citation": "@misc{ccGigafida,\n title = {Written corpus {ccGigafida} 1.0},\n author = {Logar, Nata{\u000b s}a and Erjavec, Toma{\u000b z} and Krek, Simon and Gr{\u000b c}ar, Miha and Holozan, Peter},\n url = {http://hdl.handle.net/11356/1035},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n copyright = {Creative Commons - Attribution-{NonCommercial}-{ShareAlike} 4.0 International ({CC} {BY}-{NC}-{SA} 4.0)},\n issn = {2820-4042},\n year = {2013}\n}\n", "homepage": "http://eng.slovenscina.eu/korpusi/proste-zbirke", "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"}, "authors": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "publish_date": {"dtype": "string", "id": null, "_type": "Value"}, "publisher": {"dtype": "string", "id": null, "_type": "Value"}, "genres": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "doc_tokenized": {"feature": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "doc_lemmas": {"feature": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "doc_msds": {"feature": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "doc_string": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "id_sents": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "cc_gigafida", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 4242404354, "num_examples": 31722, "dataset_name": "cc_gigafida"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1035/ccGigafidaV1_0.zip": {"num_bytes": 954116273, "checksum": "448e284d6f92d54f123e2b7fa433c9d84d060f2db07c589e9b45a356a1f5242e"}}, "download_size": 954116273, "post_processing_size": null, "dataset_size": 4242404354, "size_in_bytes": 5196520627}}
|