d2-ui
Version:
15 lines (10 loc) • 433 B
Markdown
I use algorithm kindly provided by TheSpanishInquisition here: <http://jsperf.com/damerau-levenshtein-distance>.
All credits goes there. I have only packed it into Node module.
It provides a function that takes two string arguments and returns a hash like this:
```` javascript
{
steps: 5, // Levenstein demerau distance
relative: 0.7, // steps / length of bigger of two words
similarity: 0.3 // 1 - relative
}
````