data(hanja): words, not only syllables
The import kept only readings of one syllable, so the Hanja search could convert 한 but never 한자, 학교, or 대한민국 — the conversion every other Korean input method offers. libhangul's table has 187k readings; both scripts now keep them all, and the search finds a word as readily as a syllable. The daemon pays for it: 24 MB instead of 12, and 170 ms to start instead of 30.
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extract single-character Hanja readings from libhangul data."""
|
||||
"""Extract Hanja readings from libhangul data."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def ishangul(s):
|
||||
return len(s) == 1 and 0xAC00 <= ord(s) <= 0xD7A3
|
||||
return s != "" and all(0xAC00 <= ord(c) <= 0xD7A3 for c in s)
|
||||
|
||||
|
||||
def ishanja(s):
|
||||
if len(s) != 1:
|
||||
return False
|
||||
c = ord(s)
|
||||
return (0x3400 <= c <= 0x4DBF
|
||||
or 0x4E00 <= c <= 0x9FFF
|
||||
or 0xF900 <= c <= 0xFAFF)
|
||||
return s != "" and all(0x3400 <= ord(c) <= 0x4DBF
|
||||
or 0x4E00 <= ord(c) <= 0x9FFF
|
||||
or 0xF900 <= ord(c) <= 0xFAFF for c in s)
|
||||
|
||||
|
||||
def extract(src, name):
|
||||
@@ -44,7 +41,7 @@ def extract(src, name):
|
||||
seen.add(pair)
|
||||
entries.append(pair)
|
||||
if not entries:
|
||||
raise ValueError(f"{name}: no single-character Hanja readings")
|
||||
raise ValueError(f"{name}: no Hanja readings")
|
||||
return comments, entries
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user