Closed apua closed 7 years ago
由於這個 repo 是中文輸入法,目前也還沒有英語人士加入,我先用中文回應,確保意思不會被誤解~
@apua: 我在 ime.vim 裡面做了以下的 mapping:
inoremap <expr> <CR> (pumvisible() ? "<C-Y>" : "") . "<CR>"
這會使得 <CR>
無論如何都會輸出一個換行
如果改成
inoremap <expr> <CR> (pumvisible() ? "<C-Y>" : "<CR>")
的話,就會符合你的預期,也比較符合 vim 的預設行為
當初會特別去 mapping 它是要修某個 bug,但已經忘記確切的原因了,我去 ime.vim 那裡調整一下
vim 的 popup menu 對 [<Up>
/ <Down>
] 和 [<C-n>
/ <C-p>
] 的反應不太一樣:
<Up>
/ <Down>
以後,選項並不會真的插入編輯區,要按下 <CR>
才會<C-n>
/ <C-p>
以後,選項立刻就會插入編輯區你覺得把 <Up>
/ <Down>
remapping 成 <C-n>
/ <C-p>
是個好主意嗎?
:editor: Vim 8.0 :os: FreeBSD
<C-n>
/<C-p>
-- works fine<Up>
/<Down>
and press <CR>
(enter) -- doesn`t add newline , unlike behavior on MacI think it is unnecessary to remap <Up>
/<Down>
currently.
Writing down the usage is more important; basically, software cannot be tested without specification.
Besides, in my opinion, making inputting sentences quickly with less typing has higher priority than remapping <Up>
/<Down>
.
For inputting a single Chinese character, I think the issue could be closed; for inputting sentences, what do you think?
-- ps: why I type in English is not for another people but just a practice
Before your second comment (the :os: FreeBSD
one), I changed the <CR>
behavior in ime.vim
, so please check if ime.vim
version is 0.30.2 on both side~
I updated <Up>
/ <Down>
/ <CR>
and <C-n>
/ <C-p>
information in README, and decide not to remapping <Up>
and <Down>
to let user have choices.
Currently I have no god idea for inputting sentences. Even inputting words (詞) is implemented by add a huge database now. Learning (more frequent words float to the top) is another topic I have no idea now 😛
Maybe this helps: https://blog.timc.idv.tw/posts/javascript-chinese-ime/
Sentences-inputting is a must-have feature. To implement this, maybe we need to add word occurrence frequency information into database.
It comes to me that rime
is server/client architecture, perhaps it's the right way to go if we want to do smart-input (long sentences, learning, etc.)
jieba has word occurrence frequency information: https://github.com/ldkrsi/jieba-zh_TW/tree/master/jieba /dict.txt
Planning to rebuild database.
Data source:
Extract pronouncing information from moedict and McBopomofo. Extract word frequency information from jieba and McBopomofo.
[Status] Rebuilding database with McBopomofo data: https://github.com/pi314/phonetic-table/commit/13c1e0b2435cd9780479cd31d8a87d1e5affb389 This time I write a Makefile to make sure that it is rebuildable and patchable in the future. Not finished yet, but it's closed.
[Planning] After database built, a new word selection algorithm should be implemented.
The current algorithm is greedy. For example, given phonetic codes:
A B C D E
It first tries A
; if ok, try AB
; if ok, try ABC
, and so on.
If in anyone step the word does not exist, e.g. ABC
does not exist, then previous result is used (i.e. AB
).
The remaining phonetic codes (C D E
) is used to search all over again.
One of the cons of this method is that if AB
, ABC
and CDE
are valid words, CDE
will never be considered because ABC
always being picked up.
With word occurrence information, a smarter algorithm is possible.
Instead of searching all possibilities (O(2^n)
), I think we can use DP (Dynamic Programming).
The problem will be reduced to the rod-cutting problem (O(n^3)
).
YAY f6122e0
Closed by #17. Finally, this plugin begins to be usable.
@apua I think you can input sentences now. The sentences will not be accurate, but it's another issue.
At least ㄨㄛˇㄕˋㄋㄧˇㄅㄚˋㄑㄩˋㄇㄞˋㄏㄨㄛˇㄔㄞˊ
really generates 我是你爸去賣火柴
with current database :tada:
:editor: Vim 8.0 :os: Mac
I failed to input a sentence nor a Chinese character.
Failed to input a sentence
The state of typing "ji3g4su3184fm4a94cji3t96" is as shown below
It doesn't translate to Chinese characters in addition to first term.
Failed to input a Chinese character
After input a term of phonetic symbols as below, I want to select one to output
However, neither input "space" nor "enter" are expected result:
input "enter" -- get newline
input "space" -- doesn't translate
If the fact is I misunderstand the usage of
ime-phonetic.vim
, then the problem might be improvement of guide.