Feat: Accessbilities to Dictionary & UserDictionary #80
Feat: Accessbilities to Dictionary & UserDictionary #80hchunhui merged 27 commits intohchunhui:masterfrom
Conversation
hchunhui
left a comment
There was a problem hiding this comment.
Thanks for your contribution! Please see my comments below.
| namespace MemoryReg { | ||
| using SyllableId = int32_t; // copy from rime/vocabulary.h | ||
|
|
||
| class LuaMemory : public Memory { |
There was a problem hiding this comment.
I'm not familiar with Memory. Can you add a example script to demo how to use it?
There was a problem hiding this comment.
here's my demo script for memory right now;
mem = Memory(env.ticket)
mem:dictLookup("onf",false)
while (mem:dictResultExhausted() != false)
do
dict_entry = mem:dictPeek()
print(dict_entry.text)
print(dict_entry.weight)
print(dict_entry.preedit)
print(dict_entry.comment)
...
endThere was a problem hiding this comment.
I'm not familiar with
Memory. Can you add a example script to demo how to use it?
I'm about to write a doc about librime-Lua, and I will add the usage of Memory and other components to the doc
There was a problem hiding this comment.
Can we wrap the dict class directly instead of the Memory class? In the example, the Memory object is only used to iterator a dict. I still want to know what Memory is.
There was a problem hiding this comment.
Okay. Memory class is a set of dictionary and UserDictionary for this schema, but there's more.
Memory has a method named memorize it is a callback of commit() and CommitEntry which contains Histories of committed DictEntry would be passed to it. CommitEntry would help to record commits to UserDictionary.
I discovered it recently, so I am trying to write a Lua callback and pass commitEntry to the lua right now.
It might help lua users to handle Userdictionary well.
There was a problem hiding this comment.
Memory mostly did a lot of job handling UserDictionary for Userdictionary recording needs time tick which is handled by methods like StartSession FinishSession or receiving deleted entry from FrontEnd or stops recording entry when facing unhandled key.
I think If users want to build a completed translator, some methods of handling Userdictionary is necessary.
|
My target is to build a competed translator via Lua. |
|
Accessing other schema's dictionary required a custom schema, so I add a |
|
documents are reday now |
|
Looks good! I will try building and running the code. |
thanks! BTW, could you check out this document, any improvement? |
|
Just add a example of Memory. |
|
I found there's a problem that Lua using simpleCandidate which would probably disable memorize callback memory. |
|
The new following commit implemented a ways of associate phrase! |
- eliminate global vars - add proper return value - add some comments
|
@ZenamLeong Sorry for the late reply. Today I have tried and reviewed your code, and I have added some commits (fix some memory bugs, rewrite some code, etc.). Please see the commit logs. Feel free to revert or fix them if I'm wrong. I'm willing to merge the code, but there are still some issues:
|
|
|
@TsinamLeung Thanks for your contribution! My plan is to merge the pull request next week, to allow other works based on it. If you have no further fixes, I will delete |
ok thank you for reply, |
Signed-off-by: shewer <shewer@gmail.com>
Signed-off-by: Shewer Lu <shewer@gmail.com>
#77
Features that can access Dictionary & userdictionary
user could update the userDictionary with specified arguments