I was working on a similar problem this weekend, but with whole words instead of abbreviations I had made in a dictionary, and in the general case, fine-tuned on any given corpus of text.
I wanted to know: could I write an autocorrect that is "fine-tuned" on a given corpus of text? Use case: I write a lot of docs with long phrases (i.e. "data augmentation"). Could I automate them?
I arrived at:
1. Calculate "surprisal" of unigrams and bigrams (entropy) from a general dataset (an NYT corpus), give a boost to words in the "fine-tuned" index;
2. Create a trie data structure that is weighed by surprisals. The more surprising a word, the more weight it gets.
3. Use that as advanced autocomplete.
I got a working solution here: https://github.com/capjamesg/autowrite/blob/main/autocomplet...(No docs yet -- coming in the next few days. Leave a GitHub Issue if you want to chat about it!)