{"id":23003562,"url":"https://github.com/ascriver/dice-string-similarity","last_synced_at":"2025-04-02T14:24:35.149Z","repository":{"id":226835744,"uuid":"769408654","full_name":"AScriver/dice-string-similarity","owner":"AScriver","description":"Finds degree of similarity between strings, based on Dice's Coefficient.","archived":false,"fork":false,"pushed_at":"2024-03-10T02:43:38.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T17:43:17.594Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/AScriver.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-09T02:01:17.000Z","updated_at":"2024-11-04T21:27:59.000Z","dependencies_parsed_at":"2024-03-10T02:44:37.119Z","dependency_job_id":"9eae9d3a-7848-43ba-8f34-396c5727752d","html_url":"https://github.com/AScriver/dice-string-similarity","commit_stats":null,"previous_names":["ascriver/dice-string-similarity"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AScriver%2Fdice-string-similarity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AScriver%2Fdice-string-similarity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AScriver%2Fdice-string-similarity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AScriver%2Fdice-string-similarity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AScriver","download_url":"https://codeload.github.com/AScriver/dice-string-similarity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246829755,"owners_count":20840692,"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":[],"created_at":"2024-12-15T07:14:38.141Z","updated_at":"2025-04-02T14:24:35.124Z","avatar_url":"https://github.com/AScriver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# String Similarity \n\nA simple and efficient JavaScript utility for comparing string similarity using bigram comparison/Dice's Coefficient. This utility provides functions to compare two strings for their similarity and to find the best match for a given string from an array of strings. This project is a continuation/enhancement of [string-similarity](https://github.com/aceakash/string-similarity) originally developed by [aceakash](https://github.com/aceakash).\n\n## Features\n\n- **Compare Two Strings**: Calculate the similarity score between two strings based on bigram comparison, ranging from 0 (completely different) to 1 (identical).\n- **Find Best Match**: Find the best matching string from an array of strings for a given main string, based on their similarity scores.\n\n## Installation\n\nTo use the String Similarity in your project, simply copy the provided code into your JavaScript file or module.\n\n## Usage\n\n### Comparing Two Strings\n\nTo compare the similarity between two strings, use the `compare` function:\n\n```javascript\nconst { compare } = require('dice-string-similarity');\n\nconst similarityScore = compare('string1', 'string2');\nconsole.log(similarityScore); // Outputs the similarity score between 0 and 1\n```\n\n### Finding the Best Match\n\nTo find the best match for a string from an array of target strings, use the findBestMatch function:\n\n```javascript\nconst { findBestMatch } = require('dice-string-similarity');\n\nconst mainString = 'main string to compare';\nconst targetStrings = ['target string 1', 'target string 2', 'target string 3'];\nconst bestMatch = findBestMatch(mainString, targetStrings);\n\nconsole.log(bestMatch); // Outputs the best match object containing `ratings`, `bestMatch`, and `bestMatchIndex`\n```\n\n## API Reference\n\n### `compare(first, second)`\n\n- **Parameters**\n  - `first` (string): The first string to compare.\n  - `second` (string): The second string to compare.\n- **Returns**\n  - A `number`: The similarity score between the two strings, ranging from 0 to 1.\n\n### `findBestMatch(mainString, targetStrings)`\n\n- **Parameters**\n  - `mainString` (string): The main string to compare against.\n  - `targetStrings` (Array\u003cstring\u003e): An array of strings to compare the main string with.\n- **Returns**\n  - An object containing:\n    - `ratings`: An array of objects, each containing a `target` string and its `rating`.\n    - `bestMatch`: The object from `ratings` with the highest rating.\n    - `bestMatchIndex`: The index of `bestMatch` in the `ratings` array.\n\n## Contributing\n\nContributions to the String Similarity are welcome. Please ensure to follow the coding standards and submit your pull requests for review.\n\n## License\n\nThis project is open-source and available under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fascriver%2Fdice-string-similarity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fascriver%2Fdice-string-similarity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fascriver%2Fdice-string-similarity/lists"}