{"id":13600989,"url":"https://github.com/hbakhtiyor/strsim","last_synced_at":"2025-04-12T10:51:46.275Z","repository":{"id":57483393,"uuid":"164308598","full_name":"hbakhtiyor/strsim","owner":"hbakhtiyor","description":"string similarity based on Dice's coefficient in go","archived":false,"fork":false,"pushed_at":"2019-01-07T15:40:42.000Z","size":17,"stargazers_count":44,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T05:41:55.569Z","etag":null,"topics":["dice-coefficient","go","golang","string-comparison","string-matching","string-similarity","strings"],"latest_commit_sha":null,"homepage":"","language":"Go","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/hbakhtiyor.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}},"created_at":"2019-01-06T13:14:59.000Z","updated_at":"2024-11-13T18:42:30.000Z","dependencies_parsed_at":"2022-08-27T23:21:48.777Z","dependency_job_id":null,"html_url":"https://github.com/hbakhtiyor/strsim","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/hbakhtiyor%2Fstrsim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbakhtiyor%2Fstrsim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbakhtiyor%2Fstrsim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbakhtiyor%2Fstrsim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hbakhtiyor","download_url":"https://codeload.github.com/hbakhtiyor/strsim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248557844,"owners_count":21124165,"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":["dice-coefficient","go","golang","string-comparison","string-matching","string-similarity","strings"],"created_at":"2024-08-01T18:00:51.921Z","updated_at":"2025-04-12T10:51:46.247Z","avatar_url":"https://github.com/hbakhtiyor.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/hbakhtiyor/strsim?status.svg)](https://godoc.org/github.com/hbakhtiyor/strsim) [![Build Status](https://travis-ci.com/hbakhtiyor/strsim.svg?branch=master)](https://travis-ci.org/hbakhtiyor/strsim) [![Go Report Card](https://goreportcard.com/badge/github.com/hbakhtiyor/strsim)](https://goreportcard.com/report/github.com/hbakhtiyor/strsim)\n\nstrsim\n=================\n\nFinds degree of similarity between two strings, based on [Dice's Coefficient](http://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient).\n\n## Table of Contents\n\n* [Usage](#usage)\n* [API](#api)\n    * [Compare(a, b string) float64](#comparea-b-string-float64)\n        * [Arguments](#arguments)\n        * [Returns](#returns)\n        * [Examples](#examples)\n    * [FindBestMatch(s string, targets []string) *MatchResult](#findbestmatchs-string-targets-string-matchresult)\n        * [Arguments](#arguments-1)\n        * [Returns](#returns-1)\n        * [Examples](#examples-1)\n* [Benchmark](#benchmark)\n   * [Hardware used](#hardware-used)\n   * [Version](#version)\n* [Credit](#credit)\n\n\n## Usage\nInstall using:\n\n```shell\ngo get -u github.com/hbakhtiyor/strsim\n```\n\nIn your code:\n\n```go\nimport \"github.com/hbakhtiyor/strsim\"\n\nsimilarity := strsim.Compare(\"healed\", \"sealed\")\n\nmatches := strsim.FindBestMatch(\"healed\", []string{\"edward\", \"sealed\", \"theatre\")\n```\n## API\n\nRequiring the module gives an object with two methods:\n\n### Compare(a, b string) float64\n\nReturns a fraction between 0 and 1, which indicates the degree of similarity between the two strings. 0 indicates completely different strings, 1 indicates identical strings. The comparison is case-sensitive.\n\n##### Arguments\n  \n1. a (string): The first string\n2. b (string): The second string\n  \nOrder does not make a difference.\n  \n##### Returns\n  \n(float64): A fraction from 0 to 1, both inclusive. Higher number indicates more similarity.\n\n##### Examples\n  \n```go\nstrsim.Compare(\"healed\", \"sealed\")\n// → 0.8\n\nstrsim.Compare(\"Olive-green table for sale, in extremely good condition.\", \n  \"For sale: table in very good  condition, olive green in colour.\")\n// → 0.6060606060606061\n\nstrsim.Compare(\"Olive-green table for sale, in extremely good condition.\", \n  \"For sale: green Subaru Impreza, 210,000 miles\")\n// → 0.2558139534883721\n\nstrsim.Compare(\"Olive-green table for sale, in extremely good condition.\", \n  \"Wanted: mountain bike with at least 21 gears.\")\n// → 0.1411764705882353\n```\n\n### FindBestMatch(s string, targets []string) *MatchResult\n\nCompares `s` against each string in `targets`.\n\n##### Arguments\n\n1. s (string): The string to match each target string against.\n2. targets ([]string): Each string in this array will be matched against the main string.\n\n##### Returns\n(MatchResult): An object with a `Matches` field, which gives a similarity score for each target string, a `BestMatch` field, which specifies which target string was most similar to the main string, and a `BestMatchIndex` field, which specifies the index of the `BestMatch` in the `targets` array.\n\n##### Examples\n```go\nstrsim.FindBestMatch(\"Olive-green table for sale, in extremely good condition.\", []string{\n  \"For sale: green Subaru Impreza, 210,000 miles\", \n  \"For sale: table in very good condition, olive green in colour.\", \n  \"Wanted: mountain bike with at least 21 gears.\",\n});\n// → \nMatchResult {\n  Matches: []Match {\n    { Target: \"For sale: green Subaru Impreza, 210,000 miles\",\n      Score: 0.2558139534883721 },\n    { Target: \"For sale: table in very good condition, olive green in colour.\",\n      Score: 0.6060606060606061 },\n    { Target: \"Wanted: mountain bike with at least 21 gears.\",\n      Score: 0.1411764705882353 } },\n  BestMatch: Match\n    { Target: \"For sale: table in very good condition, olive green in colour.\",\n      Score: 0.6060606060606061 },\n  BestMatchIndex: 1 \n}\n```\n\n## Benchmark\n\n```\nBenchmarkCompare-4         \t   20000\t     82479 ns/op\t   15921 B/op\t      51 allocs/op\nBenchmarkFindBestMatch-4   \t   30000\t     60800 ns/op\t   11707 B/op\t      41 allocs/op\nBenchmarkSortedByScore-4   \t 2000000\t       638 ns/op\t     128 B/op\t       4 allocs/op\n```\n\n##### Hardware used\n\n* Intel® Core™ i3-2310M CPU @ 2.10GHz × 4\n* 4Gb RAM\n\n##### Version\n\n* Go 1.11.2\n* Ubuntu 18.04.01 LTS x86_64 OS\n* 4.15.0-39-generic kernel\n\n## Credit\nhttps://github.com/aceakash/string-similarity\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbakhtiyor%2Fstrsim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhbakhtiyor%2Fstrsim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbakhtiyor%2Fstrsim/lists"}