There are algorithms that let you find out how close one text is to another. Basically the number of character additions, deletions and replacements before the texts are identical.
Here is one such algorithm:
en.m.wikipedia.org/wiki/Levenshtein_distance
I guess you could run that with the typed text and all the possible words, then use the closest one. Effectively it’s kind of your own spell checker with your own set of words. More likely you’d want to not consider words that are more than 5 edits away or something, and if there are multiple words with the same minimum distance away you could maybe show a suggestion to the user.
You can tweak it further too. Most spell checkers consider adjacent keys as closer. Or transposed characters as being close too. I didn’t look further at different algorithms though. Anyways some ideas you could pursue.