7

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?

Himmators
  • 14,278
  • 36
  • 132
  • 223

5 Answers5

2

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.

secretformula
  • 6,414
  • 3
  • 33
  • 56
2

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

davidaam
  • 443
  • 1
  • 8
  • 17
2

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.

unclejamil
  • 445
  • 3
  • 10
  • whoops! looks like davidaam beat me to javascriptspellcheck while I was posting. I'd delete but I wanted to leave in the bit about soundex. – unclejamil Jun 23 '12 at 21:53
0

php by default has levenshtein function. you can use this method by using PHPJS library.

by finding the levenshtein distance between the word and a dictionary of correct words you can obtain a word with least levenshtein distance from the miss-spelled word. This would most probably be the correct spelling for a particular word.

Sahil Singh
  • 3,352
  • 39
  • 62
0

In the past, I have used MissPlete library, which uses Jaro–Winkler distance algoritm by default.

It has no dependencies (not even jQuery), which I highly value.

Jorjon
  • 5,316
  • 1
  • 41
  • 58