{"id":22927201,"url":"https://github.com/hapytex/levenshtein","last_synced_at":"2025-04-01T15:42:22.443Z","repository":{"id":41047917,"uuid":"380326786","full_name":"hapytex/levenshtein","owner":"hapytex","description":"A module to calculate the edit distance between two lists.","archived":false,"fork":false,"pushed_at":"2022-07-27T22:30:18.000Z","size":7916,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T22:30:38.612Z","etag":null,"topics":["edit-distance","levenshtein-distance"],"latest_commit_sha":null,"homepage":"https://hackage.haskell.org/package/levenshtein","language":"Haskell","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/hapytex.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":"https://www.buymeacoffee.com/hapytex"}},"created_at":"2021-06-25T18:40:46.000Z","updated_at":"2022-06-20T19:40:14.000Z","dependencies_parsed_at":"2022-09-09T21:12:08.072Z","dependency_job_id":null,"html_url":"https://github.com/hapytex/levenshtein","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapytex%2Flevenshtein","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapytex%2Flevenshtein/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapytex%2Flevenshtein/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapytex%2Flevenshtein/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hapytex","download_url":"https://codeload.github.com/hapytex/levenshtein/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246666043,"owners_count":20814424,"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":["edit-distance","levenshtein-distance"],"created_at":"2024-12-14T09:13:54.403Z","updated_at":"2025-04-01T15:42:22.426Z","avatar_url":"https://github.com/hapytex.png","language":"Haskell","funding_links":["https://www.buymeacoffee.com/hapytex"],"categories":[],"sub_categories":[],"readme":"# levenshtein\n[![Build Status of the package by GitHub actions](https://github.com/hapytex/levenshtein/actions/workflows/build-ci.yml/badge.svg)](https://github.com/hapytex/levenshtein/actions/workflows/build-ci.yml)\n[![Build Status of the package by Hackage](https://matrix.hackage.haskell.org/api/v2/packages/levenshtein/badge)](https://matrix.hackage.haskell.org/#/package/levenshtein)\n[![Hackage version badge](https://img.shields.io/hackage/v/levenshtein.svg)](https://hackage.haskell.org/package/levenshtein)\n\n## Usage\n\nThe module `Data.Foldable.Levenshtein` exports a data type `Edit` that\nrepresent the possible ways to edit a list by `Add`ing an element, `Rem`oving\nan element, `Copy`ing (do nothing with the element), and `Swap` with a new value.\n\nOne can apply such edits to a list with the `applyEdits` function, for example:\n\n```haskell\nPrelude\u003e applyEdits [Copy 1,Swap 3 4,Swap 0 2,Swap 2 5] [1,3,0,2]\nJust [1,4,2,5]\n```\n\nWe can also calculate the minimal list of edits necessary to turn one list into another one,\nfor example:\n\n```haskell\nPrelude\u003e levenshtein [1,3,0,2] [1,4,2,5]\n(3,[Copy 1,Swap 3 4,Swap 0 2,Swap 2 5])\n```\n\nhere it means that the smallest edit distance is three, and that in order to transform\n`[1,3,0,2]` to `[1,4,2,5]` we copy `1` change `3` for `4`, change `0` for `2`, and change `2` for `5`.\n\n## Package structure\n\nThe package contains one module: **`Data.Foldable.Levenshtein`**.\nThis module provides functions to determine the edit distance and\na list of edits to turn one `Foldable` of items to another `Foldable`\nof items. The foldables are first converted to a list, so the edits\nalways eventually produce a *list* of edits, even if (one of) the `Foldable`s\nis for example a `Tree`, `Maybe`, etc.\n\nBesides the `Edit` object, the module exports three types of functions:\n\n 1. functions that return the edit distance together with a list of *reversed* edits;\n 2. functions that return the edit distance with a list of edits (not reversed); and\n 3. functions that only calculate the edit distance, not the edits itself.\n\nThe third type is more an optimized version of the first two types since it will\ntake less memory and finish slightly faster.\n\nSome functions allow to specify the penalty for an insertion, deletion, and replacement,\nand this even per item.\n\nIn the table below, we show the different implementations to determine the Levenshtein distance:\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth rowspan=\"2\"\u003eEdits\u003c/th\u003e\n      \u003cth\u003eEq\u003c/th\u003e\n      \u003cth colspan=\"2\"\u003eEquality function\u003c/th\u003e\n      \u003cth\u003eEq\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth colspan=\"2\"\u003epenalty functions\u003c/th\u003e\n      \u003cth colspan=\"2\"\u003edefault\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003eNormal\u003c/th\u003e\n      \u003ctd\u003e\u003ccode\u003egenericLevenshtein\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003egenericLevenshtein'\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003elevenshtein'\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003elevenshtein\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eReversed\u003c/th\u003e\n      \u003ctd\u003e\u003ccode\u003egenericReversedLevenshtein\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003egenericReversedLevenshtein'\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003ereversedLevenshtein'\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003ereversedLevenshtein\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eWithout\u003c/th\u003e\n      \u003ctd\u003e\u003ccode\u003egenericLevenshteinDistance\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003egenericLevenshteinDistance'\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003elevenshteinDistance'\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003elevenshteinDistance\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n## `levenshtein` is *safe* Haskell\n\nThe `levenshtein` package does not work with arrays, vectors,\netc. but only vanilla lists, making this a safe package.\n\n## Contribute\n\nYou can contribute by making a pull request on the [*GitHub\nrepository*](https://github.com/hapytex/levenshtein).\n\nYou can contact the package maintainer by sending a mail to\n[`hapytexeu+gh@gmail.com`](mailto:hapytexeu+gh@gmail.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapytex%2Flevenshtein","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhapytex%2Flevenshtein","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapytex%2Flevenshtein/lists"}