项目作者: mrshu

项目描述 :
A simple NodeJS (NPM) module for weighted Damerau–Levenshtein distance.
高级语言: JavaScript
项目地址: git://github.com/mrshu/node-weighted-damerau-levenshtein.git
创建时间: 2019-10-01T09:46:17Z
项目社区:https://github.com/mrshu/node-weighted-damerau-levenshtein

开源协议:Apache License 2.0

下载


Weighted Damerau–Levenshtein distance

Travis (.org) Coverage Status NPM

A simple Node module that allows you to compute Damerau–Levenshtein
distance

with custom weights for insertion, deletion and/or substitution (they all
default to 1). It is inspired by the
damerau-levenshtein
and
damerau-levenshtein-js
packages.

  1. let dldist = require('weighted-damerau-levenshtein');
  2. const d = dldist('hello word', 'Hello World!');
  3. // 4 -> two substitutions and two insertions
  4. const s = dldist('hello word', 'Hello World!', { insWeight: 0.5 });
  5. // 3 -> two substitutions with weight 1 and two insertions with weight 0.5

It also optionally allows you to turn-off the “Damerau” part of the
Damerau-Levenshtein distance (i..e the transpositions), which makes it the
standard Levenshtein distance.

  1. let dldist = require('weighted-damerau-levenshtein');
  2. const d = dldist('Hi there', 'Hi tehre');
  3. // 1 -> one transpostion (counted with the default subsitution weight)
  4. const s = dldist('Hi there', 'Hi tehre', { useDamerau: false });
  5. // 2 -> one substitution and one deletion (both with default weight)

Install

  1. npm install weighted-damerau-levenshtein

License

Licensed under the terms of the Apache 2.0 license. See the
LICENSE file for more details.