Skip to content

Commit

Permalink
add sample projection.lua
Browse files Browse the repository at this point in the history
Signed-off-by: shewer <shewer@gmail.com>
  • Loading branch information
shewer committed Mar 31, 2021
1 parent a1c75a7 commit a4842ab
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions sample/projection.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

local function init_func(env)

local config=env.engine.schema.config
-- load ConfigList form path
local proedit_fmt_list = conifg:get_list("translastor/preedit_format")
-- print value
for i=0,proedit_fmt_list.size do
print(i, proedit_fmt_list:get_value_at(i).value)
end
-- create Projection obj
local p1=Projection()
p1:load(proedit_fmt_list)

-- user create Projection obj
local pfl2= ConfigList()
-- create ConfigValue & ConfigList ust isnert( index, ConfigValue) append()
local v1= ConfigValue("xlit|abc|xyz|")
pfl2:append(v1)
pfl2:append( ConfigValue("xlit|def|tuv|"))
pfl2:insert(1,ConfigValue("xlit|ghi|qrs|"))
local p2=Projection()
p2:load(pfl2)
local str1= "abcdefg"
--
print(str1 , p1:apply(str1), p2:apply(str1) )
--
env.p1=p1
env.p2=p2
end
local function func(input,seg,env)
for cand in input:iter() do
cand.comment= env.p1(cand.comment) .. env.p2(cand.comment)
yield(cand)
end
end


return { init=init_func, func=func }
--- rime.lua
-- projection_filter= require("projection.lua")
--
--
-- schema.yaml
-- insert to /engine/filter
-- lua_filter@projection_filter
--

0 comments on commit a4842ab

Please sign in to comment.