Skip to content
This repository was archived by the owner on May 1, 2023. It is now read-only.

Commit 0e73321

Browse files
authored
Merge pull request #39 from aceakash/3.0.1-rc
3.0.1 rc
2 parents 69ecf81 + 4e748c8 commit 0e73321

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Finds degree of similarity between two strings, based on [Dice's Coefficient](ht
1818
* [Release Notes](#release-notes)
1919
* [2.0.0](#200)
2020
* [3.0.0](#300)
21+
* [3.0.1](#301)
2122

2223

2324
## Usage
@@ -119,6 +120,9 @@ stringSimilarity.findBestMatch('Olive-green table for sale, in extremely good co
119120
* 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
120121
* Adding a `bestMatchIndex` to the results for `findBestMatch(..)` to point to the best match in the supplied `targetStrings` array
121122

123+
### 3.0.1
124+
* Refactoring: removed unused functions; used `substring` instead of `substr`
125+
* Updated dependencies
122126

123127
![Build status](https://codeship.com/projects/2aa453d0-0959-0134-8a76-4abcb29fe9b4/status?branch=master)
124128
[![Known Vulnerabilities](https://snyk.io/test/github/aceakash/string-similarity/badge.svg)](https://snyk.io/test/github/aceakash/string-similarity)

compare-strings.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function compareTwoStrings(first, second) {
1515

1616
let firstBigrams = new Map();
1717
for (let i = 0; i < first.length - 1; i++) {
18-
const bigram = first.substr(i, 2);
18+
const bigram = first.substring(i, i + 2);
1919
const count = firstBigrams.has(bigram)
2020
? firstBigrams.get(bigram) + 1
2121
: 1;
@@ -25,7 +25,7 @@ function compareTwoStrings(first, second) {
2525

2626
let intersectionSize = 0;
2727
for (let i = 0; i < second.length - 1; i++) {
28-
const bigram = second.substr(i, 2);
28+
const bigram = second.substring(i, i + 2);
2929
const count = firstBigrams.has(bigram)
3030
? firstBigrams.get(bigram)
3131
: 0;
@@ -60,25 +60,10 @@ function findBestMatch(mainString, targetStrings) {
6060
return { ratings, bestMatch, bestMatchIndex };
6161
}
6262

63-
function flattenDeep(arr) {
64-
return Array.isArray(arr) ? arr.reduce((a, b) => a.concat(flattenDeep(b)), []) : [arr];
65-
}
66-
6763
function areArgsValid(mainString, targetStrings) {
6864
if (typeof mainString !== 'string') return false;
6965
if (!Array.isArray(targetStrings)) return false;
7066
if (!targetStrings.length) return false;
7167
if (targetStrings.find(s => typeof s !== 'string')) return false;
7268
return true;
7369
}
74-
75-
function letterPairs(str) {
76-
const pairs = [];
77-
for (let i = 0, max = str.length - 1; i < max; i++) pairs[i] = str.substring(i, i + 2);
78-
return pairs;
79-
}
80-
81-
function wordLetterPairs(str) {
82-
const pairs = str.toUpperCase().split(' ').map(letterPairs);
83-
return flattenDeep(pairs);
84-
}

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "string-similarity",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "Finds degree of similarity between strings, based on Dice's Coefficient, which is mostly better than Levenshtein distance.",
55
"main": "compare-strings.js",
66
"scripts": {
@@ -29,6 +29,6 @@
2929
"author": "Akash Kurdekar <[email protected]> (http://untilfalse.com/)",
3030
"license": "ISC",
3131
"devDependencies": {
32-
"jasmine": "^3.3.0"
32+
"jasmine": "^3.4.0"
3333
}
3434
}

0 commit comments

Comments
 (0)