Skip to main content

pyeditdistance

PyPI PyPI - Downloads PyPI - License

A pure, minimalist Python library of various edit distance metrics. MIT-licensed, zero dependencies.

Implemented methods:

Levenshtein and Damerau-Levenshtein distances use the Wagner-Fischer dynamic programming algorithm [2].

Some basic unit tests can be executed using pytest

Installation

pip install pyeditdistance

Optional (user-specific): pip install --user pyeditdistance

Usage

from pyeditdistance import distance as d

s1 = "I am Joe Bloggs"
s2 = "I am John Galt"

# Levenshtein distance
res = d.levenshtein(s1, s2) # => 8

# Normalized Levenshtein
res = d.normalized_levenshtein(s1, s2) # => 0.4324...

# Damerau-Levenshtein
s3 = "abc"
s4 = "cb"
res = d.damerau_levenshtein(s3, s4) # => 2

# Hamming distance
s5 = "abcccdeeffghh zz"
s6 = "bacccdeeffhghz z"
res = d.hamming(s5, s6) # => 6

# Longest common subsequence (LCS)
s7 = "AAGGQQERqer"
s8 = "AaQERqer"
res = d.longest_common_subsequence(s7, s8) # => 7

References

  1. L. Yujian and L. Bo, "A normalized Levenshtein distance metric," IEEE Transactions on Pattern Analysis and Machine Intelligence (2007). https://ieeexplore.ieee.org/document/4160958
  2. R. Wagner and M. Fisher, "The string to string correction problem," Journal of the ACM, 21:168-178, 1974.

Metadata

Release files for pyeditdistance 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyeditdistance 1.0.1
File Size Uploaded
pyeditdistance-1.0.1.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyeditdistance 1.0.1
File Interpreter ABI Platform
pyeditdistance-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / pyeditdistance-1.0.1.tar.gz

Download URL pyeditdistance-1.0.1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cab95198abe506437d2a82bfe151f63ed1f62358e3358522d4c0b5e96d258308
BLAKE2b-256 checksum
How to use checksums
cfcb2946404f631983903ddaa53da379bc16d15b922dc190c526b8958d81e229
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.12

Release files / pyeditdistance-1.0.1-py3-none-any.whl

Download URL pyeditdistance-1.0.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
525fc3c241bc9dbd3a713236d3d85ab299620b37a186c6df76ff4856597db148
BLAKE2b-256 checksum
How to use checksums
33b6e9ada1f6cc8bb748ed0f81912d760edfa03e1c94ff5f70e70a47099b5243
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.12

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0

2 release files

0.1

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page