js-levenshtein

WebJar for js-levenshtein

License

License

MIT
Categories

Categories

JavaScript Languages
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

js-levenshtein
Last Version

Last Version

1.1.6
Release Date

Release Date

Type

Type

jar
Description

Description

js-levenshtein
WebJar for js-levenshtein
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/gustf/js-levenshtein

Download js-levenshtein

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/js-levenshtein/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>js-levenshtein</artifactId>
    <version>1.1.6</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/js-levenshtein/
implementation 'org.webjars.npm:js-levenshtein:1.1.6'
// https://jarcasting.com/artifacts/org.webjars.npm/js-levenshtein/
implementation ("org.webjars.npm:js-levenshtein:1.1.6")
'org.webjars.npm:js-levenshtein:jar:1.1.6'
<dependency org="org.webjars.npm" name="js-levenshtein" rev="1.1.6">
  <artifact name="js-levenshtein" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='js-levenshtein', version='1.1.6')
)
libraryDependencies += "org.webjars.npm" % "js-levenshtein" % "1.1.6"
[org.webjars.npm/js-levenshtein "1.1.6"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

js-levenshtein Build Status

A very efficient JS implementation calculating the Levenshtein distance, i.e. the difference between two strings.

Based on Wagner-Fischer dynamic programming algorithm, optimized for speed and memory

  • use a single distance vector instead of a matrix
  • loop unrolling on the outer loop
  • remove common prefixes/postfixes from the calculation
  • minimize the number of comparisons
  • always allocate a new distance vector in order to not leak memory

Install

$ npm install --save js-levenshtein

Usage

const levenshtein = require('js-levenshtein');

levenshtein('kitten', 'sitting');
//=> 3

Benchmark

$ npm run bench
  
                      50 paragraphs, length max=500 min=240 avr=372.5
             162 op/s » js-levenshtein
              98 op/s » talisman
              94 op/s » levenshtein-edit-distance
              85 op/s » leven
              39 op/s » fast-levenshtein

                      100 sentences, length max=170 min=6 avr=57.5
           3,076 op/s » js-levenshtein
           2,024 op/s » talisman
           1,817 op/s » levenshtein-edit-distance
           1,633 op/s » leven
             800 op/s » fast-levenshtein

                      2000 words, length max=20 min=3 avr=9.5
           3,119 op/s » js-levenshtein
           2,416 op/s » talisman
           2,141 op/s » levenshtein-edit-distance
           1,855 op/s » leven
           1,260 op/s » fast-levenshtein

Benchmarks was performed with node v8.12.0 on a MacBook Pro 15", 2.9 GHz Intel Core i9

License

MIT © Gustaf Andersson

Versions

Version
1.1.6
1.1.3