From 4e52b0594e747f8e99548b53c7b460d053baf273 Mon Sep 17 00:00:00 2001 From: selmi-karim Date: Sat, 30 May 2020 23:33:07 +0100 Subject: [PATCH 1/3] fix: check char strings --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7a281b9..659b80e 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ const twoStrings = (sa1, sa2) => { // Comparison should not check case or whitespace let s1 = sa1.replace(/\s/g, "").toLowerCase(); let s2 = sa2.replace(/\s/g, "").toLowerCase(); - + if(s1.length === 1 || s2.length === 1) return Number(s1 === s2) const similarity_num = 2 * intersect(pairs(s1), pairs(s2)).length; const similarity_den = pairs(s1).length + pairs(s2).length; return similarity_num / similarity_den; From 90825535987233e16cafea3320f7b33a4aa60bf9 Mon Sep 17 00:00:00 2001 From: selmi-karim Date: Sat, 30 May 2020 23:33:45 +0100 Subject: [PATCH 2/3] test: strings with 1 char --- index.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.test.js b/index.test.js index af9c152..be444f5 100644 --- a/index.test.js +++ b/index.test.js @@ -2,7 +2,7 @@ const dsc = require("./index"); /** Comparing 2 exact same strings returns 1 */ test("matching two equal strings", () => { - expect(dsc.twoStrings("hello world", "hello world")).toBe(1); + expect(dsc.twoStrings("a", "a")).toBe(1); }); /** Comparing 2 different strings returns ]0,1[ */ From c259e544512ce4ad914ab5cabee4832ed6eae220 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 30 May 2020 22:35:17 +0000 Subject: [PATCH 3/3] chore(release): 1.1.1 ## [1.1.1](https://github.com/selmi-karim/dice-similarity-coeff/compare/v1.1.0...v1.1.1) (2020-05-30) ### Bug Fixes * check char strings ([4e52b05](https://github.com/selmi-karim/dice-similarity-coeff/commit/4e52b0594e747f8e99548b53c7b460d053baf273)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bcd868..dec1d28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.1.1](https://github.com/selmi-karim/dice-similarity-coeff/compare/v1.1.0...v1.1.1) (2020-05-30) + + +### Bug Fixes + +* check char strings ([4e52b05](https://github.com/selmi-karim/dice-similarity-coeff/commit/4e52b0594e747f8e99548b53c7b460d053baf273)) + # [1.1.0](https://github.com/selmi-karim/dice-similarity-coeff/compare/v1.0.3...v1.1.0) (2020-05-30) diff --git a/package.json b/package.json index 8236e95..fb91300 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dice-similarity-coeff", - "version": "1.1.0", + "version": "1.1.1", "description": "Find similarity between two strings, based on Dice Similarity Coefficient DSC", "main": "index.js", "scripts": {