{"id":21429584,"url":"https://github.com/mayank-02/minimum-edit-distance","last_synced_at":"2025-03-16T21:43:47.826Z","repository":{"id":188402713,"uuid":"321756728","full_name":"mayank-02/minimum-edit-distance","owner":"mayank-02","description":"Implementation of Wagner–Fischer algorithm for Levenshtein distance between two strings","archived":false,"fork":false,"pushed_at":"2020-12-15T18:48:35.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T08:17:37.740Z","etag":null,"topics":["dynamic-programming","edit-distance","levenshtein-distance","python","wagner-fischer-algorithm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mayank-02.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-12-15T18:38:58.000Z","updated_at":"2020-12-15T19:00:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"91ff32b4-4015-4953-bb2a-726acaab27ab","html_url":"https://github.com/mayank-02/minimum-edit-distance","commit_stats":null,"previous_names":["mayank-02/minimum-edit-distance"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayank-02%2Fminimum-edit-distance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayank-02%2Fminimum-edit-distance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayank-02%2Fminimum-edit-distance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayank-02%2Fminimum-edit-distance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mayank-02","download_url":"https://codeload.github.com/mayank-02/minimum-edit-distance/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243940062,"owners_count":20372044,"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":["dynamic-programming","edit-distance","levenshtein-distance","python","wagner-fischer-algorithm"],"created_at":"2024-11-22T22:18:22.975Z","updated_at":"2025-03-16T21:43:47.802Z","avatar_url":"https://github.com/mayank-02.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimum Edit Distance\n\nThe similarity between two strings may be measured in many ways. One of such a string metric is known as the Levenshtein distance, which is a type of edit distance.\n\nThe edit distance between two strings is the minimum number of single-character insertions, deletions, or substitutions required to change one string into the other.\n\nThe class `Levenshtein.py` implements the **[Wagner–Fischer algorithm](https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm)** allowing to pass **varying costs** for insertion, deletion and substitution.\n\nFor more info on Levenshtein distance, refer [wiki](https://en.wikipedia.org/wiki/Levenshtein_distance).\n\n## Requirements\n\n- Python 3.6+\n- No dependencies on any other library\n\n## Usage\n\n```python\nfrom Levenshtein import Levenshtein\n\nsource = \"hello\"\ntarget = \"world\"\n\nl = Levenshtein(source, target, costs=(1, 1, 2))\n\nmin_distance = l.distance()\n# min_distance = 4\n\noperations = l.edit_ops()\n# operations =\n# [{'type': 'Substitution', 'i': 0, 'j': 0},\n#  {'type': 'Substitution', 'i': 1, 'j': 1},\n#  {'type': 'Substitution', 'i': 2, 'j': 2},\n#  {'type': 'Match',        'i': 3, 'j': 3},\n#  {'type': 'Substitution', 'i': 4, 'j': 4}]\n\nl.print_distance_matrix()\n# Distance Matrix:\n# -  -  w  o  r  l  d\n# -  0  2  4  6  8 10\n# h  2  1  3  5  7  9\n# e  4  3  2  4  6  8\n# l  6  5  4  3  4  6\n# l  8  7  6  5  3  5\n# o 10  9  7  7  5  4\n\nl.print_edit_ops()\n# Edit Operations:\n# Type           i  j\n# --------------------\n# Substitution   0  0\n# Substitution   1  1\n# Substitution   2  2\n# Match          3  3\n# Substitution   4  4\n```\n\nCheck out `Levenshtein.py` for more details.\n\n## Authors\n\n[Mayank Jain](https://github.com/mayank-02)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayank-02%2Fminimum-edit-distance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayank-02%2Fminimum-edit-distance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayank-02%2Fminimum-edit-distance/lists"}