fix: is_in_user_dict (#741)

支持 table_translator 造出的用户词。
This commit is contained in:
HC 2024-03-17 23:32:11 +08:00 committed by GitHub
parent 4ffe642c9b
commit 6f28f3dbb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,19 +7,18 @@ local M = {}
function M.init(env)
local config = env.engine.schema.config
env.name_space = env.name_space:gsub('^*', '')
M.is_in_user_dict = config:get_bool(env.name_space)
M.is_in_user_dict = config:get_bool(env.name_space) or nil
end
function M.func(input, env)
local is_user = {
user_table = true,
user_phrase = true,
}
function M.func(input)
for cand in input:iter() do
if M.is_in_user_dict then
if cand.type == "user_phrase" then
cand.comment = cand.comment .. '*'
end
else
if cand.type ~= "user_phrase" then
cand.comment = cand.comment .. '*'
end
if is_user[cand.type] == M.is_in_user_dict then
cand.comment = cand.comment .. '*'
end
yield(cand)
end