0

Just recently I was looking up about Levenshtein algorithm and after searching for an hour I couldn't find a javascript file like:

var dictionary =
    [
      'coke',
      'cokeman',
      'cokeney'
      ]

Is there a faster way to do this? I haven't found any files like this and I've heard this function is kind of slow. If I could how could I do this with php?

F21
  • 32,163
  • 26
  • 99
  • 170
keji
  • 5,947
  • 3
  • 31
  • 47

1 Answers1

2

In order to get that javascript file you could run cat /usr/share/dict/words | sed "s/^.*$/\'&\'\,/g"

replacing /usr/share/dict/words with a newline separated wordfile. Then all you have to do is add var dictionary = [ and ] maybe throwing in a semicolon at the end if you feel like it.

joidegn
  • 1,078
  • 9
  • 19