Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a good way to identify a word, even if it's misspelled in javascript? [closed]

I have a bunch of words (mostly locations, like Stockholm and London) and a bunch of strings. like "I want to go from stockholm to london". I want to find out what words are in what strings.

I currently use .indexOf to perform this task.

Is there a library, method, function etc, in javascript that identifies misspelled versions of words?

like image 575
Himmators Avatar asked Jun 23 '12 21:06

Himmators


3 Answers

https://github.com/epeli/underscore.string#readme

Check out the levenshtein _.levenshtein(string1, string2) distance function. It can be used to calculate the distance between too strings.

like image 54
secretformula Avatar answered Nov 20 '22 10:11

secretformula


I found this JS library http://www.javascriptspellcheck.com/ that is supposed to check spelling in several languages

like image 24
davidaam Avatar answered Nov 20 '22 08:11

davidaam


After reading the above I'm not sure if I'm exactly clear on what you are trying to do... but regarding your final question about identifying words which are incorrectly spelled -- I'd take a look at java script spell check. And as a side note.. Often people try and use soundex when they want to count words which are spelled both correctly and incorrectly.

like image 33
unclejamil Avatar answered Nov 20 '22 09:11

unclejamil