{"id":22668637,"url":"https://github.com/lanl/pyxdameraulevenshtein","last_synced_at":"2026-04-04T12:57:59.621Z","repository":{"id":45041965,"uuid":"9456338","full_name":"lanl/pyxDamerauLevenshtein","owner":"lanl","description":"pyxDamerauLevenshtein implements the Damerau-Levenshtein (DL) edit distance algorithm for Python in Cython for high performance.","archived":false,"fork":false,"pushed_at":"2023-04-17T17:39:05.000Z","size":565,"stargazers_count":237,"open_issues_count":4,"forks_count":31,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-10T06:10:58.654Z","etag":null,"topics":["cython","damerau-levenshtein","edit-distance-algorithm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lanl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2013-04-15T19:21:04.000Z","updated_at":"2024-03-19T12:13:36.000Z","dependencies_parsed_at":"2023-09-26T03:39:52.521Z","dependency_job_id":null,"html_url":"https://github.com/lanl/pyxDamerauLevenshtein","commit_stats":{"total_commits":132,"total_committers":13,"mean_commits":"10.153846153846153","dds":"0.18939393939393945","last_synced_commit":"84575c5ae726575cfa55072092628c949c903a04"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FpyxDamerauLevenshtein","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FpyxDamerauLevenshtein/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FpyxDamerauLevenshtein/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FpyxDamerauLevenshtein/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lanl","download_url":"https://codeload.github.com/lanl/pyxDamerauLevenshtein/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135144,"owners_count":20889421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cython","damerau-levenshtein","edit-distance-algorithm"],"created_at":"2024-12-09T15:16:04.926Z","updated_at":"2026-04-01T16:45:37.721Z","avatar_url":"https://github.com/lanl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyxDamerauLevenshtein\n\n[![Tests](https://github.com/lanl/pyxDamerauLevenshtein/actions/workflows/tests.yml/badge.svg)](https://github.com/lanl/pyxDamerauLevenshtein/actions/workflows/tests.yml)\n\n## LICENSE\nThis software is licensed under the [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause). Please refer to the separate [LICENSE](LICENSE) file for the exact text of the license. You are obligated to give attribution if you use this code.\n\n## ABOUT\npyxDamerauLevenshtein implements the Damerau-Levenshtein (DL) edit distance algorithm for Python in Cython for high performance. Courtesy [Wikipedia](http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance):\n\n\u003e In information theory and computer science, the Damerau-Levenshtein distance (named after Frederick J. Damerau and Vladimir I. Levenshtein) is a \"distance\" (string metric) between two strings, i.e., finite sequence of symbols, given by counting the minimum number of operations needed to transform one string into the other, where an operation is defined as an insertion, deletion, or substitution of a single character, or a transposition of two adjacent characters.\n\nThis implementation is based on [Michael Homer's pure Python implementation](https://web.archive.org/web/20150909134357/http://mwh.geek.nz:80/2009/04/26/python-damerau-levenshtein-distance/), which implements the [optimal string alignment distance algorithm](https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance#Optimal_string_alignment_distance). It runs in `O(N*M)` time using `O(M)` space. It supports unicode characters.\n\n## REQUIREMENTS\nThis code requires Python 3.9+, C compiler such as GCC, and Cython.\n\n## INSTALL\npyxDamerauLevenshtein is available on PyPI at https://pypi.org/project/pyxDamerauLevenshtein/.\n\nInstall using [pip](https://pypi.org/project/pip/):\n\n    pip install pyxDamerauLevenshtein\n\n## USING THIS CODE\nThe following methods are available:\n\n* **Edit distance** (`damerau_levenshtein_distance`)\n    * Compute the raw distance between two sequences (i.e., the minimum number of operations necessary to transform one sequence into the other).\n    * Supports any sequence type: `str`, `list`, `tuple`, `range`, and more.\n    * Optionally accepts a `max_distance` integer threshold. If the true distance exceeds it, `max_distance + 1` is returned immediately, avoiding unnecessary computation.\n\n* **Normalized edit distance** (`normalized_damerau_levenshtein_distance`)\n    * Compute the ratio of the edit distance to the length of `max(seq1, seq2)`. 0.0 means that the sequences are identical, while 1.0 means that they have nothing in common. Note that this definition is the exact opposite of [`difflib.SequenceMatcher.ratio()`](https://docs.python.org/3/library/difflib.html#difflib.SequenceMatcher.ratio).\n\n* **Edit distance against a sequence of sequences** (`damerau_levenshtein_distance_seqs`)\n    * Compute the raw distances between a sequence and each sequence within another sequence (e.g., `list`, `tuple`).\n    * Optionally accepts a `max_distance` threshold forwarded to each individual computation.\n\n* **Normalized edit distance against a sequence of sequences** (`normalized_damerau_levenshtein_distance_seqs`)\n    * Compute the normalized distances between a sequence and each sequence within another sequence (e.g., `list`, `tuple`).\n\nBasic use:\n\n```python\nfrom pyxdameraulevenshtein import damerau_levenshtein_distance, normalized_damerau_levenshtein_distance\ndamerau_levenshtein_distance('smtih', 'smith')  # expected result: 1\nnormalized_damerau_levenshtein_distance('smtih', 'smith')  # expected result: 0.2\ndamerau_levenshtein_distance([1, 2, 3, 4, 5, 6], [7, 8, 9, 7, 10, 11, 4])  # expected result: 7\n\n# max_distance short-circuits when the true distance exceeds the threshold\ndamerau_levenshtein_distance('saturday', 'sunday', max_distance=2)  # expected result: 3 (max_distance + 1)\n\nfrom pyxdameraulevenshtein import damerau_levenshtein_distance_seqs, normalized_damerau_levenshtein_distance_seqs\narray = ['test1', 'test12', 'test123']\ndamerau_levenshtein_distance_seqs('test', array)  # expected result: [1, 2, 3]\nnormalized_damerau_levenshtein_distance_seqs('test', array)  # expected result: [0.2, 0.3333333333333333, 0.42857142857142855]\n```\n\n## DIFFERENCES\nOther Python DL implementations:\n\n* [Michael Homer's native Python code](https://web.archive.org/web/20150909134357/http://mwh.geek.nz:80/2009/04/26/python-damerau-levenshtein-distance/)\n* [jellyfish](https://github.com/jamesturk/jellyfish)\n* [RapidFuzz](https://github.com/rapidfuzz/RapidFuzz)\n\nWhen pyxDamerauLevenshtein was initially released in 2013, it was the fastest DL implementation available for Python and the only one with unicode support, and it remained that way for many years. Since then, libraries like [RapidFuzz](https://github.com/rapidfuzz/RapidFuzz) have eclipsed it in performance. pyxDamerauLevenshtein still offers respectable performance via Cython and is a solid choice if absolute maximum speed is not a requirement.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanl%2Fpyxdameraulevenshtein","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flanl%2Fpyxdameraulevenshtein","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanl%2Fpyxdameraulevenshtein/lists"}