Skip to content

Fast string distance function for the case where the distance is less or equal to 1

License

Notifications You must be signed in to change notification settings

mapado/edit_distance_lte1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

edit_distance_lte1

Fast string distance function for the case where the distance is less or equal to 1.

For some use cases (e.g simple spell checking), we are only interested in knowing if the edit distance between two strings is less or equal to 1.

Computing the exact distance, for distances above 1, is then useless and potentially time consuming.

This library computes the distance between two strings and return either :

  • 0 : strings are equals
  • 1 : there is one addition / suppression / replacement
  • 7 : there are more than 1 edit operations

This is a Python binding over a C implementation inspired by the python-Levenshtein library.

Installation

$ pip install edit-distance-lte1

Usage

from edit_distance_lte1 import distance

# distance = 0
distance('mike', 'mike')
>> 0

# distance = 1
distance('mike', 'ike')
>> 1

# distance above 1 -> return max distance value (7)
distance('mike', 'remike')
>> 7

Contributing

Clone the project.

Install pipenv.

Launch test with make test

About

Fast string distance function for the case where the distance is less or equal to 1

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published