This commit is contained in:
Dvel 2023-04-20 09:38:32 +08:00
parent c3cf9b7028
commit 0dc60fb756

View File

@ -10,17 +10,6 @@ function date_translator(input, seg, env)
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 == "s" then
-- local cand = Candidate("date", seg.start, seg._end, ("%.f"):format(collectgarbage('count')), "")
-- cand.quality = 100
-- yield(cand)
-- end
-- if input == "xxx" then
-- collectgarbage()
-- local cand = Candidate("date", seg.start, seg._end, "collectgarbage()", "")
-- cand.quality = 100
-- yield(cand)
-- end
-- 日期
if (input == date) then
local cand = Candidate("date", seg.start, seg._end, os.date("%Y-%m-%d"), "")
@ -172,10 +161,10 @@ function long_word_filter(input, env)
local i = 1
for cand in input:iter() do
-- 找齐了或者 l 太大了,就不找了
if (s == count) or (#l > 100) then
break
end
-- 找齐了或者 l 太大了,就不找了
if (s == count) or (#l > 50) then
break
end
local leng = utf8.len(cand.text)
if (firstWordLength < 1 or i < idx) then
i = i + 1
@ -191,9 +180,15 @@ function long_word_filter(input, env)
for _, cand in ipairs(l) do
yield(cand)
end
for cand in input:iter() do
yield(cand)
end
for cand in input:iter() do
yield(cand)
end
-- 如果内存大于 5000 的话GC 一次,最小间隔 60s
-- if collectgarbage('count') > 5000 and (os.time() - last_gc_time) > 60 then
-- collectgarbage("collect")
-- last_gc_time = os.time()
-- end
end
-------------------------------------------------------------
-- 降低部分英语单词在候选项的位置