From 9b072f72e2db48d55200c2b8bf0c653cfab98bc0 Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Mon, 21 Jun 2021 23:51:07 +0200 Subject: [PATCH] * Correctly handle the case where a tagged field may appear more than once in a kanjidic entry (e.g. stroke count). --- kanjidic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) -- 2.30.2