Matej Klemen
commited on
Commit
·
e883c98
1
Parent(s):
69be0d5
Update dataset script
Browse files- sloleks.py +22 -5
sloleks.py
CHANGED
@@ -56,6 +56,10 @@ class Sloleks(datasets.GeneratorBasedBuilder):
|
|
56 |
},
|
57 |
"word_forms": [{
|
58 |
"forms": datasets.Sequence(datasets.Value("string")),
|
|
|
|
|
|
|
|
|
59 |
"msd": datasets.Value("string")
|
60 |
}],
|
61 |
"is_manually_checked": datasets.Value("bool")
|
@@ -119,8 +123,6 @@ class Sloleks(datasets.GeneratorBasedBuilder):
|
|
119 |
<grammarFeature name="aspect">biaspectual</grammarFeature>
|
120 |
</grammar>
|
121 |
"""
|
122 |
-
# TODO: parse everything inside the <grammar> tag, e.g., put it in a dict with keys
|
123 |
-
# {"features": [...], "values": [...]} where `values[i]` corresponds to the feature `features[i]`
|
124 |
grammar_tag = head_tag.find("grammar")
|
125 |
|
126 |
# POS tag (or N/A)
|
@@ -141,13 +143,28 @@ class Sloleks(datasets.GeneratorBasedBuilder):
|
|
141 |
for _form in body_tag.iterfind(".//wordForm"):
|
142 |
msd_str = _form.find("msd").text.strip()
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
for _tag in
|
147 |
orthography.append(_tag.find("form").text.strip())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
word_forms.append({
|
150 |
"forms": orthography,
|
|
|
|
|
|
|
|
|
151 |
"msd": msd_str
|
152 |
})
|
153 |
|
|
|
56 |
},
|
57 |
"word_forms": [{
|
58 |
"forms": datasets.Sequence(datasets.Value("string")),
|
59 |
+
"accentuation": datasets.Sequence(datasets.Value("string")),
|
60 |
+
"pronunciation_ipa": datasets.Sequence(datasets.Value("string")),
|
61 |
+
"pronunciation_sampa": datasets.Sequence(datasets.Value("string")),
|
62 |
+
"is_nonstandard": datasets.Sequence(datasets.Value("bool")),
|
63 |
"msd": datasets.Value("string")
|
64 |
}],
|
65 |
"is_manually_checked": datasets.Value("bool")
|
|
|
123 |
<grammarFeature name="aspect">biaspectual</grammarFeature>
|
124 |
</grammar>
|
125 |
"""
|
|
|
|
|
126 |
grammar_tag = head_tag.find("grammar")
|
127 |
|
128 |
# POS tag (or N/A)
|
|
|
143 |
for _form in body_tag.iterfind(".//wordForm"):
|
144 |
msd_str = _form.find("msd").text.strip()
|
145 |
|
146 |
+
orthography, accentuation, pronunciation_ipa, pronunciation_sampa = [], [], [], []
|
147 |
+
is_nonstandard = []
|
148 |
+
for _tag in _form.findall(".//orthography"):
|
149 |
orthography.append(_tag.find("form").text.strip())
|
150 |
+
is_nonstandard.append(_tag.attrib.get("norm", "standard") == "non-standard")
|
151 |
+
|
152 |
+
for _tag in _form.findall(".//accentuation"):
|
153 |
+
accentuation.append(_tag.find("form").text.strip())
|
154 |
+
|
155 |
+
for _tag in _form.findall(".//pronunciation"):
|
156 |
+
for _pronunciation_form in _tag.findall("form"):
|
157 |
+
if _pronunciation_form.attrib["script"] == "IPA":
|
158 |
+
pronunciation_ipa.append(_pronunciation_form.text.strip())
|
159 |
+
else:
|
160 |
+
pronunciation_sampa.append(_pronunciation_form.text.strip())
|
161 |
|
162 |
word_forms.append({
|
163 |
"forms": orthography,
|
164 |
+
"accentuation": accentuation,
|
165 |
+
"pronunciation_ipa": pronunciation_ipa,
|
166 |
+
"pronunciation_sampa": pronunciation_sampa,
|
167 |
+
"is_nonstandard": is_nonstandard,
|
168 |
"msd": msd_str
|
169 |
})
|
170 |
|