Skip to main content

dam_lev

Author:

Daniel Walker

Version:

0.1.2

Date:

2023-01-05

Overview

The dam_lev package implements the Damerau–Levenshtein diff algorithm. That is, it will take two sequences and determine the minimum number of transpositions, substitutions, insertions, and deletions needed to transform the first sequence into the second.

Usage

The package exposes a single function, dam_lev.get_changes. It takes two sequences (i.e., they must implement the __len__ and __getitem__ methods) and returns a list of dam_lev.Mutation objects. There are four subclasses of dam_lev.Mutation corresponding to the four types of transformations. For example,

diffs = dam_lev.get_changes('abcdef', 'bcedxy')
print(diffs) # [Deletion(at=0), Transposition(at=3), Substitution(at=5, at2=4), Insertion(at=6, at2=5)]

We see that the sequence of transformations is:

  • Delete the item at index 0 ('a')

  • Transpose the item at index 3 ('d') with its successor

  • Substitute the item at index 5 ('f') with the item from the second sequence at index 4 ('x')

  • Insert at index 6 the item from the second sequence at index 5 ('y')

Note the index for the transposition. Even though, after the deletion, the 'd' is at index 2, it’s at index 3 in the original version of the sequence. Likewise for the successive mutations.

Key function

You can also pass a callable as the key keyword argument to dam_lev.get_changes. Similar to list.sort, this callable will be used to compare the elements of the sequences. For example,

diffs = dam_lev.get_changes('aBc', 'AbC', key=str.upper)
print(diffs) # []

Metadata

Release files for dam-lev 0.1.2

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

Source distribution (sdist)

Source distribution for dam-lev 0.1.2
File Size Uploaded Provenance Actions
dam_lev-0.1.2.tar.gz 3.6 kB Without provenance Details for dam_lev-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dam-lev 0.1.2
File Interpreter ABI Platform Actions
dam_lev-0.1.2-py3-none-any.whl Python 3 none any Details for dam_lev-0.1.2-py3-none-any.whl

Total release size: 7.5 kB

Release files / dam_lev-0.1.2.tar.gz

Download URL dam_lev-0.1.2.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a2ab0e04751c51ca118a6a0ae31b923db3a78f355e3dc3cf6e33a93711ae17fd
BLAKE2b-256 checksum
How to use checksums
e245ad5e9475b5ff7c38cc3c44b3b0c5fda2618e5ee8b01a4dccf30c52e25ec0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / dam_lev-0.1.2-py3-none-any.whl

Download URL dam_lev-0.1.2-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e0b5e3d5d6f948b0718b848183d44b70af073bddb260c1810826eaec29486eb
BLAKE2b-256 checksum
How to use checksums
a4d7599555989638860f3b309d3798d03a94dbf3c1d75a80ab45a78a5b4cf66e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Security for dam-lev 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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