fix: reduce_english_filter.lua 可识别含单引号的单词 close #519

This commit is contained in:
Dvel
2023-10-17 02:32:06 +08:00
parent 649f4935b8
commit a219451708
8 changed files with 12 additions and 12 deletions

View File

@@ -8,7 +8,7 @@ function M.init(env)
local config = env.engine.schema.config
env.name_space = env.name_space:gsub("^*", "")
M.idx = config:get_int(env.name_space .. "/idx") -- 要插入的位置
M.words = {} -- 要过滤的词
M.words = {} -- 要过滤的词
local list = config:get_list(env.name_space .. "/words")
for i = 0, list.size - 1 do
local word = list:get_value_at(i).value
@@ -24,11 +24,11 @@ function M.func(input, env)
local index = 0
for cand in input:iter() do
index = index + 1
-- 定位匹配的英文词
if not string.find(cand.preedit, " ") and not string.match(cand.text, "%A") then
table.insert(pending_cands, cand)
else
-- 找到要降低的英文词,加入 pending_cands
if cand.preedit:find(" ") or not cand.text:match("^[%a']+$") then
yield(cand)
else
table.insert(pending_cands, cand)
end
if index >= M.idx + #pending_cands - 1 then
for _, cand in ipairs(pending_cands) do