librime-lua
librime-lua copied to clipboard
可以加入 sqlite3 插件嗎
最近在做 英文字典 發現 方向有點錯誤 把碼全放在 filter身上 如果 支援 sqlite 可以簡單實現 lua_translator
另外 filter 有iter() 功能 此func 是否能在 在lua_translator 使用 ,是否要自行實現 iter 的功能??
一般都會 整出表再 yield 這樣 時間就拖在 查表上 ,邊查邊上效率應該比較好
local function _iter_match_func_(tab, str, func )
local iter,tab,index = ipairs(tab)
return function()
for i,v in iter ,tab, index do
index = i -- keep index for next start from index+1
if v:lower():match( str ) then
return func(v)
end
end
return nil
end
end
function lua_translator_func( input, seg,env)
for text,commet in iter_match_func(tab, input, func)
end
end
用 coroutine.wrap 也可以 且方便 , 提速不少
function iter()
return function()
for i=1,10 do
coroutine.yield(i)
end
return nil
end
end
for value in iter() do
print(value)
end