3.0.7 • Published 4 years ago

node-levenshtein v3.0.7

Weekly downloads
105
License
MIT
Repository
github
Last release
4 years ago

node-levenshtein :rocket:

Fastest JavaScript implementation of the Levenshtein distance algorithm - (up to 10x+ faster than closest competitor). This algorithm can be used to measure the similarity of two strings. The performance has been achieved by using Myers' bit-parallel algorithm.

Note: if you need to take the edit distance of one string against many strings (maybe billions), I have created a GPU-implementation that will be atleast 1000x faster than this. Contact me, if you're interested.

Build Status Coverage Status

$ npm install node-levenshtein --save

Usage

const levenshtein = require('node-levenshtein')

// Print edit-distance between 'fast' and 'faster' 
console.log(levenshtein.compare('fast', 'faster'))
//=> 2

// Print string from array with lowest edit-distance to 'fast'
console.log(levenshtein.find('fast', ['slow', 'faster', 'fastest']))
//=> 'faster'

Benchmark

I generated 500 pairs of strings with length N. I measured the ops/sec each library achieves to process all the given pairs. Higher is better. node-levenshtein is a lot faster in all cases.

Test TargetN=4N=8N=16N=32N=64N=128N=256N=512N=1024
node-levenshtein4242317237557734282013596.1182.649.8812.99
js-levenshtein24012126844100131137197.2525.406.4041.632
leven3029111002337890722759.9415.593.9580.998
talisman298599782331992623463.7616.123.9890.986
fast-levenshtein235177686229157615440.1310.162.5580.643
levenshtein-edit-distance3142310783320985121456.1314.243.6940.931

Relative Performance

This image shows the relative performance between node-levenshtein and js-levenshtein (the 2nd fastest). As you can see, node-levenshtein is a lot faster for small strings, but especially for long strings (8x faster when N = 1024).

Benchmark

License

This project is licensed under the MIT License - see the LICENSE.md file for details

3.0.7

4 years ago

3.0.6

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.5

4 years ago

3.0.0

4 years ago

2.0.13

5 years ago

2.0.12

5 years ago

2.0.11

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago