Learn classifier weights from synthetic typing data
Scoring is now features x weights (Features.swift / features.py), with the old hand-tuned values as defaults. training/ generates synthetic mixed Chinese/English buffers from the lexicon and word lists and trains the weights with an averaged structured perceptron over the same segmentation DP the input method runs. On 10,000 test buffers commit-time accuracy goes from 97.58% to 99.62%; typing-time (prefix) accuracy from 86.15% to 87.81%. Both apps load Resources/classifier-weights.json. A parity test checks the Swift segmentation matches the Python one on 400 fixtures. Also fixes space after a toned syllable being scored as an extra stray tone, which could turn short Chinese like "u4 " into English. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fills windows/autozhuyin/data/ from the shared Mac resources.
|
||||
|
||||
- lexicon.txt, english-common.txt: copied from Resources/
|
||||
- lexicon.txt, english-common.txt, classifier-weights.json: copied from Resources/
|
||||
- english-dict.txt: filtered from a system word list (default /usr/share/dict/words,
|
||||
Webster's 2nd edition, public domain), since Windows has no such file
|
||||
- english-bigram.json: precomputed letter-bigram table
|
||||
@@ -21,7 +21,7 @@ from autozhuyin.core.english import train_bigram # noqa: E402
|
||||
|
||||
data = WIN / "autozhuyin" / "data"
|
||||
data.mkdir(parents=True, exist_ok=True)
|
||||
for name in ("lexicon.txt", "english-common.txt"):
|
||||
for name in ("lexicon.txt", "english-common.txt", "classifier-weights.json"):
|
||||
shutil.copy(ROOT / "Resources" / name, data / name)
|
||||
|
||||
word_list = Path(sys.argv[1] if len(sys.argv) > 1 else "/usr/share/dict/words")
|
||||
|
||||
Reference in New Issue
Block a user