Quantcast
Channel: MobileRead Forums - Kobo Developer's Corner
Viewing all articles
Browse latest Browse all 1564

Implementing predictive text in English (sort of; let's discuss)

$
0
0
I'm not sure how many were aware, but when you switch your device to Japanese, you get access to a predictive text keyboard. Predictive text is important because Japanese has four different writing systems and text input is done phonetically through the Roman alphabet, so the system needs a way to translate those Roman letters to the appropriate kana or kanji (For example, there are many characters that can represent the syllable "ka" so predictive text allows you select which one you mean).

I find predictive text useful, so I wanted to see if it could be used for English words because the functionality is already there.

TL;DR: It sort of works when you replace the input method's dictionaries with English versions pulled from a PS Vita (screenshots attached) but only in the Japanese locale and as soon as you type in a valid Japanese syllable, it'll display hiragana or katakana suggestions (so that part must be built in) and makes it less useful as an English keyboard. But there's a proof-of-concept here.

Some notes about the Japanese keyboard:
  • There is a toggle to type in Japanese mode (default) or English mode (it's the second button from the bottom left).
  • Japanese mode has predictive text, English mode does not.
  • The keyboard/predictive text engine seems to be based on iWnn technology (which is also used on a variety of mobile devices such as Android, Playstation Vita and Nintendo Switch).
  • The Japanese keyboard dictionary files are located at /usr/local/Kobo/dic/JA.

This is what the JA directory looks like on the Kobo:

Code:

$ ls -Rl
.:
total 24
drwxrwxr-x+ 1 Reg Tiangha Reg Tiangha    0 Jun 11 12:57 32/
-rwxrwxr-x+ 1 Reg Tiangha Reg Tiangha 18817 May 31 13:16 njcon.a

./32:
total 4692
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha  82671 May 31 13:16 njexyomi.a
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha    9122 May 31 13:16 njexyomi_new.a*
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha  16717 May 31 13:16 njexyomi_re.a
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha    5785 May 31 13:16 njfzk.a
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha  81907 May 31 13:16 njtan.a
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha  516199 May 31 13:16 njubase1.a
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha 4071969 May 31 13:16 njubase2.a

I have a PS Vita, so I dumped the firmware and extracted the EN and JA dictionaries.

The JA directory structure is a bit different:

Code:

$ ls -Rl
.:
total 20
drwxrwxr-x+ 1 Reg Tiangha Reg Tiangha    0 Jun 11 10:58 16/
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha 18817 Jun 11 10:59 njcon.a

./16:
total 4628
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha  82299 Jun 11 10:58 njexyomi.a
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha    5785 Jun 11 10:58 njfzk.a
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha  81907 Jun 11 10:58 njtan.a
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha  513643 Jun 11 10:58 njubase1.a
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha 4046711 Jun 11 10:58 njubase2.a

The EN directory looks like this:

Code:

$ ls -Rl
.:
total 1617
drwxrwxr-x+ 1 Reg Tiangha Reg Tiangha      0 Jun 11 11:01 GB/
drwxrwxr-x+ 1 Reg Tiangha Reg Tiangha      0 Jun 11 11:01 US/
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha    160 Jun 11 11:00 njcon.a
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha  137152 Jun 11 11:00 njubase1.a
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha  258682 Jun 11 11:00 njubase2.a
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha 1247452 Jun 11 11:00 njubase3.a
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha    1759 Jun 11 11:00 njyomi.a

./GB:
total 8
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha 4608 Jun 11 11:01 njubase1gb.a

./US:
total 4
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha 3584 Jun 11 11:01 njubase1us.a

If I had to guess, the Kobo has a better Japanese input dictionary than the Vita.

To test compatibility, I erased the contents of the JA directory on the Kobo and replaced verbatim with the Vita version. It didn't work. But when I renamed the 16 directory to 32 to match the original directory structure, it DID work and I could do Japanese word lookups. So this proved dictionary compatibility.

So I tried the same with the EN dictionaries, first by copying EN directory to the /usr/local/Kobo/dic directory, but nothing happened, both in English mode on the Japanese keyboard, and in the English locale.

Next, I tried copying over everything verbatim into the JA folder; no dice. So I created a folder named 32 and moved every file except for njcon.a into it, and TA-DA! English word lookups started to work (screenshots attached)! :D

Here is what the final directory structure looked like using just the EN data:

Code:

$ ls -Rl
.:
total 1
drwxr-xr-x 1 Reg Tiangha Reg Tiangha  0 Jun 11 13:54 32/
-rwxr-xr-x 1 Reg Tiangha Reg Tiangha 160 Jun 11 11:00 njcon.a

./32:
total 1616
drwxrwxr-x+ 1 Reg Tiangha Reg Tiangha      0 Jun 11 11:01 GB/
drwxrwxr-x+ 1 Reg Tiangha Reg Tiangha      0 Jun 11 11:01 US/
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha  137152 Jun 11 11:00 njubase1.a
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha  258682 Jun 11 11:00 njubase2.a
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha 1247452 Jun 11 11:00 njubase3.a
-rwxr-xr-x  1 Reg Tiangha Reg Tiangha    1759 Jun 11 11:00 njyomi.a

./32/GB:
total 8
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha 4608 Jun 11 11:01 njubase1gb.a

./32/US:
total 4
-rwx---r-x+ 1 Reg Tiangha Reg Tiangha 3584 Jun 11 11:01 njubase1us.a

I didn't know what to do with the US and GB folders.

And for fun, I tried mixing and matching dictionary files to see if I could do both English and Kanji lookups, and after various combinations, I found that the three njubase.a files from the EN distribution definitely needed to be there to do English word lookups.

Limitations:

Unfortunately, as soon as you enter a valid Japanese syllable (ex. ta, ke, mo, etc.), all of the English suggestions disappear and are replaced with hiragana or katakana suggestions (or kanji, if the other dictionary files are also present). So this limits the usefulness somewhat. But we do have a proof of concept.

Questions:
  • Does the English locale keyboard also use iWnn technology, or is it just a plain QT keyboard with no smarts?
  • If it does use iWnn tech, is there a way to make it use the Vita's EN dictionary for predictive text?
  • If it's just a dumb keyboard, is there a way to make nickel launch the Japanese keyboard instead?
  • How exactly does the Japanese-English toggle work on the Japanese keyboard? Can English mode be made to use the EN dictionaries to do predictive text too?

This was a fun exercise, but I think I've taken it as far as I can with my current skills.

Attached Thumbnails
Click image for larger version

Name:	screen_001.png
Views:	N/A
Size:	56.7 KB
ID:	194307   Click image for larger version

Name:	screen_002.png
Views:	N/A
Size:	34.9 KB
ID:	194308   Click image for larger version

Name:	screen_003.png
Views:	N/A
Size:	66.7 KB
ID:	194309  

Viewing all articles
Browse latest Browse all 1564

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>