levenshtein-js

1.0.2 • Public • Published

ABOUT:

A levenshtein distance implementation to find the similarity score between two sentences. The score is the number of deletions, insertions or substitutions required to transform.

INSTALL:

$ npm install levenshtein-js

USAGE:

const logger = require('log4js').getLogger();
 
const levenshtein = require('levenshtein-js');
 
let sentence1 = 'levenshtein';
let sentence2 = 'levenstei';
 
let difference = levenshtein(sentence1, sentence2);
 
// difference will be 2
logger.debug('the number of insertion,deletion or substitutions to be made: '+difference);`

WORKING:

In the above example, the character 'h' will be deleted and the character 'n' will be inserted. Here 1 insertion and 1 deletion so the difference is 2.

Package Sidebar

Install

npm i levenshtein-js

Weekly Downloads

4

Version

1.0.2

License

Apache-2.0

Last publish

Collaborators

  • vibakar
  • yuvashree