@stdlib/string-base-distances
v0.2.2
Published
Implementations of various string similarity metrics.
Downloads
26
Readme
Distances
Implementations of various string similarity metrics.
Installation
npm install @stdlib/string-base-distances
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
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.