Condile this program. Did you mean "Compile"?

Hello,

i'm looking for a nice algorithm that compares a word in input to a list of words
to found the best match.

Any idea?

Kind regards

Last edited on
What do you consider to be "best match"? The Hamming Distance is commonly used; https://in.mathworks.com/matlabcentral/cody/problems/846-calculate-the-hamming-distance-between-two-strings
google around for 'autocorrect algorithm' . Here's one article from the results
https://medium.com/@willsentance/how-to-write-your-own-spellchecker-and-autocorrect-algorithm-in-under-80-lines-of-code-6d65d21bb7b6

Key points of his article:
- add a letter: ‘teh’ -> ‘ateh, bteh, cteh, dteh,….,tehy, tehz’
- remove a letter: ‘teh’ -> ‘eh, te, th’
- substitute a letter: ‘teh’ -> ‘aeh, beh, ceh,…,tey, tez’
- switch two adjacent letters: ‘teh’ -> ‘hte, the’

All the above words are said to be of error distance 1. A word of error distance 2 from ‘teh’ would be ‘too’ — ‘teh’ -> ‘toh’ -> ‘too’


Seems reasonable. Author goes on to say 'thene' might be auto-corrected to 'then' rather than 'the' because of a lower error distance in spite of 'the' being more common a word. For some reason, 'there' or 'these' isn't considered, so there's still room to improve the accuracy.

Thank you foir the reply.

Studying...
Topic archived. No new replies allowed.