Mercurial > hg > lxmldump
comparison lxmldump.py @ 63:afe5cd7626dc
Some more work, this may break things a bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 01 Jun 2021 14:00:39 +0300 |
parents | 1932f588743f |
children | 66d585e862b6 |
comparison
equal
deleted
inserted
replaced
62:1932f588743f | 63:afe5cd7626dc |
---|---|
46 PKK_MODE_NORMAL: "<PTR:{href}>{text}</PTR>", | 46 PKK_MODE_NORMAL: "<PTR:{href}>{text}</PTR>", |
47 PKK_MODE_ANKI: "<a href='https://kaino.kotus.fi/cgi-bin/kks/karjala.cgi?a={href}'>{text}</a>", | 47 PKK_MODE_ANKI: "<a href='https://kaino.kotus.fi/cgi-bin/kks/karjala.cgi?a={href}'>{text}</a>", |
48 }, | 48 }, |
49 | 49 |
50 "word_item": { | 50 "word_item": { |
51 PKK_MODE_NORMAL: "\"{word}\"{search}\n{attr}{hyphenation}{main_sense}{other_senses}\n", | 51 PKK_MODE_NORMAL: "{word}{search}{attr}{hyphenation}:{main_sense}{other_senses}\n", |
52 PKK_MODE_ANKI: "\"{word}\"{search}{attr}{hyphenation};{main_sense}{other_senses}\n", | 52 PKK_MODE_ANKI: "\"{word}\"{search}{attr}{hyphenation};{main_sense}{other_senses}\n", |
53 }, | 53 }, |
54 "word_attr_list": { | 54 "word_attr_list": { |
55 PKK_MODE_NORMAL: "{indent}attr \"({alist})\"\n", | 55 PKK_MODE_NORMAL: " ({alist})", |
56 PKK_MODE_ANKI: " ({alist})", | 56 PKK_MODE_ANKI: " ({alist})", |
57 }, | 57 }, |
58 "word_attr_list_empty": { | 58 "word_attr_list_empty": { |
59 PKK_MODE_NORMAL: " ", | 59 PKK_MODE_NORMAL: "", |
60 PKK_MODE_ANKI: "", | 60 PKK_MODE_ANKI: "", |
61 }, | 61 }, |
62 "word_attr_list_item": { | 62 "word_attr_list_item": { |
63 PKK_MODE_NORMAL: "{text}", | 63 PKK_MODE_NORMAL: "{text}", |
64 }, | 64 }, |
66 PKK_MODE_NORMAL: " ; ", | 66 PKK_MODE_NORMAL: " ; ", |
67 PKK_MODE_ANKI: " : ", | 67 PKK_MODE_ANKI: " : ", |
68 }, | 68 }, |
69 | 69 |
70 "hyphenation": { | 70 "hyphenation": { |
71 PKK_MODE_NORMAL: "{indent}hyph \"{text}\"\n", | 71 PKK_MODE_NORMAL: " [hyph: {text}]", |
72 PKK_MODE_ANKI: " [hyph: {text}]", | 72 PKK_MODE_ANKI: " [hyph: {text}]", |
73 }, | 73 }, |
74 "no_hyphenation": { | 74 "no_hyphenation": { |
75 PKK_MODE_NORMAL: "", | 75 PKK_MODE_NORMAL: "", |
76 }, | 76 }, |
77 | 77 |
78 | 78 |
79 "search_list": { | 79 "search_list": { |
80 PKK_MODE_NORMAL: ", {alist}\n", | 80 PKK_MODE_NORMAL: ", {alist}", |
81 PKK_MODE_ANKI: ", {alist}", | 81 PKK_MODE_ANKI: ", {alist}", |
82 }, | 82 }, |
83 "search_list_empty": { | 83 "search_list_empty": { |
84 PKK_MODE_NORMAL: "", | 84 PKK_MODE_NORMAL: "", |
85 }, | 85 }, |
86 "search_list_item": { | 86 "search_list_item": { |
87 PKK_MODE_NORMAL: "\"{text}\"", | 87 PKK_MODE_NORMAL: "{text}", |
88 PKK_MODE_ANKI: "\"{text}\"", | |
88 }, | 89 }, |
89 "search_list_sep": { | 90 "search_list_sep": { |
90 PKK_MODE_NORMAL: ", ", | 91 PKK_MODE_NORMAL: ", ", |
91 }, | 92 }, |
92 | 93 |
93 "main_sense_item": { | 94 "main_sense_item": { |
94 PKK_MODE_NORMAL: "{definition}{example_list}", | 95 PKK_MODE_NORMAL: "{definition}{example_list}", |
96 PKK_MODE_ANKI: "{definition}{example_list}", | |
95 }, | 97 }, |
96 "sense_list": { | 98 "sense_list": { |
97 PKK_MODE_NORMAL: "{alist}", | 99 PKK_MODE_NORMAL: "{alist}", |
98 PKK_MODE_ANKI: " | {alist}", | 100 PKK_MODE_ANKI: " | {alist}", |
99 }, | 101 }, |
100 "sense_list_empty": { | 102 "sense_list_empty": { |
101 PKK_MODE_NORMAL: "", | 103 PKK_MODE_NORMAL: "", |
102 }, | 104 }, |
103 "sense_list_item": { | 105 "sense_list_item": { |
104 PKK_MODE_NORMAL: "{indent}sense #{index}:\n{definition}{example_list}", | 106 PKK_MODE_NORMAL: "#{index}:{definition}{example_list}", |
105 PKK_MODE_ANKI: "#{index}:{definition}{example_list}", | 107 PKK_MODE_ANKI: "#{index}:{definition}{example_list}", |
106 }, | 108 }, |
107 "sense_list_sep": { | 109 "sense_list_sep": { |
110 PKK_MODE_NORMAL: " | ", | |
111 PKK_MODE_ANKI: " | ", | |
112 }, | |
113 | |
114 "definition_item": { | |
115 PKK_MODE_NORMAL: " {text}", | |
116 PKK_MODE_ANKI: " ? \"{text}\"", | |
117 }, | |
118 | |
119 "example_list": { | |
120 PKK_MODE_NORMAL: " | {alist}", | |
121 }, | |
122 "example_list_empty": { | |
108 PKK_MODE_NORMAL: "", | 123 PKK_MODE_NORMAL: "", |
109 PKK_MODE_ANKI: " | ", | 124 }, |
110 }, | 125 "example_list_item": { |
111 | 126 PKK_MODE_NORMAL: "\"{text}\"{geo_list}", |
112 "definition_item": { | |
113 PKK_MODE_NORMAL: "{indent}defn \"{text}\"\n", | |
114 PKK_MODE_ANKI: " ? \"{text}\"", | |
115 }, | |
116 | |
117 "example_item": { | |
118 PKK_MODE_NORMAL: "{indent}exmp \"{text}\"{geo_list}\n", | |
119 PKK_MODE_ANKI: " * \"{text}\"{geo_list}", | 127 PKK_MODE_ANKI: " * \"{text}\"{geo_list}", |
120 }, | 128 }, |
121 "example_item_sep": { | 129 "example_list_sep": { |
122 PKK_MODE_NORMAL: "", | 130 PKK_MODE_NORMAL: " ; ", |
123 PKK_MODE_ANKI: "", | 131 PKK_MODE_ANKI: "", |
124 }, | 132 }, |
125 | 133 |
126 "example_geo_list": { | 134 "example_geo_list": { |
127 PKK_MODE_NORMAL: " ({alist})", | 135 PKK_MODE_NORMAL: " ({alist})", |
369 geolist.append(pkk_get_fmt("example_geo_list_item").format( | 377 geolist.append(pkk_get_fmt("example_geo_list_item").format( |
370 text=pkk_node_to_text(qnode), | 378 text=pkk_node_to_text(qnode), |
371 tclass=qnode.attrib["class"], | 379 tclass=qnode.attrib["class"], |
372 indent=pkk_geti(indent + 2))) | 380 indent=pkk_geti(indent + 2))) |
373 | 381 |
374 exlist.append(pkk_get_fmt("example_item").format( | 382 exlist.append(pkk_get_fmt("example_list_item").format( |
375 text=pkk_node_to_text(wnode.find("./Example")), | 383 text=pkk_node_to_text(wnode.find("./Example")), |
376 geo_list=pkk_get_list_str(indent + 1, geolist, "example_geo", False), | 384 geo_list=pkk_get_list_str(indent + 1, geolist, "example_geo", False), |
377 indent=pkk_geti(indent + 1), | 385 indent=pkk_geti(indent + 1), |
378 index=index)) | 386 index=index)) |
379 index += 1 | 387 index += 1 |
380 | 388 |
381 return pkk_get_fmt(dname).format( | 389 return pkk_get_fmt(dname).format( |
382 definition=pkk_get_subs(indent, dnode, "./Definition", "definition_item"), | 390 definition=pkk_get_subs(indent, dnode, "./Definition", "definition_item"), |
383 example_list=pkk_get_fmt("example_item_sep").join(exlist), | 391 example_list=pkk_get_list_str(indent, exlist, "example", False), |
384 indent=pkk_geti(indent), | 392 indent=pkk_geti(indent), |
385 index=dindex) | 393 index=dindex) |
386 | 394 |
387 | 395 |
388 ## Output one "DictionaryEntry" node | 396 ## Output one "DictionaryEntry" node |