Repository navigation
feat: add Zhuyin (Bopomofo) input for Traditional Chinese - #553
Closed
CatTimothy wants to merge 5 commits into
Closed
CatTimothy wants to merge 5 commits into
CatTimothy wants to merge 5 commits into
Conversation
Adds a standard Dachen (大千) Bopomofo layout with full-width punctuation on the bottom row. This only types Zhuyin symbols for now; phrase conversion will follow in a separate change. Refs: FossifyOrg#193 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds a pure-Kotlin port of McBopomofo's Gramambular2 reading grid (Viterbi walk over a phrase lattice) together with McBopomofo's phrase data, both MIT licensed. The lexicon is kept as raw sorted bytes and searched with binary search, so it needs no parsing at load time. The engine is not wired into the keyboard yet. - zhuyin/BopomofoSyllable: standard layout syllable composer - zhuyin/Lexicon: lexicon lookups over assets/zhuyin/lexicon.txt - zhuyin/ReadingGrid: Gramambular2 port - zhuyin/ZhuyinEngine: composing, candidates, backspace and commit - scripts/zhuyin/build_lexicon.py: regenerates the lexicon asset - JVM unit tests, including tests ported from reading_grid_test.cpp Refs: FossifyOrg#193 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wires ZhuyinEngine into the keyboard when the Zhuyin layout is active: - typed Bopomofo is shown as composing text and converted to phrases - a candidate bar over the toolbar lets the user pick other phrases - space adds the first tone, or commits when no syllable is pending - enter, punctuation and other keys commit the composition first - backspace edits the composition before deleting committed text - password fields keep typing raw Bopomofo symbols - the lexicon loads in the background and is released when switching to another language Refs: FossifyOrg#193 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Tapping a candidate applies it and commits the composition, like pressing enter. - Phrases are committed automatically once they are settled: no phrase in the grid crosses the boundary after them, and the lexicon has no longer reading that starts before the boundary and could still cross it once more syllables are typed. Because unigram scores add up along the path, the best conversion before a settled boundary can no longer change, so the committed text is the same as converting the whole sentence at once (e.g. ㄍㄠ ㄎㄜ ㄐㄧˋ still becomes 高科技). In practice the composition stays at about 1-5 syllables. - Lexicon.hasReadingsStartingWith: binary-searched reading prefixes - ReadingGrid.isCrossed: whether any node crosses a boundary - tests for equivalence with full conversion and for 高科技 Refs: FossifyOrg#193 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After text is committed, the candidate bar shows endings of lexicon phrases that start with its last one or two characters, e.g. 嗎 and 像 after 你好. Tapping a suggestion commits it and suggests again; typing Bopomofo, other keys or moving the cursor hides the suggestions. The suggestions (assets/zhuyin/associated.txt, ~1 MB) are derived from the McBopomofo lexicon by build_lexicon.py. The sorted line lookup is shared with Lexicon through the new SortedLines class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Fossify accepts code contributions only for open issues labeled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Draft until a maintainer is OK with this: #193 isn't labeled help wanted yet, and this PR adds JUnit 4 as a
testImplementationdependency (the repo had no unit tests). Happy to drop the tests or split the PR if you prefer.Type of change(s)
What changed and why
Adds a Zhuyin (Bopomofo) keyboard for Traditional Chinese with phrase conversion, as requested in #193. Converting Zhuyin needs a language model, so this ports McBopomofo (MIT) to pure Kotlin. There is no NDK or new runtime dependency, so F-Droid builds are unaffected.
keys_letters_chinese_zhuyin.xmlin the standard Daqian (大千) layout, with digits on long-press and full-width,and。. The language is listed as中文 (注音).zhuyin/):associated.txt, about 1 MB).scripts/zhuyin/build_lexicon.pyregenerates both assets from McBopomofo'sdata.txt. Licenses and the source commit are inassets/zhuyin/.Tests performed
./gradlew :app:testFossDebugUnitTest), including ports of McBopomofo's reading grid tests.detektandlintpass with no new issues.Before & after preview
Screenshots to follow.
Closes the following issue(s)
Checklist
CHANGELOG.md(if applicable).🤖 Generated with Claude Code