Gathering detailed insights and metrics for string-similarity
Gathering detailed insights and metrics for string-similarity
Gathering detailed insights and metrics for string-similarity
Gathering detailed insights and metrics for string-similarity
leven
Measure the difference between two strings using the Levenshtein distance algorithm
fastest-levenshtein
Fastest Levenshtein distance implementation in JS.
string-similarity-js
Calculates similarity between two strings
@types/string-similarity
TypeScript definitions for string-similarity
Finds degree of similarity between two strings, based on Dice's Coefficient, which is mostly better than Levenshtein distance.
npm install string-similarity
Typescript
Module System
Node Version
NPM Version
99.9
Supply Chain
99.4
Quality
75.5
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
384,365,431
Last Day
420,057
Last Week
1,948,675
Last Month
7,798,181
Last Year
86,347,327
2,524 Stars
63 Commits
129 Forks
31 Watching
11 Branches
9 Contributors
Latest Version
4.0.4
Package Id
string-similarity@4.0.4
Size
4.26 kB
NPM Version
6.14.8
Node Version
14.15.1
Publised On
06 Jan 2021
Cumulative downloads
Total Downloads
Last day
18.6%
420,057
Compared to previous day
Last week
-1.9%
1,948,675
Compared to previous week
Last month
8.1%
7,798,181
Compared to previous month
Last year
-11.2%
86,347,327
Compared to previous year
3
Finds degree of similarity between two strings, based on Dice's Coefficient, which is mostly better than Levenshtein distance.
Install using:
1npm install string-similarity --save
In your code:
1var stringSimilarity = require("string-similarity"); 2 3var similarity = stringSimilarity.compareTwoStrings("healed", "sealed"); 4 5var matches = stringSimilarity.findBestMatch("healed", [ 6 "edward", 7 "sealed", 8 "theatre", 9]);
Include <script src="//unpkg.com/string-similarity/umd/string-similarity.min.js"></script>
to get the latest version.
Or <script src="//unpkg.com/string-similarity@4.0.1/umd/string-similarity.min.js"></script>
to get a specific version (4.0.1) in this case.
This exposes a global variable called stringSimilarity
which you can start using.
<script>
stringSimilarity.compareTwoStrings('what!', 'who?');
</script>
(The package is exposed as UMD, so you can consume it as such)
The package contains two methods:
Returns 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.
Order does not make a difference.
(number): A fraction from 0 to 1, both inclusive. Higher number indicates more similarity.
1stringSimilarity.compareTwoStrings("healed", "sealed"); 2// → 0.8 3 4stringSimilarity.compareTwoStrings( 5 "Olive-green table for sale, in extremely good condition.", 6 "For sale: table in very good condition, olive green in colour." 7); 8// → 0.6060606060606061 9 10stringSimilarity.compareTwoStrings( 11 "Olive-green table for sale, in extremely good condition.", 12 "For sale: green Subaru Impreza, 210,000 miles" 13); 14// → 0.2558139534883721 15 16stringSimilarity.compareTwoStrings( 17 "Olive-green table for sale, in extremely good condition.", 18 "Wanted: mountain bike with at least 21 gears." 19); 20// → 0.1411764705882353
Compares mainString
against each string in targetStrings
.
(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.
1stringSimilarity.findBestMatch('Olive-green table for sale, in extremely good condition.', [ 2 'For sale: green Subaru Impreza, 210,000 miles', 3 'For sale: table in very good condition, olive green in colour.', 4 'Wanted: mountain bike with at least 21 gears.' 5]); 6// → 7{ ratings: 8 [ { target: 'For sale: green Subaru Impreza, 210,000 miles', 9 rating: 0.2558139534883721 }, 10 { target: 'For sale: table in very good condition, olive green in colour.', 11 rating: 0.6060606060606061 }, 12 { target: 'Wanted: mountain bike with at least 21 gears.', 13 rating: 0.1411764705882353 } ], 14 bestMatch: 15 { target: 'For sale: table in very good condition, olive green in colour.', 16 rating: 0.6060606060606061 }, 17 bestMatchIndex: 1 18}
compareTwoStrings(..)
: now O(n) instead of O(n^2)bestMatchIndex
to the results for findBestMatch(..)
to point to the best match in the supplied targetStrings
arraysubstring
instead of substr
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
9 existing vulnerabilities detected
Details
Reason
Found 1/15 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More