Skip to content
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

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

shewer
Copy link
Contributor

@shewer shewer commented Jun 4, 2024

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

  • Done

Manual test

  • Done

Code Review

  1. Unit and manual test pass
  2. GitHub Action CI pass
  3. At least one contributor reviews and votes
  4. Can be merged clean without conflicts
  5. PR will be merged by rebase upstream base

Additional Info

shewer added 30 commits January 20, 2023 16:48
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
@LEOYoon-Tsaw
Copy link
Member

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?

@shewer
Copy link
Contributor Author

shewer commented Jun 5, 2024

that can eazily create translator from other schema ,
just add lua_translator@....

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
   ...

@LEOYoon-Tsaw
Copy link
Member

Why not just write the translator directly?

@shewer
Copy link
Contributor Author

shewer commented Jun 5, 2024

Why not just write the translator directly?

Why not just write the translator directly?
可以在 script 中對 Phrase 再處理

如 a?cd 產生 aacd abcd accd .... 多個 translation 合併送出
或 對 Phrase candidate 的 comment preedit text 再次加工
或 拋棄

在lua 中使用現成 translator 就可以省去再處理 userdict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants