# wuzzy

> library for simularity identification

Latest version **0.1.8** (published 2021-06-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install wuzzy
pnpm add wuzzy
yarn add wuzzy
bun add wuzzy
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.8 |
| Published | 2021-06-26 |
| First published | 2014-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/wuzzy) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 37 |
| Author | Joe D'Alessandro |
| Maintainers | xupit3r |
| Keywords | text, fuzzy, similar, jaccard, jarowinkler, tanimoto, levenshtein, ngram |

## Links

- npm: https://www.npmjs.com/package/wuzzy
- Repository: https://github.com/xupit3r/wuzzy
- Homepage: https://github.com/xupit3r/wuzzy#readme
- Issues: https://github.com/xupit3r/wuzzy/issues
- npm.io page: https://npm.io/package/wuzzy

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 0.1.8 (latest) — 2021-06-26
- 0.1.7 — 2021-04-10
- 0.1.6 — 2020-09-07
- 0.1.5 — 2020-04-07
- 0.1.4 — 2019-07-20
- 0.1.3 — 2016-11-06
- 0.1.2 — 2014-08-14
- 0.1.1 — 2014-06-08
- 0.1.0 — 2014-04-12
- 0.0.0 — 2014-03-25

## README

# Overview

Wuzzy was created to provide a smattering of some similarity identification stuff. Several simularity identification algorithm implementations are provided, including:

* Jaccard similarity coefficient
* Tanimoto coefficient
* Pearson correlation
* N-gram edit distance
* Levenshtein distance
* Jaro-Winkler distance

Fuzzy wuzzy was a bear, fuzzy wuzzy had no hair, fuzzy wuzzy wasn't very fuzzy, was he? Well, if you aren't sure maybe this library can help! :) 

# Installing
Wuzzy can be installed via [npm](http://npmjs.org/package/wuzzy)  (`npm install wuzzy`).

# Examples
Some examples of using Wuzzy can be found in the [real-wuzzy](https://github.com/xupit3r/real-wuzzy) repository.

# Methods
All bad jokes aside, below is a listing of the available functions. Have fun!

## jarowinkler(a, b, t)

Computes the jaro-winkler distance for two given arrays.

NOTE: this implementation is based on the one found in the
Lucene Java library.
### Examples:

    wuzzy.jarowinkler(
            ['D', 'W', 'A', 'Y', 'N', 'E'],
            ['D', 'U', 'A', 'N', 'E']
        );
        // -> 0.840

    wuzzy.jarowinkler(
            'DWAYNE',
            'DUANE'
        );
        // -> 0.840

### Params: 

* **String|Array** *a* - the first string/array to compare
* **String|Array** *b* - the second string/array to compare
* **Number** *t* - the threshold for adding

### Return:

* **Number** returns the jaro-winkler distance for

## levenshtein(a, b, w)

Calculates the levenshtein distance for the
two provided arrays and returns the normalized
distance.
### Examples:

    wuzzy.levenshtein(
            ['D', 'W', 'A', 'Y', 'N', 'E'],
            ['D', 'U', 'A', 'N', 'E']
        );
        // -> 0.66666667

        or

    wuzzy.levenshtein(
            'DWAYNE',
            'DUANE'
        );
        // -> 0.66666667

### Params: 

* **String|Array** *a* - the first string/array to compare
* **String|Array** *b* - the second string/array to compare
* **Object** *w* - (optional) a set of key/value pairs

### Return:

* **Number** returns the levenshtein distance for

## ngram(a, b, ng)

Computes the n-gram edit distance for any n (defaults to 2).

NOTE: this implementation is based on the one found in the
Lucene Java library.
### Examples:

    wuzzy.ngram(
            ['D', 'W', 'A', 'Y', 'N', 'E'],
            ['D', 'U', 'A', 'N', 'E']
        );
        // -> 0.583

        or

    wuzzy.ngram(
            'DWAYNE',
            'DUANE'
        );
        // -> 0.583

### Params: 

* **String|Array** *a* - the first string/array to compare
* **String|Array** *b* - the second string/array to compare
* **Number** *ng* - (optional) the n-gram size to work with (defaults to 2)

### Return:

* **Number** returns the ngram distance for

## pearson(a, b)

Calculates a pearson correlation score for two given
objects (compares values of similar keys).
### Examples:

    wuzzy.pearson(
            {a: 2.5, b: 3.5, c: 3.0, d: 3.5, e: 2.5, f: 3.0},
            {a: 3.0, b: 3.5, c: 1.5, d: 5.0, e: 3.5, f: 3.0, g: 5.0}
        );
        // -> 0.396

        or

    wuzzy.pearson(
            {a: 2.5, b: 1},
            {o: 3.5, e: 6.0}
        );
        // -> 1.0

### Params: 

* **Object** *a* - the first object to compare
* **Object** *b* - the second object to compare

### Return:

* **Number** returns the pearson correlation for

## jaccard(a, b)

Calculates the jaccard index for the two
provided arrays.
### Examples:

    wuzzy.jaccard(
            ['a', 'b', 'c', 'd', 'e', 'f'],
            ['a', 'e', 'f']
        );
        // -> 0.5

        or

    wuzzy.jaccard(
            'abcdef',
            'aef'
        );
        // -> 0.5

        or 

    wuzzy.jaccard(
            ['abe', 'babe', 'cabe', 'dabe', 'eabe', 'fabe'],
            ['babe']
        );
        // -> 0.16666667

### Params: 

* **String|Array** *a* - the first string/array to compare
* **String|Array** *b* - the second string/array to compare

### Return:

* **Number** returns the jaccard index for

## tanimoto(a, b)

Calculates the tanimoto distance (weighted jaccard index).
### Examples:

    wuzzy.tanimoto(
            ['a', 'b', 'c', 'd', 'd', 'e', 'f', 'f'],
            ['a', 'e', 'f']
        );
        // -> 0.375

        or

    wuzzy.tanimoto(
            'abcddeff',
            'aef'
        );
        // -> 0.375

        or 

    wuzzy.tanimoto(
            ['abe', 'babe', 'cabe', 'dabe', 'eabe', 'fabe', 'fabe'],
            ['babe']
        );
        // -> 0.14285714

### Params: 

* **String|Array** *a* - the first string/array to compare
* **String|Array** *b* - the second string/array to compare

### Return:

* **Number** returns the tanimoto distance for

<!-- End ./index.js -->

---
_Source: https://npm.io/package/wuzzy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
