npm.io
1.0.1 • Published 4 years ago

@autumnrowan/levensort

Licence
ISC
Version
1.0.1
Deps
0
Size
3 kB
Vulns
0
Weekly
0

levensort

A basic Wagner-Fischer implementation of the Levenshtein / Minimum Edit Distance algorithm. Solves in O(mn) for now.

NOTE: HEAVILY A WORK IN PROGRESS. Subject to change or breaking. NOT STABLE.

Use

npm install @autumnrowan/levensort

Then, require the package

const { levenshtein, levensearch } = require("@autumnrowan/levensort");

const database = ["julius caeser", "julia", "july", "orange julius"];

const search_results = levensearch(database, "julio", 100, 6);

console.log(search_results);

Output

[
    { value: 'julia', score: 1},
    { value: 'july', score: 2}, 
]

Docs

levenshtein() - takes two arguments, a (target) b (source) as strings.

levensearch() - arr array to search source source string limit limit results maxTolerance max distance