1.3.0 • Published 5 years ago
lshtein v1.3.0
Levenshtein Edit Distance
Calculates the edit distance i.e. the minimum number of changes needed to turn string A into string B.
Installation:
- Run
npm i lshtein
in your project directory.
Initialization:
The package can be imported as an ES Module in Node 13.2.0+ or in Node 12 with the --experimental-modules
flag. You may also need to add "type": "module"
to your project's package.json
.
import { lshtein } from 'lshtein';
Import as a CommonJS module is also possible:
const lshtein = require('lshtein');
Usage
Use the lshtein
function and provide two strings to get the edit distance between them:
const distance = lshtein('kitten', 'sitting');
console.log(distance) // prints 3