Skip to content

Commit

Permalink
prediction switch (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Oct 31, 2023
1 parent 1979c00 commit dbe622f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ jobs:
working-directory: build/bin
run: |
sed -i '48a \ - predictor' luna_pinyin.schema.yaml
sed -i '37a \ - name: prediction\n states: [ 关闭预测, 开启预测 ]\n reset: 1' luna_pinyin.schema.yaml
echo -e 'qi \n ' | ./rime_api_console | tee log
grep 'commit: 一' log
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ librime plugin. predict next word.
* Put the db file (by default `predict.db`) in rime user directory.
* In `*.schema.yaml`, add `predictor` to the list of `engine/processors` before `key_binder`,
or patch the schema with: `engine/processors/@before 0: predictor`
* Add the `prediction` switch:
```yaml
switches:
- name: prediction
states: [ 关闭预测, 开启预测 ]
reset: 1
```
* Config items for your predictor:
```yaml
predictor:
Expand Down
3 changes: 2 additions & 1 deletion src/predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ void Predictor::OnSelect(Context* ctx) {
}

void Predictor::OnContextUpdate(Context* ctx) {
if (!db_ || !ctx || !ctx->composition().empty())
if (!db_ || !ctx || !ctx->composition().empty() ||
!ctx->get_option("prediction"))
return;
if (last_action_ == kDelete) {
return;
Expand Down

0 comments on commit dbe622f

Please sign in to comment.