1. damerau-levenshtein
Damerau - Levenshtein distance by The Spanish Inquisition + relative distance
damerau-levenshtein
Package: damerau-levenshtein
Created by: tad-lispy
Last modified: Tue, 14 Jun 2022 08:29:48 GMT
Version: 1.0.8
License: BSD-2-Clause
Downloads: 51,945,289
Repository: https://github.com/tad-lispy/node-damerau-levenshtein

Install

npm install damerau-levenshtein
yarn add damerau-levenshtein

NPM

It provides a function that takes two string arguments and returns a hash like this:

 {
  steps: 5,       // Levenstein demerau distance
  relative: 0.7,  // steps / length of the longer string
  similarity: 0.3 // 1 - relative
}

Install

 npm install damerau-levenshtein

Use with ES6 modules

 import * as levenshtein from 'damerau-levenshtein';

const lev = levenshtein('hello world', 'Hello World!');
// { steps: 4, relative: 0.3076923076923077, similarity: 0.6923076923076923 }

Please see tests for more insights.

Use with TypeScript

 import * as levenshtein from 'damerau-levenshtein';

interface LevenshteinResponse {
  steps: number;
  relative: number;
  similarity: number;
}

const lev: LevenshteinResponse = levenshtein('hello world', 'Hello World!');

console.log(lev.steps);
// 2
console.log(lev.foo);
// TypeScript Error: Property 'foo' does not exist on type 'LevenshteinResponse'.

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code