npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wuzzy

v0.1.8

Published

library for simularity identification

Downloads

306,078

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 (npm install wuzzy).

Examples

Some examples of using Wuzzy can be found in the 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