config: 将长词优先的配置放到方案中。

This commit is contained in:
Dvel 2022-11-09 15:57:06 +08:00
parent 260460bf13
commit d35692af54
2 changed files with 33 additions and 21 deletions

View File

@ -139,10 +139,12 @@ end
-- 长词优先(提升「西安」「提案」「图案」「饥饿」等词汇的优先级) -- 长词优先(提升「西安」「提案」「图案」「饥饿」等词汇的优先级)
-- 感谢&参考于: https://github.com/tumuyan/rime-melt -- 感谢&参考于: https://github.com/tumuyan/rime-melt
-- 修改:不提升英文和中英混输的 -- 修改:不提升英文和中英混输的
function long_word_filter(input) function long_word_filter(input, env)
-- 目前的效果:将 2 个词插入到第 4、5 个候选项 -- 提升 count 个词语,插入到第 idx 个位置,默认 2、4。
local count = 2 -- 提升 count 个词语 local config = env.engine.schema.config
local idx = 4 -- 插入到第 idx 位 local count = config:get_string(env.name_space .."/count") or 2
local idx = config:get_string(env.name_space .."/idx") or 4
local l = {} local l = {}
local firstWordLength = 0 -- 记录第一个候选词的长度,提前的候选词至少要比第一个候选词长 local firstWordLength = 0 -- 记录第一个候选词的长度,提前的候选词至少要比第一个候选词长
@ -152,7 +154,7 @@ function long_word_filter(input)
local i = 1 local i = 1
for cand in input:iter() do for cand in input:iter() do
leng = utf8.len(cand.text) leng = utf8.len(cand.text)
if (firstWordLength < 1 or i < idx) then if (firstWordLength < 1 or i < tonumber(idx)) then
i = i + 1 i = i + 1
firstWordLength = leng firstWordLength = leng
yield(cand) yield(cand)
@ -167,7 +169,7 @@ function long_word_filter(input)
-- end -- end
-- 换了个正则,否则中英混输的也会被提升 -- 换了个正则,否则中英混输的也会被提升
-- elseif ((leng > firstWordLength) and (s2 < count)) and (string.find(cand.text, "^[%w%p%s]+$")==nil) then -- elseif ((leng > firstWordLength) and (s2 < count)) and (string.find(cand.text, "^[%w%p%s]+$")==nil) then
elseif ((leng > firstWordLength) and (s2 < count)) and (string.find(cand.text, "[%w%p%s]+") == nil) then elseif ((leng > firstWordLength) and (s2 < tonumber(count))) and (string.find(cand.text, "[%w%p%s]+") == nil) then
yield(cand) yield(cand)
s2 = s2 + 1 s2 = s2 + 1
else else

View File

@ -6,7 +6,7 @@
schema: schema:
schema_id: rime_ice schema_id: rime_ice
name: 雾凇拼音 name: 雾凇拼音
version: "1.0.2" version: "1.0.3"
author: author:
- Dvel - Dvel
description: | description: |
@ -38,8 +38,8 @@ switches:
# 输入引擎 # 输入引擎
engine: engine:
processors: processors:
- lua_processor@select_character # 以词定字 - lua_processor@select_character # 以词定字
- lua_processor@code_length_limit_processor@code_length_limit # 限制码长 - lua_processor@code_length_limit_processor # 限制码长
- ascii_composer - ascii_composer
- recognizer - recognizer
- key_binder - key_binder
@ -69,8 +69,15 @@ engine:
- uniquifier # 去重 - uniquifier # 去重
# 限制码长,默认 100。最多能输入 code_length_limit 个字符) # 限制码长,默认 100。最多能输入的字符个数
code_length_limit: 100 code_length_limit_processor: 100
# 长词优先,提升 count 个词语,插入到第 idx 个位置,默认 2、4。
# 示例:将 2 个词插入到第 4、5 个候选项,输入 jie 得到「1接 2解 3姐 4饥饿 5极恶」
long_word_filter:
count: 2
idx: 4
# 从 default 继承快捷键 # 从 default 继承快捷键
@ -99,7 +106,7 @@ custom_phrase:
db_class: stabledb db_class: stabledb
enable_completion: false # 补全提示 enable_completion: false # 补全提示
enable_sentence: false # 禁止造句 enable_sentence: false # 禁止造句
initial_quality: 99 # custom_phrase 的权重应该比 pinyin 和 melt_eng 大 initial_quality: 99 # custom_phrase 的权重应该比 pinyin 和 melt_eng 大
# 引入八股文 # 引入八股文
@ -123,17 +130,20 @@ translator:
# 英文 # 英文
melt_eng: melt_eng:
dictionary: melt_eng dictionary: melt_eng
spelling_hints: 9
enable_completion: true # 补全提示 enable_completion: true # 补全提示
enable_sentence: false # 禁止造句 enable_sentence: false # 禁止造句
enable_user_dict: false # 禁用用户词典 enable_user_dict: false # 禁用用户词典
initial_quality: 1.1 initial_quality: 1.1
# 引入自己的修改过的 symbols # 标点符号
# 预设的 punctuation.yaml 包含了 full_shape half_shape (全角和半角的符号映射)
# 预设的 symbols.yaml 包含了 full_shape half_shape symbols
# symbols 的功能是支持以「/」前缀开头输出一系列字符,自定义的 symbols_custom.yaml 修改成了「v」开头。
punctuator: punctuator:
# import_preset: symbols # import_preset: punctuation | symbols # 从应用目录引入自带的默认配置
import_preset: symbols_custom # 标点符号和 v 模式在里面 import_preset: symbols_custom # 从 symbols_custom.yaml 引入自己自定义的
# half_shape: # 也可以直接在这里配置
# 处理符合特定规则的输入码,如网址、反查 # 处理符合特定规则的输入码,如网址、反查
@ -146,15 +156,15 @@ recognizer:
win_path: "^[A-Za-z]:.*" # 支持 c:\file\path 之类的路径输入 win_path: "^[A-Za-z]:.*" # 支持 c:\file\path 之类的路径输入
colon: "^[A-Za-z]+:.*" # 上面的超集,冒号在句子中不直接上屏 colon: "^[A-Za-z]+:.*" # 上面的超集,冒号在句子中不直接上屏
# punct: "^/([0-9]+[a-z]*|[a-z]+)$" # punct: "^/([0-9]+[a-z]*|[a-z]+)$"
punct: "^v([0-9]|10|[A-Za-z]+)$" # 响应 punctuator/symbols(symbols_custom.yaml) 用「v」替换「/」并支持大写 punct: "^v([0-9]|10|[A-Za-z]+)$" # 响应 symbols_custom.yaml 下的 punctuator/symbols用「v」替换「/」并支持大写
reverse_lookup: "^u[A-Za-z]+$" # 响应两分的反查 reverse_lookup: "^u[a-z]+$" # 响应两分的反查
# 反查:两分(拼字) # 反查:两分(拼字)
liangfen: liangfen:
dictionary: liangfen dictionary: liangfen
prefix: "u" # 以 u 开头来反查 prefix: "u" # 以 u 开头来反查
enable_completion: true # 补全提示 enable_completion: true # 补全提示
# tips: 〔两分〕 # tips: 〔两分〕
@ -242,7 +252,7 @@ speller:
- derive/([ypfm])ou$/$1uo/ - derive/([ypfm])ou$/$1uo/
# uo # uo
# an # an
- derive/([wrtypsfghklzcbnm])an$/$1na/ # 去掉了 n不转换常用单词 DNA - derive/([wrtypsdfghklzcbnm])an$/$1na/
# en # en
- derive/([wrpsdfghklzcbnm])en$/$1ne/ - derive/([wrpsdfghklzcbnm])en$/$1ne/
# ang # ang