Giter Site home page Giter Site logo

mbleven's Introduction

mbleven

mbleven is a fast, memory-efficient algorithm to compute k-bounded Levenshtein distance.

If the upper-bound parameter k is small (especially k=1,2), this algorithm runs much faster than the Wagner-Fischer algorithm.

For details, see the documentation.

IMPORTANT NOTICE

This is a proof-of-concept implementation to show how mbleven algorithm works. If you are searching for a practical library to compute Levenshtein distance, please take a look at polyleven.

Installation

Clone this repository and run setup.py

$ git clone https://github.com/fujimotos/mbleven
$ cd mbleven
$ sudo python setup.py install

Usage

This module provides a function named compare(). It takes two strings as arguments and returns an integer, which is...

  • the exact distance between two strings (if they are within two edit distance)
  • -1 (if they are over two edit distance away)

Therefore, the return value should be any one of 0, 1, 2 or -1.

>>> from mbleven import compare
>>> compare("meet", "meat")
1
>>> compare("meet", "eat")
2
>>> compare("meet", "mars")  # distance 3
-1

You can also measure the similarity using Damerau-Levenshtein distance by setting transpose flag true.

>>> compare("meat", "meta", transpose=True)
1
>>> compare("abc", "ca", transpose=True)
2

mbleven's People

Contributors

fujimotos 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.