levenshtein-edit-distance
Levenshtein edit distance (by Vladimir Levenshtein). No cruft. Real fast.
Installation
npm:
$ npm install levenshtein-edit-distance
Component.js:
$ component install wooorm/levenshtein-edit-distance
Bower:
$ bower install levenshtein-edit-distance
Duo:
var levenshtein = require('wooorm/levenshtein-edit-distance');
Usage
var levenshtein = require('levenshtein-edit-distance');
levenshtein('levenshtein', 'levenshtein');
levenshtein('sitting', 'kitten');
levenshtein('gumbo', 'gambol');
levenshtein('saturday', 'sunday');
levenshtein('DwAyNE', 'DUANE') !== levenshtein('dwayne', 'DuAnE');
levenshtein('aarrgh', 'aargh') === levenshtein('aargh', 'aarrgh');
CLI
Install:
$ npm install --global levenshtein-edit-distance
Use:
Usage: levenshtein-edit-distance [options] word word
Levenshtein edit distance. No cruft. Real fast.
Options:
-h, --help output usage information
-v, --version output version number
Usage:
# output distance
$ levenshtein-edit-distance sitting kitten
# 3
# output distance from stdin
$ echo "saturday,sunday" | levenshtein-edit-distance
# 3
Other Levenshtein libraries
Benchmark
On a MacBook Air, it runs about 1,909,000 op/s.
Levenshtein — to be fair, it lets you inspect a matrix
113 op/s » op/s * 1,000
natural — to be fair, it offers more options
183 op/s » op/s * 1,000
levenshtein-deltas
237 op/s » op/s * 1,000
levenshtein-component
305 op/s » op/s * 1,000
fast-levenshtein
1,141 op/s » op/s * 1,000
Leven — fast.
2,076 op/s » op/s * 1,000
levenshtein-edit-distance — this module
1,909 op/s » op/s * 1,000
License
MIT © Titus Wormer