-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loading configuration from ticket.schema to support loading from other schema.yaml #886
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
I don't understand why this is needed. You can load the dict, reverse dict already, why would you load another schema with Lua? For example? |
that can eazily create translator from other schema , lua_api Compoment.Translator will overwrite ticket.schema // lua api
Ticket ticket(engine, ns); // ticket.schema = engine->schema();
ticket.schema = Schema( schema_id) -- user_data_dir/lua/script_translator.lua
-- Component.Translator will overwrite ticket.schema
-- args: (engine, ns, comp_name)
-- (engine, schema, ns , comp_name)
local T ={}
function T.init(env)
env.tran = Component.Translator(env.engine,
Schema('luna_pinyin'), env.name_space ,
'script_translatore')
-- create script_translator from build/luna_pinyin.schema.yaml:translator
end
function T.func(inp, seg, env)
local translation = env.tran:query(inp, seg)
if translation then
for cand in translation:iter() do
yield(cand)
end
end
end
return T engine/translators:
- lua_translator@*script_translator@translator
# auto load script_translator.lua , name_space = translator
- table_translator # cangjie5.schema
... |
Why not just write the translator directly? |
如 a?cd 產生 aacd abcd accd .... 多個 translation 合併送出 在lua 中使用現成 translator 就可以省去再處理 userdict |
Pull request
to support librime-lua api (Component.Translator )
loading configuration form other schema file
ex:
Component.Translator(env.engine, Schema('cangjie5'), 'translator', 'table_translator')
Issue tracker
Fixes will automatically close the related issue
Fixes #
Feature
Describe feature of pull request
Unit test
Manual test
Code Review
Additional Info