levenshtein-edit-distance
Levenshtein edit distance (by Vladimir Levenshtein).
No cruft. Real fast.
API
Install:
npm install levenshtein-edit-distance
Use:
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('DwAyNE', 'DUANE', true) === levenshtein('dwayne', 'DuAnE', true);
levenshtein('aarrgh', 'aargh') === levenshtein('aargh', 'aarrgh');
CLI
Install:
npm install -g 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
-i, --insensitive ignore casing
Usage:
# output distance
$ levenshtein-edit-distance sitting kitten
# 3
# output distance from stdin
$ echo "saturday,sunday" | levenshtein-edit-distance
# 3
Related
License
MIT © Titus Wormer