Skip to content

Commit 19877c1

Browse files
committed
AXE-2194 : FR1 - fix false positives
1 parent 50466fa commit 19877c1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/checks/label/label-content-name-mismatch-evaluate.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@ import {
55
sanitize,
66
removeUnicode
77
} from '../../commons/text';
8-
const stem = require('wink-porter2-stemmer');
8+
import stem from 'wink-porter2-stemmer';
99

10-
/**
11-
* Check if a given text exists in another
12-
*
13-
* @param {String} compare given text to check
14-
* @param {String} compareWith text against which to be compared
15-
* @returns {Boolean}
16-
*/
10+
const threshold = 0.75;
1711

1812
function cleanText(str) {
1913
return str
@@ -42,13 +36,19 @@ function stringStemmer(str) {
4236
try {
4337
return stem(w);
4438
} catch (err) {
45-
console.warn('Stemming failed for', w, err);
4639
return w;
4740
}
4841
})
4942
.join(' ');
5043
}
5144

45+
/**
46+
* Check if a given text exists in another
47+
*
48+
* @param {String} compare given text to check
49+
* @param {String} compareWith text against which to be compared
50+
* @returns {Boolean}
51+
*/
5252
function isStringContained(compare, compareWith) {
5353
compare = stringStemmer(compare);
5454
compareWith = stringStemmer(compareWith);
@@ -88,7 +88,7 @@ function isStringContained(compare, compareWith) {
8888

8989
const similarity =
9090
magA && magB ? dot / (Math.sqrt(magA) * Math.sqrt(magB)) : 0;
91-
return similarity >= 0.75; // comparision with threshold as 75%
91+
return similarity >= threshold; // comparision with threshold as 75%
9292
}
9393

9494
/**

0 commit comments

Comments
 (0)