{"id":16493603,"url":"https://github.com/petrroll/editdistancehs","last_synced_at":"2025-03-01T08:15:09.146Z","repository":{"id":73504080,"uuid":"58821568","full_name":"petrroll/EditDistanceHS","owner":"petrroll","description":"Edit distance algorithm in haskell.","archived":false,"fork":false,"pushed_at":"2016-09-15T14:39:49.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T22:17:14.313Z","etag":null,"topics":["edit-distance-algorithm","school-project"],"latest_commit_sha":null,"homepage":"","language":"Haskell","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/petrroll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-14T17:42:09.000Z","updated_at":"2021-09-10T12:43:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"f9b221a1-67f3-4b0d-9925-56cfbb169a3e","html_url":"https://github.com/petrroll/EditDistanceHS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrroll%2FEditDistanceHS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrroll%2FEditDistanceHS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrroll%2FEditDistanceHS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrroll%2FEditDistanceHS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petrroll","download_url":"https://codeload.github.com/petrroll/EditDistanceHS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241335590,"owners_count":19946085,"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-algorithm","school-project"],"created_at":"2024-10-11T14:09:56.628Z","updated_at":"2025-03-01T08:15:09.117Z","avatar_url":"https://github.com/petrroll.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Edit Distance\n=====================\n\nThis is a small script for calculating the edit distance (Levenshtein distance) \nbetween two list of almost arbitrary elements. It is a generic implementation \nof the regular _O(n*m)_ algorithm that doesn't do any fancy optimalizations (e.g.\nwhen the strings are the same). On the other hand it accepts custom costs functions\nfor insertions, deletions, and subsitutions.\n\nUsage\n-----\n\nThere're two ways to use this script. If you're fine with the regular cost of one for\none element insertion, deletion, and substitution then all you need to do is to import\n`EditDistance` and call `editDistanceDef` with two lists as arguments. The function\nreturns a regular `Maybe Int` as the final minimal cost (Nothing means that you can't\ntransform the original list to the desired one using specified modification functions). \n\nYou can also create your own scoring functions. For insertion and deletion the type is \n`data FUn a = FUn Int ([a] -\u003e Maybe Int)` where the first `Int` argument\nspecifies the maximum length of a sub-list that can be processed by the function at once\n(i.e. inserted / removed). For substitution the type is `FBin (Int, Int) ([a] -\u003e [a] -\u003e Maybe Int)`\nwhere the touple specifies the maximum length of a sub-list from original list that can be replaced \nand the maximum length of a sub-list from desired list that the one from original can be replaced with.\n\n\n````{haskell}\nimport           EditDistance\n\neditDistanceDef \"a\" \"abc\"\neditDistanceDef [1] [1,2,3]\n\nadvEDSetup = editDistance frem fadd fbin\n   where \n      frem = FUn 3 (\\x -\u003e if x == [head x | a \u003c- [1..(length x)]] then Just 1 else Just (length x))\n      fadd = FUn 3 (\\x -\u003e if x == [head x | a \u003c- [1..(length x)]] then Just 1 else Just (length x))\n      fbin = FBin (4,4) (\\x y -\u003e if x == y then Just 0 else (if x == \"abcd\" \u0026\u0026 y == \"cdfe\" then Just 1 else Just (length x + length y)))\n\nadvEDSetup \"aabcdd\" \"acdfed\"\nadvEDSetup \"abb\" \"a\"\nadvEDSetup \"abc\" \"a\"\n\n````\n\nTests\n-----\nThere're also two sets of 'tests' in `Tests.hs`. They can be run by calling `advTests` and `simpleTests` respectively.\n\nDisclaimer\n-----\nThis script was written as a final project for a semester long course \"Non-procedural programming\" at [MFF CUNI](http://www.mff.cuni.cz/) \nand is therefore neither the-best optimized nor generally the best implementation of edit distance algorithm in haskell there is. Use \nat own risk.\n\nLicence\n-----\n[MIT](https://opensource.org/licenses/MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetrroll%2Feditdistancehs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetrroll%2Feditdistancehs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetrroll%2Feditdistancehs/lists"}