"Get the edit operations of two string"
Project description
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 has the editops function but doesn't support transpose operations. So here comes the project, editdistpy supports the function of edit operations under Damerau–Levenshtein distance.
Install
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
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
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for edit_operation-1.0.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99a6a6defe65ffb82d359cd93d2ea1d90141e5532a14ceee60057e8f4824863d |
|
MD5 | d3555cb5301a814de0b4944744db0810 |
|
BLAKE2b-256 | aca79c704231faf31b26fdf016610d92a1cb9afa5902551c9ccc04883381aae2 |
Hashes for edit_operation-1.0.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b12290aa62d21b132234fc9baf4914607ba2ae208e90cf002bb5cd643c73c67a |
|
MD5 | 6cd294e39a772cd92084cd131c19e568 |
|
BLAKE2b-256 | d30af5725029c8e00b938eb5bc28c045e035e2cfac37003c55ef5dc809d129a7 |
Hashes for edit_operation-1.0.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bef55cd43e5c39245c97bd6b7b657ffcfaf24cb2211271713d392e14623ddd8 |
|
MD5 | 9bc6d98ff01ffcb22375aba4963db747 |
|
BLAKE2b-256 | 92267e7c337aac52626849887d2dca519ba53a5791cf3a3931d6f71465f078bb |
Hashes for edit_operation-1.0.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 994ab4270ef900ee06a87085ecf1bc35cd73b9a22f58607fad3a4dfafad56a25 |
|
MD5 | 445bf7a5009b966292f29a7103e2b230 |
|
BLAKE2b-256 | ba158d1e224038036a3cfebb2b6d83d95ea552dd68b4c4b041419a7453e60c0a |
Hashes for edit_operation-1.0.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f69ea6c75f08d1181efcf5649540025496fc4b167e6e0498d8f7e9f67ee57b8 |
|
MD5 | 1647fbf64d73c04d869f9d6e71e02883 |
|
BLAKE2b-256 | 4ab06ec0cd8ead92e50d727f5bd10200a30e4b379f5c718a89d5017ef15bf261 |
Hashes for edit_operation-1.0.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a24fbde78a33a0b8b3559b1cb784e82dfda0cfc6acb2cfbd23f48a9bbedec2e1 |
|
MD5 | 67ae9a7820e73715e0bb65fd74de7a9d |
|
BLAKE2b-256 | 86847a6df6f3fb8950696dc4714a2a4c8dce3b711e8d3520b5bf7618c5fc9432 |
Hashes for edit_operation-1.0.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396f4aae097ad949eb9e8978ef19785271751ffa4f2cb534c5e2d8efd1b381ca |
|
MD5 | 15f85f6b7c3dbad1fa542ad43de72a77 |
|
BLAKE2b-256 | 500ec121ecb77b00509ec0b24483dcd3ae90f7da179ffb9d83246ca0e2475de8 |