Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find similar words in array of words

I googled these days but nothing helps. I m not sure now if its possible, so I thought I just aks at stackoverflow.

The situation: The user can input a word or in a inputbox. When he finishes a function check if the word is in the array of words - easy. Now I wanna write a help, if one letter is missing or the letters are written the wrong way, a message should popout.

What are the keys to search for? I tried:

  • javascript find string in array
  • javascript find similar words in array
  • javascript regex similar words
  • ... and more

I hope you undestand what i mean, and can give me some hints.

like image 285
user1509034 Avatar asked Jan 19 '26 21:01

user1509034


1 Answers

The Levenshtein distance is a metric for computing the distance between similar words. For each changed, shuffled or missing letter the distance is increased. You can read more here: http://en.wikipedia.org/wiki/Levenshtein_distance

and take a reference for the implementation in different languages here: http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance

I hope that helps and thanks for the comment up votes ;)

like image 141
peshkira Avatar answered Jan 22 '26 11:01

peshkira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!