{"id":15067673,"url":"https://github.com/anirbanmu/str_metrics","last_synced_at":"2025-08-21T05:32:24.567Z","repository":{"id":40456035,"uuid":"236261496","full_name":"anirbanmu/str_metrics","owner":"anirbanmu","description":"Ruby gem (native extension in Rust) providing implementations of various string metrics","archived":false,"fork":false,"pushed_at":"2022-05-07T08:08:38.000Z","size":97,"stargazers_count":79,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-12-08T02:12:52.652Z","etag":null,"topics":["damerau-levenshtein","jaro","jaro-winkler","levenshtein","native","native-extension","ruby","ruby-gem","rubygem","rust","rust-lang","sorensen-dice","string-comparison","string-distance","string-metrics","strings","utility"],"latest_commit_sha":null,"homepage":null,"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/anirbanmu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-26T03:20:27.000Z","updated_at":"2023-10-12T02:20:20.000Z","dependencies_parsed_at":"2022-08-09T21:01:00.682Z","dependency_job_id":null,"html_url":"https://github.com/anirbanmu/str_metrics","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirbanmu%2Fstr_metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirbanmu%2Fstr_metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirbanmu%2Fstr_metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirbanmu%2Fstr_metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anirbanmu","download_url":"https://codeload.github.com/anirbanmu/str_metrics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230092031,"owners_count":18171618,"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","jaro","jaro-winkler","levenshtein","native","native-extension","ruby","ruby-gem","rubygem","rust","rust-lang","sorensen-dice","string-comparison","string-distance","string-metrics","strings","utility"],"created_at":"2024-09-25T01:25:48.920Z","updated_at":"2024-12-19T20:07:17.805Z","avatar_url":"https://github.com/anirbanmu.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StrMetrics\n\n[![checks](https://github.com/anirbanmu/str_metrics/workflows/checks/badge.svg)](https://github.com/anirbanmu/str_metrics/actions?query=workflow%3Achecks)\n[![Gem Version](https://badge.fury.io/rb/str_metrics.svg)](https://rubygems.org/gems/str_metrics)\n[![license](https://img.shields.io/github/license/anirbanmu/str_metrics?style=plastic)](LICENSE)\n\nRuby gem (native extension in Rust) providing implementations of various string metrics. Current metrics supported are: Sørensen–Dice, Levenshtein, Damerau–Levenshtein, Jaro \u0026 Jaro–Winkler. Strings that are UTF-8 encodable (convertible to UTF-8 representation) are supported. All comparison of strings is done at the grapheme cluster level as described by [Unicode Standard Annex #29](https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries); this may be different from many gems that calculate string metrics. See [here](#known-compatibility) for known compatibility.\n\n## Getting Started\n### Prerequisites\n\nInstall Rust (tested with version `\u003e= 1.47.0`) with:\n\n```sh\ncurl https://sh.rustup.rs -sSf | sh\n```\n\n### Known compatibility\n\n#### Ruby\n`3.1`, `3.0`, `2.7`, `2.6`, `2.5`, `2.4`, `2.3`, `jruby`, `truffleruby`\n\n#### Rust\n`1.60.0`, `1.59.0`, `1.58.1`, `1.57.0`, `1.56.1`, `1.55.0`, `1.54.0`, `1.53.0`, `1.52.1`, `1.51.0`, `1.50.0`, `1.49.0`, `1.48.0`, `1.47.0`\n\n#### Platforms\n`Linux`, `MacOS`, `Windows`\n\n### Installation\n\n#### With [`bundler`](https://bundler.io/)\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'str_metrics'\n```\n\nAnd then execute:\n\n    $ bundle install\n\n#### Without `bundler`\n\n    $ gem install str_metrics\n\n## Usage\n\nAll you need to do to use the metrics provided in this gem is to make sure `str_metrics` is required like:\n\n```ruby\nrequire 'str_metrics'\n```\n\nEach metric is shown below with an example \u0026 meanings of optional parameters.\n\n### Sørensen–Dice\n\n```ruby\nStrMetrics::SorensenDice.coefficient('abc', 'bcd', ignore_case: false)\n =\u003e 0.5\n```\nOptions:\n\nKeyword | Type | Default | Description\n--- | --- | --- | ---\n`ignore_case` | boolean | `false` | Case insensitive comparison?\n\n### Levenshtein\n\n```ruby\nStrMetrics::Levenshtein.distance('abc', 'acb', ignore_case: false)\n =\u003e 2\n```\nOptions:\n\nKeyword | Type | Default | Description\n--- | --- | --- | ---\n`ignore_case` | boolean | `false` | Case insensitive comparison?\n\n### Damerau–Levenshtein\n\n```ruby\nStrMetrics::DamerauLevenshtein.distance('abc', 'acb', ignore_case: false)\n =\u003e 1\n```\nOptions:\n\nKeyword | Type | Default | Description\n--- | --- | --- | ---\n`ignore_case` | boolean | `false` | Case insensitive comparison?\n\n### Jaro\n\n```ruby\nStrMetrics::Jaro.similarity('abc', 'aac', ignore_case: false)\n =\u003e 0.7777777777777777\n```\nOptions:\n\nKeyword | Type | Default | Description\n--- | --- | --- | ---\n`ignore_case` | boolean | `false` | Case insensitive comparison?\n\n### Jaro–Winkler\n\n```ruby\nStrMetrics::JaroWinkler.similarity('abc', 'aac', ignore_case: false, prefix_scaling_factor: 0.1, prefix_scaling_bonus_threshold: 0.7)\n =\u003e 0.7999999999999999\n\nStrMetrics::JaroWinkler.distance('abc', 'aac', ignore_case: false, prefix_scaling_factor: 0.1, prefix_scaling_bonus_threshold: 0.7)\n =\u003e 0.20000000000000007\n```\nOptions:\n\nKeyword | Type | Default | Description\n--- | --- | --- | ---\n`ignore_case` | boolean | `false` | Case insensitive comparison?\n`prefix_scaling_factor` | decimal | `0.1` | Constant scaling factor for how much to weight common prefixes. Should not exceed 0.25.\n`prefix_scaling_bonus_threshold` | decimal | `0.7` | Prefix bonus weighting will only be applied if the Jaro similarity is greater given value.\n\n## Motivation\n\nThe main motivation was to have a central gem which can provide a variety of string metric calculations. Secondary motivation was to experiment with writing a native extension in Rust (instead of C).\n\n## Development\n\n### Getting started\n\n```bash\ngem install bundler\ngit clone https://github.com/anirbanmu/str_metrics.git\ncd ./str_metrics\nbundle install\n```\n\n### Building (for native component)\n\n```bash\nrake rust_build\n```\n\n### Testing (will build native component before running tests)\n```bash\nrake spec\n```\n\n### Local installation\n```bash\nrake install\n```\n\n### Deploying a new version\nTo deploy a new version of the gem to rubygems:\n\n1. Bump version in [version.rb](lib/str_metrics/version.rb) according to [SemVer](https://semver.org/).\n2. Get your code merged to `main` branch\n3. After a `git pull` on `main` branch:\n\n```bash\nrake build \u0026\u0026 rake release\n```\n\n## Authors\n- [Anirban Mukhopadhyay](https://github.com/anirbanmu)\n\nSee all repo contributors [here](https://github.com/anirbanmu/str_metrics/contributors).\n\n## Versioning\n\n[SemVer](https://semver.org/) is employed. See [tags](https://github.com/anirbanmu/str_metrics/tags) for released versions.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/anirbanmu/str_metrics.\n\n## Code of Conduct\n\nEveryone interacting in this project's codebase, issue trackers etc. are expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanirbanmu%2Fstr_metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanirbanmu%2Fstr_metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanirbanmu%2Fstr_metrics/lists"}