glin-profanity 2.1.0 → 2.3.3
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/README.md +205 -55
- package/lib/cjs/packages/js/src/core/index.d.ts +4 -0
- package/lib/cjs/packages/js/src/core/index.js +55 -0
- package/lib/cjs/packages/js/src/core/index.js.map +1 -0
- package/lib/cjs/packages/js/src/core/types.d.ts +20 -0
- package/lib/cjs/packages/js/src/core/types.js +3 -0
- package/lib/cjs/packages/js/src/core/types.js.map +1 -0
- package/lib/cjs/{data → packages/js/src/data}/dictionary.d.ts +1 -0
- package/lib/cjs/packages/js/src/data/dictionary.js +54 -0
- package/lib/cjs/packages/js/src/data/dictionary.js.map +1 -0
- package/lib/cjs/{filters → packages/js/src/filters}/Filter.d.ts +7 -14
- package/lib/cjs/packages/js/src/filters/Filter.js +246 -0
- package/lib/cjs/packages/js/src/filters/Filter.js.map +1 -0
- package/lib/cjs/packages/js/src/hooks/useProfanityChecker.d.ts +11 -0
- package/lib/cjs/packages/js/src/hooks/useProfanityChecker.js +42 -0
- package/lib/cjs/packages/js/src/hooks/useProfanityChecker.js.map +1 -0
- package/lib/cjs/packages/js/src/index.d.ts +12 -0
- package/lib/cjs/packages/js/src/index.js +24 -0
- package/lib/cjs/packages/js/src/index.js.map +1 -0
- package/lib/cjs/packages/js/src/nlp/contextAnalyzer.d.ts +35 -0
- package/lib/cjs/packages/js/src/nlp/contextAnalyzer.js +203 -0
- package/lib/cjs/packages/js/src/nlp/contextAnalyzer.js.map +1 -0
- package/lib/cjs/packages/js/src/types/types.d.ts +56 -0
- package/lib/cjs/packages/js/src/types/types.js +14 -0
- package/lib/cjs/packages/js/src/types/types.js.map +1 -0
- package/lib/cjs/shared/dictionaries/spanish.json +72 -0
- package/lib/esm/packages/js/src/core/index.d.ts +4 -0
- package/lib/esm/packages/js/src/core/index.js +47 -0
- package/lib/esm/packages/js/src/core/index.js.map +1 -0
- package/lib/esm/packages/js/src/core/types.d.ts +20 -0
- package/lib/esm/packages/js/src/core/types.js +2 -0
- package/lib/esm/packages/js/src/core/types.js.map +1 -0
- package/lib/esm/{data → packages/js/src/data}/dictionary.d.ts +1 -0
- package/lib/esm/packages/js/src/data/dictionary.js +49 -0
- package/lib/esm/packages/js/src/data/dictionary.js.map +1 -0
- package/lib/esm/{filters → packages/js/src/filters}/Filter.d.ts +7 -14
- package/lib/esm/packages/js/src/filters/Filter.js +240 -0
- package/lib/esm/packages/js/src/filters/Filter.js.map +1 -0
- package/lib/esm/packages/js/src/hooks/useProfanityChecker.d.ts +11 -0
- package/lib/esm/packages/js/src/hooks/useProfanityChecker.js +38 -0
- package/lib/esm/packages/js/src/hooks/useProfanityChecker.js.map +1 -0
- package/lib/esm/packages/js/src/index.d.ts +12 -0
- package/lib/esm/packages/js/src/index.js +15 -0
- package/lib/esm/packages/js/src/index.js.map +1 -0
- package/lib/esm/packages/js/src/nlp/contextAnalyzer.d.ts +35 -0
- package/lib/esm/packages/js/src/nlp/contextAnalyzer.js +199 -0
- package/lib/esm/packages/js/src/nlp/contextAnalyzer.js.map +1 -0
- package/lib/esm/packages/js/src/types/types.d.ts +56 -0
- package/lib/esm/packages/js/src/types/types.js +11 -0
- package/lib/esm/packages/js/src/types/types.js.map +1 -0
- package/lib/esm/shared/dictionaries/spanish.json +72 -0
- package/package.json +26 -3
- package/lib/cjs/data/dictionary.js +0 -52
- package/lib/cjs/data/dictionary.js.map +0 -1
- package/lib/cjs/filters/Filter.js +0 -162
- package/lib/cjs/filters/Filter.js.map +0 -1
- package/lib/cjs/hooks/useProfanityChecker.d.ts +0 -34
- package/lib/cjs/hooks/useProfanityChecker.js +0 -68
- package/lib/cjs/hooks/useProfanityChecker.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -4
- package/lib/cjs/index.js +0 -10
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/types/types.d.ts +0 -21
- package/lib/cjs/types/types.js +0 -11
- package/lib/cjs/types/types.js.map +0 -1
- package/lib/esm/data/dictionary.js +0 -47
- package/lib/esm/data/dictionary.js.map +0 -1
- package/lib/esm/filters/Filter.js +0 -156
- package/lib/esm/filters/Filter.js.map +0 -1
- package/lib/esm/hooks/useProfanityChecker.d.ts +0 -34
- package/lib/esm/hooks/useProfanityChecker.js +0 -61
- package/lib/esm/hooks/useProfanityChecker.js.map +0 -1
- package/lib/esm/index.d.ts +0 -4
- package/lib/esm/index.js +0 -4
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/types/types.d.ts +0 -21
- package/lib/esm/types/types.js +0 -8
- package/lib/esm/types/types.js.map +0 -1
- /package/lib/cjs/{data → shared/dictionaries}/Norwegian.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/arabic.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/chinese.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/czech.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/danish.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/english.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/esperanto.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/finnish.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/french.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/german.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/globalWhitelist.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/hindi.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/hungarian.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/italian.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/japanese.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/korean.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/persian.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/polish.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/portuguese.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/russian.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/swedish.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/thai.json +0 -0
- /package/lib/cjs/{data → shared/dictionaries}/turkish.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/Norwegian.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/arabic.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/chinese.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/czech.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/danish.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/english.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/esperanto.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/finnish.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/french.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/german.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/globalWhitelist.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/hindi.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/hungarian.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/italian.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/japanese.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/korean.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/persian.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/polish.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/portuguese.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/russian.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/swedish.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/thai.json +0 -0
- /package/lib/esm/{data → shared/dictionaries}/turkish.json +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Filter = void 0;
|
|
7
|
+
const dictionary_1 = __importDefault(require("../data/dictionary"));
|
|
8
|
+
const types_1 = require("../types/types");
|
|
9
|
+
const contextAnalyzer_1 = require("../nlp/contextAnalyzer");
|
|
10
|
+
class Filter {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
13
|
+
const defaultLanguage = 'english';
|
|
14
|
+
this.enableContextAware = (_a = config === null || config === void 0 ? void 0 : config.enableContextAware) !== null && _a !== void 0 ? _a : false;
|
|
15
|
+
this.contextWindow = (_b = config === null || config === void 0 ? void 0 : config.contextWindow) !== null && _b !== void 0 ? _b : 3;
|
|
16
|
+
this.confidenceThreshold = (_c = config === null || config === void 0 ? void 0 : config.confidenceThreshold) !== null && _c !== void 0 ? _c : 0.7;
|
|
17
|
+
this.primaryLanguage = ((_d = config === null || config === void 0 ? void 0 : config.languages) === null || _d === void 0 ? void 0 : _d[0]) || defaultLanguage;
|
|
18
|
+
if (this.enableContextAware) {
|
|
19
|
+
this.contextAnalyzer = new contextAnalyzer_1.ContextAnalyzer({
|
|
20
|
+
contextWindow: this.contextWindow,
|
|
21
|
+
language: this.primaryLanguage,
|
|
22
|
+
domainWhitelists: ((_e = config === null || config === void 0 ? void 0 : config.domainWhitelists) === null || _e === void 0 ? void 0 : _e[this.primaryLanguage]) || []
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
let words = [];
|
|
26
|
+
this.caseSensitive = (_f = config === null || config === void 0 ? void 0 : config.caseSensitive) !== null && _f !== void 0 ? _f : false;
|
|
27
|
+
this.allowObfuscatedMatch = (_g = config === null || config === void 0 ? void 0 : config.allowObfuscatedMatch) !== null && _g !== void 0 ? _g : false;
|
|
28
|
+
this.wordBoundaries = (_h = config === null || config === void 0 ? void 0 : config.wordBoundaries) !== null && _h !== void 0 ? _h : !this.allowObfuscatedMatch;
|
|
29
|
+
this.replaceWith = config === null || config === void 0 ? void 0 : config.replaceWith;
|
|
30
|
+
this.severityLevels = (_j = config === null || config === void 0 ? void 0 : config.severityLevels) !== null && _j !== void 0 ? _j : false;
|
|
31
|
+
this.ignoreWords = new Set(((_k = config === null || config === void 0 ? void 0 : config.ignoreWords) === null || _k === void 0 ? void 0 : _k.map((word) => word.toLowerCase())) || []);
|
|
32
|
+
this.logProfanity = (_l = config === null || config === void 0 ? void 0 : config.logProfanity) !== null && _l !== void 0 ? _l : false;
|
|
33
|
+
this.fuzzyToleranceLevel = (_m = config === null || config === void 0 ? void 0 : config.fuzzyToleranceLevel) !== null && _m !== void 0 ? _m : 0.8;
|
|
34
|
+
if (config === null || config === void 0 ? void 0 : config.allLanguages) {
|
|
35
|
+
for (const lang in dictionary_1.default) {
|
|
36
|
+
if (dictionary_1.default.hasOwnProperty(lang)) {
|
|
37
|
+
words = [...words, ...dictionary_1.default[lang]];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const languages = (config === null || config === void 0 ? void 0 : config.languages) || ['english'];
|
|
43
|
+
const languagesChecks = new Set(languages);
|
|
44
|
+
languagesChecks.forEach((lang) => {
|
|
45
|
+
words = [...words, ...dictionary_1.default[lang]];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (config === null || config === void 0 ? void 0 : config.customWords) {
|
|
49
|
+
words = [...words, ...config.customWords];
|
|
50
|
+
}
|
|
51
|
+
this.words = new Map(words.map((word) => [word.toLowerCase(), 1]));
|
|
52
|
+
}
|
|
53
|
+
debugLog(...args) {
|
|
54
|
+
if (this.logProfanity) {
|
|
55
|
+
console.log('[glin-profanity]', ...args);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
normalizeObfuscated(text) {
|
|
59
|
+
let normalized = text.replace(/([a-zA-Z])\1{1,}/g, '$1$1');
|
|
60
|
+
const charMap = {
|
|
61
|
+
'@': 'a',
|
|
62
|
+
$: 's',
|
|
63
|
+
'!': 'i',
|
|
64
|
+
'1': 'i',
|
|
65
|
+
'*': '',
|
|
66
|
+
};
|
|
67
|
+
normalized = normalized.replace(/[@$!1*]/g, (m) => charMap[m] || m);
|
|
68
|
+
return normalized;
|
|
69
|
+
}
|
|
70
|
+
getRegex(word) {
|
|
71
|
+
const flags = this.caseSensitive ? 'g' : 'gi';
|
|
72
|
+
const escapedWord = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
73
|
+
const boundary = this.wordBoundaries ? '\\b' : '';
|
|
74
|
+
return new RegExp(`${boundary}${escapedWord}${boundary}`, flags);
|
|
75
|
+
}
|
|
76
|
+
isFuzzyToleranceMatch(word, text) {
|
|
77
|
+
const simplifiedText = text.toLowerCase().replace(/[^a-z]/g, '');
|
|
78
|
+
const simplifiedWord = word.toLowerCase();
|
|
79
|
+
let matchCount = 0;
|
|
80
|
+
let index = 0;
|
|
81
|
+
for (let i = 0; i < simplifiedText.length; i++) {
|
|
82
|
+
if (simplifiedText[i] === simplifiedWord[index]) {
|
|
83
|
+
matchCount++;
|
|
84
|
+
index++;
|
|
85
|
+
if (index === simplifiedWord.length)
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const score = matchCount / simplifiedWord.length;
|
|
90
|
+
return score >= this.fuzzyToleranceLevel;
|
|
91
|
+
}
|
|
92
|
+
evaluateSeverity(word, text) {
|
|
93
|
+
if (this.wordBoundaries && this.getRegex(word).test(text)) {
|
|
94
|
+
return types_1.SeverityLevel.EXACT;
|
|
95
|
+
}
|
|
96
|
+
if (this.getRegex(word).test(text))
|
|
97
|
+
return types_1.SeverityLevel.EXACT;
|
|
98
|
+
if (this.isFuzzyToleranceMatch(word, text))
|
|
99
|
+
return types_1.SeverityLevel.FUZZY;
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
isProfane(value) {
|
|
103
|
+
let input = this.allowObfuscatedMatch
|
|
104
|
+
? this.normalizeObfuscated(value)
|
|
105
|
+
: value;
|
|
106
|
+
for (const word of this.words.keys()) {
|
|
107
|
+
if (!this.ignoreWords.has(word.toLowerCase()) &&
|
|
108
|
+
this.evaluateSeverity(word, input) !== undefined) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
matches(word) {
|
|
115
|
+
return this.isProfane(word);
|
|
116
|
+
}
|
|
117
|
+
checkProfanity(text) {
|
|
118
|
+
// Backward compatibility: if not context-aware, run old logic
|
|
119
|
+
if (!this.enableContextAware) {
|
|
120
|
+
let input = this.allowObfuscatedMatch
|
|
121
|
+
? this.normalizeObfuscated(text)
|
|
122
|
+
: text;
|
|
123
|
+
input = input.toLowerCase();
|
|
124
|
+
const profaneWords = [];
|
|
125
|
+
const severityMap = {};
|
|
126
|
+
for (const dictWord of this.words.keys()) {
|
|
127
|
+
if (this.ignoreWords.has(dictWord.toLowerCase()))
|
|
128
|
+
continue;
|
|
129
|
+
const severity = this.evaluateSeverity(dictWord, input);
|
|
130
|
+
if (severity !== undefined) {
|
|
131
|
+
const regex = this.getRegex(dictWord);
|
|
132
|
+
let match;
|
|
133
|
+
while ((match = regex.exec(input)) !== null) {
|
|
134
|
+
profaneWords.push(match[0]);
|
|
135
|
+
if (severityMap[match[0]] === undefined) {
|
|
136
|
+
severityMap[match[0]] = severity;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
let processedText = text;
|
|
142
|
+
if (this.replaceWith && profaneWords.length > 0) {
|
|
143
|
+
const uniqueWords = Array.from(new Set(profaneWords));
|
|
144
|
+
for (const word of uniqueWords) {
|
|
145
|
+
const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
146
|
+
const replacementRegex = this.wordBoundaries
|
|
147
|
+
? new RegExp(`\\b${escaped}\\b`, 'gi')
|
|
148
|
+
: new RegExp(escaped, 'gi');
|
|
149
|
+
processedText = processedText.replace(replacementRegex, this.replaceWith);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
containsProfanity: profaneWords.length > 0,
|
|
154
|
+
profaneWords: Array.from(new Set(profaneWords)),
|
|
155
|
+
processedText: this.replaceWith ? processedText : undefined,
|
|
156
|
+
severityMap: this.severityLevels && Object.keys(severityMap).length > 0
|
|
157
|
+
? severityMap
|
|
158
|
+
: undefined,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// Context-aware path
|
|
162
|
+
let input = this.allowObfuscatedMatch
|
|
163
|
+
? this.normalizeObfuscated(text)
|
|
164
|
+
: text;
|
|
165
|
+
input = input.toLowerCase();
|
|
166
|
+
const originalText = text;
|
|
167
|
+
const profaneWords = [];
|
|
168
|
+
const severityMap = {};
|
|
169
|
+
const matches = [];
|
|
170
|
+
for (const dictWord of this.words.keys()) {
|
|
171
|
+
if (this.ignoreWords.has(dictWord.toLowerCase()))
|
|
172
|
+
continue;
|
|
173
|
+
const severity = this.evaluateSeverity(dictWord, input);
|
|
174
|
+
if (severity !== undefined) {
|
|
175
|
+
const regex = this.getRegex(dictWord);
|
|
176
|
+
let match;
|
|
177
|
+
while ((match = regex.exec(input)) !== null) {
|
|
178
|
+
const matchedWord = match[0];
|
|
179
|
+
const matchIndex = match.index;
|
|
180
|
+
const matchObj = {
|
|
181
|
+
word: matchedWord,
|
|
182
|
+
index: matchIndex,
|
|
183
|
+
severity: severity
|
|
184
|
+
};
|
|
185
|
+
if (this.enableContextAware && this.contextAnalyzer) {
|
|
186
|
+
const contextResult = this.contextAnalyzer.analyzeContext(originalText, matchedWord, matchIndex);
|
|
187
|
+
matchObj.contextScore = contextResult.contextScore;
|
|
188
|
+
matchObj.reason = contextResult.reason;
|
|
189
|
+
matchObj.isWhitelisted = contextResult.isWhitelisted;
|
|
190
|
+
if (contextResult.isWhitelisted || (contextResult.contextScore > this.confidenceThreshold)) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
profaneWords.push(matchedWord);
|
|
195
|
+
if (severityMap[matchedWord] === undefined) {
|
|
196
|
+
severityMap[matchedWord] = severity;
|
|
197
|
+
}
|
|
198
|
+
matches.push(matchObj);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (profaneWords.length > 0) {
|
|
203
|
+
this.debugLog('Detected:', profaneWords);
|
|
204
|
+
}
|
|
205
|
+
let processedText = text;
|
|
206
|
+
if (this.replaceWith && profaneWords.length > 0) {
|
|
207
|
+
const uniqueWords = Array.from(new Set(profaneWords));
|
|
208
|
+
for (const word of uniqueWords) {
|
|
209
|
+
const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
210
|
+
const replacementRegex = this.wordBoundaries
|
|
211
|
+
? new RegExp(`\\b${escaped}\\b`, 'gi')
|
|
212
|
+
: new RegExp(escaped, 'gi');
|
|
213
|
+
processedText = processedText.replace(replacementRegex, this.replaceWith);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
let contextScore;
|
|
217
|
+
if (this.enableContextAware && matches.length > 0) {
|
|
218
|
+
const totalScore = matches.reduce((sum, match) => sum + (match.contextScore || 0.5), 0);
|
|
219
|
+
contextScore = totalScore / matches.length;
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
containsProfanity: profaneWords.length > 0,
|
|
223
|
+
profaneWords: Array.from(new Set(profaneWords)),
|
|
224
|
+
processedText: this.replaceWith ? processedText : undefined,
|
|
225
|
+
severityMap: this.severityLevels && Object.keys(severityMap).length > 0 ? severityMap : undefined,
|
|
226
|
+
matches: matches.length > 0 ? matches : undefined,
|
|
227
|
+
contextScore,
|
|
228
|
+
reason: matches.length > 0 ?
|
|
229
|
+
`Found ${matches.length} potential profanity matches` :
|
|
230
|
+
'No profanity detected'
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
checkProfanityWithMinSeverity(text, minSeverity = types_1.SeverityLevel.EXACT) {
|
|
234
|
+
const result = this.checkProfanity(text);
|
|
235
|
+
const filteredWords = result.severityMap && result.profaneWords.length > 0
|
|
236
|
+
? result.profaneWords.filter((word) => {
|
|
237
|
+
var _a;
|
|
238
|
+
const severity = (_a = result.severityMap) === null || _a === void 0 ? void 0 : _a[word];
|
|
239
|
+
return typeof severity === 'number' && severity >= minSeverity;
|
|
240
|
+
})
|
|
241
|
+
: [];
|
|
242
|
+
return { filteredWords, result };
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
exports.Filter = Filter;
|
|
246
|
+
//# sourceMappingURL=Filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../../../src/filters/Filter.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA4C;AAC5C,0CAAoG;AACpG,4DAAyD;AAIzD,MAAM,MAAM;IAiBV,YAAY,MAAqB;;QAC/B,MAAM,eAAe,GAAa,SAAS,CAAC;QAC5C,IAAI,CAAC,kBAAkB,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,kBAAkB,mCAAI,KAAK,CAAC;QAC9D,IAAI,CAAC,aAAa,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,mCAAI,CAAC,CAAC;QAChD,IAAI,CAAC,mBAAmB,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,mBAAmB,mCAAI,GAAG,CAAC;QAC9D,IAAI,CAAC,eAAe,GAAG,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,0CAAG,CAAC,CAAC,KAAI,eAAe,CAAC;QACjE,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,IAAI,CAAC,eAAe,GAAG,IAAI,iCAAe,CAAC;gBACzC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,QAAQ,EAAE,IAAI,CAAC,eAAe;gBAC9B,gBAAgB,EAAE,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,C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CheckResult } from '../core/types';
|
|
2
|
+
import type { CheckProfanityResult } from '../types/types';
|
|
3
|
+
export type { ProfanityCheckerConfig };
|
|
4
|
+
export declare const useProfanityChecker: (config?: ProfanityCheckerConfig) => {
|
|
5
|
+
result: CheckProfanityResult;
|
|
6
|
+
checkText: (text: string) => ProfanityCheckResult;
|
|
7
|
+
checkTextAsync: (text: string) => Promise<ProfanityCheckResult>;
|
|
8
|
+
reset: () => void;
|
|
9
|
+
isDirty: boolean;
|
|
10
|
+
isWordProfane: (word: string) => boolean;
|
|
11
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useProfanityChecker = void 0;
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const core_1 = require("../core");
|
|
15
|
+
const useProfanityChecker = (config) => {
|
|
16
|
+
var _a;
|
|
17
|
+
const [result, setResult] = (0, react_1.useState)(null);
|
|
18
|
+
const checkText = (0, react_1.useCallback)((text) => {
|
|
19
|
+
const checkResult = (0, core_1.checkProfanity)(text, config);
|
|
20
|
+
setResult(checkResult);
|
|
21
|
+
return checkResult;
|
|
22
|
+
}, [config]);
|
|
23
|
+
const checkTextAsync = (0, react_1.useCallback)((text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const checkResult = yield (0, core_1.checkProfanityAsync)(text, config);
|
|
25
|
+
setResult(checkResult);
|
|
26
|
+
return checkResult;
|
|
27
|
+
}), [config]);
|
|
28
|
+
const isWordProfaneCallback = (0, react_1.useCallback)((word) => {
|
|
29
|
+
return (0, core_1.isWordProfane)(word, config);
|
|
30
|
+
}, [config]);
|
|
31
|
+
const reset = (0, react_1.useCallback)(() => setResult(null), []);
|
|
32
|
+
return {
|
|
33
|
+
result,
|
|
34
|
+
checkText,
|
|
35
|
+
checkTextAsync,
|
|
36
|
+
reset,
|
|
37
|
+
isDirty: (_a = result === null || result === void 0 ? void 0 : result.containsProfanity) !== null && _a !== void 0 ? _a : false,
|
|
38
|
+
isWordProfane: isWordProfaneCallback,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.useProfanityChecker = useProfanityChecker;
|
|
42
|
+
//# sourceMappingURL=useProfanityChecker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProfanityChecker.js","sourceRoot":"","sources":["../../../../../../src/hooks/useProfanityChecker.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAA8C;AAC9C,kCAA6E;AAMtE,MAAM,mBAAmB,GAAG,CAAC,MAA+B,EAAE,EAAE;;IACrE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAA8B,IAAI,CAAC,CAAC;IAExE,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,CAAC,IAAY,EAAE,EAAE;QAC7C,MAAM,WAAW,GAAG,IAAA,qBAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjD,SAAS,CAAC,WAAW,CAAC,CAAC;QACvB,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,cAAc,GAAG,IAAA,mBAAW,EAAC,CAAO,IAAY,EAAE,EAAE;QACxD,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAmB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC5D,SAAS,CAAC,WAAW,CAAC,CAAC;QACvB,OAAO,WAAW,CAAC;IACrB,CAAC,CAAA,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,qBAAqB,GAAG,IAAA,mBAAW,EAAC,CAAC,IAAY,EAAE,EAAE;QACzD,OAAO,IAAA,oBAAa,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAErD,OAAO;QACL,MAAM;QACN,SAAS;QACT,cAAc;QACd,KAAK;QACL,OAAO,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,iBAAiB,mCAAI,KAAK;QAC3C,aAAa,EAAE,qBAAqB;KACrC,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,mBAAmB,uBA6B9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glin-Profanity: Lightweight and efficient profanity detection and filtering.
|
|
3
|
+
*
|
|
4
|
+
* Provides multi-language support, context-aware filtering, and customizable
|
|
5
|
+
* configurations for detecting and filtering profane language in text inputs.
|
|
6
|
+
*/
|
|
7
|
+
export { checkProfanity, checkProfanityAsync, isWordProfane } from './core';
|
|
8
|
+
export type { ProfanityCheckerConfig, ProfanityCheckResult } from './core/types';
|
|
9
|
+
export { useProfanityChecker } from './hooks/useProfanityChecker';
|
|
10
|
+
export { Filter } from './filters/Filter';
|
|
11
|
+
export { SeverityLevel } from './types/types';
|
|
12
|
+
export type { Language, CheckProfanityResult, FilterConfig, FilteredProfanityResult, Match, ContextAwareConfig } from './types/types';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Glin-Profanity: Lightweight and efficient profanity detection and filtering.
|
|
4
|
+
*
|
|
5
|
+
* Provides multi-language support, context-aware filtering, and customizable
|
|
6
|
+
* configurations for detecting and filtering profane language in text inputs.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SeverityLevel = exports.Filter = exports.useProfanityChecker = exports.isWordProfane = exports.checkProfanityAsync = exports.checkProfanity = void 0;
|
|
10
|
+
// Core API (framework-agnostic)
|
|
11
|
+
var core_1 = require("./core");
|
|
12
|
+
Object.defineProperty(exports, "checkProfanity", { enumerable: true, get: function () { return core_1.checkProfanity; } });
|
|
13
|
+
Object.defineProperty(exports, "checkProfanityAsync", { enumerable: true, get: function () { return core_1.checkProfanityAsync; } });
|
|
14
|
+
Object.defineProperty(exports, "isWordProfane", { enumerable: true, get: function () { return core_1.isWordProfane; } });
|
|
15
|
+
// React-specific
|
|
16
|
+
var useProfanityChecker_1 = require("./hooks/useProfanityChecker");
|
|
17
|
+
Object.defineProperty(exports, "useProfanityChecker", { enumerable: true, get: function () { return useProfanityChecker_1.useProfanityChecker; } });
|
|
18
|
+
// Advanced/Low-level
|
|
19
|
+
var Filter_1 = require("./filters/Filter");
|
|
20
|
+
Object.defineProperty(exports, "Filter", { enumerable: true, get: function () { return Filter_1.Filter; } });
|
|
21
|
+
// Legacy types (maintain compatibility)
|
|
22
|
+
var types_1 = require("./types/types");
|
|
23
|
+
Object.defineProperty(exports, "SeverityLevel", { enumerable: true, get: function () { return types_1.SeverityLevel; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,gCAAgC;AAChC,+BAIgB;AAHd,sGAAA,cAAc,OAAA;AACd,2GAAA,mBAAmB,OAAA;AACnB,qGAAA,aAAa,OAAA;AAQf,iBAAiB;AACjB,mEAAkE;AAAzD,0HAAA,mBAAmB,OAAA;AAE5B,qBAAqB;AACrB,2CAA0C;AAAjC,gGAAA,MAAM,OAAA;AAEf,wCAAwC;AACxC,uCAA8C;AAArC,sGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Language } from '../types/types';
|
|
2
|
+
export interface ContextAnalysisResult {
|
|
3
|
+
contextScore: number;
|
|
4
|
+
reason: string;
|
|
5
|
+
isWhitelisted: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ContextConfig {
|
|
8
|
+
contextWindow: number;
|
|
9
|
+
language: Language;
|
|
10
|
+
domainWhitelists?: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare class ContextAnalyzer {
|
|
13
|
+
private contextWindow;
|
|
14
|
+
private language;
|
|
15
|
+
private domainWhitelists;
|
|
16
|
+
constructor(config: ContextConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Analyzes the context around a profanity match to determine if it should be flagged
|
|
19
|
+
*/
|
|
20
|
+
analyzeContext(text: string, matchWord: string, matchIndex: number): ContextAnalysisResult;
|
|
21
|
+
private tokenize;
|
|
22
|
+
private findWordIndex;
|
|
23
|
+
private checkPhraseContext;
|
|
24
|
+
private isDomainWhitelisted;
|
|
25
|
+
private calculateSentimentScore;
|
|
26
|
+
private generateReason;
|
|
27
|
+
/**
|
|
28
|
+
* Updates the domain whitelist for this analyzer instance
|
|
29
|
+
*/
|
|
30
|
+
updateDomainWhitelist(newWhitelist: string[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* Adds words to the domain whitelist
|
|
33
|
+
*/
|
|
34
|
+
addToDomainWhitelist(words: string[]): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextAnalyzer = void 0;
|
|
4
|
+
// Positive sentiment indicators
|
|
5
|
+
const POSITIVE_INDICATORS = new Set([
|
|
6
|
+
'amazing', 'awesome', 'excellent', 'fantastic', 'great', 'love', 'wonderful',
|
|
7
|
+
'brilliant', 'perfect', 'incredible', 'outstanding', 'superb', 'magnificent',
|
|
8
|
+
'marvelous', 'spectacular', 'phenomenal', 'terrific', 'fabulous', 'divine',
|
|
9
|
+
'best', 'good', 'nice', 'cool', 'sweet', 'rad', 'sick', 'dope', 'fire',
|
|
10
|
+
'lit', 'epic', 'legendary', 'godlike', 'insane', 'crazy', 'wild', 'beast',
|
|
11
|
+
'movie', 'film', 'show', 'song', 'music', 'game', 'book', 'restaurant',
|
|
12
|
+
'food', 'dish', 'meal', 'place', 'spot', 'location', 'experience'
|
|
13
|
+
]);
|
|
14
|
+
// Negative sentiment indicators
|
|
15
|
+
const NEGATIVE_INDICATORS = new Set([
|
|
16
|
+
'hate', 'terrible', 'awful', 'horrible', 'disgusting', 'pathetic', 'stupid',
|
|
17
|
+
'idiot', 'moron', 'loser', 'worthless', 'useless', 'garbage', 'trash',
|
|
18
|
+
'suck', 'sucks', 'worst', 'bad', 'ugly', 'gross', 'nasty', 'annoying',
|
|
19
|
+
'irritating', 'frustrating', 'disappointing', 'lame', 'weak', 'fail',
|
|
20
|
+
'you', 'your', 'yourself', 'u', 'ur', 'ure', 'youre'
|
|
21
|
+
]);
|
|
22
|
+
// Domain-specific positive contexts
|
|
23
|
+
const GAMING_POSITIVE = new Set([
|
|
24
|
+
'player', 'gamer', 'team', 'squad', 'clan', 'guild', 'match', 'game',
|
|
25
|
+
'round', 'level', 'boss', 'raid', 'quest', 'achievement', 'skill',
|
|
26
|
+
'build', 'loadout', 'strategy', 'tactic', 'play', 'move', 'combo'
|
|
27
|
+
]);
|
|
28
|
+
// Common positive phrases that might contain flagged words
|
|
29
|
+
const POSITIVE_PHRASES = new Map([
|
|
30
|
+
['the bomb', 0.9], // "this movie is the bomb"
|
|
31
|
+
['da bomb', 0.9], // slang for "the best"
|
|
32
|
+
['bomb.com', 0.9], // website reference
|
|
33
|
+
['bomb diggity', 0.9], // slang for excellent
|
|
34
|
+
['photo bomb', 0.8], // photography term
|
|
35
|
+
['bath bomb', 0.8], // cosmetic product
|
|
36
|
+
['bomb squad', 0.7], // could be neutral/positive in gaming
|
|
37
|
+
]);
|
|
38
|
+
// Negative phrases that should remain flagged
|
|
39
|
+
const NEGATIVE_PHRASES = new Map([
|
|
40
|
+
['you are', 0.1], // "you are [profanity]"
|
|
41
|
+
['ur a', 0.1], // "ur a [profanity]"
|
|
42
|
+
['such a', 0.2], // "such a [profanity]"
|
|
43
|
+
['fucking', 0.1], // intensifier, usually negative
|
|
44
|
+
['damn', 0.2], // mild profanity, context dependent
|
|
45
|
+
]);
|
|
46
|
+
class ContextAnalyzer {
|
|
47
|
+
constructor(config) {
|
|
48
|
+
this.contextWindow = config.contextWindow;
|
|
49
|
+
this.language = config.language;
|
|
50
|
+
this.domainWhitelists = new Set(config.domainWhitelists || []);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Analyzes the context around a profanity match to determine if it should be flagged
|
|
54
|
+
*/
|
|
55
|
+
analyzeContext(text, matchWord, matchIndex) {
|
|
56
|
+
const words = this.tokenize(text);
|
|
57
|
+
const matchWordIndex = this.findWordIndex(words, matchIndex);
|
|
58
|
+
if (matchWordIndex === -1) {
|
|
59
|
+
return {
|
|
60
|
+
contextScore: 0.5,
|
|
61
|
+
reason: 'Could not locate match in tokenized text',
|
|
62
|
+
isWhitelisted: false
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Extract context window
|
|
66
|
+
const startIndex = Math.max(0, matchWordIndex - this.contextWindow);
|
|
67
|
+
const endIndex = Math.min(words.length, matchWordIndex + this.contextWindow + 1);
|
|
68
|
+
const contextWords = words.slice(startIndex, endIndex);
|
|
69
|
+
const contextText = contextWords.join(' ').toLowerCase();
|
|
70
|
+
// Check for exact phrase matches first
|
|
71
|
+
const phraseResult = this.checkPhraseContext(contextText, matchWord);
|
|
72
|
+
if (phraseResult) {
|
|
73
|
+
return phraseResult;
|
|
74
|
+
}
|
|
75
|
+
// Check domain-specific whitelists
|
|
76
|
+
if (this.isDomainWhitelisted(contextWords, matchWord)) {
|
|
77
|
+
return {
|
|
78
|
+
contextScore: 0.8,
|
|
79
|
+
reason: 'Domain-specific whitelist match',
|
|
80
|
+
isWhitelisted: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Perform sentiment analysis
|
|
84
|
+
const sentimentScore = this.calculateSentimentScore(contextWords, matchWordIndex - startIndex);
|
|
85
|
+
return {
|
|
86
|
+
contextScore: sentimentScore,
|
|
87
|
+
reason: this.generateReason(sentimentScore, contextWords),
|
|
88
|
+
isWhitelisted: false
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
tokenize(text) {
|
|
92
|
+
// Simple tokenization - split on whitespace and punctuation
|
|
93
|
+
return text.toLowerCase()
|
|
94
|
+
.replace(/[^\w\s]/g, ' ')
|
|
95
|
+
.split(/\s+/)
|
|
96
|
+
.filter(word => word.length > 0);
|
|
97
|
+
}
|
|
98
|
+
findWordIndex(words, charIndex) {
|
|
99
|
+
// This is a simplified approach - in production, you'd want more robust mapping
|
|
100
|
+
// For now, we'll estimate based on the character position
|
|
101
|
+
let currentPos = 0;
|
|
102
|
+
for (let i = 0; i < words.length; i++) {
|
|
103
|
+
if (currentPos >= charIndex) {
|
|
104
|
+
return Math.max(0, i - 1);
|
|
105
|
+
}
|
|
106
|
+
currentPos += words[i].length + 1; // +1 for space
|
|
107
|
+
}
|
|
108
|
+
return words.length - 1;
|
|
109
|
+
}
|
|
110
|
+
checkPhraseContext(contextText, matchWord) {
|
|
111
|
+
// Check positive phrases
|
|
112
|
+
for (const [phrase, score] of POSITIVE_PHRASES.entries()) {
|
|
113
|
+
if (contextText.includes(phrase)) {
|
|
114
|
+
return {
|
|
115
|
+
contextScore: score,
|
|
116
|
+
reason: `Positive phrase detected: "${phrase}"`,
|
|
117
|
+
isWhitelisted: true
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Check negative phrases
|
|
122
|
+
for (const [phrase, score] of NEGATIVE_PHRASES.entries()) {
|
|
123
|
+
if (contextText.includes(phrase)) {
|
|
124
|
+
return {
|
|
125
|
+
contextScore: score,
|
|
126
|
+
reason: `Negative phrase detected: "${phrase}"`,
|
|
127
|
+
isWhitelisted: false
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
isDomainWhitelisted(contextWords, matchWord) {
|
|
134
|
+
// Check if any domain whitelist words are present
|
|
135
|
+
for (const word of contextWords) {
|
|
136
|
+
if (this.domainWhitelists.has(word) || GAMING_POSITIVE.has(word)) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
calculateSentimentScore(contextWords, matchPosition) {
|
|
143
|
+
let positiveCount = 0;
|
|
144
|
+
let negativeCount = 0;
|
|
145
|
+
let totalWords = contextWords.length;
|
|
146
|
+
// Weight words closer to the match more heavily
|
|
147
|
+
for (let i = 0; i < contextWords.length; i++) {
|
|
148
|
+
const word = contextWords[i];
|
|
149
|
+
const distance = Math.abs(i - matchPosition);
|
|
150
|
+
const weight = Math.max(0.1, 1 - (distance * 0.2)); // Closer words have higher weight
|
|
151
|
+
if (POSITIVE_INDICATORS.has(word)) {
|
|
152
|
+
positiveCount += weight;
|
|
153
|
+
}
|
|
154
|
+
else if (NEGATIVE_INDICATORS.has(word)) {
|
|
155
|
+
negativeCount += weight;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// Calculate base score
|
|
159
|
+
const totalSentiment = positiveCount + negativeCount;
|
|
160
|
+
if (totalSentiment === 0) {
|
|
161
|
+
return 0.5; // Neutral if no sentiment indicators
|
|
162
|
+
}
|
|
163
|
+
const rawScore = positiveCount / totalSentiment;
|
|
164
|
+
// Apply context-specific adjustments
|
|
165
|
+
let adjustedScore = rawScore;
|
|
166
|
+
// If there are personal pronouns (you, your), lean towards negative
|
|
167
|
+
const hasPersonalPronouns = contextWords.some(word => ['you', 'your', 'u', 'ur'].includes(word));
|
|
168
|
+
if (hasPersonalPronouns && rawScore < 0.7) {
|
|
169
|
+
adjustedScore *= 0.7; // Reduce score when personal pronouns are present
|
|
170
|
+
}
|
|
171
|
+
// If there are object/thing references, lean towards positive
|
|
172
|
+
const hasObjectReferences = contextWords.some(word => ['movie', 'song', 'game', 'book', 'show', 'this', 'that', 'it'].includes(word));
|
|
173
|
+
if (hasObjectReferences && rawScore > 0.3) {
|
|
174
|
+
adjustedScore = Math.min(1, adjustedScore * 1.3); // Boost score for object references
|
|
175
|
+
}
|
|
176
|
+
return Math.max(0, Math.min(1, adjustedScore));
|
|
177
|
+
}
|
|
178
|
+
generateReason(score, contextWords) {
|
|
179
|
+
if (score >= 0.7) {
|
|
180
|
+
return 'Positive context detected - likely not profanity';
|
|
181
|
+
}
|
|
182
|
+
else if (score <= 0.3) {
|
|
183
|
+
return 'Negative context detected - likely profanity';
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return 'Neutral context - uncertain classification';
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Updates the domain whitelist for this analyzer instance
|
|
191
|
+
*/
|
|
192
|
+
updateDomainWhitelist(newWhitelist) {
|
|
193
|
+
this.domainWhitelists = new Set(newWhitelist);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Adds words to the domain whitelist
|
|
197
|
+
*/
|
|
198
|
+
addToDomainWhitelist(words) {
|
|
199
|
+
words.forEach(word => this.domainWhitelists.add(word.toLowerCase()));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.ContextAnalyzer = ContextAnalyzer;
|
|
203
|
+
//# sourceMappingURL=contextAnalyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextAnalyzer.js","sourceRoot":"","sources":["../../../../../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