Search code examples
algorithmartificial-intelligencelevenshtein-distancemisspelling

Levenshtein-distance is there another way rather than compare the missspelled word with all the dictionary word


i was searching for AI algorithm for spelling correction and i found Levenshtein distance algorithm that compare the similarity between two string so my question should i implement this similarity between the wrong word with the all the words that's in my dictionary? because if yes the time run will be slow. and my second question can this algorithm implement on two string that don't have the same length thanks in advance


Solution

  • If you are working with Java or JavaScript, I have a library that can find all spelling candidates in your dictionary in linear time on the length of the query term:

    https://github.com/universal-automata/liblevenshtein-java

    The trick is that it intersects a Levenshtein automaton with your dictionary automaton, and only follows those paths which lead to terms having a Levenshtein distance no greater than what you specify from the query term.

    I've set up a demo that you can play with:

    http://universal-automata.github.io/liblevenshtein/