Git Product home page Git Product logo

seqfuzz's Introduction

Seqfuzz is an implementation of a sequential fuzzy string matching algorithm, similar to those used in code editors like Sublime Text. It is based on Forrest Smith's work on lib_ftps and his blog post Reverse Engineering Sublime Text's Fuzzy Match.

There is an alternate implementation by @WolfDan which can be found here: Fuzzy Match v0.2.0 Elixir.

Documentation

Installation

The package can be installed by adding seqfuzz to your list of dependencies in mix.exs:

def deps do
  [
    {:seqfuzz, "~> 0.2.0"}
  ]
end

Examples

  iex> Seqfuzz.match("Hello, world!", "hellw")
  %{match?: true, matches: [0, 1, 2, 3, 7], score: 202}

  iex> items = [{1, "Hello Goodbye"}, {2, "Hell on Wheels"}, {3, "Hello, world!"}]
  iex> Seqfuzz.filter(items, "hellw", &(elem(&1, 1)))
  [{3, "Hello, world!"}, {2, "Hell on Wheels"}]

Scoring

Scores can be passed as options if you want to override the defaults. I have added additional separators as a default as well as two additional scoring features: case match bonus and string match bonus. Case match bonus provides a small bonus for matching case. String match bonus provides a large bonus when the pattern and the string match exactly (although with different cases) to make sure that those results are always highest.

Changelog

  • 0.2.0 - Change scoring to be via options instead of configuration.
  • 0.1.0 - Initial version. Supports basic algorithm but does not search recursively for better matches.

Roadmap

  • Add support for recursive search for better matches.
  • Add support for asynchronous stream search.

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.