简体   繁体   中英

Any known javascript/php dictionaries like 'word1', 'word2'?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM