Skip to content

kenspc/rime-predict-zh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rime-predict-zh

English · 繁體中文 · 简体中文

Next-word prediction dictionaries for RIME input method — Simplified / Traditional / Merged Chinese.

After you commit a character or word, the candidate bar automatically suggests the next common character or word — type and it offers , type and it offers . This works with any Chinese RIME schema (Cangjie, Pinyin, Wubi, Zhuyin, …); it is not tied to a particular input method.

The files are binary dictionaries in the Rime::Predict/1.0 format, read by the official librime-predict plugin.

The configuration example below uses Cangjie 5 (Cangjie5_SC) purely for illustration. The dictionary itself is schema-independent — Pinyin and other schemas work the same way.


Files

File Content Heads Entries Freq. coverage Size
dist/predict-zhs.db Simplified only 4,169 52,780 99.1% 524 KB
dist/predict-zht.db Traditional only 4,409 54,381 88.5% 550 KB
dist/predict-merged.db Merged (Simplified-first, Traditional alongside) 6,061 94,810 924 KB
src/*.tsv Plain-text sources (head ⇥ continuation ⇥ weight) for audit / rebuild
raw/*.txt Upstream raw association lists from chinesecj.com

Naming: zhs = Simplified, zht = Traditional, merged = both combined. RIME loads a file named predict.db (set by predictor/db in the schema). So "enabling a version" means copying the version you want to predict.db, or pointing predictor/db at a specific filename. predict.db itself is not committed to this repo — create your own copy.


Quick start

  1. Pick a .db from dist/, copy it into your RIME user directory (%APPDATA%\Rime\ on Windows), renaming it to predict.db — or keep its name and reference it directly in step 2.
  2. Enable the predictor in <your_schema>.custom.yaml (example uses cangjie5_sc.custom.yaml):
patch:
  translator/enable_sentence: false
  translator/enable_encoder: false
  translator/enable_completion: false
  translator/enable_user_dict: false

  "engine/processors/@before 0": predictor
  "engine/translators/@before 0": predict_translator
  "switches/+":
    - { name: prediction, states: [ Prediction Off, Prediction On ], reset: 1 }
  predictor:
    db: predict.db          # or point directly at predict-zht.db, etc.
    max_candidates: 6
  1. Redeploy from the tray menu. Type and the candidate bar should show 我们 · 我见 · 我行我素 ….

A ready-to-copy config lives at docs/example.custom.yaml.

Switching versions (drop multiple .db files into %APPDATA%\Rime\, change one line):

  predictor:
    db: predict-zhs.db      # or predict-zht.db / predict-merged.db

Then redeploy.


Which version to use

  • Simplified predict-zhs.db — for Simplified-only input. Cleanest. 99.1% frequency coverage.
  • Traditional predict-zht.db — for Traditional-only input. 88.5% coverage (see Technical notes).
  • Merged predict-merged.db — for mixed input with Simplified as the primary (recommended for daily use).
    • Heads that differ by form (問≠问, 愛≠爱, 國≠国 …) have naturally distinct keys, so the two datasets never interfere — zero cross-talk.
    • Heads with identical form (我 / 中 / 你 …) share one key, with Simplified first and Traditional trailing, so Simplified input is virtually unaffected.

How these were built

chinesecj.com association lists (GBK/GB18030)
   ├─ jtlx.txt  Simplified source
   └─ ftlx.txt  Traditional source
        │  ① Parse: split each line into (head → [continuations...])
        │  ② Sort: reorder continuations by commonness
        │        (the raw lists are in phonetic order, so this step is needed)
        │        frequencies taken from rime-ice cn_dicts/base.dict.yaml
        │        Traditional words are first converted to Simplified via OpenCC t2s,
        │        then looked up — one consistent frequency ruler
        │  ③ Merge (merged only): Simplified tier first, Traditional tier after,
        │        identical-form duplicates removed
        ▼
   head ⇥ continuation ⇥ weight   (src/predict-*.tsv)
        │  ④ compiled to binary by librime-predict's build_predict tool
        ▼
   dist/predict-*.db   (Rime::Predict/1.0)

Rebuilding

The .db files are binary and cannot be hand-edited. To change content, edit the matching .tsv and recompile, or rerun the whole pipeline.

  • Fine-tune ordering / add / remove words: edit src/predict-*.tsv (head ⇥ continuation ⇥ weight; the row order under a head = the candidate display order), then recompile with build_predict.
  • New upstream list from chinesecj.com: replace raw/jtlx.txt / raw/ftlx.txt and rerun the pipeline.

build_predict links against librime; building it natively on Windows is fiddly. A Linux environment is the easy path for rebuilds.


Technical notes

  • Display order = the storage row order in the db, not re-sorted by weight. librime-predict reads candidates sequentially up to max_candidates. So "common words first" is achieved by the row order when generating the TSV; the weight column is recorded for reference only.
  • Traditional coverage is 88.5% (lower than Simplified's 99.1%): rime-ice is Simplified-oriented, and a few Taiwan-specific terms don't match after t2s conversion (e.g. 愛滋病→爱滋病, 阿茨海默症). Those words get no frequency and sort after the common words of their head, but they remain in the candidate list. Common words (問題, 我們, 愛情 …) all convert and sort correctly.
  • Merged heads with identical form trail a few Traditional "ride-along" candidates near the end of max_candidates; Simplified input barely notices.
  • librime version: compiled with librime 1.10; the Rime::Predict/1.0 format is stable across versions (the loader only checks the Rime::Predict/ prefix), and loads fine on Weasel 1.13.x. If candidates ever stop appearing or the log reports a predict-db error, just recompile.
  • Keep simplification OFF (default 漢字 state), otherwise everything is forced to Simplified, breaking bidirectional Simplified/Traditional lookup. (This is a schema setting unrelated to predict.db, noted here for completeness.)

Credits & sources

This project would not exist without the work of others. Sincere thanks to:

If you redistribute or build upon this work, please keep this attribution.


License

Released under the GNU General Public License v3.0 (see LICENSE), following the license of the upstream rime-ice frequency data this work is derived from.

The upstream association word lists come from the Cangjie Platform 2022 (chinesecj.com), whose authors state on their official forum that the platform and its code tables are "completely free and open, welcoming everyone to help promote Cangjie" (source). This project redistributes the raw/ lists in that spirit, with attribution. The underlying Cangjie input method is patent-free — released by Chu Bong-Foo (朱邦復) for free use and modification. The sibling project Jackchows/Cangjie5, likewise derived from the Cangjie Platform tables, follows the same approach.


Last updated: 2026-06-26

About

Next-word prediction dictionaries for RIME — Simplified / Traditional / Merged Chinese. RIME 输入法上屏联想词库 — 简体 / 繁体 / 简繁合并,适用任何中文方案

Topics

Resources

License

Stars

4 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors