@joliegg/moderation 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -1
- package/package.json +2 -2
- package/src/index.ts +3 -1
package/dist/index.js
CHANGED
|
@@ -57,9 +57,10 @@ class ModerationClient {
|
|
|
57
57
|
const normalizedText = text.toLowerCase();
|
|
58
58
|
const matches = this.banList.filter(w => normalizedText.indexOf(w) > -1);
|
|
59
59
|
if (matches.length > 0) {
|
|
60
|
+
const words = normalizedText.split(' ');
|
|
60
61
|
categories.push({
|
|
61
62
|
category: 'BAN_LIST',
|
|
62
|
-
confidence: matches.length,
|
|
63
|
+
confidence: (matches.length / words.length) * 100,
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joliegg/moderation",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "A set of tools for chat moderation",
|
|
5
5
|
"author": "Diana Islas Ocampo",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"test": "node test/index.js"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
|
-
"node": "20.x"
|
|
15
|
+
"node": ">=20.x"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@babel/eslint-parser": "^7.24.8",
|
package/src/index.ts
CHANGED
|
@@ -73,9 +73,11 @@ class ModerationClient {
|
|
|
73
73
|
const matches = this.banList.filter(w => normalizedText.indexOf(w) > -1);
|
|
74
74
|
|
|
75
75
|
if (matches.length > 0) {
|
|
76
|
+
const words = normalizedText.split(' ');
|
|
77
|
+
|
|
76
78
|
categories.push({
|
|
77
79
|
category: 'BAN_LIST',
|
|
78
|
-
confidence: matches.length,
|
|
80
|
+
confidence: (matches.length / words.length) * 100,
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
83
|
}
|