Mercurial > hg > lxmldump
comparison lxmldump.py @ 19:7c6eb57798bd
Ja niin.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 11 May 2021 16:15:16 +0300 |
parents | ff959de0f6c8 |
children | f274504eafd0 |
comparison
equal
deleted
inserted
replaced
18:ff959de0f6c8 | 19:7c6eb57798bd |
---|---|
40 "ahavakala", | 40 "ahavakala", |
41 "ahavakoittuo", | 41 "ahavakoittuo", |
42 "ahvaliha", | 42 "ahvaliha", |
43 "aloilleh", | 43 "aloilleh", |
44 "hanjahtoakseh", | 44 "hanjahtoakseh", |
45 "akkalisto", | |
45 ] | 46 ] |
46 | 47 |
47 | 48 |
48 ### | 49 ### |
49 ### Misc. helper functions, etc | 50 ### Misc. helper functions, etc |
182 tmpl = [] | 183 tmpl = [] |
183 for pnode in wnode.findall("./PartOfSpeechCtn/PartOfSpeech"): | 184 for pnode in wnode.findall("./PartOfSpeechCtn/PartOfSpeech"): |
184 tmpl.append(pnode.attrib["freeValue"]) | 185 tmpl.append(pnode.attrib["freeValue"]) |
185 | 186 |
186 for pnode in wnode.findall("./GrammaticalNote"): | 187 for pnode in wnode.findall("./GrammaticalNote"): |
187 tmpl.append(pnode.text.strip()) | 188 tmpl.append(pkk_node_to_text(pnode)) |
188 | 189 |
189 # Remove duplicates and sort the list | 190 # Remove duplicates and sort the list |
190 tmpl = list(set(tmpl)) | 191 tmpl = list(set(tmpl)) |
191 tmpl.sort(reverse=False, key=lambda attr: (attr, len(attr))) | 192 tmpl.sort(reverse=False, key=lambda attr: (attr, len(attr))) |
192 | 193 |
302 | 303 |
303 if pkk_cfg["debug"] and dnode.attrib["identifier"] not in pkk_debug_list: | 304 if pkk_cfg["debug"] and dnode.attrib["identifier"] not in pkk_debug_list: |
304 continue | 305 continue |
305 | 306 |
306 if pkk_cfg["mode"] == 0: | 307 if pkk_cfg["mode"] == 0: |
307 pkk_output_node(0, dnode) | 308 try: |
309 pkk_output_node(0, dnode) | |
310 except Exception as e: | |
311 pkk_dump_recursive(0, dnode) | |
312 print(str(e)) | |
313 sys.exit(0) | |
308 elif pkk_cfg["mode"] == 1: | 314 elif pkk_cfg["mode"] == 1: |
309 pkk_dump_recursive(0, dnode) | 315 pkk_dump_recursive(0, dnode) |
310 elif pkk_cfg["mode"] == 2: | 316 elif pkk_cfg["mode"] == 2: |
311 pkk_print(str(xmlET.tostring(dnode, encoding="utf8")) + "\n") | 317 pkk_print(str(xmlET.tostring(dnode, encoding="utf8")) + "\n") |
312 else: | 318 else: |