* Correctly handle the case where a tagged field may appear more than once in a kanji...
authorUrban Wallasch <urban.wallasch@freenet.de>
Mon, 21 Jun 2021 21:51:07 +0000 (23:51 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Mon, 21 Jun 2021 21:51:07 +0000 (23:51 +0200)
kanjidic.py

index b49a0341a665f4c858eda572b5fbe32036b3d1ca..da7dd2cfc5bfff5e4c083b1d9f04e6ff1420ebdc 100755 (executable)
@@ -205,7 +205,9 @@ def _kanjidic_load(dict_fname):
                     line = re_tags.sub('', line, 1)
                 for t in tlist:
                     for k in ktable:
-                        if t[:len(k[0])] == k[0]:
+                        # if a tag appears more than once the first one wins,
+                        # e.g. 'S<num>' (stroke count)
+                        if t[:len(k[0])] == k[0] and not info[k[1]]:
                             info[k[1]] = t[len(k[0]):]
                             break
                 # get readings (i.e. all that's left)