Repository navigation
feat(android): 笔画/英文/联想改用 Rime,删除自家词库 - #1455
Conversation
Android 输入法里"拼音已上 Rime、笔画/英文/联想还压着自家词库"是半迁移状态。 这一步先把 Rime 侧准备好: - `build-mobile-rime.py`:`schema_list` 启用 `stroke` 与 `melt_eng`(以前只启用 pinyin_simp,所以 stroke schema 打进去也不会部署);同时从已 vendored 的 rime-ice 拷入 `melt_eng.schema.yaml` / `melt_eng.dict.yaml` / `en_dicts/` —— 英文词库直接复用现有依赖,不需要我们自己的 `english-frequency.tsv`。 - `mobile-ime/rime_engine.cpp`:`create` 按用途选方案(默认/learning/stroke/ english),部署清单加入 `stroke`、`melt_eng`。 已用真实 `rime_api.h`(mobile-rime 缓存里的 1.17.0)做过语法校验。 依赖结论(对应"能不能找依赖"): - 英文:**不用新增**,rime-ice 自带 melt_eng(en.dict.yaml 2.3 万条 + en_ext)。 - 联想:`rime/librime-predict`(librime 1.17 已支持 predict 插件; `predict.db` 可在构建期由 essay.txt + 词典文本生成,仓库不新增数据; 若想边走边学,用 `fxliang/librime-predict-leveldb`,无需预生成库)。 后续(未在本提交):Kotlin 侧笔画/英文/联想改调 Rime、接入 predict 插件、 删除 android/assets 下的 4 个 TSV(43 万行)。
- `StrokeInput.kt` 不再加载/索引 TSV:查询改成向 Rime 的 `stroke` 会话喂 h/s/p/n/z 取候选;`*` 通配符由宿主侧展开成具体编码(Rime table 只做精确/ 前缀匹配,没有通配),每次通配 5 条查询、上限 25 条。 - 保留两部分我们自己的逻辑(不是语料):个人选字优先(`StrokeUserFrequency`, 存在偏好里)和候选排序 `rankStrokeCandidates`;Rime 负责词频与用户词典学习。 - 删除 `assets/stroke.dict.tsv`(17 万行)与 `assets/stroke-frequency.tsv` (1.7 万行),以及只用于生成它们的 `scripts/generate-stroke-frequency.mjs`。 - 契约测试保留:`input_target` 与 Kotlin 单测里的 `rankStrokeCandidates` / `strokeCodeMatches` 语义未变,仍按原样跑。
- `EnglishCandidateProvider` 不再加载/索引词表:查询改成向 Rime 的 `melt_eng` 会话喂字母取候选;词表本身来自 rime-ice(已 vendored 的 `en_dicts/en.dict.yaml`, 2.3 万条)。 - 保留三处自有逻辑(都不是语料):个人选词权重 `EnglishUserFrequency`; 用户自造的、词典里没有的词(内存集合 + 前缀匹配,冷启动从偏好恢复); 长按"忘记"的排除集合。 - `recordCommit` 通过"Rime 是否认识这个词"判断要不要记成自定义词,不再依赖 本地 trie 的 `indexedWords`。 - 删除 `android/assets/english-frequency.tsv`(2 万行)、它的 LICENSE 与 `scripts/generate-english-dictionary.mjs`。
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca2e7128bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d827480759
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (code in expandStrokePattern(pattern)) { | ||
| if (merged.size >= MAX_CANDIDATES) break | ||
| merged += queryCode(code) |
There was a problem hiding this comment.
Cancel superseded wildcard replays on the shared input queue
When the user types past a sparse four-wildcard pattern, queryEpoch invalidates only the callback; this entire loop still runs inside one RimeTaskQueue task. For example, ****hhspnpphs has only eight matches in the bundled table but requires 625 replays—at least 9,375 native requests—even after a newer query supersedes it. Obsolete queued patterns are also processed in full, while pinyin keys and commit delivery share this queue, so continued typing or switching to pinyin leaves input waiting behind discarded work. Check cancellation before starting and between concrete codes, and propagate mode/session invalidation to the repository.
Useful? React with 👍 / 👎.
| (assetMarker in files && !File(selected, assetMarker).isFile))) { | ||
| selected = shared.absolutePath |
There was a problem hiding this comment.
Rebase cached dictionaries when rejecting their asset format
When upgrading an installation that already cached the current public rime-ice revision, its snapshot lacks the new marker, so this fallback selects the bundled dictionaries without invalidating or migrating the cached snapshot. ime_dictionary::select() has already marked that snapshot active, and update() in openless-all/app/crates/openless-core/src/ime_dictionary.rs:274–279 returns immediately while the upstream SHA equals state.ready. Consequently, successful update checks cannot restore the downloaded tables, and the IME keeps using older bundled data until a different upstream revision is downloaded. Version or migrate these snapshots, or arrange for the updater to rebuild an incompatible snapshot even when its upstream SHA is unchanged.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d827480759
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ensureSession() | ||
| val merged = LinkedHashSet<String>() | ||
| for (code in expandStrokePattern(pattern)) { | ||
| if (merged.size >= MAX_CANDIDATES) break |
There was a problem hiding this comment.
Preserve wildcard branches before applying the result cap
The expansion fix covers the earlier three-wildcard example, but a * query can still lose branches here: its first code is h, and queryCode can return up to 40 candidates from the bundled table’s 48,405 h-prefixed entries, reaching the 36-candidate cap before s, p, n, or z are queried. Keep the cap after sampling across concrete codes so the wildcard does not silently become a literal first stroke.
Useful? React with 👍 / 👎.
|
已按用户要求仅解决与当前beta的合并冲突并推回本PR原分支,提交 ce8cc19(parents: 原head d827480 + beta b471f2a)。 12项均为Android目录迁移引起的rename/delete或新增文件位置冲突:保留本PR既有删除意图,3个新增Kotlin/测试文件落到新android目录且与原PR字节一致。相对beta最终仍恰好原PR的24个文件;无额外功能修复、无鸿蒙输入法提交。 验证:无未解决index项;PR相对beta diff --check通过;copy-android-scaffolding string/debug-manifest/instrumentation fixture测试通过;JS与Python相关脚本语法检查通过。未宣称全量Android构建或设备测试。GitHub当前mergeable=MERGEABLE;PR仍OPEN,未执行合并、未push beta,剩余检查/保护规则照常。 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4131461c6b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for ((character, code) in entries) { | ||
| if (strokeCodeMatches(pattern, code)) { | ||
| merged += character | ||
| if (merged.size >= limit) break |
There was a problem hiding this comment.
Cover wildcard branches before applying the result cap
The new table-filter path fixes the bare * example, but fresh *s evidence shows the cap still drops valid branches: the bundled table has matches for all five first strokes, yet its first 36 unique matches contain only h and p. Because this stops in raw table order, candidates from the n, s, and z branches are never offered; sample or rank across the wildcard alternatives before enforcing the limit.
Useful? React with 👍 / 👎.
| } else { | ||
| strokeCandidates?.removeAllViews() | ||
| } | ||
| confirmedText = "" |
There was a problem hiding this comment.
Retain the remaining prediction context after one backspace
With personalized learning and association ranking enabled, if a user commits stroke text and then backspaces with no active code or segment and no editor selection, deleteBackward() removes one character but this assignment discards the entire confirmedText buffer. The next stroke query therefore has no context to promote continuations from the remaining text until another commit; retain the remaining code points and clear the buffer only when a deletion removes the whole tracked context.
Useful? React with 👍 / 👎.
Integrate the Rime candidate backends with the rewritten Android keyboard panels, preserving pinyin readiness and preedit handling and versioning the bundled prebuilt tables.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0787a3577
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| val fromRime = queryRime(normalized) | ||
| val fromCustom = customWords.filter { it.startsWith(normalized) } | ||
| (fromCustom + fromRime) | ||
| .filter { it !in excludedWords } |
There was a problem hiding this comment.
Case-fold native candidates before filtering forgotten words
When an upgrade retains a custom word that melt_eng now returns with capital letters, long-pressing “Forget” leaves the native suggestion visible. forgetCustomWord() stores the lowercase spelling in excludedWords, but strings() preserves Rime’s capitalization and this comparison is case-sensitive. A provider-level fixture with saved myterm and native MyTerm reproduces the failure: the next query still returns MyTerm. Compare using the same normalized word key used by the custom-word store so forgetting also excludes the native spelling.
Useful? React with 👍 / 👎.
改动
stroke,保留宿主侧通配展开和个人选字优先。melt_eng,保留个人词频和自定义词。librime-predict的数据库实现,从 rime-ice 构建预测索引,对已经匹配当前编码的候选重新排序;不改默认首选,不在私密模式启用。predict.db。验证