levenshteinDistance
Calculate the Levenshtein (edit) distance between two strings.
Usage
var levenshteinDistance = require( '@stdlib/string/base/distances/levenshtein' );
levenshteinDistance( s1, s2 )
Calculates the Levenshtein (edit) distance between two strings.
var dist = levenshteinDistance( 'frog', 'from' );
// returns 1
dist = levenshteinDistance( 'frog', 'froth' );
// returns 2
dist = levenshteinDistance( 'cat', 'kitty' );
// returns 4
dist = levenshteinDistance( '', 'abcdef' );
// returns 6
dist = levenshteinDistance( '1638452297', '2311638451' );
// returns 7
Examples
var levenshteinDistance = require( '@stdlib/string/base/distances/levenshtein' );
var dist = levenshteinDistance( 'algorithm', 'altruistic' );
// returns 6
dist = levenshteinDistance( 'elephant', 'hippo' );
// returns 7
dist = levenshteinDistance( 'javascript', 'typescript' );
// returns 4
dist = levenshteinDistance( 'levenshtein', 'leviathan' );
// returns 6