mike-fabian / ibus-typing-booster

ibus-typing-booster is a completion input method for faster typing
https://mike-fabian.github.io/ibus-typing-booster/
Other
232 stars 16 forks source link

Export predictions to new Linux computer #257

Open du82 opened 3 years ago

du82 commented 3 years ago

How can I export what the algorithm has learned about how I type to a new Linux computer with the software installed? Is there a way to export my predictions so I don't have to retrain the algorithm every time I wipe the OS or switch between computers?

mike-fabian commented 3 years ago

Yes, you can copy the file ~/.local/share/ibus-typing-booster/user.db to the same place on the new computer.

I wonder wether there should be a more convenient way to do that.

I was thinking about adding an “Backup/Export” button to export a backup of the current contents of the sqlite database in user.db file to a text file, maybe a text file containing a representation of the database in form of a python dictionary, or maybe a .json file.

And then add a “Restore/Import” button to read such a backup file and either replace the current contents of the database with that import or merge that import into the current database (letting the user choose whether to replace or merge).

It would not be very much easier than copying the user.db file around, but I could offer the extra option on import to choose between replacing or merging.

And, when copying the user.db file, one has to take a little bit of care that the place where one copies it is not currently used by a running ibus-typing-booster. For example if there are these files:

$ ls ~/.local/share/ibus-typing-booster/user.db{,-shm,-wal}
/home/mfabian/.local/share/ibus-typing-booster/user.db
/home/mfabian/.local/share/ibus-typing-booster/user.db-shm
/home/mfabian/.local/share/ibus-typing-booster/user.db-wal

And one does something like:

$ cp ~/user.db-backup /home/mfabian/.local/share/ibus-typing-booster/user.db

while /home/mfabian/.local/share/ibus-typing-booster/user.db is in use by ibus-typing-booster, then one might not see any change at all as what one has just copied will soon be overwritten from the user.db-shm and user.db-wal files.

I.e. when overwriting /home/mfabian/.local/share/ibus-typing-booster/user.db with a backup, I should first make sure that it is not in use.

With an export and import feature one would not need to worry about that.

mike-fabian commented 2 years ago

https://github.com/mike-fabian/ibus-typing-booster/issues/251#issuecomment-979335004

mike-fabian commented 2 years ago

@ducheng0 : What do you think? Is copying the database file easy enough or should there be an extra export/import feature for the database?