Distances
Implementations of various string similarity metrics.
Usage
var distances = require( '@stdlib/string/base/distances' );
distances
Namespace containing "distances", i.e, implementations of various string similarity metrics.
var ns = distances;
// returns {...}
The namespace contains the following functions:
hammingDistance( s1, s2 )
: calculate the Hamming distance between two equal-length strings.levenshteinDistance( s1, s2 )
: calculate the Levenshtein (edit) distance between two strings.
Examples
var ns = require( '@stdlib/string/base/distances' );
// Calculate the edit distance between two input strings...
var dist = ns.levenshteinDistance( 'algorithm', 'altruistic' );
// returns 6