Giter Club home page Giter Club logo

stringsoup's Introduction

StringSoup

Use a variety of string similarity functions to find the best string in a group of strings.

Example Usage

import { StringSoup } from 'stringsoup';

const stringSoup = new StringSoup([
  'London',
  'Washington',
  'Mumbai',
  'Sydney',
  'Tokyo',
  'Moscow',
  'Neverland',
]);

const result = stringSoup.matchSoup('wshng');
/*
 {
  best: {
    token: 'wshng',
    match: { knownString: 'Washington', score: 0.7333333333333334 }
  },
  all: [
    {
      token: 'wshng',
      match: { knownString: 'Washington', score: 0.7333333333333334 }
    }
  ]
}
 */

const result = stringSoup.matchSoup(
  'I like to visit lndon, but I live elsewhere'
);
/*
{
  best: {
    token: 'lndon,',
    match: { knownString: 'London', score: 0.6527777777777778 }
  },
  all: [
    {
      token: 'lndon,',
      match: { knownString: 'London', score: 0.6527777777777778 }
    },
    {
      token: 'to',
      match: { knownString: 'Tokyo', score: 0.5666666666666667 }
    },
    {
      token: 'elsewhere',
      match: { knownString: 'Neverland', score: 0.5555555555555555 }
    },
    {
      token: 'visit',
      match: { knownString: 'Washington', score: 0.5222222222222221 }
    },
    { token: 'but', match: { knownString: 'Mumbai', score: 0.5 } },
    {
      token: 'like',
      match: { knownString: 'Tokyo', score: 0.48333333333333334 }
    },
    {
      token: 'live',
      match: { knownString: 'Sydney', score: 0.47222222222222215 }
    },
    { token: 'I', match: { knownString: 'London', score: 0 } },
    { token: 'I', match: { knownString: 'London', score: 0 } }
  ]
}
*/

TODO

  • Add options to sanitize
    • Charset transformations
    • Ignored characters
    • Replaced characters
  • Add options to tokenize
    • Specify delimiters
  • Add different distance functions

stringsoup's People

Contributors

puj avatar

Watchers

James Cloos 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.