{"id":13468518,"url":"https://github.com/aceakash/string-similarity","last_synced_at":"2025-03-26T05:31:09.475Z","repository":{"id":23675483,"uuid":"27046827","full_name":"aceakash/string-similarity","owner":"aceakash","description":"Finds degree of similarity between two strings, based on Dice's Coefficient, which is mostly better than Levenshtein distance.","archived":true,"fork":false,"pushed_at":"2023-05-01T13:28:53.000Z","size":112,"stargazers_count":2525,"open_issues_count":23,"forks_count":129,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-03-05T17:07:50.898Z","etag":null,"topics":["dice-coefficient","javascript","string-comparison","string-similarity","strings"],"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/aceakash.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}},"created_at":"2014-11-23T20:42:18.000Z","updated_at":"2025-02-28T03:02:50.000Z","dependencies_parsed_at":"2023-10-20T16:18:38.240Z","dependency_job_id":null,"html_url":"https://github.com/aceakash/string-similarity","commit_stats":{"total_commits":49,"total_committers":9,"mean_commits":5.444444444444445,"dds":"0.26530612244897955","last_synced_commit":"07cbc8d1569013a10c6075ce02d3efca71a5cfb6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceakash%2Fstring-similarity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceakash%2Fstring-similarity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceakash%2Fstring-similarity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceakash%2Fstring-similarity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aceakash","download_url":"https://codeload.github.com/aceakash/string-similarity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245597240,"owners_count":20641861,"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","javascript","string-comparison","string-similarity","strings"],"created_at":"2024-07-31T15:01:12.747Z","updated_at":"2025-03-26T05:31:08.690Z","avatar_url":"https://github.com/aceakash.png","language":"JavaScript","readme":"# ⚰️ ⚰️ DEPRECATED ⚰️ ⚰️ \nThis repository and the associated NPM package is no longer being maintained.\n\n# string-similarity\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), which is mostly better than [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance).\n\n## Table of Contents\n\n- [string-similarity](#string-similarity)\n  - [Table of Contents](#table-of-contents)\n  - [Usage](#usage)\n    - [For Node.js](#for-nodejs)\n    - [For browser apps](#for-browser-apps)\n  - [API](#api)\n    - [compareTwoStrings(string1, string2)](#comparetwostringsstring1-string2)\n      - [Arguments](#arguments)\n      - [Returns](#returns)\n      - [Examples](#examples)\n    - [findBestMatch(mainString, targetStrings)](#findbestmatchmainstring-targetstrings)\n      - [Arguments](#arguments-1)\n      - [Returns](#returns-1)\n      - [Examples](#examples-1)\n  - [Release Notes](#release-notes)\n    - [2.0.0](#200)\n    - [3.0.0](#300)\n    - [3.0.1](#301)\n    - [4.0.1](#401)\n    - [4.0.2](#402)\n    - [4.0.3](#403)\n\n## Usage\n\n#### For Node.js\n\nInstall using:\n\n```shell\nnpm install string-similarity --save\n```\n\nIn your code:\n\n```javascript\nvar stringSimilarity = require(\"string-similarity\");\n\nvar similarity = stringSimilarity.compareTwoStrings(\"healed\", \"sealed\");\n\nvar matches = stringSimilarity.findBestMatch(\"healed\", [\n  \"edward\",\n  \"sealed\",\n  \"theatre\",\n]);\n```\n\n#### For browser apps\n\nInclude `\u003cscript src=\"//unpkg.com/string-similarity/umd/string-similarity.min.js\"\u003e\u003c/script\u003e` to get the latest version.\n\nOr `\u003cscript src=\"//unpkg.com/string-similarity@4.0.1/umd/string-similarity.min.js\"\u003e\u003c/script\u003e` to get a specific version (4.0.1) in this case.\n\nThis exposes a global variable called `stringSimilarity` which you can start using.\n\n```\n\u003cscript\u003e\n  stringSimilarity.compareTwoStrings('what!', 'who?');\n\u003c/script\u003e\n```\n\n(The package is exposed as UMD, so you can consume it as such)\n\n## API\n\nThe package contains two methods:\n\n### compareTwoStrings(string1, string2)\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. string1 (string): The first string\n2. string2 (string): The second string\n\nOrder does not make a difference.\n\n##### Returns\n\n(number): A fraction from 0 to 1, both inclusive. Higher number indicates more similarity.\n\n##### Examples\n\n```javascript\nstringSimilarity.compareTwoStrings(\"healed\", \"sealed\");\n// → 0.8\n\nstringSimilarity.compareTwoStrings(\n  \"Olive-green table for sale, in extremely good condition.\",\n  \"For sale: table in very good  condition, olive green in colour.\"\n);\n// → 0.6060606060606061\n\nstringSimilarity.compareTwoStrings(\n  \"Olive-green table for sale, in extremely good condition.\",\n  \"For sale: green Subaru Impreza, 210,000 miles\"\n);\n// → 0.2558139534883721\n\nstringSimilarity.compareTwoStrings(\n  \"Olive-green table for sale, in extremely good condition.\",\n  \"Wanted: mountain bike with at least 21 gears.\"\n);\n// → 0.1411764705882353\n```\n\n### findBestMatch(mainString, targetStrings)\n\nCompares `mainString` against each string in `targetStrings`.\n\n##### Arguments\n\n1. mainString (string): The string to match each target string against.\n2. targetStrings (Array): Each string in this array will be matched against the main string.\n\n##### Returns\n\n(Object): An object with a `ratings` property, which gives a similarity rating for each target string, a `bestMatch` property, which specifies which target string was most similar to the main string, and a `bestMatchIndex` property, which specifies the index of the bestMatch in the targetStrings array.\n\n##### Examples\n\n```javascript\nstringSimilarity.findBestMatch('Olive-green table for sale, in extremely good condition.', [\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// →\n{ ratings:\n   [ { target: 'For sale: green Subaru Impreza, 210,000 miles',\n       rating: 0.2558139534883721 },\n     { target: 'For sale: table in very good condition, olive green in colour.',\n       rating: 0.6060606060606061 },\n     { target: 'Wanted: mountain bike with at least 21 gears.',\n       rating: 0.1411764705882353 } ],\n  bestMatch:\n   { target: 'For sale: table in very good condition, olive green in colour.',\n     rating: 0.6060606060606061 },\n  bestMatchIndex: 1\n}\n```\n\n## Release Notes\n\n### 2.0.0\n\n- Removed production dependencies\n- Updated to ES6 (this breaks backward-compatibility for pre-ES6 apps)\n\n### 3.0.0\n\n- Performance improvement for `compareTwoStrings(..)`: now O(n) instead of O(n^2)\n- The algorithm has been tweaked slightly to disregard spaces and word boundaries. This will change the rating values slightly but not enough to make a significant difference\n- Adding a `bestMatchIndex` to the results for `findBestMatch(..)` to point to the best match in the supplied `targetStrings` array\n\n### 3.0.1\n\n- Refactoring: removed unused functions; used `substring` instead of `substr`\n- Updated dependencies\n\n### 4.0.1\n\n- Distributing as an UMD build to be used in browsers.\n\n### 4.0.2\n\n- Update dependencies to latest versions.\n\n### 4.0.3\n\n- Make compatible with IE and ES5. Also, update deps. (see [PR56](https://github.com/aceakash/string-similarity/pull/56))\n\n### 4.0.4\n\n- Simplify some conditional statements. Also, update deps. (see [PR50](https://github.com/aceakash/string-similarity/pull/50))\n\n![Build status](https://codeship.com/projects/2aa453d0-0959-0134-8a76-4abcb29fe9b4/status?branch=master)\n[![Known Vulnerabilities](https://snyk.io/test/github/aceakash/string-similarity/badge.svg)](https://snyk.io/test/github/aceakash/string-similarity)\n","funding_links":[],"categories":["JavaScript","Framework agnostic packages"],"sub_categories":["General utilities"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceakash%2Fstring-similarity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faceakash%2Fstring-similarity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceakash%2Fstring-similarity/lists"}