fix: v 模式的少许 Bug

This commit is contained in:
Dvel 2023-01-19 18:36:43 +08:00
parent 708522aeb6
commit ae9840446d
3 changed files with 33 additions and 38 deletions

View File

@ -3,12 +3,12 @@
-- 日期时间
-- 提高权重的原因:因为在方案中设置了大于 1 的 initial_quality导致 rq sj xq dt ts 产出的候选项在所有词语的最后。
function date_translator(input, seg, env)
local config = env.engine.schema.config
local date = config:get_string(env.name_space .."/date") or "rq"
local time = config:get_string(env.name_space .."/time") or "sj"
local week = config:get_string(env.name_space .."/week") or "xq"
local datetime = config:get_string(env.name_space .."/datetime") or "dt"
local timestamp = config:get_string(env.name_space .."/timestamp") or "ts"
local config = env.engine.schema.config
local date = config:get_string(env.name_space .. "/date") or "rq"
local time = config:get_string(env.name_space .. "/time") or "sj"
local week = config:get_string(env.name_space .. "/week") or "xq"
local datetime = config:get_string(env.name_space .. "/datetime") or "dt"
local timestamp = config:get_string(env.name_space .. "/timestamp") or "ts"
-- 日期
if (input == date) then
local cand = Candidate("date", seg.start, seg._end, os.date("%Y-%m-%d"), "")
@ -39,7 +39,7 @@ function date_translator(input, seg, env)
local cand = Candidate("week", seg.start, seg._end, "星期" .. weakTab[tonumber(os.date("%w") + 1)], "")
cand.quality = 100
yield(cand)
local cand = Candidate("week", seg.start, seg._end, "礼拜" .. weakTab[tonumber(os.date("%w") + 1)], "")
local cand = Candidate("week", seg.start, seg._end, "礼拜" .. weakTab[tonumber(os.date("%w") + 1)], "")
cand.quality = 100
yield(cand)
local cand = Candidate("week", seg.start, seg._end, "" .. weakTab[tonumber(os.date("%w") + 1)], "")
@ -150,9 +150,9 @@ end
-- 修改:不提升英文和中英混输的
function long_word_filter(input, env)
-- 提升 count 个词语,插入到第 idx 个位置,默认 2、4。
local config = env.engine.schema.config
local count = config:get_string(env.name_space .."/count") or 2
local idx = config:get_string(env.name_space .."/idx") or 4
local config = env.engine.schema.config
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 firstWordLength = 0 -- 记录第一个候选词的长度,提前的候选词至少要比第一个候选词长
@ -189,30 +189,25 @@ function long_word_filter(input, env)
end
end
-------------------------------------------------------------
-- 因为英文方案的 initial_quality 大于 1导致输入「va」时候选项是「van vain。。。」
-- 单字优先,候选项应改为「ā á ǎ à」
--
-- 不知道这个方法为什么不行啊???
-- function v_single_char_first_filter(input)
-- if (string.find(input, "v") == 1 and string.len(input) == 2) then
-- local l = {}
-- for cand in input:iter() do
-- if (utf8.len(cand.text) == 1) then
-- yield(cand)
-- else
-- table.insert(l, cand)
-- end
-- end
-- for cand in ipairs(l) do
-- yield(cand)
-- end
-- end
-- end
--
-- 反正是解决了,不知道怎么就解决了,就是最后多一个候选项,没多大影响。
function v_single_char_first_filter(input, seg)
if (string.find(input, "v") == 1 and string.len(input) == 2) then
yield(Candidate("", seg.start, seg._end, "", ""))
-- v 模式,单个字符优先
-- 因为设置了英文翻译器的 initial_quality 大于 1导致输入「va」时候选项是「van vain …… ā á ǎ à」
-- 把候选项应改为「ā á ǎ à …… van vain」让单个字符的排在前面
function v_filter(input, env)
local code = env.engine.context.input -- 当前编码
local l = {}
for cand in input:iter() do
if (cand.text == "Vs.") then -- 特殊情况处理
yield(cand)
end
-- 以 v 开头、2 个长度的编码、候选项为单个字符的,提到前面来。
if (string.len(code) == 2 and string.find(code, "v") == 1 and utf8.len(cand.text) == 1) then
yield(cand)
else
table.insert(l, cand)
end
end
for i, cand in ipairs(l) do
yield(cand)
end
end
-------------------------------------------------------------

View File

@ -6,7 +6,7 @@
schema:
schema_id: rime_ice
name: 雾凇拼音
version: "1.1.0"
version: "1.2.0"
author:
- Dvel
description: |
@ -60,7 +60,6 @@ engine:
translators:
- punct_translator
- script_translator
- lua_translator@v_single_char_first_filter # v 模式 symbols 优先(否则是英文优先)
- lua_translator@date_translator # 时间、日期、星期
- table_translator@custom_phrase # 自定义短语 custom_phrase.txt
- table_translator@melt_eng # 英文输入
@ -70,6 +69,7 @@ engine:
- lua_filter@long_word_filter # 长词优先
- simplifier@emoji # Emoji
- simplifier@traditionalize # 简繁切换
- lua_filter@v_filter # v 模式 symbols 优先(否则是英文优先)
- uniquifier # 去重

View File

@ -16,7 +16,7 @@
# 一些韵母前四位顺序改为「一声、二声、三声、四声、其他...」如输入 va 得到 ā á ǎ à
config_version: '2022-11-08'
config_version: '2023-01-19'
punctuator:
@ -202,7 +202,7 @@ punctuator:
'vy': [ȳ, ý, ỳ, ŷ, ẏ, ÿ, ẙ, ỹ, ʸ, ɏ, ỷ, ỵ, ƴ, ʎ, ỿ, ]
'vY': [Ȳ, Ý, Ỳ, Ŷ, Ẏ, Ÿ, Ỹ, ʏ, Ɏ, Ỷ, Ỵ, Ƴ, Ỿ ]
'vz': [ź, ž, ẑ, ż, ᶻ, ʐ, ᶼ, ʑ, ᶽ, ƶ, ẕ, ẓ, ᵶ, ȥ, ⱬ, ᶎ, ʒ, ᶾ, ǯ, ʓ, ƹ, ƺ, ᶚ, θ, ᶿ, ɀ, ꝣ]
'vZ': [Ź, Ž, Ẑ, Ż, , Ƶ, Ẕ, Ẓ, Ȥ, Ⱬ Ʒ, ᴣ, Ǯ, Ƹ, Ɀ, Ꝣ]
'vZ': [Ź, Ž, Ẑ, Ż, , Ƶ, Ẕ, Ẓ, Ȥ, Ⱬ, Ʒ, ᴣ, Ǯ, Ƹ, Ɀ, Ꝣ]
'vaa': [ꜳ]
'vAA': [Ꜳ]
'vae': [æ, ǣ, ǽ, ᵆ, ᴂ]