similarity
How similar are these two strings?
Install
npm:
npm install similarity
Use
var similarity = // 1 // 0.75 // 0 // 0.714285714 // 0.875 (case insensitive) // 0.5 (case sensitive)
API
similarity(left, right[, options])
Get the similarity (number
) between two values (string
s),
where 0
is dissimilar, and 1
is equal.
options.sensitive
(boolean
, default:false
) — Turn on (true
) to treat casing differences as differences
CLI
Usage: similarity [options] <word> <word> How similar are these two strings? Options: -h, --help output usage information -v, --version output version number -s, --sensitive be sensitive to casing differences Usage: # output similarity$ similarity sitting kitten0.5714285714285714$ similarity saturday sunday0.625
See also
Note: This module uses Levenshtein distance to measure similarity, but there are many other algorithms for string comparison. Here are a few:
clj-fuzzy
— Handy collection of algorithms dealing with fuzzy strings and phoneticsnatural
— General natural language facilities for nodestring-similarity
— Finds degree of similarity between two strings, based on Dice’s coefficientdice-coefficient
— Sørensen–Dice coefficientjaro-winkler
— The Jaro-Winkler distance metric