1. 如何处理自己以前保存的自定义短语
直接打开 Excel 或 WPS表格 来处理:
用记事本打开 phrases.ini,全选复制,粘贴到 Excel 的 A 列。
使用 “数据” -> “分列” 功能,以 逗号(,) 和 等号(=) 为分隔符。
你会得到三列:
A列:缩写 (如 jq)
B列:位置 (如 1)
C列:内容 (如 经常)
调整顺序: 在 D 列用公式 =C1&CHAR(9)&A1&CHAR(9)&B1 (CHAR(9) 是 Tab 键),或者手动把内容列换到最前面。
复制结果到 custom_phrase.txt 中即可。
避坑指南
Tab 是关键: Rime 的自定义短语文档必须用 Tab(制表符) 分隔,不能用空格,否则小狼毫会报错。
编码: 转换出的文档一定要确认是 UTF-8 编码,Windows 默认的 ANSI 编码会导致乱码。
2. 如何启用自定义短语
在用户文档夹中找到 default.custom.yaml 或者你正在使用的输入法皮肤配置文档(如 luna_pinyin.simple.custom.yaml)。
在 patch: 下方添加以下配置(注意缩进):
YAML
patch:
"engine/translators/+" :
- table_translator@custom_phrase
custom_phrase:
dictionary: ""
user_dict: custom_phrase
db_class: stabledb
enable_completion: false
enable_sentence: false
initial_quality: 1000 # 这里的数字大一些,确保短语排在第一位
第四步:重新部署
右键点击任务栏的小狼毫图标。
选择 “重新部署” (Deploy)。
等待几秒钟,试着输入你定义的缩写,看看短语是否已经生效
3. 如何开启v模式?
新建或修改luna_pinyin_simp.custom.yaml
# luna_pinyin_simp.custom.yaml
patch:
# 1. 内核引擎处理器
engine/processors:
- ascii_composer
- recognizer
- key_binder
- speller
- punctuator
- selector
- navigator
- express_editor
# 2. 翻译器顺序:确保 script_translator 在前保证中文正常
engine/translators:
- punct_translator
- script_translator
- lua_translator@v_eng_translator
- table_translator@custom_phrase
# 3. 匹配规则:允许 v 后面跟字母、数字、点、@等符号
recognizer/patterns:
v_eng: "^v[a-zA-Z0-9.@_-]*$"
# 4. 解决小键盘导致输入框消失的问题
# 将小键盘数字映射为普通数字输入,避免触发“选词”逻辑
key_binder/bindings:
- { when: composing, accept: KP_0, send: 0 }
- { when: composing, accept: KP_1, send: 1 }
- { when: composing, accept: KP_2, send: 2 }
- { when: composing, accept: KP_3, send: 3 }
- { when: composing, accept: KP_4, send: 4 }
- { when: composing, accept: KP_5, send: 5 }
- { when: composing, accept: KP_6, send: 6 }
- { when: composing, accept: KP_7, send: 7 }
- { when: composing, accept: KP_8, send: 8 }
- { when: composing, accept: KP_9, send: 9 }
- { when: composing, accept: KP_Decimal, send: "." }
新建rime.lua
function v_eng_translator(input, seg)
if input:match("^v[a-zA-Z0-9.@_-]*$") then -- 只处理v+纯英文
local eng_str = input:sub(2) -- 去掉第一个字符v
yield(Candidate("v_eng", seg.start, seg._end, eng_str, "英文模式"))
end
end
修改 default.custom.yaml
添加
patch:
engine:
translators:
- lua_translator@v_eng_translator
No comments:
Post a Comment