Skip to content

Instantly share code, notes, and snippets.

@yshalsager
Last active March 31, 2024 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yshalsager/014f20d3666153febdd8a7c5ed568cc7 to your computer and use it in GitHub Desktop.
Save yshalsager/014f20d3666153febdd8a7c5ed568cc7 to your computer and use it in GitHub Desktop.
Migrating AnySoftKeyboard user words history to HeliBoard

Migrating AnySoftKeyboard user words history to HeliBoard

  • Get a copy from AnySoftKeyboard user words (in app settings there's an option to open its location)
  • You need Python and Java JRE.
  • Run this python code, you can adjust file path to your xml correct one.
from xml.etree import ElementTree as etree
from pathlib import Path
from datetime import datetime

file = Path("UserWords.xml")


def xml_to_aosp(lang, locale, description, date, version):
    tree = etree.parse(file)
    root = tree.getroot()
    aosp_wordlist = f"dictionary=anysoftkeyboard:{lang},locale={locale},description={description},date={date},version={version}\n"
    elements = root.findall(".//pref/pref")
    for element in elements:
        freq = element.find("value[@freq]").get("freq")
        word = element.find("value[@word]").get("word")
        aosp_wordlist += " word={},f={}\n".format(word, freq)

    Path(f"aosp_wordlist_{lang}.txt").write_text(aosp_wordlist)

xml_to_aosp("ar", "ar", "Arabic wordlist", datetime.now().timestamp(), 18)
java -jar dicttool_aosp.jar makedict -s aosp_wordlist_ar.txt -d anysoftkey_words.dict
  • Copy the dict file to your device and open it from file manager to load with HeliBoard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment