Coder Social home page Coder Social logo

ogus / jaro-winkler Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 8 KB

A measure of distance between words with the Jaro-Winkler algorithm

License: Do What The F*ck You Want To Public License

JavaScript 70.65% HTML 29.35%
jaro-winkler jaro winkler distance similarity string text

jaro-winkler's Introduction

Jaro-Winkler distance

An algorithm to compute strings similarity / distance.

For an accurate description, see Wikipedia.

Usage

JaroWinkler.distance("qwerty", "qwertyu");
// output: 0.028571[...]

JaroWinkler.distance("foo", "");
// output: 1

JaroWinkler.similarity("one", "once");
// output: 0.933333[...]

JaroWinkler.similarity("One", "once", {caseSensitive: true});
// output: 0.722222[...]

API

The module has two method, one for similarity and one for distance

  • They both accept the same input arguments
  • They both return a value in the range [0, 1]
  • They are complementary: similarity = 1 - distance (with perfect floating point precision)

JaroWinkler.similarity(string1, string2, inputConfig={})

Takes two strings as input, and an optionnal configuration, and compute their similarity.

It returns a value in value in the range [0, 1]. A value of 0 corresponds to no similarity, a value of 1 corresponds to complete similarity.

JaroWinkler.distance(string1, string2, inputConfig={})

Takes two strings as input, and an optionnal configuration, and compute their similarity.

It returns a value in value in the range [0, 1]. A value of 0 corresponds to no distance, a value of 1 corresponds to the maximum distance.

Configuration

  • caseSensitive: boolean, indicates if the similarity should be case-sensitive (default: false)
  • enableWinkler: boolean, indicates if the Winkler score modifier should be used (default: true)
  • scalingFactor: float, set how much the score is adjusted to common prefixes (default: 0.25)
  • prefixLength: integer, set the length of words prefix (default: 4)

This is the default config:

var config = {
  caseSensitive: false,
  enableWinkler: true,
  scalingFactor: 0.1,
  prefixLength: 4
};

Installation

The module can be installed from npm

npm install @ogus/jaro-winkler

It can also be installed by downloading the repo & including the jaro-winkler.js file in your project.

License

This project is licensed under the WTFPL - see LICENSE for more details

jaro-winkler's People

Contributors

ogus avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.