ibus-typing-booster
ibus-typing-booster copied to clipboard
Offer option for two-word hints
To further boost typing with ibus-typing-booster, I suggest to add an option enabling auto-completion suggestions for the next word as well.
Just FIY, I use such a feature in my favourite professional cross-platform translation tool, CafeTran Espresso (the feature is called "Prompter", and can be adjusted in Preferences > Prompter).
Having it across the desktop would be awesome!
@idimitriadis0 I was about to request that feature too, but I came across your issue ticket.
First of all, I congratulate all who contributed to this project. I am quadriplegic and I can use my computer via onboard
virtual keyboard. onboard
also has that next word prediction feature
, it records frequently typed words sequence
, and it offers that ordered words. I must say that it's very practical for me.
Unfortunately onboard
doesn't work with non-GTK
applications.
I must note that ibus-typing-booster
is a sophisticated tool, because it works with any application on the screen. I wonder how Mike Fabian achieved it.
When I first read the subject of this issue “Offer option for two word hints”, I thought ibus-typing-booster already has that feature.
It already suggests two word candidates when they appear to be very likely.
While typing, ibus-typing-booster remembers the context in which words have been typed. For example, when a sentence like
I am going to read a book about...
is typed, then when the word about is finished, it is written the data base that the two words before “about” were “a” and “book”, so the trigram
a book about
is written to the database when one next types “a book a” the word “about” gets a hight score because it appeared before in just t context (there are many words starting with “a” but probably not so many were typed before with the context “a book” in front of it. If only the second word of the context matches, the score doesn’t get as high. For example if “a book about” has been typed before and one types “the book a” next the word “about” still gets a quite hight score because at least the 2 word context “book about” was typed before. And if typing only “a” without context, words like “about” which have been typed before get higher scores than just dictionary words.
The score depends of course also on how often a certain context has occured.
In addition to the trigram “a book about”, another trigram is also written to the database which consists of the last two words as a single unit and the two words before that. I.e. in the above example this trigram
read a “book about”
is written to the data base where “book about” is one unit. So the next time one types “read a b” one might get the suggestion “book about”.
So such a two word suggestions already exist, as you can see in this video:
https://user-images.githubusercontent.com/2330175/179752377-2d8a3d85-54cd-4c67-93e5-d3e2af02c76d.mp4
The video shows the two word suggestions when used with the inline completion off (default) and with inline completion on. Both works (Even a three word suggestion “reading a book” appears once in the video:
(This can happen when “a book” was already a two word suggestion and then “reading a” was typed and the suggestion “a book” is accepted, then “reading a book” becomes a possible suggestion).
So as far as two word suggestions are concerned, they are already there. If they are not accurate enough, then one has to think about how to improve the algorithm and prove that a different algorithm makes accuracy better on average.
To check whether changes in the algorithm improve things, I let ibus-typing-booster read a freely available book with the “Learn from text file” function, then I simulate the retyping of that whole book letter by letter and for every word check how many letters need to be typed until the correct word is suggested and how many letters of typing were saved.
When doing this with a big book I can test whether a tweak in the algorithm improves things or not.
When tweaking the way two word suggestions are handled such a test should be done again to make sure it is really an improvement and doesn’t make things worse.
But when reading both comments by @idimitriadis0 and @trappedinspacetime more carefully, I thought that this might be not only about suggesting two words but also about already suggesting the next word when no character at all has been typed of the next word.
Most virtual keyboards on mobile phones do that.
And I played a bit with CafeTran Espresso in the "Preferences -> Prompter" settings there is an option
Prompting starts at (char): [ 0 ]
which seems to do that.
I tried to test whether onboard does this as well, unfortunately onboard crashes for me on Fedora 36 as soon as I click on the checkbox to enable suggestions in the setup tool l (I am trying to report a bug against onboard about that).
Now ibus-typing-booster has an option similar to the CafeTran Expresso option
Prompting starts at (char): [ 0 ]
Ibus-typing-booster has:
Minimum number of chars for completion: [ 1 ]
Currently ibus-typing-booster allows only values from 1 to 9 for that option.
For a long time already I was thinking about allowing 0 as well, i.e. allow suggestions to be shown if one word has been committed (finished) but no letter has been typed yet of the next word.
I didn't yet try to implement that yet only because I thought that it would be annoying to see such a suggestion (either as a popup or inline) always, even when it cannot be very good (Context completly empty for example because one starts writing in an empty buffer or the context is empty because of focus switches or cursor repositioning and surrounding text failed to fetch an update for the context (surrounding text is very buggy and often fails)).
For virtual keyboards, this is no problem because they display the suggestions typically as a row of buttons at the top of the virtual keyboard, so they are not in the way, not as disturbing as a usesless suggestions inline or as a popup at the cursor position.
In case of ibus-typing-booster one would need to cancel
the popup or inline completion if one doesn't want it (cancel
is by default bound to the Escape key).
But when I thought about this more, I thought that even if:
Minimum number of chars for completion: [ 0 ]
I don't have to show a suggestions absolutely always when no letter has been typed yet. .
When that option is set to any number > 0, it is also possible that no suggestion is shown if absolutely nothing matches.
So I could allow 0 but show suggestions when no letter has been typed yet only if the suggestion seems to be rather good. Maybe like this:
- Context of at least two previous words is available (either remembered and the cursor position has not changed or surrounding text worked and returned some useful context)
- That context has been typed before, i.e. there are trigrams starting with that context in the user database
- There are words in the user database to complete the two word context to a full trigram with a very high score.
If these conditons are met, the suggestion seems pretty reasonable, even if no letter has been typed yet. If it is still wrong, one can of course continue typing letters to get better suggestions or type Escape if one just wants the suggestion to disappear.
@mike-fabian Thank you for responding. Unfortunately I have been suffering from covid. I have a fever, I only read some parts of your posts. As you mentioned above, yes, onboard suggest next word without no character typed.
By the way, I encountered an onboard bug in the past. The author of onboard issued a patch under a branch. I noticed that it was not merged to main branch. You can find rev branch here : https://bugs.launchpad.net/onboard/+bug/1672166
@mike-fabian Thank you for responding. Unfortunately I have been suffering from covid. I have a fever, I only read some parts of your posts.
Take care and get well soon!
As you mentioned above, yes, onboard suggest next word without no character typed.
By the way, I encountered an onboard bug in the past. The author of onboard issued a patch under a branch. I noticed that it was not merged to main branch. You can find rev branch here : https://bugs.launchpad.net/onboard/+bug/1672166
I suffer from a different bug, I cannot even switch on suggestions onboard crashes immediately as soon as I check the checkbox
☑️ Show suggestions
I reported that here:
https://bugzilla.redhat.com/show_bug.cgi?id=2108645 and https://bugs.launchpad.net/onboard/+bug/1982309
@trappedinspacetime
As you mentioned above, yes, onboard suggest next word without no character typed.
I have implemented now that words can be suggested when no character has been typed yet.
Test builds including that feature are available at
https://copr.fedorainfracloud.org/coprs/mfabian/ibus-typing-booster/builds/
for Fedora and at
https://build.opensuse.org/package/show/home:mike-fabian/ibus-typing-booster
for OpenSUSE.
Builds with version number >= 2.19.17 have this new feature.
In the setup tool one can now set:
Minimum number of chars for completion: [ 0 ]
(Previously one could set this option only to a value between 1 and 9, now 0 is also allowed).
This video shows how this looks when this option is set to 0 and inline completions are enabled:
https://user-images.githubusercontent.com/2330175/212863906-c085a8de-2a5a-47e9-991e-c377956fe93b.mp4
Included in https://github.com/mike-fabian/ibus-typing-booster/releases/tag/2.20.0
@mike-fabian thank you for all your help. I watched it in the video you posted. It looks very well. I will test it when I have time apart from my health issues. I don't know how to thank you. I'm grateful all the people who contributed this project for a better world. Regards.