Getting more data from the Japanese IME

2019-04-12 18:04发布

问题:

In my c# form I have a data grid view where I want to input both kanji and kana version of a word or sentence, putting them in different columns. For example:

転寝 | うたたね
寝坊 | ねぼう

What I want to achieve is having the second column automatically filled when I commit on the first one. I know there are dictionaries containing kanji readings but for sentences it gets complicated, and also there are many kanji with more than one reading. What I know is that the IME has both informations because while typing I first use hiragana and then convert it to kanji so, is there a way to get the original input of the user?

回答1:

Unfortunately I'm pretty sure you can't get anymore information from the IME. As I understand it, they are designed in such a way to not enter in anything before the user has selected the correct kana/kanji.

I had a play with a WinForms app hooking up any events that looked promising and came back with nothing. The input is handled by the OS and handed back to the application once the selection is made.

I would suggest doing what you don't want to do and grabbing JMDict or something similar and building an internal database containing the furigana. On top of this you could implement your own IME in .NET that accepts English character input and acts as a traditional IME does.

Alternatively you could change your application to be web based and use an existing javascript IME library like this one which will allow you to grab the hiragana before it is converted.