Skip to content

refactor: upgrade and rewrite #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 29, 2023
Prev Previous commit
Next Next commit
Replace deprecated method substr
  • Loading branch information
aoor9 committed Aug 13, 2023
commit 07a17cec133c2f32edbda7b77733b3b7bb5219c6
121 changes: 64 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,67 @@
{
"name": "string-comparison",
"version": "1.1.0",
"description": "A library implementing different string similarity",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"scripts": {
"test": "mocha",
"lint": "eslint -c .eslintrc.json \"src/**/*.ts\"",
"lint:fix": "eslint -c .eslintrc.json \"src/**/*.ts\" --fix",
"build": "tsup src/index.ts --dts --format cjs,esm --minify",
"watch": "tsup src/index.ts --watch"
},
"repository": {
"type": "git",
"url": "https://github.com/Rabbitzzc/js-string-comparision"
},
"files": [
"dist"
],
"keywords": [
"strings",
"compare similarity",
"similarity",
"Dice's Coefficient",
"Cosine",
"Jaccard Index",
"Levenshtein",
"Longest Common Subsequence",
"Metric Longest Common Subsequence",
"difference",
"compare",
"comparision",
"similar",
"distance",
"match",
"sort match"
],
"author": {
"name": "Rabbitzzc",
"email": "zzclovelcs@gmail.com"
},
"license": "MIT",
"devDependencies": {
"@swc/core": "^1.3.76",
"@types/mocha": "^10.0.1",
"@types/node": "^20.4.9",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"async": "^3.2.4",
"eslint": "^8.47.0",
"eslint-config-alloy": "^5.1.1",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"ts-node": "^10.9.1",
"tsup": "^7.2.0",
"typescript": "^5.1.6"
"name": "string-comparison",
"version": "1.1.0",
"description": "A library implementing different string similarity",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"scripts": {
"test": "mocha",
"lint": "eslint -c .eslintrc.json \"src/**/*.ts\"",
"lint:fix": "eslint -c .eslintrc.json \"src/**/*.ts\" --fix",
"build": "tsup src/index.ts --dts --format cjs,esm --minify",
"watch": "tsup src/index.ts --watch"
},
"repository": {
"type": "git",
"url": "https://github.com/Rabbitzzc/js-string-comparision"
},
"files": [
"dist"
],
"keywords": [
"strings",
"compare similarity",
"similarity",
"Dice's Coefficient",
"Cosine",
"Jaccard Index",
"Levenshtein",
"Longest Common Subsequence",
"Metric Longest Common Subsequence",
"difference",
"compare",
"comparision",
"similar",
"distance",
"match",
"sort match"
],
"author": {
"name": "Rabbitzzc",
"email": "zzclovelcs@gmail.com"
},
"license": "MIT",
"devDependencies": {
"@swc/core": "^1.3.76",
"@types/mocha": "^10.0.1",
"@types/node": "^20.4.10",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"async": "^3.2.4",
"eslint": "^8.47.0",
"eslint-config-alloy": "^5.1.1",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"ts-node": "^10.9.1",
"tsup": "^7.2.0",
"typescript": "^5.1.6"
}
}
4 changes: 2 additions & 2 deletions src/core/packages/DiceCoefficient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class DiceCoefficient extends Similarity {

// get the intersecting character, two strings as a group
for (let i = 0; i < length1 - 1; i++) {
const bigram = thanos.substr(i, 2);
const bigram = thanos.slice(i, i + 2);
const count = thanosBigrams.has(bigram)
? thanosBigrams.get(bigram) + 1
: 1;
Expand All @@ -24,7 +24,7 @@ export default class DiceCoefficient extends Similarity {
}
let intersectionSize = 0;
for (let i = 0; i < length2 - 1; i++) {
const bigram = rival.substr(i, 2);
const bigram = rival.slice(i, i + 2);
const count = thanosBigrams.has(bigram) ? thanosBigrams.get(bigram) : 0;

if (count > 0) {
Expand Down