{"id":23426921,"url":"https://github.com/tcrouch/edits","last_synced_at":"2025-04-12T19:08:38.859Z","repository":{"id":25558066,"uuid":"104515221","full_name":"tcrouch/edits","owner":"tcrouch","description":"Edit distance algorithms inc. Jaro, Damerau-Levenshtein, and Optimal Alignment","archived":false,"fork":false,"pushed_at":"2024-04-07T22:10:21.000Z","size":70,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T13:21:15.666Z","etag":null,"topics":["damerau-levenshtein","edit-distance","edit-distance-algorithm","fuzzy-matching","jaro","jaro-winkler","levenshtein","restricted-edit","ruby","similarity-measures","text"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/tcrouch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-22T20:18:00.000Z","updated_at":"2024-05-08T09:49:52.000Z","dependencies_parsed_at":"2023-01-14T02:57:47.814Z","dependency_job_id":null,"html_url":"https://github.com/tcrouch/edits","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcrouch%2Fedits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcrouch%2Fedits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcrouch%2Fedits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcrouch%2Fedits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcrouch","download_url":"https://codeload.github.com/tcrouch/edits/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322609,"owners_count":21084336,"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":["damerau-levenshtein","edit-distance","edit-distance-algorithm","fuzzy-matching","jaro","jaro-winkler","levenshtein","restricted-edit","ruby","similarity-measures","text"],"created_at":"2024-12-23T06:14:43.691Z","updated_at":"2025-04-12T19:08:38.824Z","avatar_url":"https://github.com/tcrouch.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Edits\n\n[![Gem](https://img.shields.io/gem/v/edits)](https://rubygems.org/gems/edits)\n[![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/tcrouch/edits/ruby.yml)](https://github.com/tcrouch/edits/actions/workflows/ruby.yml)\n[![Inline docs](http://inch-ci.org/github/tcrouch/edits.svg?branch=master)](https://inch-ci.org/github/tcrouch/edits)\n[![Yard Docs](https://img.shields.io/badge/yard-docs-informational)](https://rubydoc.info/github/tcrouch/edits)\n\nA collection of edit distance algorithms in Ruby.\n\nIncludes Levenshtein, Restricted Edit (Optimal Alignment) and\nDamerau-Levenshtein distances, and Jaro and Jaro-Winkler similarity.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'edits'\n```\n\nAnd then execute:\n\n```console\n$ bundle\n```\n\nOr install it yourself as:\n\n```console\n$ gem install edits\n```\n\n## Usage\n\n### Levenshtein variants\n\nCalculate the edit distance between two sequences with variants of the\nLevenshtein distance algorithm.\n\n```ruby\nEdits::Levenshtein.distance \"raked\", \"bakers\"\n# =\u003e 3\nEdits::RestrictedEdit.distance \"iota\", \"atom\"\n# =\u003e 3\nEdits::DamerauLevenshtein.distance \"acer\", \"earn\"\n# =\u003e 3\n```\n\n- **Levenshtein** edit distance, counting insertion, deletion and\n  substitution.\n- **Restricted Damerau-Levenshtein** edit distance (aka **Optimal Alignment**),\n  counting insertion, deletion, substitution and transposition\n  (adjacent symbols swapped). Restricted by the condition that no substring is\n  edited more than once.\n- **Damerau-Levenshtein** edit distance, counting insertion, deletion,\n  substitution and transposition (adjacent symbols swapped).\n\n|                      | Levenshtein | Restricted Damerau-Levenshtein | Damerau-Levenshtein |\n|----------------------|-------------|--------------------------------|---------------------|\n| \"raked\" vs. \"bakers\" | 3           | 3                              | 3                   |\n| \"iota\" vs. \"atom\"    | 4           | 3                              | 3                   |\n| \"acer\" vs. \"earn\"    | 4           | 4                              | 3                   |\n\nLevenshtein and Restricted Edit distances also have a bounded version.\n\n\n```ruby\n# Max distance\nEdits::Levenshtein.distance_with_max \"fghijk\", \"abcde\", 3\n# =\u003e 3\n```\n\nThe convenience method `most_similar` searches for the best match to a\ngiven sequence from a collection. It is similar to using `min_by`, but leverages\na maximum bound.\n\n```ruby\nEdits::RestrictedEdit.most_similar \"atom\", [\"iota\", \"tome\", \"mown\", \"tame\"]\n# =\u003e \"tome\"\n```\n\n### Jaro \u0026 Jaro-Winkler\n\nCalculate the Jaro and Jaro-Winkler similarity/distance of two sequences.\n\n```ruby\nEdits::Jaro.similarity \"information\", \"informant\"\n# =\u003e 0.90235690235690236\nEdits::Jaro.distance \"information\", \"informant\"\n# =\u003e 0.097643097643097643\n\nEdits::JaroWinkler.similarity \"information\", \"informant\"\n# =\u003e 0.94141414141414137\nEdits::JaroWinkler.distance \"information\", \"informant\"\n# =\u003e 0.05858585858585863\n```\n\n### Hamming\n\nCalculate the hamming distance between two sequences.\n\n```ruby\nEdits::Hamming.distance(\"explorer\", \"exploded\")\n# =\u003e 2\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/tcrouch/edits.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcrouch%2Fedits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcrouch%2Fedits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcrouch%2Fedits/lists"}