update lua
This commit is contained in:
parent
117d779105
commit
558fcf7246
22
rime.lua
22
rime.lua
@ -199,27 +199,31 @@ function reduce_english_filter(input, env)
|
|||||||
env.idx = config:get_int(env.name_space .. "/idx") -- 要插入的位置
|
env.idx = config:get_int(env.name_space .. "/idx") -- 要插入的位置
|
||||||
end
|
end
|
||||||
if not env.words then
|
if not env.words then
|
||||||
env.words = {} -- 要过滤的词 ,使用hash table
|
env.words = {} -- 要过滤的词
|
||||||
-- for old version
|
local list = config:get_list(env.name_space .. "/words")
|
||||||
local list_size = config:get_list_size(env.name_space .. "/words")
|
|
||||||
for i = 0, list.size - 1 do
|
for i = 0, list.size - 1 do
|
||||||
local word = config:get_string(env.name_space .. "/words/@" .. i)
|
local word = list:get_value_at(i).value
|
||||||
env.words[word]=true
|
env.words[word] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- filter start
|
-- filter start
|
||||||
local code = env.engine.context.input
|
local code = env.engine.context.input
|
||||||
if env.words[code] then
|
if env.words[code] then
|
||||||
-- 交換 1 2 順序
|
local l = {}
|
||||||
local l ={}
|
|
||||||
for cand in input:iter() do
|
for cand in input:iter() do
|
||||||
table.insert(l, cand)
|
table.insert(l, cand)
|
||||||
if #l >=2 then break end
|
if #l >= env.idx then
|
||||||
|
break
|
||||||
end
|
end
|
||||||
for i=#l,1,-1 do
|
end
|
||||||
|
-- 先 yield 汉字,再把英文放到后面
|
||||||
|
for i = 2, #l do
|
||||||
yield(l[i])
|
yield(l[i])
|
||||||
end
|
end
|
||||||
|
yield(l[1])
|
||||||
end
|
end
|
||||||
|
|
||||||
-- yield other
|
-- yield other
|
||||||
for cand in input:iter() do
|
for cand in input:iter() do
|
||||||
yield(cand)
|
yield(cand)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user