sailfish-keyboard / presage

Fork of Presage (http://presage.sourceforge.net/)
GNU General Public License v2.0
6 stars 10 forks source link

Adds API for forgetting learned words #21

Closed rinigus closed 6 years ago

rinigus commented 6 years ago

Fixes: https://github.com/sailfish-keyboard/presage/issues/19

Through method forget, a word can be given that will be forgotten by all actively learning predictors. In practice, its implemented for smoothedNgramPredictor only since the other predictors are either not learning or hard to use in practice (DejavuPredictor) on mobile devices due to the heavy resource consumption.

In the implementation, the given word is searched for in all n-grams (any of the words) and the corresponding n-grams are removed. This is done for word as given (case sensitive) as well as normalized version (at present we use lowercasing, this will change with Unicode, will have adjust forget method of the predictor).

As a limitation, word is not deleted from predictors that have learning disabled (files are either readonly or predictor doesn't support write operations, as for Marisa).

rinigus commented 6 years ago

@ljo or @martonmiklos : please review. I'll wait for 24h, if there are no objections, I'll merge the commit. I presume that one review should be sufficient, if we get it done.

Its possible to test forget branch on device using the build from my devel version of keyboard OBS: https://build.merproject.org/project/show/home:rinigus:keyboard:devel . To trigger forget action, just press and hold the word in Maliit keyboard.

Note that if you try to forget a word by typing it, pressing space, trying to type again and then forgetting it while its available in the history, it will be relearned immediately. So, delete the word first, before trying to forget it.

rinigus commented 6 years ago

PS: @ljo or @martonmiklos: If you want to review, but cannot in time, let me know. I just want to keep momentum and move with the development...

martonmiklos commented 6 years ago

:D Haha I have seen that you have figured out how to handle the lack of response. I agree with deadlines, and I would like to keep the release at the weekend schedule. Our weekend will start on Thursday because of national holiday so the free time related things looks better than they used to be.

ljo commented 6 years ago

@rinigus Yes, sorry was occupied with meeting other deadlines. But agree deadlines are good. :)

rinigus commented 6 years ago

Thanks guys! I'll fix the printout and then will merge it tonight, assuming that there are no other outstanding issues. For testing, please use devel OBS. As soon as hunspell is in SFOS plugin, I'll submit the 'forget' branch for review as well.

rinigus commented 6 years ago

Thank you for reviews, merged.