From: Urban Wallasch Date: Mon, 21 Jun 2021 21:51:07 +0000 (+0200) Subject: * Correctly handle the case where a tagged field may appear more than once in a kanji... X-Git-Tag: v0.1.0~87 X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=9b072f72e2db48d55200c2b8bf0c653cfab98bc0;p=jiten-pai.git * Correctly handle the case where a tagged field may appear more than once in a kanjidic entry (e.g. stroke count). --- diff --git a/kanjidic.py b/kanjidic.py index b49a034..da7dd2c 100755 --- a/kanjidic.py +++ b/kanjidic.py @@ -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' (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)