Metadata-Version: 2.1
Name: edit-operation
Version: 1.0.0
Summary: "Get the edit operations of two string"
Home-page: https://github.com/xcTorres/edit_operation
Author: xcTorres
Author-email: xcwhu2016@gmail.com
License: UNKNOWN
Project-URL: Bug Tracker, https://github.com/xcTorres/edit_operation/issues
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown

 # edit_operation

 There are already several Python packages that implement levenshtein distance, which are writtend by C or C++ to improve the efficiency. In certain occasions, besides the edit distance, the edit operations are also needed. [python-Levenshtein](https://pypi.org/project/python-Levenshtein/) has the [editops](https://rawgit.com/ztane/python-Levenshtein/master/docs/Levenshtein.html#Levenshtein-editops) function but doesn't support transpose operations. So here comes the project, **editdistpy** supports the function of edit operations under [Damerau–Levenshtein distance](https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance).


# Install 
```python
    pip install -U edit_operation
```

# Usage
The package supports distance and edit_operations two functions. They have the same parameters  
- string a
- string b
- max_distance: Only return right result under max_distance.
- is_damerau: Whether support transpose operation or not.

## distance
```python
from edit_operation import levenshtein

a = 'absolute'
b = 'absiluti'

dis = levenshtein.distance(a, b)
```
return -1 if the actual distance is beyond max_distance, by default max_distance is -1, which means no max_distance limit.

## edit_operations

```python
from edit_operation import levenshtein

a = 'absolute'
b = 'bsiluti'
operations = levenshtein.edit_operations(a, b, is_damerau=True)

"""
[{'operation': 'replace', 'location': 7, 'char_x': 'e', 'char_y': 'i'}, 
 {'operation': 'delete', 'location': 0, 'char_x': '@', 'char_y': 'a'}]
"""
```
@ character means the beginning of the input string. Return empty list if the actual distance is beyond max_distance.


