with open(dict_fname) as dict_file:
# edict example line:
# 〆日 [しめび] /(n) time limit/closing day/settlement day (payment)/deadline/
- re_split = re.compile(r'^(.*) *\[(.*)\] */(.*)/$')
+ re_split = re.compile(r'^\s*(.*?)\s*\[\s*(.*?)\s*\]\s*/\s*(.*?)\s*/\s*$')
re_term = re.compile(term)
for line in dict_file:
try:
kanji, kana, trans = re_split.match(line.strip()).groups()
except:
continue
- kanji = kanji.strip()
# for now promiscuously try to match anything anywhere
if re_term.search(kanji) is not None or \
re_term.search(kana) is not None or \