data(emoji): every Japanese alias in both kana

A query typed in the Hiragana mode is hiragana; CLDR's Japanese
keywords are mostly katakana (スマイル, ハート), so the one could not
find the other.  mkemoji now writes each alias that has kana in both
scripts.
This commit is contained in:
2026-08-17 01:44:29 +09:00
parent 0c4271b8b5
commit fcdce7dc16
3 changed files with 3345 additions and 37 deletions

View File

@@ -12,11 +12,21 @@ MAXRUNES = 64
MAXCANDIDATES = 128
HIRA = {c: c + 0x60 for c in range(0x3041, 0x3097)}
KATA = {c: c - 0x60 for c in range(0x30A1, 0x30F7)}
def fold(s):
s = "".join(chr(ord(c) + 32) if "A" <= c <= "Z" else c for c in s)
return unicodedata.normalize("NFC", s)
def kana(alias):
"""The alias, and in the other kana where it has any: a query typed
in either Japanese mode finds it."""
return {alias, alias.translate(HIRA), alias.translate(KATA)}
def hascontrol(s):
return any(unicodedata.category(c) == "Cc" for c in s)
@@ -42,7 +52,7 @@ def read(path):
if (not alias or len(alias) > MAXRUNES or hascontrol(alias)
or alias != alias.strip() or alias.startswith(";")):
raise ValueError(f"{path}:{lineno}: bad alias")
entries.append((result, alias))
entries.extend((result, a) for a in sorted(kana(alias)))
return entries