Algorithm wanted: Find all words of a dictionary that are similar to words in a free text

后端 未结 4 455
迷失自我
迷失自我 2020-12-24 09:39

We have a list of about 150,000 words, and when the user enters a free text, the system should present a list of words from the dictionary, that are very close to words in t

4条回答
  •  天涯浪人
    2020-12-24 10:04

    It might be of interest to look at a some algorithms such as the Levenshtein distance, which can calculate the amount of difference between 2 strings.

    I'm not sure what language you are thinking of using but PHP has a function called levenshtein that performs this calculation and returns the distance. There's also a function called similar_text that does a similar thing. There's a code example here for the levenshtein function that checks a word against a dictionary of possible words and returns the closest words.

    I hope this gives you a bit of insight into how a solution could work!

提交回复
热议问题