Metadata-Version: 2.1
Name: pyeditdistance
Version: 0.0.4
Summary: A pure, minimalist Python library of various edit distances
Project-URL: Homepage, https://github.com/cgshep/pyeditdistance
Project-URL: Bug Tracker, https://github.com/cgshep/pyeditdistance/issues
Author-email: Carlton Shepherd <carlton@linux.com>
License: MIT License
        
        Copyright (c) 2022 Carlton Shepherd
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown

# pyeditdistance
A pure, minimalist, single-file Python library of various edit distance metrics.

Implemented methods:
  - Levenshtein (iterative and recursive implementations)
  - Normalized Levenshtein (using Yujian-Bo [1])
  - Damerau-Levenshtein
  - Hamming distance

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 Gault"

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

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

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

# 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
```

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