koreader / koreader

An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices
http://koreader.rocks/
GNU Affero General Public License v3.0
15.71k stars 1.22k forks source link

Japanese keyboard only types hiragana and doesnt have a kanji option #11588

Open aaronindhouse opened 3 months ago

aaronindhouse commented 3 months ago

Issue

Im not sure if this is intentional or not, but the japanese keyboard in koreader will only type hiragana when looking up words in the dictionary or when using the notepad. It is usable for searching dictionary words, but when wanting to write in a text file it would be great to be able to complete hiragana into the desired kanji. I can understand though if this is a somewhat difficult feature to build, the autocomplete feature for kanji seems like black magic.

Steps to reproduce

when typing on a phone keyboard, as you type out hiragana a menu will pop up above the keyboard and you can tab through the predicted kanji you may be typing and choose one. the keyboard in koreader only types the hiragana with no interface to choose the kanji you are typing.

crash.log (if applicable)

crash.log is a file that is automatically created when KOReader crashes. It can normally be found in the KOReader directory:

Android logs are kept in memory. Please go to [Menu] → Help → Bug Report to save these logs to a file.

Please try to include the relevant sections in your issue description. You can upload the whole crash.log file (zipped if necessary) on GitHub by dragging and dropping it onto this textbox.

If your issue doesn't directly concern a Lua crash, we'll quite likely need you to reproduce the issue with verbose debug logging enabled before providing the logs to us. To do so, from the file manager, go to [Tools] → More tools → Developer options, and tick both Enable debug logging and Enable verbose debug logging. You'll need to restart KOReader after toggling these on.

If you instead opt to inline it, please do so behind a spoiler tag:

crash.log ``` ```
Frenzie commented 3 months ago

Whatever it does is intentional. See https://github.com/koreader/koreader/pull/8372. Pinging @cyphar.

https://github.com/koreader/koreader/blob/ca8e9352ba962e48843cd1d86812e42bdade7708/frontend/ui/data/keyboardlayouts/ja_keyboard.lua#L1-L11

https://github.com/koreader/koreader/blob/ca8e9352ba962e48843cd1d86812e42bdade7708/frontend/ui/data/keyboardlayouts/ja_keyboard.lua#L25-L29

aaronindhouse commented 3 months ago

Wow, that was very fast, thanks for such a quick response!

I understand that that is intentional, that isn't what im talking about. If you use the built in kindle keyboard for example, as you type out hiragana, kanji will appear on the top of the keyboard and you choose what it is you are typing. for example

あげる this is all hiragana. As you type that there is a autocomplete that pops up above the keyboard so you can choose the kanji you want to use. The kanji is:

上げる

あげる should be written as 上げる but the keyboard has no autocomplete function to convert the proper hiragana to the kanji.

EDIT: here is an image of it on an iphone: unnamed

aaronindhouse commented 3 months ago

This explains how the japanese ime works on a very basic level: https://github.com/katahiromz/ImeStudy?tab=readme-ov-file

Frenzie commented 3 months ago

I understand that that is intentional, that isn't what im talking about. If you use the built in kindle keyboard for example, as you type out hiragana, kanji will appear on the top of the keyboard and you choose what it is you are typing. for example

I intended to convey that every single thing it does (give or take potential minor oversights, nothing of the sort you're talking about) is intentional. The links I provided are where to find more specific details and thoughts. Unless we're talking past each other: I don't mean intentional as a rejection, merely as a purposeful decision by @cyphar not to spend his time this way or that way.

aaronindhouse commented 3 months ago

Ah, ok, I understand. It does seem like a big step to implement that feature or a Japanese IME. It makes sense to implement at least the basic swipe hiragana keyboard first and it works wonderfully!

It does work for looking up entries in a dictionary etc. but the downside is in things like the vocabulary builder, it will only show you the hiragana instead of the kanji because it saves what you searched in the input field. It defeats the purpose of using the vocabulary builder if you can"t quiz yourself on the kanji and the builder only saves entries based on your input which in this case is only hiragana.

動物 食物 飲物 漢字 練習

Those are all the written words you would read in a book for an adult they are written in kanji. You usually only see hiragana only for words like these in books for children.

動物 どうぶつ 食物 たべもの 飲物 のみもの 漢字 かんじ 練習 れんしゅう

the words on the right are all you can type or write right now. It is enough to pull up the result you need on the left in the dictionary so it is partially functional, but isn't quite fully functional until you can use kanji with the keyboard. I understand if this is a feature on the back burner, but if you have some time please take a look. It would be amazing to have a fully functioning kanji input with the keyboard!

cyphar commented 3 months ago

The short version for the reason it's kana-only is that implementing an IME is a pretty big project and there isn't any existing IME we could re-use for that purpose. And since I'm the only person who worked on the feature in the first place, I suspect I'd be the one who'd have to implement it. Personally, I would prefer to spend my time actually reading Japanese rather than re-implementing something that has marginal use for most people (speaking personally, I use Anki for flashcards and use highlights to save sentences with unknown words -- so the only benefit for me would be making dictionary lookups slightly less annoying).

Even implementing the most basic version of an IME (look up the "current working segment" in the dictionary and let the user pick one of the results) would be unusable without at least a few more features (the ability to write inflected verbs like 食べられる for instance -- which would be non-trivial) and there is no mechanism for having a "working segment" with the current keyboard infrastructure in KOReader so that would also need to be implemented.

(FWIW, even the Chinese kanji keyboard for KOReader is also not based on readings but is instead based on strokes, even though readings are more consistent in Chinese and there is no kana so 送り仮名 placement is also not an issue.)

My original hope was that it would eventually be possible for KOReader to use the system keyboard (which, on Android, would have an IME) but there are very deep technical problems that make this impossible with KOReader's current architecture IIRC.

(And to be honest, I read physical books more often than I use KOReader these days...)

Frenzie commented 3 months ago

I don't think anyone's ever been motivated to investigate native Android integration more than cursorily, since for most of us our main focus is Kobo or Kindle. For more details see https://github.com/koreader/koreader/issues/7423#issuecomment-802171037

weijiuqiao commented 2 months ago

Quick tip from the person who made the Chinese keyboard. In case of an "emergency", you can actually use the stroke-based Chinese keyboard to type out the characters you need. It’s not the simplified one that uses pinyin, but the one that’s purely based on strokes (as mentioned above). For instance, to input the character “上”, you would type the sequence 丨一 一.

cyphar commented 2 months ago

Quick tip from the person who made the Chinese keyboard. In case of an "emergency", you can actually use the stroke-based Chinese keyboard to type out the characters you need. It’s not the simplified one that uses pinyin, but the one that’s purely based on strokes (as mentioned above). For instance, to input the character “上”, you would type the sequence 丨一 一.

Unfortunately Japanese stroke order is different to Chinese in quite a few cases (必ず for instance), but yes that would work in a pinch. 😅

For an idea of how complicated a decent IME is to implement, see Google's mozc. I suspect it would be possible to implement a single-word inflection-based IME using nothing but our current dictionary infrastructure (and implementing an inflection system to reverse deinflection) but I really don't have any time to spend on this.