Compare commits
80 Commits
nightly
...
2024.09.25
| Author | SHA1 | Date | |
|---|---|---|---|
| ea74e40bec | |||
| 3542aa9fec | |||
| f75e70d3c2 | |||
| 9cf93a65ce | |||
| d1f49235bb | |||
| 5bb6b00aa4 | |||
| a3b7d073c9 | |||
| 2ea99c5e4f | |||
| 16affc6674 | |||
| 2cf8aa100b | |||
| 1a3a57d067 | |||
| fc1cf8f90b | |||
| e04b3d4592 | |||
| fe27ae8fe6 | |||
| 4dd55a62eb | |||
| 0fe3a8f958 | |||
| 0ff2c93762 | |||
| b9f3e511e4 | |||
| 59f81a5a18 | |||
| 0367c85243 | |||
| 4fbd67f1dc | |||
| 0407f13bfd | |||
| bab54fd172 | |||
| 66d083bc75 | |||
| 5f30dfbd72 | |||
| 0dc8c2d84b | |||
| 63671a96a9 | |||
| 7942d9c328 | |||
| f7aa0c7437 | |||
| a85c1dd911 | |||
| 2fec735d66 | |||
| ac1579e96d | |||
| 918e6ed11b | |||
| a8f5b6ceee | |||
| f37863cbc5 | |||
| 5903b2780e | |||
| f0bf04f328 | |||
| 4ad08e5c08 | |||
| 9c7d1287f4 | |||
| fce588292f | |||
| 3c9dd7d77d | |||
| 3c8ba3d3db | |||
| 3717e90855 | |||
| 028ecec79f | |||
| b812a8b2c7 | |||
| eec59685c4 | |||
| bf863a9edb | |||
| 3e1e8d9691 | |||
| 546017504a | |||
| 2b4bf3afeb | |||
| 6e9f7a2685 | |||
| 49c1bd78f2 | |||
| bd5bcceb88 | |||
| f7423ecfa1 | |||
| 60a2d21d92 | |||
| 4fbf489038 | |||
| 37ca416a9c | |||
| 9d79f2920e | |||
| 9503250adf | |||
| 11e8efc194 | |||
| b70ef9cd46 | |||
| 25988ae752 | |||
| fdb6141a18 | |||
| 6431222558 | |||
| b2cb11c0d6 | |||
| 0b59306d61 | |||
| 12daff6ef1 | |||
| af2480ba1b | |||
| 69381881ef | |||
| cd4534a28d | |||
| 50e0ddf6a2 | |||
| 21f3cb8625 | |||
| e33e1d2c44 | |||
| 0d93df2174 | |||
| c5b8efc6ad | |||
| edee978ed4 | |||
| 9c4399aae2 | |||
| 1ac25b3ed5 | |||
| d0a6143f93 | |||
| ea7770e408 |
@@ -0,0 +1,76 @@
|
||||
name: Bug 报告
|
||||
description: 我遇到了一个 bug 或是非预期行为
|
||||
title: '[Bug]: '
|
||||
labels:
|
||||
- bug
|
||||
body:
|
||||
- type: input
|
||||
id: input
|
||||
attributes:
|
||||
label: 摘要
|
||||
description: 一两句话概述遇到的问题
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: check_box
|
||||
attributes:
|
||||
label: 基本检查
|
||||
description: 如实勾选相关选项,以提高沟通的效率
|
||||
options:
|
||||
- label: 我使用的是雾凇拼音 iDvel/rime-ice
|
||||
required: true
|
||||
- label: 我搜索了过往的 issue,没找到解决办法
|
||||
required: true
|
||||
- label: 我查看了置顶 issue 和详细介绍,没找到解决办法
|
||||
required: true
|
||||
- label: 不对雾凇拼音进行任何修改,也会有这个问题
|
||||
required: false
|
||||
- label: 雾凇拼音最新 commit 或 Nightly 版,仍然有这个问题
|
||||
required: false
|
||||
- label: 我知晓:如果此 issue 不符合模板,或者长时间不活跃,会被无条件关闭
|
||||
required: true
|
||||
- type: input
|
||||
id: os_version
|
||||
attributes:
|
||||
label: 系统信息
|
||||
description: 请提供你能复现此问题的系统名称,以及版本号
|
||||
placeholder: macOS 14.5 / Windows 11 23H2 / Ubuntu 22.04 LTS
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: app_version
|
||||
attributes:
|
||||
label: 应用信息
|
||||
description: 提供你使用的 RIME 前端和版本号,自构建前端请说明
|
||||
placeholder: Squirrel 1.0.2 / Weasel 0.16.1
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: step_to_reproduce
|
||||
attributes:
|
||||
label: 复现办法和预期行为
|
||||
description: 重现该问题的办法,雾凇在你预期中应当如何行为
|
||||
value: |
|
||||
1.
|
||||
2.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: info
|
||||
attributes:
|
||||
label: '补充信息'
|
||||
description: ' 请提供你认为重要的其他信息,例如截图、视频、Rime 的报错信息等'
|
||||
- type: textarea
|
||||
id: config
|
||||
attributes:
|
||||
label: 自定义配置
|
||||
description: 如果你对雾凇进行了修改或者打了补丁,请在此处提供你的自定义配置
|
||||
placeholder: |
|
||||
完整配置文件请压缩上传。
|
||||
配置片段请包裹在 Markdown 代码块中。即用三个反引号(```)包裹,如
|
||||
```yaml
|
||||
# 你的配置片段
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
blank_issues_enabled: false
|
||||
|
||||
contact_links:
|
||||
- name: 词库问题
|
||||
url: https://github.com/iDvel/rime-ice/issues/666
|
||||
about: 如果你发现了词库中有字词音形有错讹、缺漏等情况,请直接在这个链接中评论。鼓励你直接 PR,参与雾凇的维护。
|
||||
|
||||
- name: 雾凇拼音详细介绍
|
||||
url: https://dvel.me/posts/rime-ice/
|
||||
about: 这里是雾凇拼音的详细介绍,包括了安装、配置、使用和配置思路等内容。
|
||||
|
||||
- name: 雾凇拼音常见问题
|
||||
url: https://github.com/iDvel/rime-ice/issues/133
|
||||
about: 这里有一些重要问题的答案,提问前请查看,也请事先搜索 issue,你的问题也许已经有现成的答案。
|
||||
|
||||
- name: RIME 定制文档
|
||||
url: https://github.com/rime/home/wiki
|
||||
about: 这里有自定义 RIME 方案的全面教程。
|
||||
|
||||
- name: 小狼毫(Weasel)文档
|
||||
url: https://github.com/rime/weasel/wiki
|
||||
about: 这里有定制 Weasel 样式和行为的指导。
|
||||
|
||||
- name: 鼠须管(Squirrel)文档
|
||||
url: https://github.com/LEOYoon-Tsaw/Rime_collections/blob/master/鼠鬚管介面配置指南.md
|
||||
about: 这里有定制 Squirrel 样式和行为的参考资料。
|
||||
@@ -0,0 +1,47 @@
|
||||
name: 想法、求助和提议
|
||||
description: 我有一些想法和建议;或是一些不理解的地方想要求助
|
||||
|
||||
body:
|
||||
- type: input
|
||||
id: summary
|
||||
attributes:
|
||||
label: 摘要
|
||||
description: 用一两句话概括此 issue 的内容
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: app_version
|
||||
attributes:
|
||||
label: 相关应用
|
||||
description: 这个议题涉及的,或者是你在使用的 RIME 前端
|
||||
placeholder: e.g. Squirrel 1.0.2 / Fcitx5 for Android 0.9 / Weasel CI 9bc58
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: os_version
|
||||
attributes:
|
||||
label: 系统信息
|
||||
description: 这个议题涉及的,或者是你在使用的系统及版本号,Unix/Linux 请提供具体发行版名称
|
||||
placeholder: e.g. macOS 14.5 / Windows 11 23H2 / Ubuntu 22.04 LTS
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: content
|
||||
attributes:
|
||||
label: 详细说明
|
||||
description: 请详细说明你的问题或者想法,越具体越好。可以辅以图片、视频等资料。
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: config
|
||||
attributes:
|
||||
label: 补充信息
|
||||
description: 此处可以提供配置文件片段、完整配置文件压缩包、或者日志等信息。你认为相关的 issue 也可以在此处注明。
|
||||
placeholder: |
|
||||
完整配置文件请压缩上传。
|
||||
|
||||
配置片段请包裹在 Markdown 代码块中。即用三个反引号(```)包裹,如
|
||||
```yaml
|
||||
# 你的配置片段
|
||||
```
|
||||
|
||||
@@ -1,27 +1,41 @@
|
||||
name: Pack and Release
|
||||
name: Build and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.*'
|
||||
- "[0-9]+.*"
|
||||
paths:
|
||||
- '**/**'
|
||||
- '!**.md'
|
||||
- '!**.gitignore'
|
||||
- '!others/**'
|
||||
- '!.github/**'
|
||||
- "**/**"
|
||||
- "!**.md"
|
||||
- "!**.gitignore"
|
||||
- "!.github/**"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
Release:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'iDvel/rime-ice'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
if: ${{ contains(github.event.head_commit.message, ' [build]') || github.event_name == 'workflow_dispatch' }}
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.22
|
||||
|
||||
- name: Check and build
|
||||
id: check_and_build
|
||||
if: ${{ contains(github.event.head_commit.message, ' [build]') || github.event_name == 'workflow_dispatch' }}
|
||||
run: |
|
||||
cd others/script
|
||||
go mod tidy
|
||||
go run main.go --rime_path "${{ github.workspace }}" --auto_confirm
|
||||
|
||||
- name: Pack dicts
|
||||
run: |
|
||||
mkdir dist
|
||||
@@ -29,28 +43,33 @@ jobs:
|
||||
find . -maxdepth 1 -name "*.lua" -o -name "*.yaml" -o -name "*.txt" | zip dist/full.zip -@
|
||||
zip -r dist/full.zip cn_dicts en_dicts lua opencc LICENSE
|
||||
echo "Pack dicts ..."
|
||||
zip -r dist/all_dicts.zip cn_dicts en_dicts radical_pinyin.dict.yaml
|
||||
zip -r dist/all_dicts.zip cn_dicts en_dicts opencc radical_pinyin.dict.yaml
|
||||
echo "Pack cn_dicts ..."
|
||||
zip -r dist/cn_dicts.zip cn_dicts
|
||||
echo "Pack en_dicts ..."
|
||||
zip -r dist/en_dicts.zip en_dicts
|
||||
echo "Pack opencc ..."
|
||||
zip -r dist/opencc.zip opencc
|
||||
echo "copy LICENSE and README.md..."
|
||||
cp LICENSE dist/LICENSE.txt
|
||||
cp README.md dist/README.md
|
||||
|
||||
- name: Create nightly release
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
uses: 'softprops/action-gh-release@v2'
|
||||
uses: "softprops/action-gh-release@v2"
|
||||
with:
|
||||
body: |
|
||||
## 说明
|
||||
|
||||
|
||||
这里是每次提交后自动打包的版本,包含最新的功能和词库
|
||||
|
||||
- `README.md`:简易的使用说明
|
||||
- `full.zip` : 包含所有词典和方案文件
|
||||
- `cn_dicts.zip`:中文词库
|
||||
- `en_dicts.zip`:英文词库
|
||||
- `opencc.zip`:opencc 词库(emoji 等)
|
||||
- `all_dicts.zip`:以上三个词库的整合
|
||||
- `LICENSE.txt`:开源协议
|
||||
|
||||
tag_name: nightly
|
||||
name: "nightly build"
|
||||
@@ -60,10 +79,24 @@ jobs:
|
||||
|
||||
- name: Create stable release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: 'softprops/action-gh-release@v2'
|
||||
uses: "softprops/action-gh-release@v2"
|
||||
with:
|
||||
body_path: ${{ github.workspace }}/others/CHANGELOG.md
|
||||
draft: true
|
||||
make_latest: true
|
||||
files: |
|
||||
dist/*
|
||||
dist/*
|
||||
|
||||
- name: Push and commit
|
||||
if: ${{ steps.check_and_build.outcome == 'success' }}
|
||||
run: |
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add --all
|
||||
if ! git diff --cached --quiet; then
|
||||
COMMIT_MSG=$(git log -1 --pretty=%B | sed -e 's/\s\[build\]$//' -e 's/^[a-zA-Z()]*:\s*//')
|
||||
git commit -m "build(ci): auto build for -> ${COMMIT_MSG} <-"
|
||||
git push
|
||||
else
|
||||
echo "No changes to commit."
|
||||
fi
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
这里是 Rime 的一份配置仓库,用户需要下载各平台对应的前端,并将此配置应用到配置目录。
|
||||
|
||||
雾凇拼音提供了一套开箱即用的完整配置,包含了输入方案(全拼、双拼)、长期维护的词库及各项扩展功能。
|
||||
雾凇拼音提供了一套开箱即用的完整配置,包含输入方案(全拼、常见双拼)、长期维护的开源词库及各项扩展功能。
|
||||
|
||||
详细介绍:[Rime 配置:雾凇拼音](https://dvel.me/posts/rime-ice/)
|
||||
|
||||
@@ -24,33 +24,40 @@
|
||||
|
||||
- 简体 | 全拼 | 双拼
|
||||
- 主要功能
|
||||
- [melt_eng](https://github.com/tumuyan/rime-melt) 英文输入(@tumuyan | [Apache 2.0](https://github.com/tumuyan/rime-melt/blob/master/LICENSE))
|
||||
- 轻量的英文输入,支持中英混输
|
||||
- [优化英文输入体验](https://dvel.me/posts/make-rime-en-better/)
|
||||
- [部件拆字方案](https://github.com/mirtlecn/rime-radical-pinyin) 反查、辅码(@mirtlecn | [CC BY-SA 4.0](https://github.com/mirtlecn/rime-radical-pinyin/blob/master/LICENSE))
|
||||
- 拆字反查(<kbd>uU</kbd>+拼音),拆字辅码(拼音+<kbd>`</kbd>+拆字辅码)
|
||||
- 自整理的 Emoji
|
||||
- [以词定字](https://github.com/BlindingDark/rime-lua-select-character)(@BlindingDark | [LGPL 3.0](https://github.com/BlindingDark/rime-lua-select-character/blob/master/LICENSE))
|
||||
- [长词优先](https://github.com/tumuyan/rime-melt/blob/master/lua/melt.lua)(@tumuyan | [Apache 2.0](https://github.com/tumuyan/rime-melt/blob/master/LICENSE))
|
||||
- [Unicode](https://github.com/shewer/librime-lua-script/blob/main/lua/component/unicode.lua)(@shewer | [MIT](https://github.com/shewer/librime-lua-script/blob/main/lua/component/unicode.lua))
|
||||
- [数字、人民币大写](https://github.com/yanhuacuo/98wubi/blob/master/lua/number.lua)(@98wubi)
|
||||
- 日期、时间、星期、[农历](https://github.com/boomker/rime-fast-xhup)(@boomker | [LGPL 3.0](https://github.com/boomker/rime-fast-xhup/blob/master/LICENSE))
|
||||
- 以词定字(左右中括号:<kbd>[</kbd>、<kbd>]</kbd>)
|
||||
- 长词优先
|
||||
- Unicode(<kbd>U</kbd>+Unicode 码位)
|
||||
- 数字、人民币大写(<kbd>R</kbd>+数字)
|
||||
- 日期、时间、星期(详见方案 `/date_translator` 节点)
|
||||
- 农历(转写:<kbd>N</kbd>+八位数字;获取当前农历:全拼<kbd>nl</kbd>,双拼<kbd>lunar</kbd>)
|
||||
- 常见错音错字提示
|
||||
- 置顶候选项
|
||||
- 所有标点符号直接上屏,/ 模式改为 v 模式,/ 直接上屏
|
||||
- 增加了许多拼音纠错
|
||||
- 置顶候选项(详见方案 `/pin_cand_filter` 节点)
|
||||
- 所有标点符号直接上屏
|
||||
- 特殊符号、字符输入(全拼<kbd>v</kbd>+首字母缩写;双拼<kbd>V</kbd>+首字母缩写)
|
||||
- 拼音纠错(模糊音)
|
||||
- 更多默认未启用的功能请参考 `rime.lua` 文件以及方案注释
|
||||
- 简体字表、词库
|
||||
- [《通用规范汉字表》](https://github.com/iDvel/The-Table-of-General-Standard-Chinese-Characters)
|
||||
- [华宇野风系统词库](http://bbs.pinyin.thunisoft.com/forum.php?mod=viewthread&tid=30049)(@野风)
|
||||
- [清华大学开源词库](https://github.com/thunlp/THUOCL)(@THUNLP | [MIT](https://github.com/thunlp/THUOCL/blob/master/LICENSE))
|
||||
- [现代汉语常用词表](https://gist.github.com/indiejoseph/eae09c673460aa0b56db)(@Joseph cheng)
|
||||
- [腾讯词向量](https://ai.tencent.com/ailab/nlp/en/download.html)(@Tencent AI Lab | [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/))
|
||||
- 参考
|
||||
- 《现代汉语词典》
|
||||
- 《同义词词林》
|
||||
- 《新华成语大词典》
|
||||
- [通用规范汉字表](https://github.com/iDvel/The-Table-of-General-Standard-Chinese-Characters)(by 中华人民共和国教育部)8K 常用汉字
|
||||
- [Unihan 字库](https://www.unicode.org/Public/)(by Unicode lnc | [UNICODE LICENSE V3](https://www.unicode.org/license.txt))40K 大字库, **默认未启用**
|
||||
- [现代汉语常用词表](https://zh.wikipedia.org/wiki/%E7%8E%B0%E4%BB%A3%E6%B1%89%E8%AF%AD%E5%B8%B8%E7%94%A8%E8%AF%8D%E8%A1%A8)(by 中国国家语言文字工作委员会)
|
||||
- [华宇野风词库](http://bbs.pinyin.thunisoft.com/forum.php?mod=viewthread&tid=30049)(by 野风)
|
||||
- [简化字八股文](https://github.com/rime/rime-essay-simp)(by rime | [LGPL](https://github.com/rime/rime-essay-simp/blob/master/LICENSE))
|
||||
- [清华大学开源词库](https://github.com/thunlp/THUOCL)(by THUNLP | [MIT](https://github.com/thunlp/THUOCL/blob/master/LICENSE))
|
||||
- [腾讯词向量](https://ai.tencent.com/ailab/nlp/en/download.html)(@Huandeep [整理](https://github.com/iDvel/rime-ice/issues/24) | by Tencent AI Lab | [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/))
|
||||
- 词库修订
|
||||
- 校对大量异形词、错别字、错误注音
|
||||
- 全词库完成注音
|
||||
- 同义多音字注音
|
||||
- 参考
|
||||
- 《现代汉语词典》
|
||||
- 《同义词词林》
|
||||
- 《新华成语大词典》
|
||||
- [校对标准论坛](http://www.jiaodui.com/bbs/)
|
||||
- Rime、Squirrel、Weasel 常用配置项的详尽注释
|
||||
|
||||
<br>
|
||||
|
||||
@@ -82,10 +89,12 @@
|
||||
|
||||
### 手动安装
|
||||
|
||||
将仓库所有文件复制粘贴到配置目录,重新部署。
|
||||
您可以将仓库打包下载,或者整体 clone 后,将所有文件复制粘贴到配置目录,重新部署。
|
||||
|
||||
更新词库,手动覆盖 `cn_dicts` `en_dcits` `opencc` 三个文件夹。
|
||||
|
||||
您也可以前往 [Release](https://github.com/iDvel/rime-ice/releases) 界面,下载特定版本的词典文件(具体描述见 Release 说明),覆盖配置目录的对应文件。
|
||||
|
||||
### 东风破 [plum](https://github.com/rime/plum)
|
||||
|
||||
选择配方(`others/recipes/*.recipe.yaml`)来进行安装或更新。
|
||||
@@ -135,6 +144,14 @@ bash rime-install iDvel/rime-ice:others/recipes/config:schema=abc
|
||||
bash rime-install iDvel/rime-ice:others/recipes/config:schema=ziguang
|
||||
```
|
||||
|
||||
℞ 下载特定版本的配置
|
||||
|
||||
在仓库后加 `@tag` 即可,例如:
|
||||
|
||||
```sh
|
||||
bash rime-install iDvel/rime-ice@2024.05.21:others/recipes/full
|
||||
```
|
||||
|
||||
### 仓输入法 [Hamster](https://github.com/imfuxiao/Hamster)
|
||||
|
||||
参考 [如何导入"雾淞拼音输入方案"](https://github.com/imfuxiao/Hamster/wiki/%E5%A6%82%E4%BD%95%E5%AF%BC%E5%85%A5%22%E9%9B%BE%E6%B7%9E%E6%8B%BC%E9%9F%B3%E8%BE%93%E5%85%A5%E6%96%B9%E6%A1%88%22)
|
||||
@@ -189,7 +206,16 @@ patch:
|
||||
|
||||
## 感谢 ❤️
|
||||
|
||||
感谢上述提到的词库、方案及功能参考。
|
||||
特别感谢上文已经提及的词库、词典的作者、贡献者及整理者;特别感谢以及下列词库、方案、脚本的作者及贡献者(提及的均为 GitHub id):
|
||||
|
||||
- @mozillazg 开发的汉字转拼音工具和数据库(MIT)
|
||||
- [melt_eng](https://github.com/tumuyan/rime-melt)(@tumuyan | [Apache 2.0](https://github.com/tumuyan/rime-melt/blob/master/LICENSE)) :提供了部分(约 1000 条)英文词汇以及原始英文方案参考;
|
||||
- [部件拆字方案 v1](https://github.com/mirtlecn/rime-radical-pinyin)(@mirtlecn | [CC BY-SA 4.0](https://github.com/mirtlecn/rime-radical-pinyin/blob/master/LICENSE)):提供的拆字反查,辅码插件;
|
||||
- [长词优先插件](https://github.com/tumuyan/rime-melt/blob/master/lua/melt.lua)(@tumuyan | [Apache 2.0](https://github.com/tumuyan/rime-melt/blob/master/LICENSE))
|
||||
- [Unicode 插件](https://github.com/shewer/librime-lua-script/blob/main/lua/component/unicode.lua)(@shewer | [MIT](https://github.com/shewer/librime-lua-script/blob/main/lua/component/unicode.lua))
|
||||
- [数字、人民币大写插件](https://github.com/yanhuacuo/98wubi/blob/master/lua/number.lua)(@98wubi)
|
||||
- [农历插件](https://github.com/boomker/rime-fast-xhup)(@boomker | [LGPL 3.0](https://github.com/boomker/rime-fast-xhup/blob/master/LICENSE))
|
||||
- 未能在此处详述的、在本库源码注释中提及的项目及作者给予的帮助和参考
|
||||
|
||||
感谢 [@Huandeep](https://github.com/Huandeep) 整理的多个词库。
|
||||
|
||||
@@ -197,9 +223,7 @@ patch:
|
||||
|
||||
感谢所有贡献者。
|
||||
|
||||
搜狗转 Rime:[lewangdev/scel2txt](https://github.com/lewangdev/scel2txt)
|
||||
|
||||
大量参考 [校对标准论坛](http://www.jiaodui.com/bbs/)
|
||||
<!-- 搜狗转 Rime:[lewangdev/scel2txt](https://github.com/lewangdev/scel2txt) -->
|
||||
|
||||
Thanks to JetBrains for the OSS development license.
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 这样小字表里存在的字按权重靠前排列,大字表殿后,生僻字自动就排在末尾。
|
||||
---
|
||||
name: 41448
|
||||
version: "2024-05-16"
|
||||
version: "2024-07-28"
|
||||
sort: by_weight
|
||||
...
|
||||
# 注释掉了一些
|
||||
@@ -8676,6 +8676,7 @@ sort: by_weight
|
||||
𩙣 feng
|
||||
𩪌 feng
|
||||
𪐃 feng
|
||||
覅 fiao
|
||||
㤇 fo
|
||||
仏 fo
|
||||
仸 fo
|
||||
@@ -23504,6 +23505,7 @@ sort: by_weight
|
||||
疑 ni
|
||||
眤 ni
|
||||
睨 ni
|
||||
祢 ni
|
||||
秜 ni
|
||||
籾 ni
|
||||
縌 ni
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
# 需要注音的字词设定在 others/script/rime/需要注音.txt
|
||||
---
|
||||
name: 8105
|
||||
version: "2024-05-21"
|
||||
version: "2024-06-10"
|
||||
sort: by_weight
|
||||
...
|
||||
### 按需启用
|
||||
@@ -45,7 +45,6 @@ sort: by_weight
|
||||
|
||||
### 扩展,不在《通用规范汉字表》的字:
|
||||
𤭢 cei 1000
|
||||
𤭢了 cei le 1000
|
||||
𰻝 biang 1
|
||||
嬢 niang 1
|
||||
薙 ti 1
|
||||
@@ -60,6 +59,10 @@ sort: by_weight
|
||||
珮 pei 0
|
||||
睆 huan 1
|
||||
挼 rua 1
|
||||
㨃 dui 1
|
||||
燿 yao 1
|
||||
侗 tong 1
|
||||
|
||||
# 注释掉的这几行已经加入到下面并调整到合适的权重了
|
||||
# 〇 ling
|
||||
# 囧 jiong
|
||||
|
||||
+189
-67
File diff suppressed because it is too large
Load Diff
+550
-14
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
#
|
||||
---
|
||||
name: others
|
||||
version: "2024-05-21"
|
||||
version: "2024-06-10"
|
||||
sort: by_weight
|
||||
...
|
||||
##### 容错词
|
||||
@@ -82,8 +82,6 @@ sort: by_weight
|
||||
主角 zhu jiao
|
||||
角色 jue se
|
||||
角色 jiao se
|
||||
比萨 bi sa
|
||||
比萨 pi sa
|
||||
比萨饼 bi sa bing
|
||||
比萨饼 pi sa bing
|
||||
吃比萨 chi bi sa
|
||||
@@ -228,6 +226,8 @@ sort: by_weight
|
||||
饮鸩止渴 yin jiu zhi ke
|
||||
饮鸩解渴 yin zhen jie ke
|
||||
饮鸩解渴 yin jiu jie ke
|
||||
宫商角徵羽 gong shang jue zhi yu
|
||||
宫商角徵羽 gong shang jiao zhi yu
|
||||
### 错字
|
||||
曾经 ceng jing
|
||||
曾今 ceng jin
|
||||
@@ -250,6 +250,8 @@ sort: by_weight
|
||||
钜惠 ju hui
|
||||
摩羯座 mo jie zuo
|
||||
魔蝎座 mo xie zuo
|
||||
比萨 bi sa
|
||||
披萨 pi sa
|
||||
|
||||
|
||||
##### 叠字
|
||||
|
||||
+99
-1702
File diff suppressed because it is too large
Load Diff
@@ -157,6 +157,7 @@ pin_cand_filter:
|
||||
# 主翻译器,拼音
|
||||
translator:
|
||||
dictionary: rime_ice # 挂载词库 rime_ice.dict.yaml
|
||||
enable_word_completion: true # 大于 4 音节的词条自动补全,librime > 1.11.2
|
||||
prism: double_pinyin # 多方案共用一个词库时,为避免冲突,需要用 prism 指定一个名字。
|
||||
spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中
|
||||
always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。
|
||||
|
||||
@@ -157,6 +157,7 @@ pin_cand_filter:
|
||||
# 主翻译器,拼音
|
||||
translator:
|
||||
dictionary: rime_ice # 挂载词库 rime_ice.dict.yaml
|
||||
enable_word_completion: true # 大于 4 音节的词条自动补全,librime > 1.11.2
|
||||
prism: double_pinyin_abc # 多方案共用一个词库时,为避免冲突,需要用 prism 指定一个名字。
|
||||
spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中
|
||||
always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。
|
||||
|
||||
@@ -157,6 +157,7 @@ pin_cand_filter:
|
||||
# 主翻译器,拼音
|
||||
translator:
|
||||
dictionary: rime_ice # 挂载词库 rime_ice.dict.yaml
|
||||
enable_word_completion: true # 大于 4 音节的词条自动补全,librime > 1.11.2
|
||||
prism: double_pinyin_flypy # 多方案共用一个词库时,为避免冲突,需要用 prism 指定一个名字。
|
||||
spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中
|
||||
always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。
|
||||
|
||||
@@ -157,6 +157,7 @@ pin_cand_filter:
|
||||
# 主翻译器,拼音
|
||||
translator:
|
||||
dictionary: rime_ice # 挂载词库 rime_ice.dict.yaml
|
||||
enable_word_completion: true # 大于 4 音节的词条自动补全,librime > 1.11.2
|
||||
prism: double_pinyin_mspy # 多方案共用一个词库时,为避免冲突,需要用 prism 指定一个名字。
|
||||
spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中
|
||||
always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。
|
||||
|
||||
@@ -157,6 +157,7 @@ pin_cand_filter:
|
||||
# 主翻译器,拼音
|
||||
translator:
|
||||
dictionary: rime_ice # 挂载词库 rime_ice.dict.yaml
|
||||
enable_word_completion: true # 大于 4 音节的词条自动补全,librime > 1.11.2
|
||||
prism: double_pinyin_sogou # 多方案共用一个词库时,为避免冲突,需要用 prism 指定一个名字。
|
||||
spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中
|
||||
always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。
|
||||
|
||||
@@ -157,6 +157,7 @@ pin_cand_filter:
|
||||
# 主翻译器,拼音
|
||||
translator:
|
||||
dictionary: rime_ice # 挂载词库 rime_ice.dict.yaml
|
||||
enable_word_completion: true # 大于 4 音节的词条自动补全,librime > 1.11.2
|
||||
prism: double_pinyin_ziguang # 多方案共用一个词库时,为避免冲突,需要用 prism 指定一个名字。
|
||||
spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中
|
||||
always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。
|
||||
|
||||
@@ -912,3 +912,27 @@ O不OK obuok
|
||||
人均GDP renjungdp
|
||||
V8引擎 Vbayinqing
|
||||
V8引擎 vbayinqing
|
||||
4A级 siAji
|
||||
4A级 siaji
|
||||
5A级 wuAji
|
||||
5A级 wuaji
|
||||
2G网络 erGwangluo
|
||||
2G网络 ergwangluo
|
||||
3G网络 sanGwangluo
|
||||
3G网络 sangwangluo
|
||||
4G网络 siGwangluo
|
||||
4G网络 sigwangluo
|
||||
5G网络 wuGwangluo
|
||||
5G网络 wugwangluo
|
||||
3G流量 sanGliuliang
|
||||
3G流量 sangliuliang
|
||||
4G流量 siGliuliang
|
||||
4G流量 sigliuliang
|
||||
5G流量 wuGliuliang
|
||||
5G流量 wugliuliang
|
||||
3D打印 sanDdayin
|
||||
3D打印 sanddayin
|
||||
2D电影 erDdianying
|
||||
2D电影 erddianying
|
||||
3D电影 sanDdianying
|
||||
3D电影 sanddianying
|
||||
|
||||
@@ -912,3 +912,27 @@ O不OK obuok
|
||||
人均GDP rfjngdp
|
||||
V8引擎 Vbaycqy
|
||||
V8引擎 vbaycqy
|
||||
4A级 siAji
|
||||
4A级 siaji
|
||||
5A级 wuAji
|
||||
5A级 wuaji
|
||||
2G网络 orGwhlo
|
||||
2G网络 orgwhlo
|
||||
3G网络 sjGwhlo
|
||||
3G网络 sjgwhlo
|
||||
4G网络 siGwhlo
|
||||
4G网络 sigwhlo
|
||||
5G网络 wuGwhlo
|
||||
5G网络 wugwhlo
|
||||
3G流量 sjGlrlt
|
||||
3G流量 sjglrlt
|
||||
4G流量 siGlrlt
|
||||
4G流量 siglrlt
|
||||
5G流量 wuGlrlt
|
||||
5G流量 wuglrlt
|
||||
3D打印 sjDdayc
|
||||
3D打印 sjddayc
|
||||
2D电影 orDdwyy
|
||||
2D电影 orddwyy
|
||||
3D电影 sjDdwyy
|
||||
3D电影 sjddwyy
|
||||
|
||||
@@ -912,3 +912,27 @@ O不OK obuok
|
||||
人均GDP rfjpgdp
|
||||
V8引擎 Vbaynqy
|
||||
V8引擎 vbaynqy
|
||||
4A级 siAji
|
||||
4A级 siaji
|
||||
5A级 wuAji
|
||||
5A级 wuaji
|
||||
2G网络 erGwhlo
|
||||
2G网络 ergwhlo
|
||||
3G网络 sjGwhlo
|
||||
3G网络 sjgwhlo
|
||||
4G网络 siGwhlo
|
||||
4G网络 sigwhlo
|
||||
5G网络 wuGwhlo
|
||||
5G网络 wugwhlo
|
||||
3G流量 sjGlqld
|
||||
3G流量 sjglqld
|
||||
4G流量 siGlqld
|
||||
4G流量 siglqld
|
||||
5G流量 wuGlqld
|
||||
5G流量 wuglqld
|
||||
3D打印 sjDdayn
|
||||
3D打印 sjddayn
|
||||
2D电影 erDdmyy
|
||||
2D电影 erddmyy
|
||||
3D电影 sjDdmyy
|
||||
3D电影 sjddmyy
|
||||
|
||||
@@ -912,3 +912,27 @@ O不OK obuok
|
||||
人均GDP rfjygdp
|
||||
V8引擎 Vbaybqk
|
||||
V8引擎 vbaybqk
|
||||
4A级 siAji
|
||||
4A级 siaji
|
||||
5A级 wuAji
|
||||
5A级 wuaji
|
||||
2G网络 erGwhlo
|
||||
2G网络 ergwhlo
|
||||
3G网络 sjGwhlo
|
||||
3G网络 sjgwhlo
|
||||
4G网络 siGwhlo
|
||||
4G网络 sigwhlo
|
||||
5G网络 wuGwhlo
|
||||
5G网络 wugwhlo
|
||||
3G流量 sjGlqll
|
||||
3G流量 sjglqll
|
||||
4G流量 siGlqll
|
||||
4G流量 siglqll
|
||||
5G流量 wuGlqll
|
||||
5G流量 wuglqll
|
||||
3D打印 sjDdayb
|
||||
3D打印 sjddayb
|
||||
2D电影 erDdmyk
|
||||
2D电影 erddmyk
|
||||
3D电影 sjDdmyk
|
||||
3D电影 sjddmyk
|
||||
|
||||
@@ -912,3 +912,27 @@ O不OK obuok
|
||||
人均GDP rfjpgdp
|
||||
V8引擎 Vbaynq;
|
||||
V8引擎 vbaynq;
|
||||
4A级 siAji
|
||||
4A级 siaji
|
||||
5A级 wuAji
|
||||
5A级 wuaji
|
||||
2G网络 orGwhlo
|
||||
2G网络 orgwhlo
|
||||
3G网络 sjGwhlo
|
||||
3G网络 sjgwhlo
|
||||
4G网络 siGwhlo
|
||||
4G网络 sigwhlo
|
||||
5G网络 wuGwhlo
|
||||
5G网络 wugwhlo
|
||||
3G流量 sjGlqld
|
||||
3G流量 sjglqld
|
||||
4G流量 siGlqld
|
||||
4G流量 siglqld
|
||||
5G流量 wuGlqld
|
||||
5G流量 wuglqld
|
||||
3D打印 sjDdayn
|
||||
3D打印 sjddayn
|
||||
2D电影 orDdmy;
|
||||
2D电影 orddmy;
|
||||
3D电影 sjDdmy;
|
||||
3D电影 sjddmy;
|
||||
|
||||
@@ -912,3 +912,27 @@ O不OK obuok
|
||||
人均GDP rfjpgdp
|
||||
V8引擎 Vbaynq;
|
||||
V8引擎 vbaynq;
|
||||
4A级 siAji
|
||||
4A级 siaji
|
||||
5A级 wuAji
|
||||
5A级 wuaji
|
||||
2G网络 orGwhlo
|
||||
2G网络 orgwhlo
|
||||
3G网络 sjGwhlo
|
||||
3G网络 sjgwhlo
|
||||
4G网络 siGwhlo
|
||||
4G网络 sigwhlo
|
||||
5G网络 wuGwhlo
|
||||
5G网络 wugwhlo
|
||||
3G流量 sjGlqld
|
||||
3G流量 sjglqld
|
||||
4G流量 siGlqld
|
||||
4G流量 siglqld
|
||||
5G流量 wuGlqld
|
||||
5G流量 wuglqld
|
||||
3D打印 sjDdayn
|
||||
3D打印 sjddayn
|
||||
2D电影 orDdmy;
|
||||
2D电影 orddmy;
|
||||
3D电影 sjDdmy;
|
||||
3D电影 sjddmy;
|
||||
|
||||
@@ -912,3 +912,27 @@ O不OK obuok
|
||||
人均GDP rwjmgdp
|
||||
V8引擎 Vbayyq;
|
||||
V8引擎 vbayyq;
|
||||
4A级 siAji
|
||||
4A级 siaji
|
||||
5A级 wuAji
|
||||
5A级 wuaji
|
||||
2G网络 ojGwslo
|
||||
2G网络 ojgwslo
|
||||
3G网络 srGwslo
|
||||
3G网络 srgwslo
|
||||
4G网络 siGwslo
|
||||
4G网络 sigwslo
|
||||
5G网络 wuGwslo
|
||||
5G网络 wugwslo
|
||||
3G流量 srGljlg
|
||||
3G流量 srgljlg
|
||||
4G流量 siGljlg
|
||||
4G流量 sigljlg
|
||||
5G流量 wuGljlg
|
||||
5G流量 wugljlg
|
||||
3D打印 srDdayy
|
||||
3D打印 srddayy
|
||||
2D电影 ojDdfy;
|
||||
2D电影 ojddfy;
|
||||
3D电影 srDdfy;
|
||||
3D电影 srddfy;
|
||||
|
||||
+694
-605
File diff suppressed because it is too large
Load Diff
+108
-364
File diff suppressed because it is too large
Load Diff
@@ -1,92 +0,0 @@
|
||||
#! /usr/bin/env lua
|
||||
--
|
||||
-- debugtool.lua
|
||||
-- Copyright (C) 2021 Shewer Lu <shewer@gmail.com>
|
||||
--
|
||||
-- Distributed under terms of the MIT license.
|
||||
--
|
||||
-- puts(tag,...)
|
||||
-- DEBUG --> log.error
|
||||
-- WARN --> log.warning
|
||||
-- INFO --> log.info
|
||||
-- CONSOLE --> print
|
||||
--
|
||||
-- ex:
|
||||
-- test.lua
|
||||
--
|
||||
-- local puts = require 'tools/debugtool'
|
||||
-- --set tag D103 C102
|
||||
-- local D103= DEBUG .. "103"
|
||||
-- local C102= CONSOLE .. "102"
|
||||
-- local C103= nil
|
||||
--
|
||||
--
|
||||
-- puts(ERROR,__FILE__(),__LINE__(),__FUNC__(), 1, 2 , 3 )
|
||||
-- --> log.error( "error" .. tran_msg(...))
|
||||
--
|
||||
-- puts(DEBUG,__FILE__(),__LINE__(),__FUNC__(), 1, 2 , 3 )
|
||||
-- --> log.error( DEBUG .. tran_msg(...))
|
||||
--
|
||||
-- puts(D103,__FILE__(),__LINE__(),__FUNC__(), 1 2 3)
|
||||
-- --> log.error("trace103" .. tran_msg(...)
|
||||
--
|
||||
-- puts(C102,__FILE__(),__LINE__(),__FUNC__(), 1 2 3)
|
||||
-- --> print("console103" .. tran_msg(...)
|
||||
--
|
||||
-- puts(C103,__FILE__(),__LINE__(),__FUNC__(), 1 2 3)
|
||||
-- --> pass
|
||||
--
|
||||
--
|
||||
--
|
||||
-- puts(DEBUG,__FILE__(),__LINE__(),__FUNC__() , ...)
|
||||
-- puts(INFO,__FILE__(),__LINE__(),__FUNC__() , ...)
|
||||
--
|
||||
-- global variable
|
||||
function __FILE__(n)
|
||||
n = n or 2
|
||||
return debug.getinfo(n, 'S').source
|
||||
end
|
||||
|
||||
function __LINE__(n)
|
||||
n = n or 2
|
||||
return debug.getinfo(n, 'l').currentline
|
||||
end
|
||||
|
||||
function __FUNC__(n)
|
||||
n = n or 2
|
||||
return debug.getinfo(n, 'n').name
|
||||
end
|
||||
|
||||
INFO = "log"
|
||||
WARN = "warn"
|
||||
ERROR = "error"
|
||||
DEBUG = "trace"
|
||||
CONSOLE = "console"
|
||||
|
||||
|
||||
|
||||
|
||||
local function tran_msg(...)
|
||||
local msg = "\t"
|
||||
for i, k in next, { ... } do msg = msg .. ": " .. tostring(k) end
|
||||
return msg
|
||||
end
|
||||
local function puts(tag, ...)
|
||||
if type(tag) ~= "string" then return end
|
||||
|
||||
if INFO and tag:match("^" .. INFO) then
|
||||
(log and log.info or print)(tag .. tran_msg(...))
|
||||
elseif WARN and tag:match("^" .. WARN) then
|
||||
(log and log.warning or print)(tag .. tran_msg(...))
|
||||
elseif ERROR and tag:match("^" .. ERROR) then
|
||||
(log and log.error or print)(tag .. tran_msg(...))
|
||||
elseif DEBUG and tag:match("^" .. DEBUG) then
|
||||
(log and log.error or print)(tag .. tran_msg(...))
|
||||
elseif CONSOLE and tag:match("^" .. CONSOLE) then
|
||||
(print)(tag .. tran_msg(...))
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
return puts
|
||||
@@ -1,4 +1,3 @@
|
||||
local drop_words =
|
||||
{ "示~例~",
|
||||
}
|
||||
return drop_words
|
||||
{ "示~例~", "肏女人", }
|
||||
return drop_words
|
||||
@@ -1,54 +1,60 @@
|
||||
local drop_list = require("cold_word_drop.drop_words")
|
||||
local hide_list = require("cold_word_drop.hide_words")
|
||||
local turndown_freq_list = require("cold_word_drop.turndown_freq_words")
|
||||
local filter = {}
|
||||
|
||||
local function filter(input, env)
|
||||
local idx = 3 -- 降频的词条放到第三个后面, 即第四位, 可在 yaml 里配置
|
||||
local i = 1
|
||||
local cands = {}
|
||||
local context = env.engine.context
|
||||
local preedit_code = context.input
|
||||
function filter.init(env)
|
||||
local engine = env.engine
|
||||
local config = engine.schema.config
|
||||
env.word_reduce_idx = config:get_int("cold_word_reduce/idx") or 4
|
||||
env.drop_words = require("cold_word_drop.drop_words") or {}
|
||||
env.hide_words = require("cold_word_drop.hide_words") or {}
|
||||
env.reduce_freq_words = require("cold_word_drop.reduce_freq_words") or {}
|
||||
end
|
||||
|
||||
for cand in input:iter() do
|
||||
local cpreedit_code = string.gsub(cand.preedit, ' ', '')
|
||||
if (i <= idx) then
|
||||
local tfl = turndown_freq_list[cand.text] or nil
|
||||
-- 前三个 候选项排除 要调整词频的词条, 要删的(实际假性删词, 彻底隐藏罢了) 和要隐藏的词条
|
||||
if not
|
||||
((tfl and table.find_index(tfl, cpreedit_code)) or
|
||||
table.find_index(drop_list, cand.text) or
|
||||
(hide_list[cand.text] and table.find_index(hide_list[cand.text], cpreedit_code))
|
||||
)
|
||||
then
|
||||
i = i + 1
|
||||
---@diagnostic disable-next-line: undefined-global
|
||||
yield(cand)
|
||||
else
|
||||
table.insert(cands, cand)
|
||||
end
|
||||
else
|
||||
table.insert(cands, cand)
|
||||
end
|
||||
if (#cands > 50) then
|
||||
break
|
||||
end
|
||||
end
|
||||
for _, cand in ipairs(cands) do
|
||||
local cpreedit_code = string.gsub(cand.preedit, ' ', '')
|
||||
if not
|
||||
-- 要删的 和要隐藏的词条不显示
|
||||
(
|
||||
table.find_index(drop_list, cand.text) or
|
||||
(hide_list[cand.text] and table.find_index(hide_list[cand.text], cpreedit_code))
|
||||
)
|
||||
then
|
||||
---@diagnostic disable-next-line: undefined-global
|
||||
yield(cand)
|
||||
end
|
||||
end
|
||||
for cand in input:iter() do
|
||||
yield(cand)
|
||||
end
|
||||
function filter.func(input, env)
|
||||
local cands = {}
|
||||
local context = env.engine.context
|
||||
local preedit_str = context.input:gsub(" ", "")
|
||||
local drop_words = env.drop_words
|
||||
local hide_words = env.hide_words
|
||||
local word_reduce_idx = env.word_reduce_idx
|
||||
local reduce_freq_words = env.reduce_freq_words
|
||||
for cand in input:iter() do
|
||||
local cand_text = cand.text:gsub(" ", "")
|
||||
local preedit_code = cand.preedit:gsub(" ", "") or preedit_str
|
||||
|
||||
local reduce_freq_list = reduce_freq_words[cand_text] or {}
|
||||
if word_reduce_idx > 1 then
|
||||
-- 前三个 候选项排除 要调整词频的词条, 要删的(实际假性删词, 彻底隐藏罢了) 和要隐藏的词条
|
||||
if reduce_freq_list and table.find_index(reduce_freq_list, preedit_code) then
|
||||
table.insert(cands, cand)
|
||||
elseif
|
||||
not (
|
||||
table.find_index(drop_words, cand_text)
|
||||
or (hide_words[cand_text] and table.find_index(hide_words[cand_text], preedit_code))
|
||||
|
||||
)
|
||||
then
|
||||
yield(cand)
|
||||
word_reduce_idx = word_reduce_idx - 1
|
||||
end
|
||||
else
|
||||
if
|
||||
not (
|
||||
table.find_index(drop_words, cand_text)
|
||||
or (hide_words[cand_text] and table.find_index(hide_words[cand_text], preedit_code))
|
||||
)
|
||||
then
|
||||
table.insert(cands, cand)
|
||||
end
|
||||
end
|
||||
|
||||
if #cands >= 80 then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
for _, cand in ipairs(cands) do
|
||||
yield(cand)
|
||||
end
|
||||
end
|
||||
|
||||
return filter
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local hide_words =
|
||||
{ ["示~例~"] = { "shil", "shili", },
|
||||
{ ["示~例~"] = { "shil", "shili", },
|
||||
["么特瑞"] = { "meter", },
|
||||
}
|
||||
return hide_words
|
||||
return hide_words
|
||||
@@ -0,0 +1,48 @@
|
||||
-- runLog.lua
|
||||
-- Copyright (C) 2023 yaoyuan.dou <douyaoyuan@126.com>
|
||||
|
||||
local M = {}
|
||||
local dbgFlg = true
|
||||
|
||||
--设置 dbg 开关
|
||||
M.setDbg = function(flg)
|
||||
dbgFlg = flg
|
||||
|
||||
print('runLog dbgFlg is ' .. tostring(dbgFlg))
|
||||
end
|
||||
|
||||
local current_path = string.sub(debug.getinfo(1).source, 2, string.len("/runLog.lua") * -1)
|
||||
M.logDoc = current_path .. 'runLog.txt'
|
||||
|
||||
M.writeLog = function(logStr, newLineFlg)
|
||||
logStr = logStr or "nothing"
|
||||
|
||||
if not newLineFlg then newLineFlg = true end
|
||||
|
||||
local f = io.open(M.logDoc, 'a')
|
||||
if f then
|
||||
local timeStamp = os.date("%Y/%m/%d %H:%M:%S")
|
||||
f:write(timeStamp .. '[' .. _VERSION .. ']' .. '\t' .. logStr .. '\n')
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
||||
--===========================test========================
|
||||
M.test = function(printPrefix)
|
||||
if nil == printPrefix then
|
||||
printPrefix = ' '
|
||||
end
|
||||
if dbgFlg then
|
||||
M.writeLog('this is a test string on new line', true)
|
||||
M.writeLog('this is a test string appending the last line', false)
|
||||
M.writeLog('runLogDoc is: ' .. M.logDoc, true)
|
||||
end
|
||||
end
|
||||
|
||||
function M.init(...)
|
||||
--如果有需要初始化的动作,可以在这里运行
|
||||
end
|
||||
|
||||
M.init()
|
||||
|
||||
return M
|
||||
+110
-105
@@ -2,162 +2,167 @@
|
||||
orgtype = type
|
||||
|
||||
function type(obj)
|
||||
local _type = orgtype(obj)
|
||||
if "table" == _type and obj._cname then
|
||||
return obj._cname
|
||||
end
|
||||
return _type
|
||||
local _type = orgtype(obj)
|
||||
if "table" == _type and obj._cname then
|
||||
return obj._cname
|
||||
end
|
||||
return _type
|
||||
end
|
||||
|
||||
function metatable(...)
|
||||
if ... and type(...) == "table" then
|
||||
return setmetatable(..., { __index = table })
|
||||
else
|
||||
return setmetatable({ ... }, { __index = table })
|
||||
end
|
||||
if ... and type(...) == "table" then
|
||||
return setmetatable(..., { __index = table })
|
||||
else
|
||||
return setmetatable({ ... }, { __index = table })
|
||||
end
|
||||
end
|
||||
|
||||
-- chech metatble
|
||||
function metatable_chk(tab)
|
||||
if "table" == type(tab)
|
||||
then
|
||||
return (tab.each and tab) or metatable(tab)
|
||||
else
|
||||
return tab
|
||||
end
|
||||
if "table" == type(tab) then
|
||||
return (tab.each and tab) or metatable(tab)
|
||||
else
|
||||
return tab
|
||||
end
|
||||
end
|
||||
|
||||
table.eachi = function(tab, func)
|
||||
for i = 1, #tab do
|
||||
func(tab[i], i)
|
||||
end
|
||||
return tab
|
||||
for i = 1, #tab do
|
||||
func(tab[i], i)
|
||||
end
|
||||
return tab
|
||||
end
|
||||
table.eacha = function(tab, func)
|
||||
for i, v in ipairs(tab) do
|
||||
func(v, i)
|
||||
end
|
||||
return tab
|
||||
for i, v in ipairs(tab) do
|
||||
func(v, i)
|
||||
end
|
||||
return tab
|
||||
end
|
||||
table.each = function(tab, func)
|
||||
for k, v in pairs(tab) do
|
||||
func(v, k)
|
||||
end
|
||||
return tab
|
||||
for k, v in pairs(tab) do
|
||||
func(v, k)
|
||||
end
|
||||
return tab
|
||||
end
|
||||
table.find_index = function(tab, elm, ...)
|
||||
local _, i = table.find(tab, elm, ...)
|
||||
return i
|
||||
local _, i = table.find(tab, elm, ...)
|
||||
return i
|
||||
end
|
||||
table.find = function(tab, elm, func)
|
||||
for i, v in ipairs(tab) do
|
||||
if elm == v then
|
||||
return v, i
|
||||
end
|
||||
end
|
||||
for i, v in ipairs(tab) do
|
||||
if elm == v then
|
||||
return v, i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
table.find_with_func = function(tab, elm, ...)
|
||||
local i, v = table.find(tab, elm)
|
||||
local i, v = table.find(tab, elm)
|
||||
end
|
||||
table.delete = function(tab, elm, ...)
|
||||
local index = table.find_index(tab, elm)
|
||||
return index and table.remove(tab, index)
|
||||
local index = table.find_index(tab, elm)
|
||||
return index and table.remove(tab, index)
|
||||
end
|
||||
|
||||
table.find_all = function(tab, elm, ...)
|
||||
local tmptab = setmetatable({}, { __index = table })
|
||||
local _func = (type(elm) == "function" and elm) or function(v, k, ...) return v == elm end
|
||||
for k, v in pairs(tab) do
|
||||
if _func(v, k, ...) then
|
||||
tmptab:insert(v)
|
||||
end
|
||||
end
|
||||
return tmptab
|
||||
local tmptab = setmetatable({}, { __index = table })
|
||||
local _func = (type(elm) == "function" and elm) or function(v, k, ...)
|
||||
return v == elm
|
||||
end
|
||||
for k, v in pairs(tab) do
|
||||
if _func(v, k, ...) then
|
||||
tmptab:insert(v)
|
||||
end
|
||||
end
|
||||
return tmptab
|
||||
end
|
||||
table.select = table.find_all
|
||||
|
||||
table.reduce = function(tab, func, arg)
|
||||
local new, old = arg, arg
|
||||
for i, v in ipairs(tab) do
|
||||
new, old = func(v, new)
|
||||
end
|
||||
return new, arg
|
||||
local new, old = arg, arg
|
||||
for i, v in ipairs(tab) do
|
||||
new, old = func(v, new)
|
||||
end
|
||||
return new, arg
|
||||
end
|
||||
|
||||
table.map = function(tab, func)
|
||||
local newtab = setmetatable({}, { __index = table })
|
||||
func = func or function(v, i) return v, i end
|
||||
for i, v in ipairs(tab) do
|
||||
newtab[i] = func(v, i)
|
||||
end
|
||||
return newtab
|
||||
local newtab = setmetatable({}, { __index = table })
|
||||
func = func or function(v, i)
|
||||
return v, i
|
||||
end
|
||||
for i, v in ipairs(tab) do
|
||||
newtab[i] = func(v, i)
|
||||
end
|
||||
return newtab
|
||||
end
|
||||
table.map_hash = function(tab, func) -- table to list of array { key, v}
|
||||
local newtab = setmetatable({}, { __index = table })
|
||||
func = func or function(k, v) return { k, v } end
|
||||
for k, v in pairs(tab) do
|
||||
newtab:insert(func(k, v))
|
||||
end
|
||||
return newtab
|
||||
table.map_hash = function(tab, func) -- table to list of array { key, v}
|
||||
local newtab = setmetatable({}, { __index = table })
|
||||
func = func or function(k, v)
|
||||
return { k, v }
|
||||
end
|
||||
for k, v in pairs(tab) do
|
||||
newtab:insert(func(k, v))
|
||||
end
|
||||
return newtab
|
||||
end
|
||||
function table:push(elm)
|
||||
self:insert(elm)
|
||||
self:insert(elm)
|
||||
end
|
||||
|
||||
table.append = table.push
|
||||
function table:pop()
|
||||
return self:remove(#self)
|
||||
return self:remove(#self)
|
||||
end
|
||||
|
||||
function table:shift()
|
||||
self:remove(1)
|
||||
self:remove(1)
|
||||
end
|
||||
|
||||
function table:unshift(elm)
|
||||
self:insert(1, elm)
|
||||
self:insert(1, elm)
|
||||
end
|
||||
|
||||
function table.len(t)
|
||||
local leng = 0
|
||||
for k, v in pairs(t) do
|
||||
leng = leng + 1
|
||||
end
|
||||
return leng;
|
||||
local leng = 0
|
||||
for k, v in pairs(t) do
|
||||
leng = leng + 1
|
||||
end
|
||||
return leng
|
||||
end
|
||||
|
||||
-- table to string 序列化
|
||||
function table.serialize(obj)
|
||||
local serialize_str = ""
|
||||
local t = type(obj)
|
||||
if t == "number" then
|
||||
serialize_str = serialize_str .. obj
|
||||
elseif t == "boolean" then
|
||||
serialize_str = serialize_str .. tostring(obj)
|
||||
elseif t == "string" then
|
||||
serialize_str = serialize_str .. string.format("%q", obj)
|
||||
elseif t == "table" then
|
||||
serialize_str = serialize_str .. "{ "
|
||||
local record_sep = #obj < 4 and ", " or ",\n"
|
||||
local record_prefix = #obj < 4 and "" or "\t"
|
||||
for k, v in pairs(obj) do
|
||||
if type(k) == "number" then
|
||||
serialize_str = serialize_str .. record_prefix .. '"' .. v .. '"' .. record_sep
|
||||
else
|
||||
serialize_str = serialize_str .. "\t[" .. table.serialize(k) .. "] = " .. table.serialize(v) .. ",\n"
|
||||
end
|
||||
end
|
||||
-- local metatable = getmetatable(obj)
|
||||
-- if metatable ~= nil and type(metatable.__index) == "table" then
|
||||
-- for k, v in pairs(metatable.__index) do
|
||||
-- serialize_str = serialize_str .. "[" .. table.serialize(k) .. "]=" .. table.serialize(v) .. ",\n"
|
||||
-- end
|
||||
-- end
|
||||
serialize_str = serialize_str .. "}"
|
||||
elseif t == "nil" then
|
||||
return nil
|
||||
else
|
||||
error("can not serialize a " .. t .. " type.")
|
||||
end
|
||||
return serialize_str
|
||||
local serialize_str = ""
|
||||
local t = type(obj)
|
||||
if t == "number" then
|
||||
serialize_str = serialize_str .. obj
|
||||
elseif t == "boolean" then
|
||||
serialize_str = serialize_str .. tostring(obj)
|
||||
elseif t == "string" then
|
||||
serialize_str = serialize_str .. string.format("%q", obj)
|
||||
elseif t == "table" then
|
||||
serialize_str = serialize_str .. "{ "
|
||||
local record_sep = #obj < 4 and ", " or ",\n"
|
||||
local record_prefix = #obj < 4 and "" or "\t"
|
||||
for k, v in pairs(obj) do
|
||||
if type(k) == "number" then
|
||||
serialize_str = serialize_str .. record_prefix .. '"' .. v .. '"' .. record_sep
|
||||
else
|
||||
serialize_str = serialize_str .. "\t[" .. table.serialize(k) .. "] = " .. table.serialize(v) .. ",\n"
|
||||
end
|
||||
end
|
||||
-- local metatable = getmetatable(obj)
|
||||
-- if metatable ~= nil and type(metatable.__index) == "table" then
|
||||
-- for k, v in pairs(metatable.__index) do
|
||||
-- serialize_str = serialize_str .. "[" .. table.serialize(k) .. "]=" .. table.serialize(v) .. ",\n"
|
||||
-- end
|
||||
-- end
|
||||
serialize_str = serialize_str .. "}"
|
||||
elseif t == "nil" then
|
||||
return nil
|
||||
else
|
||||
error("can not serialize a " .. t .. " type.")
|
||||
end
|
||||
return serialize_str
|
||||
end
|
||||
|
||||
+102
-134
@@ -1,151 +1,119 @@
|
||||
require('cold_word_drop.string')
|
||||
require("cold_word_drop.string")
|
||||
require("cold_word_drop.metatable")
|
||||
-- local puts = require("tools/debugtool")
|
||||
local drop_list = require("cold_word_drop.drop_words")
|
||||
local hide_list = require("cold_word_drop.hide_words")
|
||||
local turndown_freq_list = require("cold_word_drop.turndown_freq_words")
|
||||
local tbls = {
|
||||
['drop_list'] = drop_list,
|
||||
['hide_list'] = hide_list,
|
||||
['turndown_freq_list'] = turndown_freq_list
|
||||
}
|
||||
-- local cold_word_drop = {}
|
||||
|
||||
local processor = {}
|
||||
|
||||
local function get_record_filername(record_type)
|
||||
local user_distribute_name = rime_api:get_distribution_name()
|
||||
if user_distribute_name == '小狼毫' then
|
||||
return string.format("%s\\Rime\\lua\\cold_word_drop\\%s_words.lua", os.getenv("APPDATA"), record_type)
|
||||
end
|
||||
|
||||
local system = io.popen("uname -s"):read("*l")
|
||||
local filename = nil
|
||||
-- body
|
||||
if system == "Darwin" then
|
||||
filename = string.format("%s/Library/Rime/lua/cold_word_drop/%s_words.lua", os.getenv('HOME'), record_type)
|
||||
elseif system == "Linux" then
|
||||
filename = string.format("%s/%s/rime/lua/cold_word_drop/%s_words.lua",
|
||||
os.getenv('HOME'),
|
||||
(string.find(os.getenv('GTK_IM_MODULE'), 'fcitx') and '.local/share/fcitx5' or '.config/ibus'),
|
||||
record_type)
|
||||
end
|
||||
return filename
|
||||
local path_sep = "/"
|
||||
local user_data_dir = rime_api:get_user_data_dir()
|
||||
local user_distribute_name = rime_api:get_distribution_code_name()
|
||||
if user_distribute_name:lower():match("weasel") then path_sep = "\\" end
|
||||
if user_distribute_name:lower():match("ibus") then
|
||||
return string.format("%s/rime/lua/cold_word_records/%s_words.lua",
|
||||
os.getenv("HOME") .. "/.config/ibus",
|
||||
record_type
|
||||
)
|
||||
else
|
||||
local file_path = string.format("%s/lua/cold_word_records/%s_words.lua", user_data_dir, record_type)
|
||||
return file_path:gsub("/", path_sep)
|
||||
end
|
||||
end
|
||||
|
||||
local function write_word_to_file(record_type)
|
||||
-- local filename = string.format("%s/Library/Rime/lua/cold_word_drop/%s_words.lua", os.getenv('HOME'), record_type)
|
||||
local filename = get_record_filername(record_type)
|
||||
local record_header = string.format("local %s_words =\n", record_type)
|
||||
local record_tailer = string.format("\nreturn %s_words", record_type)
|
||||
local fd = assert(io.open(filename, "w")) --打开
|
||||
fd:setvbuf("line")
|
||||
fd:write(record_header) --写入文件头部
|
||||
-- df:flush() --刷新
|
||||
local x = string.format("%s_list", record_type)
|
||||
local record = table.serialize(tbls[x]) -- lua 的 table 对象 序列化为字符串
|
||||
fd:write(record) --写入 序列化的字符串
|
||||
fd:write(record_tailer) --写入文件尾部, 结束记录
|
||||
fd:close() --关闭
|
||||
local function write_word_to_file(env, record_type)
|
||||
local filename = get_record_filername(record_type)
|
||||
local record_header = string.format("local %s_words =\n", record_type)
|
||||
local record_tailer = string.format("\nreturn %s_words", record_type)
|
||||
if not filename then
|
||||
return false
|
||||
end
|
||||
local fd = assert(io.open(filename, "w")) --打开
|
||||
-- fd:flush() --刷新
|
||||
local x = string.format("%s_list", record_type)
|
||||
local record = table.serialize(env.tbls[x]) -- lua 的 table 对象 序列化为字符串
|
||||
fd:setvbuf("line")
|
||||
fd:write(record_header) --写入文件头部
|
||||
fd:write(record) --写入 序列化的字符串
|
||||
fd:write(record_tailer) --写入文件尾部, 结束记录
|
||||
fd:close() --关闭
|
||||
end
|
||||
|
||||
local function check_encode_matched(cand_code, word, input_code_tbl, reversedb)
|
||||
if #cand_code < 1 and utf8.len(word) > 1 then -- 二字词以上的词条反查, 需要逐个字去反查
|
||||
local word_cand_code = string.split(word, "")
|
||||
for i, v in ipairs(word_cand_code) do
|
||||
-- 如有 `[` 引导的辅助码情况, 去掉引导符及之后的所有形码字符
|
||||
local char_code = string.gsub(reversedb:lookup(v), '%[%l%l', '')
|
||||
local _char_preedit_code = input_code_tbl[i] or " "
|
||||
-- 如有 `[` 引导的辅助码情况, 同上, 去掉之
|
||||
local char_preedit_code = string.gsub(_char_preedit_code, '%[%l+', '')
|
||||
if not string.match(char_code, char_preedit_code) then
|
||||
-- 输入编码串和词条反查结果不匹配(考虑到多音字, 开启了模糊音, 纠错音), 返回false, 表示隐藏这个词条
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
-- 输入编码串和词条反查结果匹配, 返回true, 表示对这个词条降频
|
||||
return true
|
||||
local function append_word_to_droplist(env, ctx, action_type)
|
||||
local word = ctx.word:gsub(" ", "")
|
||||
local input_code = ctx.code:gsub(" ", "")
|
||||
|
||||
if action_type == "drop" then
|
||||
table.insert(env.drop_words, word) -- 高亮选中的词条插入到 drop_list
|
||||
return true
|
||||
end
|
||||
|
||||
if action_type == "hide" then
|
||||
if not env.hide_words[word] then
|
||||
env.hide_words[word] = { input_code }
|
||||
-- 隐藏的词条如果已经在 hide_list 中, 则将输入串追加到 值表中, 如: ['藏'] = {'chang', 'zhang'}
|
||||
elseif not table.find_index(env.hide_words[word], input_code) then
|
||||
table.insert(env.hide_words[word], input_code)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
if action_type == "reduce_freq" then
|
||||
if env.reduce_freq_words[word] then
|
||||
table.insert(env.reduce_freq_words[word], input_code)
|
||||
else
|
||||
env.reduce_freq_words[word] = { input_code }
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local function append_word_to_droplist(ctx, action_type, reversedb)
|
||||
local word = ctx.word
|
||||
local input_code = ctx.code
|
||||
if action_type == 'drop' then
|
||||
table.insert(drop_list, word) -- 高亮选中的词条插入到 drop_list
|
||||
return true
|
||||
end
|
||||
local input_code_tbl = string.split(input_code, " ")
|
||||
local cand_code = reversedb:lookup(word) or "" -- 反查候选项文字编码
|
||||
-- 二字词 的匹配检查, 匹配返回true, 不匹配返回false
|
||||
local match_result = check_encode_matched(cand_code, word, input_code_tbl, reversedb)
|
||||
local ccand_code = string.gsub(cand_code, '%[%l%l', '')
|
||||
-- 如有 `[` 引导的辅助码情况, 去掉引导符及之后的所有形码字符
|
||||
local input_str = string.gsub(input_code, '%[%l+', '')
|
||||
local input_code_str = table.concat(input_code_tbl, '')
|
||||
-- 单字和二字词 的匹配检查, 如果匹配, 降频
|
||||
if string.match(ccand_code, input_str) or match_result then
|
||||
if turndown_freq_list[word] then
|
||||
table.insert(turndown_freq_list[word], input_code_str)
|
||||
else
|
||||
turndown_freq_list[word] = { input_code_str }
|
||||
end
|
||||
return 'turndown_freq'
|
||||
end
|
||||
|
||||
-- 单字和二字词 如果不匹配 就隐藏
|
||||
if not hide_list[word] then
|
||||
hide_list[word] = { input_code_str }
|
||||
return true
|
||||
else
|
||||
-- 隐藏的词条如果已经在 hide_list 中, 则将输入串追加到 值表中, 如: ['藏'] = {'chang', 'zhang'}
|
||||
if not table.find_index(hide_list[word], input_code_str) then
|
||||
table.insert(hide_list[word], input_code_str)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
function processor.init(env)
|
||||
local engine = env.engine
|
||||
local config = engine.schema.config
|
||||
env.drop_cand_key = config:get_string("key_binder/drop_cand") or "Control+d"
|
||||
env.hide_cand_key = config:get_string("key_binder/hide_cand") or "Control+x"
|
||||
env.reduce_cand_key = config:get_string("key_binder/reduce_freq_cand") or "Control+j"
|
||||
env.drop_words = require("cold_word_drop.drop_words") or {}
|
||||
env.hide_words = require("cold_word_drop.hide_words") or {}
|
||||
env.reduce_freq_words = require("cold_word_drop.reduce_freq_words") or {}
|
||||
env.tbls = {
|
||||
["drop_list"] = env.drop_words,
|
||||
["hide_list"] = env.hide_words,
|
||||
["reduce_freq_list"] = env.reduce_freq_words,
|
||||
}
|
||||
end
|
||||
|
||||
local function processor(key, env)
|
||||
local engine = env.engine
|
||||
local config = engine.schema.config
|
||||
local context = engine.context
|
||||
-- local top_cand_text = context:get_commit_text()
|
||||
-- local preedit_code = context.input
|
||||
local preedit_code = context:get_script_text()
|
||||
local turndown_cand_key = config:get_string("key_binder/turn_down_cand") or "Control+j"
|
||||
local drop_cand_key = config:get_string("key_binder/drop_cand") or "Control+d"
|
||||
local action_map = {
|
||||
[turndown_cand_key] = 'hide',
|
||||
[drop_cand_key] = 'drop'
|
||||
}
|
||||
function processor.func(key, env)
|
||||
local engine = env.engine
|
||||
local context = engine.context
|
||||
local preedit_code = context:get_script_text()
|
||||
local action_map = {
|
||||
[env.drop_cand_key] = "drop",
|
||||
[env.hide_cand_key] = "hide",
|
||||
[env.reduce_cand_key] = "reduce_freq",
|
||||
}
|
||||
|
||||
-- local schema_id = config:get_string("schema/schema_id")
|
||||
local schema_id = config:get_string("translator/dictionary") -- 多方案共用字典取主方案名称
|
||||
---@diagnostic disable-next-line: undefined-global
|
||||
local reversedb = ReverseLookup(schema_id)
|
||||
if key:repr() == turndown_cand_key or key:repr() == drop_cand_key then
|
||||
local cand = context:get_selected_candidate()
|
||||
local action_type = action_map[key:repr()]
|
||||
local ctx_map = {
|
||||
['word'] = cand.text,
|
||||
['code'] = preedit_code
|
||||
}
|
||||
local res = append_word_to_droplist(ctx_map, action_type, reversedb)
|
||||
if context:has_menu() and action_map[key:repr()] then
|
||||
local cand = context:get_selected_candidate()
|
||||
local action_type = action_map[key:repr()]
|
||||
local ctx_map = {
|
||||
["word"] = cand.text,
|
||||
["code"] = preedit_code,
|
||||
}
|
||||
local res = append_word_to_droplist(env, ctx_map, action_type)
|
||||
|
||||
context:refresh_non_confirmed_composition() -- 刷新当前输入法候选菜单, 实现看到实时效果
|
||||
if type(res) == "boolean" then
|
||||
-- 期望被删的词和隐藏的词条写入文件(drop_words.lua, hide_words.lua)
|
||||
write_word_to_file(action_type)
|
||||
else
|
||||
-- 期望 要调整词频的词条写入 turndown_freq_words.lua 文件
|
||||
write_word_to_file(res)
|
||||
end
|
||||
return 1 -- kAccept
|
||||
end
|
||||
context:refresh_non_confirmed_composition() -- 刷新当前输入法候选菜单, 实现看到实时效果
|
||||
if not res then
|
||||
return 2
|
||||
end
|
||||
|
||||
return 2 -- kNoop, 不做任何操作, 交给下个组件处理
|
||||
if res then
|
||||
-- 期望被删的词和隐藏的词条写入文件(drop_words.lua, hide_words.lua)
|
||||
write_word_to_file(env, action_type)
|
||||
end
|
||||
|
||||
return 1 -- kAccept
|
||||
end
|
||||
|
||||
return 2 -- kNoop, 不做任何操作, 交给下个组件处理
|
||||
end
|
||||
|
||||
return processor
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
local reduce_freq_words =
|
||||
{ ["示~例~"] = { "shili", },
|
||||
["颜射"] = { "yanshe", },
|
||||
}
|
||||
return reduce_freq_words
|
||||
@@ -4,35 +4,34 @@
|
||||
-- string.utf8_offset= utf8.offset
|
||||
-- string.utf8_sub= utf8.sub
|
||||
function string.split(str, sp, sp1)
|
||||
sp = type(sp) == "string" and sp or " "
|
||||
if #sp == 0 then
|
||||
sp = "([%z\1-\127\194-\244][\128-\191]*)"
|
||||
elseif #sp == 1 then
|
||||
sp = "[^" .. (sp == "%" and "%%" or sp) .. "]*"
|
||||
else
|
||||
sp1 = sp1 or "^"
|
||||
str = str:gsub(sp, sp1)
|
||||
sp = "[^" .. sp1 .. "]*"
|
||||
end
|
||||
sp = type(sp) == "string" and sp or " "
|
||||
if #sp == 0 then
|
||||
sp = "([%z\1-\127\194-\244][\128-\191]*)"
|
||||
elseif #sp == 1 then
|
||||
sp = "[^" .. (sp == "%" and "%%" or sp) .. "]*"
|
||||
else
|
||||
sp1 = sp1 or "^"
|
||||
str = str:gsub(sp, sp1)
|
||||
sp = "[^" .. sp1 .. "]*"
|
||||
end
|
||||
|
||||
local tab = {}
|
||||
for v in str:gmatch(sp) do
|
||||
table.insert(tab, v)
|
||||
end
|
||||
return tab
|
||||
local tab = {}
|
||||
for v in str:gmatch(sp) do
|
||||
table.insert(tab, v)
|
||||
end
|
||||
return tab
|
||||
end
|
||||
|
||||
function utf8.gsub(str, si, ei)
|
||||
local function index(ustr, i)
|
||||
return i >= 0 and (ustr:utf8_offset(i) or ustr:len() + 1)
|
||||
or (ustr:utf8_offset(i) or 1)
|
||||
end
|
||||
local function index(ustr, i)
|
||||
return i >= 0 and (ustr:utf8_offset(i) or ustr:len() + 1) or (ustr:utf8_offset(i) or 1)
|
||||
end
|
||||
|
||||
local u_si = index(str, si)
|
||||
ei = ei or str:utf8_len()
|
||||
ei = ei >= 0 and ei + 1 or ei
|
||||
local u_ei = index(str, ei) - 1
|
||||
return str:sub(u_si, u_ei)
|
||||
local u_si = index(str, si)
|
||||
ei = ei or str:utf8_len()
|
||||
ei = ei >= 0 and ei + 1 or ei
|
||||
local u_ei = index(str, ei) - 1
|
||||
return str:sub(u_si, u_ei)
|
||||
end
|
||||
|
||||
string.utf8_len = utf8.len
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
local turndown_freq_words =
|
||||
{ ["示~例~"] = { "shili", },
|
||||
}
|
||||
return turndown_freq_words
|
||||
+2
-1
@@ -25,7 +25,6 @@ function M.init(env)
|
||||
["hun dun"] = { text = "馄饨", comment = "hún tun" },
|
||||
["zhu jiao"] = { text = "主角", comment = "zhǔ jué" },
|
||||
["jiao se"] = { text = "角色", comment = "júe sè" },
|
||||
["pi sa"] = { text = "比萨", comment = "bǐ sà" },
|
||||
["chi pi sa"] = { text = "吃比萨", comment = "chī bǐ sà" },
|
||||
["pi sa bing"] = { text = "比萨饼", comment = "bǐ sà bǐng" },
|
||||
["shui fu"] = { text = "说服", comment = "shuō fú" },
|
||||
@@ -98,6 +97,7 @@ function M.init(env)
|
||||
["nuo da"] = { text = "偌大", comment = "偌(ruò)大" },
|
||||
["yin jiu zhi ke"] = { text = "饮鸩止渴", comment = "饮鸩(zhèn)止渴" },
|
||||
["yin jiu jie ke"] = { text = "饮鸩解渴", comment = "饮鸩(zhèn)解渴" },
|
||||
["gong shang jiao zhi yu"] = { text = "宫商角徵羽", comment = "宫商角(jué)徵羽" },
|
||||
-- 错字
|
||||
["pu jie"] = { text = "扑街", comment = "仆街" },
|
||||
["pu gai"] = { text = "扑街", comment = "仆街" },
|
||||
@@ -117,6 +117,7 @@ function M.init(env)
|
||||
["cou huo"] = { text = "凑活", comment = "凑合(he)" },
|
||||
["ju hui"] = { text = "钜惠", comment = "巨惠" },
|
||||
["mo xie zuo"] = { text = "魔蝎座", comment = "摩羯(jié)座" },
|
||||
["pi sa"] = { text = "披萨", comment = "比(bǐ)萨" },
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
+9
-14
@@ -1,20 +1,15 @@
|
||||
-- 这个 Lua 给英文单词后面自动加一个空格 #496
|
||||
-- 英文后,再输入英文单词(必须为候选项)自动添加空格
|
||||
local F = {}
|
||||
|
||||
local function add_space_to_english_word(input)
|
||||
-- 匹配纯英文单词(don't 算纯英文单词)并在单词后添加空格
|
||||
input = input:gsub("(%a+'?%a*)", "%1 ")
|
||||
return input
|
||||
end
|
||||
|
||||
-- 在候选项上屏时触发的函数
|
||||
local function en_spacer(input, env)
|
||||
function F.func( input, env )
|
||||
local latest_text = env.engine.context.commit_history:latest_text()
|
||||
for cand in input:iter() do
|
||||
if cand.text:match("^[%a']+[%a']*$") then
|
||||
-- 如果候选项是纯英文单词,则在输入后添加一个空格
|
||||
cand = cand:to_shadow_candidate(cand.type, add_space_to_english_word(cand.text), cand.comment)
|
||||
if cand.text:match( '^[%a\']+[%a\']*$' ) and latest_text and #latest_text > 0 and
|
||||
latest_text:find( '^ ?[%a\']+[%a\']*$' ) then
|
||||
cand = cand:to_shadow_candidate( 'en_spacer', cand.text:gsub( '(%a+\'?%a*)', ' %1' ), cand.comment )
|
||||
end
|
||||
yield(cand)
|
||||
yield( cand )
|
||||
end
|
||||
end
|
||||
|
||||
return en_spacer
|
||||
return F
|
||||
|
||||
+2
-1
@@ -549,6 +549,7 @@ local function Date2LunarDate(Gregorian)
|
||||
Month = tonumber(Gregorian.sub(Gregorian, 5, 6))
|
||||
Day = tonumber(Gregorian.sub(Gregorian, 7, 8))
|
||||
if Year > 2100 or Year < 1899 or Month > 12 or Month < 1 or Day < 1 or Day > 31 or string.len(Gregorian) < 8 then
|
||||
-- 2024.07.27 这个不能判断不存在的日期,例如 02.31 04.30 等,会显示农历,但不存在 by Mirtle
|
||||
return "无效日期", "无效日期"
|
||||
end
|
||||
|
||||
@@ -657,7 +658,7 @@ local function translator(input, seg, env)
|
||||
local lunar_date = Candidate("", seg.start, seg._end, date1, "")
|
||||
lunar_date.quality = 999
|
||||
yield(lunar_date)
|
||||
elseif env.gregorian_to_lunar ~= '' and input:sub(1, 1) == env.gregorian_to_lunar then
|
||||
elseif env.gregorian_to_lunar ~= '' and input:sub(1, 1) == env.gregorian_to_lunar and input:sub(2):find("^%d%d%d%d%d%d%d%d$") then
|
||||
local date1, date2 = Date2LunarDate(input:sub(2))
|
||||
local lunar_ymd = (Candidate("", seg.start, seg._end, date2, ""))
|
||||
lunar_ymd.quality = 999
|
||||
|
||||
@@ -130,10 +130,16 @@ local function number_translatorFunc(num)
|
||||
{ number2cnChar(numberPart.int, 0) ..
|
||||
decimal_func(numberPart.dec, { [1] = "角", [2] = "分", [3] = "厘", [4] = "毫" },
|
||||
{ [0] = "〇", "一", "二", "三", "四", "五", "六", "七", "八", "九" }), "〔金额小写〕" })
|
||||
table.insert(result,
|
||||
{ number2cnChar(numberPart.int, 1) ..
|
||||
decimal_func(numberPart.dec, { [1] = "角", [2] = "分", [3] = "厘", [4] = "毫" },
|
||||
{ [0] = "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }), "〔金额大写〕" })
|
||||
|
||||
local number2cnCharInt = number2cnChar(numberPart.int, 1)
|
||||
local number2cnCharDec = decimal_func(numberPart.dec, { [1] = "角", [2] = "分", [3] = "厘", [4] = "毫" }, { [0] = "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" })
|
||||
if string.len(numberPart.int) > 4 and number2cnCharInt:find('^拾[壹贰叁肆伍陆柒捌玖]?') and number2cnCharInt:find('[万亿]') then -- 简易地规避 utf8 匹配问题
|
||||
local number2cnCharInt_var = number2cnCharInt:gsub('^拾', '壹拾')
|
||||
table.insert(result, { number2cnCharInt_var .. number2cnCharDec , "〔金额大写〕"})
|
||||
-- 会计书写要求 https://github.com/iDvel/rime-ice/issues/989
|
||||
else
|
||||
table.insert(result, { number2cnCharInt .. number2cnCharDec , "〔金额大写〕"})
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
+4
-1
@@ -32,6 +32,7 @@ local function update_dict_entry( s, code, mem, proj )
|
||||
return 0
|
||||
end
|
||||
local e = DictEntry()
|
||||
s = s:gsub( '^%s+', '' ):gsub( '%s+$', '' )
|
||||
e.text = s
|
||||
|
||||
local pos = {}
|
||||
@@ -80,7 +81,7 @@ end
|
||||
|
||||
-- 通过 reverse db 查询(以字查码,然后比对辅码是否相同,快,但只能匹配未经算法转换的码)
|
||||
local function reverse_lookup( code_projection, db_table, wildcard, text, s, global_match )
|
||||
if wildcard then s = s:gsub( wildcard, '.*' ) end
|
||||
if wildcard then s = s:gsub( wildcard, '.+' ) end
|
||||
if code_projection then
|
||||
-- old librime do not return original string when apply failed
|
||||
local p = code_projection:apply( s, true )
|
||||
@@ -294,6 +295,8 @@ function f.fini( env )
|
||||
if env.if_reverse_lookup or env.if_schema_lookup then
|
||||
env.notifier:disconnect()
|
||||
env.commit_notifier:disconnect()
|
||||
if env.mem and env.mem.disconnect then env.mem:disconnect() end
|
||||
if env.search and env.search.disconnect then env.search:disconnect() end
|
||||
if env.mem or env.search or env.db_table then
|
||||
env.db_table = nil
|
||||
env.mem = nil
|
||||
|
||||
+24
-18
@@ -3,26 +3,32 @@
|
||||
-- 示例:输入 U62fc 得到「拼」
|
||||
-- 触发前缀默认为 recognizer/patterns/unicode 的第 2 个字符,即 U
|
||||
-- 2024.02.26: 限定编码最大值
|
||||
-- 2024.06.01: 部分变量初始化,条件语句调整。
|
||||
|
||||
local path = 'recognizer/patterns/unicode'
|
||||
local function unicode(input, seg, env)
|
||||
if not seg:has_tag("unicode") or input == '' then return end
|
||||
-- 获取 recognizer/patterns/unicode 的第 2 个字符作为触发前缀
|
||||
env.unicode_keyword = env.unicode_keyword or
|
||||
env.engine.schema.config:get_string('recognizer/patterns/unicode'):sub(2, 2)
|
||||
if seg:has_tag("unicode") and env.unicode_keyword ~= '' and input:sub(1, 1) == env.unicode_keyword then
|
||||
local ucodestr = input:match(env.unicode_keyword .. "(%x+)")
|
||||
if ucodestr and #ucodestr > 1 then
|
||||
local code = tonumber(ucodestr, 16)
|
||||
if code > 0x10FFFF then
|
||||
yield(Candidate("unicode", seg.start, seg._end, "数值超限!", ""))
|
||||
return
|
||||
end
|
||||
local text = utf8.char(code)
|
||||
yield(Candidate("unicode", seg.start, seg._end, text, string.format("U%x", code)))
|
||||
if code < 0x10000 then
|
||||
for i = 0, 15 do
|
||||
local text = utf8.char(code * 16 + i)
|
||||
yield(Candidate("unicode", seg.start, seg._end, text, string.format("U%x~%x", code, i)))
|
||||
end
|
||||
end
|
||||
-- config:get_string(path) 可能取得 nil 造成error
|
||||
if not env.unicode_keyword then
|
||||
local pattern = env.engine.schema.config:get_string(path) or "UU"
|
||||
env.unicode_keyword = pattern:sub(2,2)
|
||||
end
|
||||
|
||||
local ucodestr = input:match(env.unicode_keyword .. "(%x+)")
|
||||
if ucodestr and #ucodestr > 1 then
|
||||
local code = tonumber(ucodestr, 16)
|
||||
if code > 0x10FFFF then
|
||||
yield(Candidate("unicode", seg.start, seg._end, "数值超限!", ""))
|
||||
return
|
||||
end
|
||||
local text = utf8.char(code)
|
||||
yield(Candidate("unicode", seg.start, seg._end, text, string.format("U%x", code)))
|
||||
if code < 0x10000 then
|
||||
for i = 0, 15 do
|
||||
local text = utf8.char(code * 16 + i)
|
||||
yield(Candidate("unicode", seg.start, seg._end, text, string.format("U%x~%x", code, i)))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
新加坡币 新加坡币 S$
|
||||
欧元 欧元 € 💶
|
||||
英镑 英镑 £ 💷
|
||||
镑 镑 £
|
||||
比特币 比特币 ₿
|
||||
泰铢 泰铢 ฿
|
||||
铢 铢 ฿
|
||||
卢比 卢比 ₨
|
||||
印度卢比 印度卢比 ₹
|
||||
笑脸 笑脸 😀
|
||||
露齿笑 露齿笑 😃
|
||||
哈 哈 😄
|
||||
@@ -2725,6 +2731,7 @@ cloud cloud ☁️
|
||||
吹拂 吹拂 🌬
|
||||
吹风 吹风 🌬
|
||||
吹口气 吹口气 🌬
|
||||
吹气 吹气 🌬
|
||||
台风 台风 🌀
|
||||
旋风 旋风 🌀
|
||||
飓风 飓风 🌀
|
||||
|
||||
+2
-2
@@ -1369,8 +1369,8 @@ rime rime 㞢
|
||||
九次方 九次方 ⁹
|
||||
十次方 十次方 ¹⁰
|
||||
度 度 °
|
||||
摄氏度 摄氏度 °C
|
||||
华氏度 华氏度 °F
|
||||
摄氏度 摄氏度 ℃
|
||||
华氏度 华氏度 ℉
|
||||
点 点 · 丶
|
||||
间隔号 间隔号 ·
|
||||
连接号 连接号 —
|
||||
|
||||
+18
-1
@@ -1,6 +1,23 @@
|
||||
# 更新日志
|
||||
|
||||
除日常更新词库外的一些主要更新 🆕 及破坏性变更 ⚠️。
|
||||
除日常更新词库外的一些主要更新 🆕、破坏性变更 ⚠️。
|
||||
|
||||
## 2024-09-25
|
||||
|
||||
- `number_translator.lua`:⚙️ 依会计凭证书写要求,修正万亿的金额大写格式
|
||||
- radical_pinyin: 🆕 拆字词典更新至 v2,包含更多汉字
|
||||
|
||||
## 2024-08-29
|
||||
- `cold_word_drop`:🆕 支持 iOS (#1003)
|
||||
|
||||
## 2024-08-18
|
||||
|
||||
- ci: 词典处理脚本可在 GitHub CI 中运行,提交信息以 ` [build]` 结尾或者手动执行时触发。
|
||||
|
||||
## 2024-07-27
|
||||
|
||||
- `number_translator.lua`: 🆕 转换时,将「拾万」和「壹拾万」作为两个独立的候选。
|
||||
- `en_spacer.lua`:⚠️ 现在不会在中英标点、空字符前添加空格。将在英文后添加空格,修改为在英文前添加空格。
|
||||
|
||||
## 2024-05-15
|
||||
|
||||
|
||||
@@ -462,3 +462,15 @@ TF版本
|
||||
O不OK
|
||||
人均GDP
|
||||
V8引擎
|
||||
4A级
|
||||
5A级
|
||||
2G网络
|
||||
3G网络
|
||||
4G网络
|
||||
5G网络
|
||||
3G流量
|
||||
4G流量
|
||||
5G流量
|
||||
3D打印
|
||||
2D电影
|
||||
3D电影
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 139 KiB |
@@ -1,7 +1,7 @@
|
||||
# Emoji 映射表
|
||||
# 根据此文件生成 emoji.txt
|
||||
#
|
||||
# version: 2024-05-21
|
||||
# version: 2024-06-10
|
||||
#
|
||||
# 中文映射由 Dvel 纯手工打造 https://github.com/iDvel/rime-ice
|
||||
#
|
||||
@@ -24,7 +24,11 @@ HK$ 港元 港币
|
||||
MOP$ 澳门元 澳门币 葡币
|
||||
S$ 新加坡元 新加坡币
|
||||
€ 欧元
|
||||
£ 英镑
|
||||
£ 英镑 镑
|
||||
₿ 比特币
|
||||
฿ 泰铢 铢
|
||||
₨ 卢比
|
||||
₹ 印度卢比
|
||||
|
||||
|
||||
### Smileys & Emotion
|
||||
@@ -1116,7 +1120,7 @@ S$ 新加坡元 新加坡币
|
||||
🌩 打雷 雷云
|
||||
🌪 龙卷风
|
||||
🌫 雾 霾 雾霾
|
||||
🌬 风吹拂的脸 风吹拂 吹拂 吹风 吹口气
|
||||
🌬 风吹拂的脸 风吹拂 吹拂 吹风 吹口气 吹气
|
||||
🌀 台风 旋风 飓风 漩涡 蚊香 气旋
|
||||
🌈 彩虹
|
||||
🌂 收起的伞 收起的雨伞 雨伞
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module script
|
||||
|
||||
go 1.20
|
||||
go 1.22
|
||||
|
||||
require github.com/deckarep/golang-set/v2 v2.3.0
|
||||
|
||||
|
||||
@@ -68,6 +68,11 @@ SORT:
|
||||
}
|
||||
|
||||
func areYouOK() {
|
||||
if rime.AutoConfirm {
|
||||
fmt.Println("Auto confirm enabled. Skipping prompt.")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("Are you OK:")
|
||||
var isOK string
|
||||
_, _ = fmt.Scanf("%s", &isOK)
|
||||
|
||||
@@ -28,7 +28,7 @@ var (
|
||||
)
|
||||
|
||||
// 初始化特殊词汇列表、需要注音列表、错别字列表、拼音列表
|
||||
func init() {
|
||||
func initCheck() {
|
||||
// 特殊词汇列表,不进行任何检查
|
||||
specialWords.Add("狄尔斯–阿尔德反应")
|
||||
specialWords.Add("特里斯坦–达库尼亚")
|
||||
@@ -102,7 +102,7 @@ func init() {
|
||||
text, code := parts[0], parts[1]
|
||||
hanPinyin[text] = append(hanPinyin[text], code)
|
||||
}
|
||||
// 给 hanPinyin 补充不再字表的读音,和过滤列表 hanPinyinFilter
|
||||
// 给 hanPinyin 补充不在字表的读音,和过滤列表 hanPinyinFilter
|
||||
file4, err := os.Open(汉字拼音映射TXT)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
|
||||
+334
-319
@@ -92,6 +92,10 @@ var polyphones = map[string]string{
|
||||
"Chrome系 > 系": "xi",
|
||||
"QQ游戏大厅 > 大": "da",
|
||||
"QQ飞车 > 车": "che",
|
||||
"2G网络 > 络": "luo",
|
||||
"3G网络 > 络": "luo",
|
||||
"4G网络 > 络": "luo",
|
||||
"5G网络 > 络": "luo",
|
||||
}
|
||||
|
||||
var digitMap = map[string]string{
|
||||
@@ -118,330 +122,341 @@ type schema struct {
|
||||
file *os.File
|
||||
}
|
||||
|
||||
var doublePinyin = schema{
|
||||
name: "cn_en_double_pinyin",
|
||||
desc: "自然码双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_double_pinyin.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "aa",
|
||||
"-e-": "ee",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ai",
|
||||
"-ei-": "ei",
|
||||
"-ou-": "ou",
|
||||
"-an-": "an",
|
||||
"-en-": "en",
|
||||
"-ang-": "ah",
|
||||
"-eng-": "eg",
|
||||
"-ao-": "ao",
|
||||
"-er-": "er",
|
||||
// zh ch sh
|
||||
"zh": "v",
|
||||
"ch": "i",
|
||||
"sh": "u",
|
||||
// 韵母
|
||||
"iu": "q",
|
||||
"ia": "w",
|
||||
"ua": "w",
|
||||
"uan": "r",
|
||||
"ue": "t",
|
||||
"ve": "t",
|
||||
"ing": "y",
|
||||
"uai": "y",
|
||||
"uo": "o",
|
||||
"un": "p",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"iang": "d",
|
||||
"uang": "d",
|
||||
"en": "f",
|
||||
"eng": "g",
|
||||
"ang": "h",
|
||||
"an": "j",
|
||||
"ao": "k",
|
||||
"ai": "l",
|
||||
"ei": "z",
|
||||
"ie": "x",
|
||||
"iao": "c",
|
||||
"ui": "v",
|
||||
"ou": "b",
|
||||
"in": "n",
|
||||
"ian": "m",
|
||||
},
|
||||
}
|
||||
var (
|
||||
doublePinyin schema
|
||||
doublePinyinFlypy schema
|
||||
doublePinyinMSPY schema
|
||||
doublePinyinSogou schema
|
||||
doublePinyinZiGuang schema
|
||||
doublePinyinABC schema
|
||||
)
|
||||
|
||||
var doublePinyinFlypy = schema{
|
||||
name: "cn_en_flypy",
|
||||
desc: "小鹤双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_flypy.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "aa",
|
||||
"-e-": "ee",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ai",
|
||||
"-ei-": "ei",
|
||||
"-ou-": "ou",
|
||||
"-an-": "an",
|
||||
"-en-": "en",
|
||||
"-ang-": "ah",
|
||||
"-eng-": "eg",
|
||||
"-ao-": "ao",
|
||||
"-er-": "er",
|
||||
// zh ch sh
|
||||
"zh": "v",
|
||||
"ch": "i",
|
||||
"sh": "u",
|
||||
// 韵母
|
||||
"iu": "q",
|
||||
"ei": "w",
|
||||
"uan": "r",
|
||||
"ue": "t",
|
||||
"ve": "t",
|
||||
"un": "y",
|
||||
"uo": "o",
|
||||
"ie": "p",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"ai": "d",
|
||||
"en": "f",
|
||||
"eng": "g",
|
||||
"ang": "h",
|
||||
"an": "j",
|
||||
"ing": "k",
|
||||
"uai": "k",
|
||||
"iang": "l",
|
||||
"uang": "l",
|
||||
"ou": "z",
|
||||
"ia": "x",
|
||||
"ua": "x",
|
||||
"ao": "c",
|
||||
"ui": "v",
|
||||
"in": "b",
|
||||
"iao": "n",
|
||||
"ian": "m",
|
||||
},
|
||||
}
|
||||
func initSchemas() {
|
||||
doublePinyin = schema{
|
||||
name: "cn_en_double_pinyin",
|
||||
desc: "自然码双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_double_pinyin.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "aa",
|
||||
"-e-": "ee",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ai",
|
||||
"-ei-": "ei",
|
||||
"-ou-": "ou",
|
||||
"-an-": "an",
|
||||
"-en-": "en",
|
||||
"-ang-": "ah",
|
||||
"-eng-": "eg",
|
||||
"-ao-": "ao",
|
||||
"-er-": "er",
|
||||
// zh ch sh
|
||||
"zh": "v",
|
||||
"ch": "i",
|
||||
"sh": "u",
|
||||
// 韵母
|
||||
"iu": "q",
|
||||
"ia": "w",
|
||||
"ua": "w",
|
||||
"uan": "r",
|
||||
"ue": "t",
|
||||
"ve": "t",
|
||||
"ing": "y",
|
||||
"uai": "y",
|
||||
"uo": "o",
|
||||
"un": "p",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"iang": "d",
|
||||
"uang": "d",
|
||||
"en": "f",
|
||||
"eng": "g",
|
||||
"ang": "h",
|
||||
"an": "j",
|
||||
"ao": "k",
|
||||
"ai": "l",
|
||||
"ei": "z",
|
||||
"ie": "x",
|
||||
"iao": "c",
|
||||
"ui": "v",
|
||||
"ou": "b",
|
||||
"in": "n",
|
||||
"ian": "m",
|
||||
},
|
||||
}
|
||||
|
||||
var doublePinyinMSPY = schema{
|
||||
name: "cn_en_mspy",
|
||||
desc: "微软双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_mspy.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "oa",
|
||||
"-e-": "oe",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ol",
|
||||
"-ei-": "oz",
|
||||
"-ou-": "ob",
|
||||
"-an-": "oj",
|
||||
"-en-": "of",
|
||||
"-ang-": "oh",
|
||||
"-eng-": "og",
|
||||
"-ao-": "ok",
|
||||
"-er-": "or",
|
||||
// zh ch sh
|
||||
"zh": "v",
|
||||
"ch": "i",
|
||||
"sh": "u",
|
||||
// 韵母
|
||||
"iu": "q",
|
||||
"ia": "w",
|
||||
"ua": "w",
|
||||
"er": "r",
|
||||
"uan": "r",
|
||||
"ue": "t",
|
||||
"uai": "y",
|
||||
"uo": "o",
|
||||
"un": "p",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"iang": "d",
|
||||
"uang": "d",
|
||||
"en": "f",
|
||||
"eng": "g",
|
||||
"ang": "h",
|
||||
"an": "j",
|
||||
"ao": "k",
|
||||
"ai": "l",
|
||||
"ing": ";",
|
||||
"ei": "z",
|
||||
"ie": "x",
|
||||
"iao": "c",
|
||||
"ui": "v",
|
||||
"ve": "v",
|
||||
"ou": "b",
|
||||
"in": "n",
|
||||
"ian": "m",
|
||||
},
|
||||
}
|
||||
doublePinyinFlypy = schema{
|
||||
name: "cn_en_flypy",
|
||||
desc: "小鹤双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_flypy.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "aa",
|
||||
"-e-": "ee",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ai",
|
||||
"-ei-": "ei",
|
||||
"-ou-": "ou",
|
||||
"-an-": "an",
|
||||
"-en-": "en",
|
||||
"-ang-": "ah",
|
||||
"-eng-": "eg",
|
||||
"-ao-": "ao",
|
||||
"-er-": "er",
|
||||
// zh ch sh
|
||||
"zh": "v",
|
||||
"ch": "i",
|
||||
"sh": "u",
|
||||
// 韵母
|
||||
"iu": "q",
|
||||
"ei": "w",
|
||||
"uan": "r",
|
||||
"ue": "t",
|
||||
"ve": "t",
|
||||
"un": "y",
|
||||
"uo": "o",
|
||||
"ie": "p",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"ai": "d",
|
||||
"en": "f",
|
||||
"eng": "g",
|
||||
"ang": "h",
|
||||
"an": "j",
|
||||
"ing": "k",
|
||||
"uai": "k",
|
||||
"iang": "l",
|
||||
"uang": "l",
|
||||
"ou": "z",
|
||||
"ia": "x",
|
||||
"ua": "x",
|
||||
"ao": "c",
|
||||
"ui": "v",
|
||||
"in": "b",
|
||||
"iao": "n",
|
||||
"ian": "m",
|
||||
},
|
||||
}
|
||||
|
||||
var doublePinyinSogou = schema{
|
||||
name: "cn_en_sogou",
|
||||
desc: "搜狗双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_sogou.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "oa",
|
||||
"-e-": "oe",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ol",
|
||||
"-ei-": "oz",
|
||||
"-ou-": "ob",
|
||||
"-an-": "oj",
|
||||
"-en-": "of",
|
||||
"-ang-": "oh",
|
||||
"-eng-": "og",
|
||||
"-ao-": "ok",
|
||||
"-er-": "or",
|
||||
// zh ch sh
|
||||
"zh": "v",
|
||||
"ch": "i",
|
||||
"sh": "u",
|
||||
// 韵母
|
||||
"iu": "q",
|
||||
"ia": "w",
|
||||
"ua": "w",
|
||||
"er": "r",
|
||||
"uan": "r",
|
||||
"ue": "t",
|
||||
"uai": "y",
|
||||
"uo": "o",
|
||||
"un": "p",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"iang": "d",
|
||||
"uang": "d",
|
||||
"en": "f",
|
||||
"eng": "g",
|
||||
"ang": "h",
|
||||
"an": "j",
|
||||
"ao": "k",
|
||||
"ai": "l",
|
||||
"ing": ";",
|
||||
"ei": "z",
|
||||
"ie": "x",
|
||||
"iao": "c",
|
||||
"ui": "v",
|
||||
"ve": "t",
|
||||
"ou": "b",
|
||||
"in": "n",
|
||||
"ian": "m",
|
||||
},
|
||||
}
|
||||
doublePinyinMSPY = schema{
|
||||
name: "cn_en_mspy",
|
||||
desc: "微软双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_mspy.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "oa",
|
||||
"-e-": "oe",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ol",
|
||||
"-ei-": "oz",
|
||||
"-ou-": "ob",
|
||||
"-an-": "oj",
|
||||
"-en-": "of",
|
||||
"-ang-": "oh",
|
||||
"-eng-": "og",
|
||||
"-ao-": "ok",
|
||||
"-er-": "or",
|
||||
// zh ch sh
|
||||
"zh": "v",
|
||||
"ch": "i",
|
||||
"sh": "u",
|
||||
// 韵母
|
||||
"iu": "q",
|
||||
"ia": "w",
|
||||
"ua": "w",
|
||||
"er": "r",
|
||||
"uan": "r",
|
||||
"ue": "t",
|
||||
"uai": "y",
|
||||
"uo": "o",
|
||||
"un": "p",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"iang": "d",
|
||||
"uang": "d",
|
||||
"en": "f",
|
||||
"eng": "g",
|
||||
"ang": "h",
|
||||
"an": "j",
|
||||
"ao": "k",
|
||||
"ai": "l",
|
||||
"ing": ";",
|
||||
"ei": "z",
|
||||
"ie": "x",
|
||||
"iao": "c",
|
||||
"ui": "v",
|
||||
"ve": "v",
|
||||
"ou": "b",
|
||||
"in": "n",
|
||||
"ian": "m",
|
||||
},
|
||||
}
|
||||
|
||||
var doublePinyinZiGuang = schema{
|
||||
name: "cn_en_ziguang",
|
||||
desc: "紫光双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_ziguang.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "oa",
|
||||
"-e-": "oe",
|
||||
"-o-": "oo",
|
||||
"-ai-": "op",
|
||||
"-ei-": "ok",
|
||||
"-ou-": "oz",
|
||||
"-an-": "or",
|
||||
"-en-": "ow",
|
||||
"-ang-": "os",
|
||||
"-eng-": "ot",
|
||||
"-ao-": "oq",
|
||||
"-er-": "oj",
|
||||
// zh ch sh
|
||||
"zh": "u",
|
||||
"ch": "a",
|
||||
"sh": "i",
|
||||
// 韵母
|
||||
"ao": "q",
|
||||
"en": "w",
|
||||
"an": "r",
|
||||
"eng": "t",
|
||||
"in": "y",
|
||||
"uai": "y",
|
||||
"uo": "o",
|
||||
"ai": "p",
|
||||
"ang": "s",
|
||||
"ie": "d",
|
||||
"ian": "f",
|
||||
"iang": "g",
|
||||
"uang": "g",
|
||||
"iong": "h",
|
||||
"ong": "h",
|
||||
"er": "j",
|
||||
"iu": "j",
|
||||
"ei": "k",
|
||||
"uan": "l",
|
||||
"ing": ";",
|
||||
"ou": "z",
|
||||
"ia": "x",
|
||||
"ua": "x",
|
||||
"iao": "b",
|
||||
"ue": "n",
|
||||
"ui": "n",
|
||||
"un": "m",
|
||||
},
|
||||
}
|
||||
doublePinyinSogou = schema{
|
||||
name: "cn_en_sogou",
|
||||
desc: "搜狗双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_sogou.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "oa",
|
||||
"-e-": "oe",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ol",
|
||||
"-ei-": "oz",
|
||||
"-ou-": "ob",
|
||||
"-an-": "oj",
|
||||
"-en-": "of",
|
||||
"-ang-": "oh",
|
||||
"-eng-": "og",
|
||||
"-ao-": "ok",
|
||||
"-er-": "or",
|
||||
// zh ch sh
|
||||
"zh": "v",
|
||||
"ch": "i",
|
||||
"sh": "u",
|
||||
// 韵母
|
||||
"iu": "q",
|
||||
"ia": "w",
|
||||
"ua": "w",
|
||||
"er": "r",
|
||||
"uan": "r",
|
||||
"ue": "t",
|
||||
"uai": "y",
|
||||
"uo": "o",
|
||||
"un": "p",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"iang": "d",
|
||||
"uang": "d",
|
||||
"en": "f",
|
||||
"eng": "g",
|
||||
"ang": "h",
|
||||
"an": "j",
|
||||
"ao": "k",
|
||||
"ai": "l",
|
||||
"ing": ";",
|
||||
"ei": "z",
|
||||
"ie": "x",
|
||||
"iao": "c",
|
||||
"ui": "v",
|
||||
"ve": "t",
|
||||
"ou": "b",
|
||||
"in": "n",
|
||||
"ian": "m",
|
||||
},
|
||||
}
|
||||
|
||||
var doublePinyinABC = schema{
|
||||
name: "cn_en_abc",
|
||||
desc: "智能 ABC 双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_abc.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "oa",
|
||||
"-e-": "oe",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ol",
|
||||
"-ei-": "oq",
|
||||
"-ou-": "ob",
|
||||
"-an-": "oj",
|
||||
"-en-": "of",
|
||||
"-ang-": "oh",
|
||||
"-eng-": "og",
|
||||
"-ao-": "ok",
|
||||
"-er-": "or",
|
||||
// zh ch sh
|
||||
"zh": "a",
|
||||
"ch": "e",
|
||||
"sh": "v",
|
||||
// 韵母
|
||||
"ao": "k",
|
||||
"en": "f",
|
||||
"an": "j",
|
||||
"eng": "g",
|
||||
"in": "c",
|
||||
"uai": "c",
|
||||
"uo": "o",
|
||||
"ai": "l",
|
||||
"ang": "h",
|
||||
"ie": "x",
|
||||
"ian": "w",
|
||||
"iang": "t",
|
||||
"uang": "t",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"er": "r",
|
||||
"iu": "r",
|
||||
"ei": "q",
|
||||
"uan": "p",
|
||||
"ing": "y",
|
||||
"ou": "b",
|
||||
"ia": "d",
|
||||
"ua": "d",
|
||||
"iao": "z",
|
||||
"ue": "m",
|
||||
"ui": "m",
|
||||
"un": "n",
|
||||
},
|
||||
doublePinyinZiGuang = schema{
|
||||
name: "cn_en_ziguang",
|
||||
desc: "紫光双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_ziguang.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "oa",
|
||||
"-e-": "oe",
|
||||
"-o-": "oo",
|
||||
"-ai-": "op",
|
||||
"-ei-": "ok",
|
||||
"-ou-": "oz",
|
||||
"-an-": "or",
|
||||
"-en-": "ow",
|
||||
"-ang-": "os",
|
||||
"-eng-": "ot",
|
||||
"-ao-": "oq",
|
||||
"-er-": "oj",
|
||||
// zh ch sh
|
||||
"zh": "u",
|
||||
"ch": "a",
|
||||
"sh": "i",
|
||||
// 韵母
|
||||
"ao": "q",
|
||||
"en": "w",
|
||||
"an": "r",
|
||||
"eng": "t",
|
||||
"in": "y",
|
||||
"uai": "y",
|
||||
"uo": "o",
|
||||
"ai": "p",
|
||||
"ang": "s",
|
||||
"ie": "d",
|
||||
"ian": "f",
|
||||
"iang": "g",
|
||||
"uang": "g",
|
||||
"iong": "h",
|
||||
"ong": "h",
|
||||
"er": "j",
|
||||
"iu": "j",
|
||||
"ei": "k",
|
||||
"uan": "l",
|
||||
"ing": ";",
|
||||
"ou": "z",
|
||||
"ia": "x",
|
||||
"ua": "x",
|
||||
"iao": "b",
|
||||
"ue": "n",
|
||||
"ui": "n",
|
||||
"un": "m",
|
||||
},
|
||||
}
|
||||
|
||||
doublePinyinABC = schema{
|
||||
name: "cn_en_abc",
|
||||
desc: "智能 ABC 双拼",
|
||||
combinationType: "unique",
|
||||
path: filepath.Join(RimeDir, "en_dicts/cn_en_abc.txt"),
|
||||
mapping: map[string]string{
|
||||
// 零声母
|
||||
"-a-": "oa",
|
||||
"-e-": "oe",
|
||||
"-o-": "oo",
|
||||
"-ai-": "ol",
|
||||
"-ei-": "oq",
|
||||
"-ou-": "ob",
|
||||
"-an-": "oj",
|
||||
"-en-": "of",
|
||||
"-ang-": "oh",
|
||||
"-eng-": "og",
|
||||
"-ao-": "ok",
|
||||
"-er-": "or",
|
||||
// zh ch sh
|
||||
"zh": "a",
|
||||
"ch": "e",
|
||||
"sh": "v",
|
||||
// 韵母
|
||||
"ao": "k",
|
||||
"en": "f",
|
||||
"an": "j",
|
||||
"eng": "g",
|
||||
"in": "c",
|
||||
"uai": "c",
|
||||
"uo": "o",
|
||||
"ai": "l",
|
||||
"ang": "h",
|
||||
"ie": "x",
|
||||
"ian": "w",
|
||||
"iang": "t",
|
||||
"uang": "t",
|
||||
"iong": "s",
|
||||
"ong": "s",
|
||||
"er": "r",
|
||||
"iu": "r",
|
||||
"ei": "q",
|
||||
"uan": "p",
|
||||
"ing": "y",
|
||||
"ou": "b",
|
||||
"ia": "d",
|
||||
"ua": "d",
|
||||
"iao": "z",
|
||||
"ue": "m",
|
||||
"ui": "m",
|
||||
"un": "n",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// CnEn 从 others/cn_en.txt 生成全拼和各个双拼的中英混输词库
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package rime
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func getRimeDirForPlatform() string {
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
return filepath.Join(u.HomeDir, ".config", "rime")
|
||||
}
|
||||
@@ -5,26 +5,14 @@ package rime
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// 获取 macOS/Windows Rime 配置目录
|
||||
func getRimeDir() string {
|
||||
var dir string
|
||||
switch runtime.GOOS {
|
||||
case "darwin": // macOS
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
dir = filepath.Join(u.HomeDir, "Library/Rime")
|
||||
// case "windows": // Windows
|
||||
// dir = getWeaselDir()
|
||||
default:
|
||||
log.Fatalf("Unsupported OS: %s so far", runtime.GOOS)
|
||||
// 获取 macOS Rime 配置目录
|
||||
func getRimeDirForPlatform() string {
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
return dir
|
||||
return filepath.Join(u.HomeDir, "Library/Rime")
|
||||
}
|
||||
|
||||
@@ -7,31 +7,11 @@ import (
|
||||
"golang.org/x/sys/windows/registry"
|
||||
"log"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// 获取 macOS/Windows Rime 配置目录
|
||||
func getRimeDir() string {
|
||||
var dir string
|
||||
switch runtime.GOOS {
|
||||
case "darwin": // macOS
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
dir = filepath.Join(u.HomeDir, "Library/Rime")
|
||||
case "windows": // Windows
|
||||
dir = getWeaselDir()
|
||||
default:
|
||||
log.Fatalf("Unsupported OS: %s so far", runtime.GOOS)
|
||||
}
|
||||
|
||||
return dir
|
||||
}
|
||||
|
||||
func getWeaselDir() string {
|
||||
// 获取 Windows Rime 配置目录
|
||||
func getRimeDirForPlatform() string {
|
||||
keyPath := `Software\Rime\Weasel`
|
||||
valueName := "RimeUserDir"
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ var onlyOne = map[string]string{
|
||||
"给": "gei",
|
||||
}
|
||||
|
||||
func init() {
|
||||
func initPinyin() {
|
||||
// 从 base、ext 准备结巴的词典和词组拼音映射
|
||||
for _, dictPath := range []string{BasePath, ExtPath} {
|
||||
file, err := os.Open(dictPath)
|
||||
|
||||
+53
-12
@@ -2,6 +2,7 @@ package rime
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
mapset "github.com/deckarep/golang-set/v2"
|
||||
"log"
|
||||
@@ -21,26 +22,66 @@ type lemma struct {
|
||||
}
|
||||
|
||||
var (
|
||||
mark = "# +_+" // 词库中的标记符号,表示从这行开始进行检查或排序
|
||||
RimeDir = getRimeDir() // Rime 配置目录
|
||||
mark = "# +_+" // 词库中的标记符号,表示从这行开始进行检查或排序
|
||||
RimeDir string
|
||||
EmojiMapPath string
|
||||
EmojiPath string
|
||||
HanziPath string
|
||||
BasePath string
|
||||
ExtPath string
|
||||
TencentPath string
|
||||
HanziSet mapset.Set[string]
|
||||
BaseSet mapset.Set[string]
|
||||
ExtSet mapset.Set[string]
|
||||
TencentSet mapset.Set[string]
|
||||
需要注音TXT string
|
||||
错别字TXT string
|
||||
汉字拼音映射TXT string
|
||||
AutoConfirm bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 定义命令行参数
|
||||
flag.StringVar(&RimeDir, "rime_path", "", "Specify the Rime configuration directory")
|
||||
flag.BoolVar(&AutoConfirm, "auto_confirm", false, "Automatically confirm the prompt")
|
||||
flag.Parse()
|
||||
|
||||
RimeDir = getRimeDir(RimeDir) // Rime 配置目录
|
||||
|
||||
EmojiMapPath = filepath.Join(RimeDir, "others/emoji-map.txt")
|
||||
EmojiPath = filepath.Join(RimeDir, "opencc/emoji.txt")
|
||||
EmojiPath = filepath.Join(RimeDir, "opencc/emoji.txt")
|
||||
|
||||
HanziPath = filepath.Join(RimeDir, "cn_dicts/8105.dict.yaml")
|
||||
BasePath = filepath.Join(RimeDir, "cn_dicts/base.dict.yaml")
|
||||
ExtPath = filepath.Join(RimeDir, "cn_dicts/ext.dict.yaml")
|
||||
HanziPath = filepath.Join(RimeDir, "cn_dicts/8105.dict.yaml")
|
||||
BasePath = filepath.Join(RimeDir, "cn_dicts/base.dict.yaml")
|
||||
ExtPath = filepath.Join(RimeDir, "cn_dicts/ext.dict.yaml")
|
||||
TencentPath = filepath.Join(RimeDir, "cn_dicts/tencent.dict.yaml")
|
||||
|
||||
HanziSet = readToSet(HanziPath)
|
||||
BaseSet = readToSet(BasePath)
|
||||
ExtSet = readToSet(ExtPath)
|
||||
HanziSet = readToSet(HanziPath)
|
||||
BaseSet = readToSet(BasePath)
|
||||
ExtSet = readToSet(ExtPath)
|
||||
TencentSet = readToSet(TencentPath)
|
||||
|
||||
需要注音TXT = filepath.Join(RimeDir, "others/script/rime/需要注音.txt")
|
||||
错别字TXT = filepath.Join(RimeDir, "others/script/rime/错别字.txt")
|
||||
需要注音TXT = filepath.Join(RimeDir, "others/script/rime/需要注音.txt")
|
||||
错别字TXT = filepath.Join(RimeDir, "others/script/rime/错别字.txt")
|
||||
汉字拼音映射TXT = filepath.Join(RimeDir, "others/script/rime/汉字拼音映射.txt")
|
||||
)
|
||||
|
||||
initCheck()
|
||||
initSchemas()
|
||||
initPinyin()
|
||||
}
|
||||
|
||||
func getRimeDir(rimePath string) string {
|
||||
if rimePath != "" {
|
||||
absPath, err := filepath.Abs(rimePath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get absolute path: %v", err)
|
||||
}
|
||||
// 使用传入的路径
|
||||
return absPath
|
||||
}
|
||||
|
||||
return getRimeDirForPlatform()
|
||||
}
|
||||
|
||||
// 将所有词库读入 set,供检查或排序使用
|
||||
func readToSet(dictPath string) mapset.Set[string] {
|
||||
|
||||
@@ -109,7 +109,7 @@ func Sort(dictPath string, _type int) {
|
||||
// 排序:拼音升序,权重降序,最后直接按 Unicode 编码排序
|
||||
// 英文排序不区分大小写
|
||||
if strings.Contains(dictPath, "en.dict.yaml") {
|
||||
sort.Slice(contents, func(i, j int) bool {
|
||||
sort.SliceStable(contents, func(i, j int) bool {
|
||||
textI, textJ := strings.ToLower(contents[i].text), strings.ToLower(contents[j].text)
|
||||
if strings.HasPrefix(textI, "# ") {
|
||||
textI = textI[2:]
|
||||
@@ -123,7 +123,7 @@ func Sort(dictPath string, _type int) {
|
||||
return false
|
||||
})
|
||||
} else {
|
||||
sort.Slice(contents, func(i, j int) bool {
|
||||
sort.SliceStable(contents, func(i, j int) bool {
|
||||
if contents[i].code != contents[j].code {
|
||||
return contents[i].code < contents[j].code
|
||||
}
|
||||
|
||||
@@ -84,6 +84,8 @@
|
||||
菈 la
|
||||
咲 xiao
|
||||
螓 qin
|
||||
㨃 dui
|
||||
𤭢 cei
|
||||
# -_- ----------这行下面是要过滤掉的词汇,不进行注音检查----------
|
||||
杭育
|
||||
深厉浅揭
|
||||
@@ -819,3 +821,6 @@
|
||||
宕昌
|
||||
宕昌山
|
||||
郦食其
|
||||
蛣蟟
|
||||
擸𢶍
|
||||
蠽蟟
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
# 在 # -_- 上面是错词;下面是包含错词但不是错词。
|
||||
夏侯敦
|
||||
看的出
|
||||
天侯
|
||||
喜剧届
|
||||
音乐届
|
||||
体育届
|
||||
目步转睛
|
||||
奥门
|
||||
三圾
|
||||
|
||||
+24171
-1
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
schema:
|
||||
schema_id: radical_pinyin
|
||||
name: "部件拆字 | 全拼双拼"
|
||||
version: "1.1.0"
|
||||
version: "2.0.0"
|
||||
author: Mirtle
|
||||
description: |
|
||||
用拼音按顺序打出偏旁部件,组合出汉字
|
||||
@@ -271,3 +271,5 @@ algebra_ziguang:
|
||||
- xform/an(?=^|$|')/<r>/
|
||||
- xform/'|<|>//
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ long_word_filter = require("long_word_filter")
|
||||
-- 在 engine/filters 增加 - lua_filter@cn_en_spacer
|
||||
cn_en_spacer = require("cn_en_spacer")
|
||||
|
||||
-- 英文词条上屏自动空格
|
||||
-- 在 engine/filters 增加 - lua_filter@en_spacer
|
||||
-- 英文词条上屏自动添加空格
|
||||
-- 在 engine/filters 的倒数第二个位置,增加 - lua_filter@en_spacer
|
||||
en_spacer = require("en_spacer")
|
||||
|
||||
-- 九宫格,将输入框的数字转为对应的拼音或英文,iRime 用,Hamster 不需要。
|
||||
|
||||
+2
-23
@@ -61,30 +61,9 @@ Z Z
|
||||
7 qi
|
||||
8 ba
|
||||
9 jiu
|
||||
# 示例:输入 siSdian 得到 4S店
|
||||
3G
|
||||
4G
|
||||
5G
|
||||
3G网络
|
||||
4G网络
|
||||
5G网络
|
||||
3G流量
|
||||
4G流量
|
||||
5G流量
|
||||
2D
|
||||
3D
|
||||
4D
|
||||
3D打印
|
||||
2D电影
|
||||
3D电影
|
||||
4S店
|
||||
AE86
|
||||
M1
|
||||
M2
|
||||
M3
|
||||
M4
|
||||
M4A1
|
||||
|
||||
# 示例:输入 sanDdayin 得到 3D打印
|
||||
3D打印
|
||||
|
||||
# 加入词典,响应 opencc/others.txt 的 emoji 集合
|
||||
V动物
|
||||
|
||||
+13
-12
@@ -140,7 +140,7 @@ reduce_english_filter:
|
||||
rand, rant, rent, rep, res, ret, rex, rib, rid, rig, rim, rub, rug, rum, runc, runs, ranch,
|
||||
sac, sail, sal, sam, sans, sap, saw, sax, sew, sham, shaw, shin, sig, sin, sip, sis, suit, sung, suns, sup, sur, sus,
|
||||
tad, tail, taj, tar, tax, tec, ted, tel, ter, tex, tic, tied, tier, ties, tim, tin, tit, tour, tout, tum,
|
||||
wag, wand, womens, wap, wax, weir, won,
|
||||
wag, wand, womens, wap, wax, weir, won, went,
|
||||
yan, yen,
|
||||
zach
|
||||
]
|
||||
@@ -289,19 +289,20 @@ pin_cand_filter:
|
||||
|
||||
# 主翻译器,拼音
|
||||
translator:
|
||||
dictionary: rime_ice # 挂载词库 rime_ice.dict.yaml
|
||||
spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中
|
||||
always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。
|
||||
initial_quality: 1.2 # 拼音的权重应该比英文大
|
||||
comment_format: # 标记拼音注释,供 corrector.lua 做判断用
|
||||
dictionary: rime_ice # 挂载词库 rime_ice.dict.yaml
|
||||
enable_word_completion: true # 大于 4 音节的词条自动补全,librime > 1.11.2
|
||||
spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中
|
||||
always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。
|
||||
initial_quality: 1.2 # 拼音的权重应该比英文大
|
||||
comment_format: # 标记拼音注释,供 corrector.lua 做判断用
|
||||
- xform/^/[/
|
||||
- xform/$/]/
|
||||
preedit_format: # preedit_format 影响到输入框的显示和“Shift+回车”上屏的字符
|
||||
- xform/([jqxy])v/$1u/ # 显示为 ju qu xu yu
|
||||
# - xform/([nl])v/$1ü/ # 显示为 nü lü
|
||||
# - xform/([nl])ue/$1üe/ # 显示为 nüe lüe
|
||||
- xform/([nl])v/$1v/ # 显示为 nv lv
|
||||
- xform/([nl])ue/$1ve/ # 显示为 nve lve
|
||||
preedit_format: # preedit_format 影响到输入框的显示和“Shift+回车”上屏的字符
|
||||
- xform/([jqxy])v/$1u/ # 显示为 ju qu xu yu
|
||||
# - xform/([nl])v/$1ü/ # 显示为 nü lü
|
||||
# - xform/([nl])ue/$1üe/ # 显示为 nüe lüe
|
||||
- xform/([nl])v/$1v/ # 显示为 nv lv
|
||||
- xform/([nl])ue/$1ve/ # 显示为 nve lve
|
||||
|
||||
|
||||
# 次翻译器,英文
|
||||
|
||||
+33
-33
@@ -103,8 +103,7 @@ preset_color_schemes:
|
||||
# border_color: # 外边框颜色
|
||||
|
||||
|
||||
# 下面是内置的皮肤 /Library/Input Methods/Squirrel.app/Contents/SharedSupport/squirrel.yaml
|
||||
|
||||
# 下面是内置的皮肤 https://github.com/rime/squirrel/blob/master/data/squirrel.yaml
|
||||
|
||||
native:
|
||||
name: 系統配色
|
||||
@@ -262,7 +261,7 @@ preset_color_schemes:
|
||||
clean_white:
|
||||
name: 简约白/Clean White
|
||||
author: Chongyu Zhu <lembacon@gmail.com>, based on 搜狗「简约白」
|
||||
horizontal: true
|
||||
candidate_list_layout: linear
|
||||
candidate_format: '%c %@'
|
||||
corner_radius: 6
|
||||
border_height: 6
|
||||
@@ -282,7 +281,7 @@ preset_color_schemes:
|
||||
apathy:
|
||||
name: 冷漠/Apathy
|
||||
author: LIANG Hai
|
||||
horizontal: true # 水平排列
|
||||
candidate_list_layout: linear # 水平排列
|
||||
inline_preedit: true #单行显示,false双行显示
|
||||
candidate_format: "%c\u2005%@\u2005" # 编号 %c 和候选词 %@ 前后的空间
|
||||
corner_radius: 5 #候选条圆角
|
||||
@@ -301,7 +300,7 @@ preset_color_schemes:
|
||||
dust:
|
||||
name: 浮尘/Dust
|
||||
author: Superoutman <asticosmo@gmail.com>
|
||||
horizontal: true # 水平排列
|
||||
candidate_list_layout: linear # 水平排列
|
||||
inline_preedit: true #单行显示,false双行显示
|
||||
candidate_format: "%c\u2005%@\u2005" # 用 1/6 em 空格 U+2005 来控制编号 %c 和候选词 %@ 前后的空间。
|
||||
corner_radius: 2 #候选条圆角
|
||||
@@ -326,7 +325,7 @@ preset_color_schemes:
|
||||
mojave_dark:
|
||||
name: 沙漠夜/Mojave Dark
|
||||
author: xiehuc <xiehuc@gmail.com>
|
||||
horizontal: true # 水平排列
|
||||
candidate_list_layout: linear # 水平排列
|
||||
inline_preedit: true # 单行显示,false双行显示
|
||||
candidate_format: "%c\u2005%@" # 用 1/6 em 空格 U+2005 来控制编号 %c 和候选词 %@ 前后的空间。
|
||||
corner_radius: 5 # 候选条圆角
|
||||
@@ -354,34 +353,35 @@ preset_color_schemes:
|
||||
name: 曬經・日/Solarized Light
|
||||
author: 雪齋 <lyc20041@gmail.com>
|
||||
color_space: display_p3 # Only available on macOS 10.12+
|
||||
back_color: 0xf0E5F6FB #Lab 97, 0, 10
|
||||
border_color: 0xf0EDFFFF #Lab 100, 0, 10
|
||||
preedit_back_color: 0xf0D7E8ED #Lab 92, 0, 10
|
||||
candidate_text_color: 0x3942CB #Lab 50, 65, 45
|
||||
label_color: 0x2566C6 #Lab 55, 45, 65
|
||||
comment_text_color: 0x8144C2 #Lab 50, 65, -5
|
||||
text_color: 0x756E5D #Lab 45, -7, -7
|
||||
hilited_back_color: 0xf0C9DADF #Lab 87, 0, 10
|
||||
hilited_candidate_back_color: 0x403516 #Lab 20, -12, -12
|
||||
hilited_candidate_text_color: 0x989F52 #Lab 60, -35, -5
|
||||
hilited_candidate_label_color: 0xCC8947 #Lab 55, -10, -45
|
||||
hilited_comment_text_color: 0x289989 #Lab 60, -20, 65
|
||||
hilited_text_color: 0xBE706D #Lab 50, 15, -45
|
||||
back_color: 0xF0E5F6FB #Lab 97 , 0 , 10
|
||||
border_color: 0xEDFFFF #Lab 100, 0 , 10
|
||||
preedit_back_color: 0x403516 #Lab 20 ,-12,-12
|
||||
#candidate_back_color: 0x403516 #Lab 20 ,-12,-12
|
||||
candidate_text_color: 0x595E00 #Lab 35 ,-35,-5
|
||||
label_color: 0xA36407 #Lab 40 ,-10,-45
|
||||
comment_text_color: 0x005947 #Lab 35 ,-20, 65
|
||||
text_color: 0xA1A095 #Lab 65 ,-5 ,-2
|
||||
hilited_back_color: 0x4C4022 #Lab 25 ,-12,-12
|
||||
hilited_candidate_back_color: 0xD7E8ED #Lab 92 , 0 , 10
|
||||
hilited_candidate_text_color: 0x3942CB #Lab 50 , 65, 45
|
||||
hilited_candidate_label_color: 0x2566C6 #Lab 55 , 45, 65
|
||||
hilited_comment_text_color: 0x8144C2 #Lab 50 , 65,-5
|
||||
hilited_text_color: 0x2C8BAE #Lab 60 , 10, 65
|
||||
|
||||
solarized_dark:
|
||||
name: 曬經・月/Solarized Dark
|
||||
author: 雪齋 <lyc20041@gmail.com>
|
||||
color_space: display_p3 # Only available on macOS 10.12+
|
||||
back_color: 0xf0352A0A #Lab 15, -12, -12
|
||||
border_color: 0xf02A1F00 #Lab 10, -12, -12
|
||||
preedit_back_color: 0xf0403516 #Lab 20, -12, -12
|
||||
candidate_text_color: 0x989F52 #Lab 60, -35, -5
|
||||
label_color: 0xCC8947 #Lab 55, -10, -45
|
||||
comment_text_color: 0x289989 #Lab 60, -20, 65
|
||||
text_color: 0xA1A095 #Lab 65, -05, -02
|
||||
hilited_back_color: 0xf04C4022 #Lab 25, -12, -12
|
||||
hilited_candidate_back_color: 0xD7E8ED #Lab 92, 0, 10
|
||||
hilited_candidate_text_color: 0x3942CB #Lab 50, 65, 45
|
||||
hilited_candidate_label_color: 0x2566C6 #Lab 55, 45, 65
|
||||
hilited_comment_text_color: 0x8144C2 #Lab 50, 65, -5
|
||||
hilited_text_color: 0x2C8BAE #Lab 60, 10, 65
|
||||
back_color: 0xF0352A0A #Lab 15 ,-12,-12
|
||||
border_color: 0x2A1F00 #Lab 10 ,-12,-12
|
||||
preedit_back_color: 0xD7E8ED #Lab 92 , 0 , 10
|
||||
#candidate_back_color: 0xD7E8ED #Lab 92 , 0 , 10
|
||||
candidate_text_color: 0x7389FF #Lab 75 , 65, 45
|
||||
label_color: 0x478DF4 #Lab 70 , 45, 65
|
||||
comment_text_color: 0xC38AFF #Lab 75 , 65,-5
|
||||
text_color: 0x756E5D #Lab 45 ,-7 ,-7
|
||||
hilited_back_color: 0xC9DADF #Lab 87 , 0 , 10
|
||||
hilited_candidate_back_color: 0x403516 #Lab 20 ,-12,-12
|
||||
hilited_candidate_text_color: 0x989F52 #Lab 60 ,-35,-5
|
||||
hilited_candidate_label_color: 0xCC8947 #Lab 55 ,-10,-45
|
||||
hilited_comment_text_color: 0x289989 #Lab 60 ,-20, 65
|
||||
hilited_text_color: 0xBE706D #Lab 50 , 15,-45
|
||||
+8
-2
@@ -6,15 +6,21 @@
|
||||
# Weasel 定制文档 <https://github.com/rime/weasel/wiki/Weasel-定制化>
|
||||
# Weasel 字体设定 <https://github.com/rime/weasel/wiki/字體設定>
|
||||
|
||||
# Weasel 特殊行为的命令行选项
|
||||
# WeaselServer.exe /ascii - CLI 中切换 ASCII 模式
|
||||
# WeaselServer.exe /nascii - CLI 中切换非 ASCII 模式
|
||||
# WeaselSetup.exe /toggleime - 设置系统快捷键用于开启/关闭键盘(0.16.1 以上版本)
|
||||
# WeaselSetup.exe /toggleascii - 设置系统快捷键用于切换 ASCII 模式(0.16.1 以上版本)
|
||||
|
||||
# 部分选项需要将 Weasel 更新 16.0 及以上版本才能生效
|
||||
config_version: "2024-05-14"
|
||||
config_version: "2024-09-25"
|
||||
|
||||
# [app_options]
|
||||
# 针对特定应用的设置
|
||||
app_options:
|
||||
firefox.exe:
|
||||
inline_preedit: true # 行内显示预编辑区:规避 <https://github.com/rime/weasel/issues/946>
|
||||
# cmd.exe: # 带 .exe 的进程名:Weasel 15.0 及之前版本须小写; PR #1049 合并后释出的版本大小写不敏感
|
||||
# cmd.exe: # 带 .exe 的进程名:Weasel 15.0 及之前版本须小写
|
||||
# ascii_mode: true # 英文模式
|
||||
# conhost.exe:
|
||||
# ascii_mode: true
|
||||
|
||||
Reference in New Issue
Block a user