librime-lua
librime-lua copied to clipboard
增加 Component::Require 配合 ticket 建立 component 是否可行
之前想說 建 TableTranslatorREG compile 過不了 通過 Require 把己可用 component 包入lua 再整合
是不是利用 Require 和 Create 來取得 容昜多了 加上 ConfigItem List Map Value
新增 修改 schema 變容昜了
Translator::Require("table_translator")->Create("translator" )
text(In) ->[ Translator ]->(out) translation --> [ filter ] -translation
lua_translator local t1 =table_translator( input,seg) for cand = t1:itor() do yield(cand)
end
end
------
src/rime/dict/user_db.h:51: return dynamic_cast<Component*>(Db::Require(name));
sample/test/trivial_translator_test.cc:20: auto component = Translator::Require("trivial_translator");
src/rime_api.cc:661: Config::Component* cc = Config::Require(config_component);
src/rime/deployer.cc:28: auto c = DeploymentTask::Require(task_name);
src/rime/deployer.cc:42: auto c = DeploymentTask::Require(task_name);
src/rime/dict/user_db_recovery_task.cc:62: UserDb::Component* component = UserDb::Require("userdb");
src/rime/dict/user_dictionary.cc:151: auto task = DeploymentTask::Require("userdb_recovery_task");
src/rime/dict/user_dictionary.cc:528: auto component = Db::Require(db_class);
src/rime/engine.cc:307: if (auto c = Processor::Require(ticket.klass)) {
src/rime/engine.cc:324: if (auto c = Segmentor::Require(ticket.klass)) {
src/rime/engine.cc:341: if (auto c = Translator::Require(ticket.klass)) {
src/rime/engine.cc:358: if (auto c = Filter::Require(ticket.klass)) {
src/rime/engine.cc:368: if (auto c = Formatter::Require("shape_formatter")) {
src/rime/engine.cc:376: if (auto c = Processor::Require("shape_processor")) {
src/rime/gear/ascii_composer.cc:181: the<Config> preset_config(Config::Require("config")->Create("default"));
src/rime/gear/memory.cc:54: if (auto dictionary = Dictionary::Require("dictionary")) {
src/rime/gear/memory.cc:60: if (auto user_dictionary = UserDictionary::Require("user_dictionary")) {
src/rime/gear/poet.cc:78: if (auto* grammar = Grammar::Require("grammar")) {
src/rime/gear/reverse_lookup_filter.cc:49: if (auto c = ReverseLookupDictionary::Require("reverse_lookup_dictionary")) {
src/rime/gear/reverse_lookup_translator.cc:119: if (auto component = Dictionary::Require("dictionary")) {
src/rime/gear/reverse_lookup_translator.cc:129: ReverseLookupDictionary::Require("reverse_lookup_dictionary");
src/rime/gear/script_translator.cc:168: if (auto* corrector = Corrector::Require("corrector")) {
src/rime/gear/unity_table_encoder.cc:26: auto c = ReverseLookupDictionary::Require("reverse_lookup_dictionary");
src/rime/lever/deployment_tasks.cc:72: the<Config> user_config(Config::Require("user_config")->Create("user"));
src/rime/lever/deployment_tasks.cc:178: the<Config> config(Config::Require("config")->Create("default"));
src/rime/lever/deployment_tasks.cc:223: auto schema_component = Config::Require("schema");
src/rime/lever/deployment_tasks.cc:250: the<Config> user_config(Config::Require("user_config")->Create("user"));
src/rime/lever/deployment_tasks.cc:350: config.reset(Config::Require("schema")->Create(schema_id));
src/rime/lever/deployment_tasks.cc:358: Dictionary::Require("dictionary")->Create({&schema, "translator"}));
src/rime/lever/deployment_tasks.cc:450: the<Config> config(Config::Require("config")->Create(file_name_));
src/rime/lever/deployment_tasks.cc:455: config.reset(Config::Require("config_builder")->Create(file_name_));
src/rime/lever/deployment_tasks.cc:516: auto legacy_userdb_component = UserDb::Require("legacy_userdb");
src/rime/lever/user_dict_manager.cc:25: user_db_component_(UserDb::Require("userdb")) {
src/rime/lever/user_dict_manager.cc:163: UserDb::Component* legacy_component = UserDb::Require("legacy_userdb");
src/rime/schema.cc:14: config_.reset(Config::Require("config")->Create("default"));
src/rime/schema.cc:21: Config::Require("config")->Create(schema_id.substr(1)) :
src/rime/schema.cc:22: Config::Require("schema")->Create(schema_id));
src/rime/switcher.cc:30: user_config_.reset(Config::Require("user_config")->Create("user"));
src/rime/switcher.cc:287: if (auto c = Processor::Require("key_binder")) {
src/rime/switcher.cc:294: if (auto c = Processor::Require("selector")) {
src/rime/switcher.cc:302: if (auto c = Translator::Require("schema_list_translator")) {
src/rime/switcher.cc:309: if (auto c = Translator::Require("switch_translator")) {
test/component_test.cc:51: Greeting::Component* h = Greeting::Require("test_hello");
test/component_test.cc:53: Greeting::Component* gm = Greeting::Require("test_morning");
test/config_test.cc:40: Config::Component* cc = Config::Require("test_config");
test/segmentor_test.cc:17: Segmentor::Component* component = Segmentor::Require("abc_segmentor");
test/segmentor_test.cc:31: Segmentor::Component* component = Segmentor::Require("abc_segmentor");
test/segmentor_test.cc:48: Segmentor::Component* component = Segmentor::Require("abc_segmentor");
例: lua_translator@table_translator < -- 替代 table_translator
function ini( env)
env.tr=Translator::Require("table_translator")->Create("translator)
end
--- table_translator ? 碼輸入 展開 a-z 26個 組合 text
function tran_func( input,segment,env)
local translations={}
for inp in next, tab_create(input) q do
table.insert ( trasnlatinos,env.tr(inp,segment) )
end
-- 把 translatorn.h 整合 translation 導入lua 或 自己 用 iter() 整
for cand in merge( translations):iter() do
yield(cand)
end
--
for tr_i in next, translations do
for cond in tr_i:iter() do
yield(cand)
end
end
-----
end
測試 OK 可用 Translator:Require("table_translator")->Create(ticket) 生 TableTranslator 但是 query( text,segment) 返迴的 translation
可行 , 但是不可以在 Lua_translator func 中 處理 translation:iter()
Translator.exhausted() 會提前中止跳離 func ,, 在跳離同時也是結束就不影嚮.
local function func(input,seg,env)
local translaton = translator:query(input,seg)
local translaton1= translator:query( "abc",seq)
for cand in translation:iter() do
yield(cand)
end
-------------- exit func -----以下無法處理--------
for cand in translation1:iter() do
yield(can)
end
end
-- ex2
local function func(input,seg,env)
local translaton1 = translator:query(input,seg)
local translaton2= translator:query( "abc",seq)
translaton1:append( translation1) -- <-- 未實現
for cand in translation1:iter() do
yield(cand)
end
end
-------------- exit func -----以下無法處理--------
end
``
看來真得再 實現 UnionTranslation MergedTranslation ......
.
己 Register 的component
➜ librime git:(master) ✗ grep -Rn "Register(" src/**/*.{h,cc}
src/rime/algo/calculus.h:33: void Register(const string& token, Calculation::Factory* factory);
src/rime/module.h:21: void Register(const string& name, RimeModule* module);
src/rime/registry.h:22: RIME_API void Register(const string& name, ComponentBase* component);
src/rime/algo/calculus.cc:18: Register("xlit", &Transliteration::Parse);
src/rime/algo/calculus.cc:19: Register("xform", &Transformation::Parse);
src/rime/algo/calculus.cc:20: Register("erase", &Erasion::Parse);
src/rime/algo/calculus.cc:21: Register("derive", &Derivation::Parse);
src/rime/algo/calculus.cc:22: Register("fuzz", &Fuzzing::Parse);
src/rime/algo/calculus.cc:23: Register("abbrev", &Abbreviation::Parse);
src/rime/algo/calculus.cc:26:void Calculus::Register(const string& token,
src/rime_api.cc:861: ModuleManager::instance().Register(module->module_name, module);
src/rime/core_module.cc:32: r.Register("config_builder", config_builder);
src/rime/core_module.cc:36: r.Register("config", config_loader);
src/rime/core_module.cc:37: r.Register("schema", new SchemaComponent(config_loader));
src/rime/core_module.cc:44: r.Register("user_config", user_config);
src/rime/dict/dict_module.cc:28: r.Register("tabledb", new DbComponent<TableDb>);
src/rime/dict/dict_module.cc:29: r.Register("stabledb", new DbComponent<StableDb>);
src/rime/dict/dict_module.cc:30: r.Register("plain_userdb", new UserDbComponent<TextDb>);
src/rime/dict/dict_module.cc:31: r.Register("userdb", new UserDbComponent<LevelDb>);
src/rime/dict/dict_module.cc:34: //r.Register("legacy_userdb", ...);
src/rime/dict/dict_module.cc:36: r.Register("corrector", new CorrectorComponent);
src/rime/dict/dict_module.cc:38: r.Register("dictionary", new DictionaryComponent);
src/rime/dict/dict_module.cc:39: r.Register("reverse_lookup_dictionary",
src/rime/dict/dict_module.cc:41: r.Register("user_dictionary", new UserDictionaryComponent);
src/rime/dict/dict_module.cc:43: r.Register("userdb_recovery_task", new UserDbRecoveryTaskComponent);
src/rime/gear/gears_module.cc:46: r.Register("ascii_composer", new Component<AsciiComposer>);
src/rime/gear/gears_module.cc:47: r.Register("chord_composer", new Component<ChordComposer>);
src/rime/gear/gears_module.cc:48: r.Register("express_editor", new Component<ExpressEditor>);
src/rime/gear/gears_module.cc:49: r.Register("fluid_editor", new Component<FluidEditor>);
src/rime/gear/gears_module.cc:50: r.Register("fluency_editor", new Component<FluidEditor>); // alias
src/rime/gear/gears_module.cc:51: r.Register("key_binder", new Component<KeyBinder>);
src/rime/gear/gears_module.cc:52: r.Register("navigator", new Component<Navigator>);
src/rime/gear/gears_module.cc:53: r.Register("punctuator", new Component<Punctuator>);
src/rime/gear/gears_module.cc:54: r.Register("recognizer", new Component<Recognizer>);
src/rime/gear/gears_module.cc:55: r.Register("selector", new Component<Selector>);
src/rime/gear/gears_module.cc:56: r.Register("speller", new Component<Speller>);
src/rime/gear/gears_module.cc:57: r.Register("shape_processor", new Component<ShapeProcessor>);
src/rime/gear/gears_module.cc:60: r.Register("abc_segmentor", new Component<AbcSegmentor>);
src/rime/gear/gears_module.cc:61: r.Register("affix_segmentor", new Component<AffixSegmentor>);
src/rime/gear/gears_module.cc:62: r.Register("ascii_segmentor", new Component<AsciiSegmentor>);
src/rime/gear/gears_module.cc:63: r.Register("matcher", new Component<Matcher>);
src/rime/gear/gears_module.cc:64: r.Register("punct_segmentor", new Component<PunctSegmentor>);
src/rime/gear/gears_module.cc:65: r.Register("fallback_segmentor", new Component<FallbackSegmentor>);
src/rime/gear/gears_module.cc:68: r.Register("echo_translator", new Component<EchoTranslator>);
src/rime/gear/gears_module.cc:69: r.Register("punct_translator", new Component<PunctTranslator>);
src/rime/gear/gears_module.cc:70: r.Register("table_translator", new Component<TableTranslator>);
src/rime/gear/gears_module.cc:71: r.Register("script_translator", new Component<ScriptTranslator>);
src/rime/gear/gears_module.cc:72: r.Register("r10n_translator", new Component<ScriptTranslator>); // alias
src/rime/gear/gears_module.cc:73: r.Register("reverse_lookup_translator",
src/rime/gear/gears_module.cc:75: r.Register("schema_list_translator", new Component<SchemaListTranslator>);
src/rime/gear/gears_module.cc:76: r.Register("switch_translator", new Component<SwitchTranslator>);
src/rime/gear/gears_module.cc:77: r.Register("history_translator", new Component<HistoryTranslator>);
src/rime/gear/gears_module.cc:80: r.Register("simplifier", new Component<Simplifier>);
src/rime/gear/gears_module.cc:81: r.Register("uniquifier", new Component<Uniquifier>);
src/rime/gear/gears_module.cc:83: r.Register("charset_filter", new Component<CharsetFilter>);
src/rime/gear/gears_module.cc:85: r.Register("cjk_minifier", new Component<CharsetFilter>); // alias
src/rime/gear/gears_module.cc:86: r.Register("reverse_lookup_filter", new Component<ReverseLookupFilter>);
src/rime/gear/gears_module.cc:87: r.Register("single_char_filter", new Component<SingleCharFilter>);
src/rime/gear/gears_module.cc:90: r.Register("shape_formatter", new Component<ShapeFormatter>);
src/rime/lever/levers_module.cc:27: r.Register("detect_modifications", new Component<DetectModifications>);
src/rime/lever/levers_module.cc:28: r.Register("installation_update", new Component<InstallationUpdate>);
src/rime/lever/levers_module.cc:29: r.Register("workspace_update", new Component<WorkspaceUpdate>);
src/rime/lever/levers_module.cc:30: r.Register("schema_update", new Component<SchemaUpdate>);
src/rime/lever/levers_module.cc:31: r.Register("config_file_update", new Component<ConfigFileUpdate>);
src/rime/lever/levers_module.cc:32: r.Register("prebuild_all_schemas", new Component<PrebuildAllSchemas>);
src/rime/lever/levers_module.cc:33: r.Register("user_dict_upgrade", new Component<UserDictUpgrade>);
src/rime/lever/levers_module.cc:34: r.Register("cleanup_trash", new Component<CleanupTrash>);
src/rime/lever/levers_module.cc:35: r.Register("user_dict_sync", new Component<UserDictSync>);
src/rime/lever/levers_module.cc:36: r.Register("backup_config_files", new Component<BackupConfigFiles>);
src/rime/lever/levers_module.cc:37: r.Register("clean_old_log_files", new Component<CleanOldLogFiles>);
src/rime/module.cc:13:void ModuleManager::Register(const string& name,
src/rime/registry.cc:13:void Registry::Register(const string &name, ComponentBase *component) {