feat: replace wanakana with english-to-kana 49K dictionary

- Vendor english-kana-matcher.js (english-to-kana, MIT, 49216 words)
- Rewrite bridge: dictionary lookup + letter-by-letter fallback for OOV words
- Convert English punctuation (,.!?) to Japanese pauses (、。)
- Fix Chinese fullwidth comma being stripped by filter_kana
- Preserve decimal points in numbers (3.5 -> スリーファイブ)
- main.py now applies filter_kana (matches web UI behavior)
- Remove wanakana dependency; rebuild portable zip (82.5 MB)
This commit is contained in:
2026-08-08 15:06:34 +08:00
parent fd5c732d8a
commit 0c0e63161d
8 changed files with 152 additions and 40 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ _KANA_SAFE_RE = re.compile(
r"\u3001\u3002\uFF01\uFF1F"
r"\u300C\u300D"
r"\u30FB\u3000"
r"a-zA-Z0-9 ]"
r"a-zA-Z0-9 ,.!?\uFF0C]"
)
_CHINESE_DIGITS = ["", "", "", "", "", "", "", "", "", ""]
@@ -85,7 +85,7 @@ def chinese_to_kana(text: str, convert_numbers: bool = True) -> str:
else:
result_parts.append(seg)
result = "".join(result_parts)
result = re.sub(r"(?<=\S) (?=\S)", "", result)
result = re.sub(r"(?<=[^\x00-\x7F]) (?=[^\x00-\x7F])", "", result)
return result