Text Prediction on GNOME
I was disappointed with the text completion provided by the N900 (eZiText) that, on top of that, is closed and I wondered if it was possible to have an Open Source solution to provide text prediction and completion.
I searched a bit and besides my original intentions of developing a library to search Free and Open Source dictionaries’ words from a prefix, I found Presage.
Presage is better than most text prediction systems I have seen out there because it really is text prediction, not text completion. This C++ library, retrieves words taking into account the surrounding text, not only the prefix or frequency of words. It uses a database representing N-grams that can be trained with more text; the more you train it, the more accurate it can be.
This means that is you type something like:
“I m”
instead of suggesting nonsense things like:
“I mouse” “I mother” “I market” or “I more“
it suggests something more like:
“I must” “I met” “I mean” or “I might“
The difference is obvious!
So I developed a little wrapper around Presage in C that provides a yet very basic API to get text completion. Then I created a GTK+ Input Method context to control the user’s input in regular GTK+ text widgets and used the wrapper to process the inputted text. I called it: Predictor Input Method (not very original I know…).
The result is that Predictor suggests you words, even if you type a prefix or not, and lets you accept the candidate word or scroll through a list of suggestions as you can see in the video below:
Text prediction in GNOME from Joaquim Rocha on Vimeo.
How to use it
The current key bindings are:
Ctrl+Enter -> Selects the current candidate
Ctrl+Up/Down -> Scrolls through the list of candidates
Backspace -> Deletes the character previous to the cursor and suggests again
Directional arrows -> Move cursor and discard suggestions
Who should use it
This kind of assistance technology can have many applications but the main ones are: the usage in small/mobile devices and the assistance of users with disabilities. Both have the same reasons behind: speeding the input and reducing failed characters, because the input required gets minimized;
Of course, you can as well use it in your GNOME desktop regularly for faster typing your emails, etc.
In the case of users with disabilities, a popup menu could be added to show a complete list of candidates and the bound fast-access keys.
Why is Free Software important in this
This is the kind of technology that everybody should have an interest in using a FOSS solution because of the obvious advantage that is developers from all over the world being able to modify it.
Suppose you’re creating a mobile phone and you choose a closed solution to provide text prediction for your phone. And then you find out you’re disappointing all your users from country X because that library you’re paying for does not support their language and the library owner is not interested that much in adding it. Now if you’re using an open solution, local communities from many places in the world can add support for their languages and your phone can have a better acceptance in places you hadn’t even imagined.
Software that reaches an international audience with different languages is software you want to have open.
How to get Predictor Input Method
You can find the Predictor Input Method’s source its Gitorious page: http://gitorious.org/text-predictor-input-method
Of course, you should also install Presage for it to work.
If you are not using GTK+ Input Methods then you can use the wrapper text-predictor.cpp which is not tight to the Input Method code itself. And of course, you can copy the little tricks used on the Input Method code and apply it to your source (like delaying the retrieval of the candidates some fractions of a second to not block the input, etc.).
Hope you like it.

March 3rd, 2010 at 11:37 am
Very sweet!
March 3rd, 2010 at 11:56 am
Very awesome! Although I do think that ctrl + enter clashes with Send in Evolution.
March 3rd, 2010 at 12:08 pm
Kudos ! Keep up the good work
March 3rd, 2010 at 12:19 pm
Well, I didn’t put much thought into the shortcuts as they can be easily changed from the define in the code. Soon I should use a more versatile way of configuring them.
March 3rd, 2010 at 12:19 pm
Thank you folks!
March 3rd, 2010 at 12:47 pm
Great! Would love to see a maemo package in extras some day. I think at the moment not all users are able to install it on their own…
March 3rd, 2010 at 12:59 pm
Stephan, I am looking forward to do it. Soon..
March 3rd, 2010 at 4:32 pm
i’ve downloaded the presage but i earlier used some maemo safe scripts to free up some space on the rootfs, so it moved many directories to a new location.
when i tried to run .?configure, it didn’t find te locations it needed, so, i couldn’t set it up
March 3rd, 2010 at 9:37 pm
You can try it on a regular GNOME desktop, no need to install it on Maemo if you don’t need it there..
March 4th, 2010 at 6:43 am
Good work. Can it be used as the text input method for SMS etc. on the N900? If not would it require a re-write of the SMS app?
March 4th, 2010 at 9:06 am
Yes it can, as soon as I make it work on the N900. Theoretically it would not require rewriting any application because GTK+ Input Methods integrate with any widgets that implement GTK+ IM context.
March 4th, 2010 at 2:04 pm
That’s small but great project. I’ve announced it at my Russian Web site for FLOSS addicts: http://www.nixp.ru/news/10175.html
March 4th, 2010 at 3:03 pm
Thank you Dmitry!
March 8th, 2010 at 4:24 pm
Looks very interesting!
I have a N900 and this could be a long waited relief to the standard word completion.
So I figured I test your work first in Ubuntu, but I don’t get Presage to work which is the first thing to do.
March 12th, 2010 at 3:39 pm
[...] few days back I came to know about this project :Text Prediction on GNOME based on GTK+ Input Method context. Basically it is an input method with text prediction [...]
August 5th, 2010 at 9:09 am
[...] year I gave again a lightening talk, this time about the Predictor Input Method which you might one day use in a mobile device or on the desktop itself if you need assisted [...]
December 30th, 2011 at 4:32 pm
gtk-query-immodules-2.0 is missing for me, and so this won’t configure. Was dropped from libgtk2.0-bin in a recent version apparently. Shame, the app looks great!