Helium314 / HeliBoard

Customizable and privacy-conscious open-source keyboard
Apache License 2.0
1.9k stars 67 forks source link

Export/Import Personal dictionaries #500

Open User1l0 opened 4 months ago

Uranusek commented 4 months ago

You can already do it. The backup and restore option is in the advanced keyboard settings.

BlackyHawky commented 4 months ago

If you're talking about the user dictionary, it doesn't work. I've implemented todo in the code so that it can be done later.

Helium314 commented 4 months ago

I think there are already apps that can do it, so adding this functionality has rather low priority.

Uranusek commented 4 months ago

I thought it was possible :0 I once added this feature request and it was implemented, or at least I think so, since it was closed as completed. What is the UserHistoryDictionary.dict file?

BlackyHawky commented 4 months ago

What is the UserHistoryDictionary.dict file?

If I'm not mistaken, it's the file containing the words you've often typed, which are then automatically suggested in the suggestion bar.

Uranusek commented 4 months ago

I disabled this option, created a backup and these files are still there. The spellcheck_userunigram.dict files have disappeared.

Charles7z commented 3 months ago

For those looking for this feature:

User Dictionary Manager (UDM) play store is a great app.

However, be careful as to the dictionary being used.

Some keyboard use the "all languages" personal dictionary. HeliBoard adds words to the en_US personal keyboard for US English. Just an FYI.

Roccobot commented 3 months ago

Why is this low priority though? Wouldn't users be more open to switching from GBoard if they could transfer their personal dictionaries? I'm loving HeliBoard so far, but I have a big personal dictionary (2 languages plus 'All languages') and copying words one by one would take forever ๐Ÿ˜…

Helium314 commented 3 months ago

The phone's personal dictionary is part of the Android system and works across keyboards, the keyboard just needs to support it. Import / export is just required for backup and switching devices.

Roccobot commented 3 months ago

Oh, so probably the real question is: why isn't my GBoard dictionary available for HeliBoard? I see it completely empty :( Should I open a bug issue?

Helium314 commented 3 months ago

Maybe Gboard doesn't use the system personal dictionary? But I think words added when via the menu in spell checker (when clicking words underlined in red) should always go to system dictionary. Though maybe Play services have a way to override this...

Roccobot commented 3 months ago

So basically there's no way to copy my Gboard user dictionary to HeliBoard? ๐Ÿ˜ฐ

Charles7z commented 3 months ago

Introduction

Since this post has been linked to from the readme FAQ, I figured I would make it more comprehensive.

Gboard uses its own internal personal/user dictionary, therefore, while it looks like the system's personal dictionary it is not and therefore no other keyboards can see your Gboard words. So this tutorial will show you how to get your words out of Gboard and import them into system's personal dictionary, and I'll show you how you can manipulate the word's "weight".

Step one: export from Gboard

  1. Open Gboard's settings.
  2. Tap Dictionary
  3. Tap Personal dictionary
  4. You should see your dictionary (English US in my case) tap it
  5. Tap the three dot menu in the upper right.
  6. Tap export (Gboard will export the dictionary in a zip file.)
  7. File share menu will come up.
  8. Select an app you can share the zip file with. I use MiXplorer as my file manager so it handles copying from share menu. If you don't have a file manager that can do this you can share to email and send it to yourself.
  9. Once you have the zip export you'll need to extract it. It contains a dictionary.txt file with a list of all your words. Use a good file manager from F-Droid or MiXplorer if you don't have something that'll work already installed.
  10. You should now have the dictionary.txt file. ๐ŸŽ‰

Step two: import

  1. Download User Dictionary Manager UDM()
  2. Install UDM
  3. Setup UDM โ€” enable it as a keyboard, etc.
  4. Open UDM
  5. Select import
  6. Tap browse and locate the dictionary.txt file you exported & extracted in step one.
  7. Under "export file format" check Gboard.
  8. Under "export language" you have to decide which personal dictionary you want to import into โ€” all languages, en_US etc.
  9. Tap start โ€” UDM often has some type of notification/warming letting you know that it doesn't always work on all devices, clear it and continue importing your dictionary words.
  10. You should see a notice at the bottom telling you how many words imported.
  11. Done! ๐Ÿ˜

Step three: alt import & word "weight"

HeliBoard gives a "weight" (I don't know what it's actually called) between 0-255 to every word in the dictionary and in the personal dictionary it gives all words the maximum weight of 255. This can be problematic.

The numbers from 0-255 correspond as 0 = don't show word, and 1-255 the higher the more important the word is. This means a word with 255 will be highly recommended in the suggestions. This may not be what you want and you may want to change the weight to something less important however, the only way to adjust this number in HeliBoard is one word at a time via the personal dictionary. Furthermore there is No way to backup these words with their number.

The solution is "Multiling O Keyboard" on the Google play store here.

Multiling O Keyboard hasn't been updated in a long time and its user dictionary can't be installed on my pixel 6a running GrapheneOS Android 14, but the keyboard does install.

Once you have it installed and enabled in the settings for Multiling O Keyboard you'll see:

  1. settings
  2. Misc.
  3. Import|Export
  4. User Dictionary

If you have imported your words and setup Multiling O Keyboard so it's using the user dictionary you'll see listed all you words with their weight number:

MLK_UDic_Begin able::255::en_US about::255::en_US MLK_UDic_End

Notice the first and last line? Those lines are required by Multiling O Keyboard to import words. This list can't be used by UDM!

From this setting's screen you can copy all your words with their corresponding numbers and save them in a .txt file = export. This makes "batch" changing of the weight number easy (find & replace) along with an easy way to backup those numbers with their words.

Remember 0-255 are the numbers you can use, the higher the more important the word is. The number 0 doesn't seem to do anything in the personal dictionary โ€” in the main dictionary it's used to signify a word that is NOT to be shown.

That's all I can think of. ๐Ÿคทโ€โ™‚๏ธ

Edit: the "null" dictionary, if you used "all languages" to import using UDM, doesn't seem to work very well importing in Multiling, best to use a language specific dictionary (en_US).

Roccobot commented 3 months ago

Thanks, I'll try that!

Roccobot commented 2 months ago

I forgot to reply that it worked! The multi language is a but weird, but at least all my words are there now! ๐Ÿ™

BerziOnline commented 3 weeks ago

If I have a list of words, how can I directly import them including the weight?

I just need to understand the process, but I am not able to find out.

Let's say I have a .txt file with

word-one word-two word-three word-four

Importing over UDM works fine and it is directly recognized by heliboard's personal directory. But all with weight 255.

Editing the word list to:

word-one::100 word-two::100 word-three::100 word-four::100

Doesn't work, because the import of this kind of txt-file over UDM interprets each line as a string. So it is landing into heliboard, but now you have a string like "word-one::100" with still weight 255.

So how to import a text-file in which format to import a wordlist directly with weight?

I plan to edit my wordlist on my linuxhost, but I need to know how to save and import the txt-file then. Also "word-one::100::de_DE" ends up just in that string, because UDM interprets each line as a full string. I tried it this way, because @Charles7z used this as import/export format in his described way with the app "Multiling O Keyboard". But this is not compatible with my smartphone (and I think not really necessary, if I would understand where to import a list of words in which format to help heliboard interpreting it correctly?)

In the end, maybe I just can manipulate the personal directory itself from heliboard and edit my words into it, if I would know where it is saved?

Charles7z commented 3 weeks ago

@BerziOnline

the only way to import with word weight is with multiling o keyboard.

there is currently no other way! This is a major issue!!!

therefore if you can't install multiling then โ€Œ๐Ÿ‡พโ€Œ๐Ÿ‡ดโ€Œ๐Ÿ‡บใ€€โ€Œ๐Ÿ‡จโ€Œ๐Ÿ‡ฆโ€Œ๐Ÿ‡ณโ€Œ๐Ÿ‡ณโ€Œ๐Ÿ‡ดโ€Œ๐Ÿ‡นใ€€โ€Œ๐Ÿ‡ฉโ€Œ๐Ÿ‡ดใ€€โ€Œ๐Ÿ‡ฎโ€Œ๐Ÿ‡นโ•

โ€Œ๐Ÿ‡ญโ€Œ๐Ÿ‡ดโ€Œ๐Ÿ‡ผโ€Œ๐Ÿ‡ชโ€Œ๐Ÿ‡ปโ€Œ๐Ÿ‡ชโ€Œ๐Ÿ‡ท๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ

What you could do is, compile your own dictionary. That's the best way.

See my discussion on dictionaries