glin-profanity 3.2.0 → 3.2.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/{types-Dj5vaoch.d.cts → Filter-BGcyIAvO.d.ts} +2 -162
- package/dist/{types-Dj5vaoch.d.ts → Filter-D34Wsmrj.d.cts} +2 -162
- package/dist/frameworks/index.cjs +5257 -0
- package/dist/frameworks/index.d.cts +2 -0
- package/dist/frameworks/index.d.ts +2 -0
- package/dist/frameworks/index.js +5252 -0
- package/dist/frameworks/nextjs.cjs +5257 -0
- package/dist/frameworks/nextjs.d.cts +173 -0
- package/dist/frameworks/nextjs.d.ts +173 -0
- package/dist/frameworks/nextjs.js +5252 -0
- package/dist/index.cjs +0 -28
- package/dist/index.d.cts +5 -29
- package/dist/index.d.ts +5 -29
- package/dist/index.js +1 -28
- package/dist/integrations/index.cjs +6110 -0
- package/dist/integrations/index.d.cts +5 -0
- package/dist/integrations/index.d.ts +5 -0
- package/dist/integrations/index.js +6082 -0
- package/dist/integrations/langchain.cjs +5252 -0
- package/dist/integrations/langchain.d.cts +231 -0
- package/dist/integrations/langchain.d.ts +231 -0
- package/dist/integrations/langchain.js +5239 -0
- package/dist/integrations/openai.cjs +5367 -0
- package/dist/integrations/openai.d.cts +167 -0
- package/dist/integrations/openai.d.ts +167 -0
- package/dist/integrations/openai.js +5362 -0
- package/dist/integrations/semantic.cjs +5314 -0
- package/dist/integrations/semantic.d.cts +268 -0
- package/dist/integrations/semantic.d.ts +268 -0
- package/dist/integrations/semantic.js +5309 -0
- package/dist/integrations/vercel-ai.cjs +5282 -0
- package/dist/integrations/vercel-ai.d.cts +224 -0
- package/dist/integrations/vercel-ai.d.ts +224 -0
- package/dist/integrations/vercel-ai.js +5273 -0
- package/dist/ml/index.cjs +207 -0
- package/dist/ml/index.d.cts +5 -2
- package/dist/ml/index.d.ts +5 -2
- package/dist/ml/index.js +203 -1
- package/dist/ml/transformers.cjs +5237 -0
- package/dist/ml/transformers.d.cts +232 -0
- package/dist/ml/transformers.d.ts +232 -0
- package/dist/ml/transformers.js +5231 -0
- package/dist/multimodal/audio.cjs +5269 -0
- package/dist/multimodal/audio.d.cts +255 -0
- package/dist/multimodal/audio.d.ts +255 -0
- package/dist/multimodal/audio.js +5264 -0
- package/dist/multimodal/index.cjs +5432 -0
- package/dist/multimodal/index.d.cts +4 -0
- package/dist/multimodal/index.d.ts +4 -0
- package/dist/multimodal/index.js +5422 -0
- package/dist/multimodal/ocr.cjs +5193 -0
- package/dist/multimodal/ocr.d.cts +157 -0
- package/dist/multimodal/ocr.d.ts +157 -0
- package/dist/multimodal/ocr.js +5187 -0
- package/dist/react.cjs +5133 -0
- package/dist/react.d.cts +13 -0
- package/dist/react.d.ts +13 -0
- package/dist/react.js +5131 -0
- package/dist/types-B9c_ik4k.d.cts +88 -0
- package/dist/types-B9c_ik4k.d.ts +88 -0
- package/dist/types-BuKh9tvV.d.ts +20 -0
- package/dist/types-Ct_ueYqw.d.cts +76 -0
- package/dist/types-Ct_ueYqw.d.ts +76 -0
- package/dist/types-DI8nzwWc.d.cts +20 -0
- package/package.json +170 -3
|
@@ -1,89 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Type definitions for glin-profanity JavaScript/TypeScript package.
|
|
3
|
-
* Unified API that mirrors the Python package structure.
|
|
4
|
-
*/
|
|
5
|
-
/** Severity levels for profanity matches - unified with Python */
|
|
6
|
-
declare enum SeverityLevel {
|
|
7
|
-
EXACT = 1,
|
|
8
|
-
FUZZY = 2
|
|
9
|
-
}
|
|
10
|
-
/** Supported languages - unified list with Python */
|
|
11
|
-
type Language = 'arabic' | 'chinese' | 'czech' | 'danish' | 'dutch' | 'english' | 'esperanto' | 'finnish' | 'french' | 'german' | 'hindi' | 'hungarian' | 'italian' | 'japanese' | 'korean' | 'norwegian' | 'persian' | 'polish' | 'portuguese' | 'russian' | 'spanish' | 'swedish' | 'thai' | 'turkish';
|
|
12
|
-
/** Represents a profanity match in text - unified with Python */
|
|
13
|
-
interface Match {
|
|
14
|
-
word: string;
|
|
15
|
-
index: number;
|
|
16
|
-
severity: SeverityLevel;
|
|
17
|
-
contextScore?: number;
|
|
18
|
-
reason?: string;
|
|
19
|
-
isWhitelisted?: boolean;
|
|
20
|
-
}
|
|
21
|
-
/** Result of profanity check operation - unified field names */
|
|
22
|
-
interface CheckProfanityResult {
|
|
23
|
-
containsProfanity: boolean;
|
|
24
|
-
profaneWords: string[];
|
|
25
|
-
processedText?: string;
|
|
26
|
-
severityMap?: Record<string, SeverityLevel>;
|
|
27
|
-
matches?: Match[];
|
|
28
|
-
contextScore?: number;
|
|
29
|
-
reason?: string;
|
|
30
|
-
}
|
|
31
|
-
/** Configuration for context-aware filtering - unified with Python */
|
|
32
|
-
interface ContextAwareConfig {
|
|
33
|
-
enableContextAware?: boolean;
|
|
34
|
-
contextWindow?: number;
|
|
35
|
-
confidenceThreshold?: number;
|
|
36
|
-
domainWhitelists?: Record<string, string[]>;
|
|
37
|
-
}
|
|
38
|
-
/** Leetspeak detection intensity levels */
|
|
39
|
-
type LeetspeakLevel = 'basic' | 'moderate' | 'aggressive';
|
|
40
|
-
/** Main filter configuration options - unified with Python */
|
|
41
|
-
interface FilterConfig extends ContextAwareConfig {
|
|
42
|
-
languages?: Language[];
|
|
43
|
-
allLanguages?: boolean;
|
|
44
|
-
caseSensitive?: boolean;
|
|
45
|
-
wordBoundaries?: boolean;
|
|
46
|
-
customWords?: string[];
|
|
47
|
-
replaceWith?: string;
|
|
48
|
-
severityLevels?: boolean;
|
|
49
|
-
ignoreWords?: string[];
|
|
50
|
-
logProfanity?: boolean;
|
|
51
|
-
allowObfuscatedMatch?: boolean;
|
|
52
|
-
fuzzyToleranceLevel?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Enable leetspeak detection (e.g., "f4ck" → "fuck").
|
|
55
|
-
* @default false
|
|
56
|
-
*/
|
|
57
|
-
detectLeetspeak?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Leetspeak detection intensity level.
|
|
60
|
-
* - `basic`: Numbers only (0→o, 1→i, 3→e, 4→a, 5→s)
|
|
61
|
-
* - `moderate`: Basic + symbols (@→a, $→s, !→i)
|
|
62
|
-
* - `aggressive`: All known substitutions
|
|
63
|
-
* @default 'moderate'
|
|
64
|
-
*/
|
|
65
|
-
leetspeakLevel?: LeetspeakLevel;
|
|
66
|
-
/**
|
|
67
|
-
* Enable Unicode normalization to detect homoglyphs and obfuscation.
|
|
68
|
-
* @default true
|
|
69
|
-
*/
|
|
70
|
-
normalizeUnicode?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Cache profanity check results for repeated strings.
|
|
73
|
-
* @default false
|
|
74
|
-
*/
|
|
75
|
-
cacheResults?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Maximum cache size when caching is enabled.
|
|
78
|
-
* @default 1000
|
|
79
|
-
*/
|
|
80
|
-
maxCacheSize?: number;
|
|
81
|
-
}
|
|
82
|
-
/** Result with minimum severity filtering */
|
|
83
|
-
interface FilteredProfanityResult {
|
|
84
|
-
result: CheckProfanityResult;
|
|
85
|
-
filteredWords: string[];
|
|
86
|
-
}
|
|
1
|
+
import { F as FilterConfig, C as CheckProfanityResult, S as SeverityLevel } from './types-B9c_ik4k.js';
|
|
87
2
|
|
|
88
3
|
/**
|
|
89
4
|
* Core profanity filter class.
|
|
@@ -274,79 +189,4 @@ declare class Filter {
|
|
|
274
189
|
};
|
|
275
190
|
}
|
|
276
191
|
|
|
277
|
-
|
|
278
|
-
* Type definitions for ML-based profanity detection.
|
|
279
|
-
*/
|
|
280
|
-
/**
|
|
281
|
-
* Toxicity categories detected by the TensorFlow.js model.
|
|
282
|
-
* These map to the civil comments dataset labels.
|
|
283
|
-
*/
|
|
284
|
-
type ToxicityLabel = 'identity_attack' | 'insult' | 'obscene' | 'severe_toxicity' | 'sexual_explicit' | 'threat' | 'toxicity';
|
|
285
|
-
/**
|
|
286
|
-
* Result from a single toxicity prediction.
|
|
287
|
-
*/
|
|
288
|
-
interface ToxicityPrediction {
|
|
289
|
-
/** The toxicity category */
|
|
290
|
-
label: ToxicityLabel;
|
|
291
|
-
/** Whether the text matches this category (null if below threshold) */
|
|
292
|
-
match: boolean | null;
|
|
293
|
-
/** Probability scores [non-toxic, toxic] */
|
|
294
|
-
probabilities: [number, number];
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Result from ML-based toxicity analysis.
|
|
298
|
-
*/
|
|
299
|
-
interface MLAnalysisResult {
|
|
300
|
-
/** Whether any toxicity was detected */
|
|
301
|
-
isToxic: boolean;
|
|
302
|
-
/** Overall toxicity score (0-1) */
|
|
303
|
-
overallScore: number;
|
|
304
|
-
/** Predictions for each category */
|
|
305
|
-
predictions: ToxicityPrediction[];
|
|
306
|
-
/** Categories that matched */
|
|
307
|
-
matchedCategories: ToxicityLabel[];
|
|
308
|
-
/** Processing time in milliseconds */
|
|
309
|
-
processingTimeMs: number;
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Configuration for the ML toxicity detector.
|
|
313
|
-
*/
|
|
314
|
-
interface MLDetectorConfig {
|
|
315
|
-
/**
|
|
316
|
-
* Minimum confidence threshold for predictions.
|
|
317
|
-
* Values below this threshold will return null for match.
|
|
318
|
-
* @default 0.85
|
|
319
|
-
*/
|
|
320
|
-
threshold?: number;
|
|
321
|
-
/**
|
|
322
|
-
* Specific toxicity categories to check.
|
|
323
|
-
* If not specified, all categories are checked.
|
|
324
|
-
*/
|
|
325
|
-
labels?: ToxicityLabel[];
|
|
326
|
-
/**
|
|
327
|
-
* Whether to load the model immediately on instantiation.
|
|
328
|
-
* If false, model will be loaded on first use.
|
|
329
|
-
* @default false
|
|
330
|
-
*/
|
|
331
|
-
preloadModel?: boolean;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Combined result from both rule-based and ML detection.
|
|
335
|
-
*/
|
|
336
|
-
interface HybridAnalysisResult {
|
|
337
|
-
/** Rule-based detection result */
|
|
338
|
-
ruleBasedResult: {
|
|
339
|
-
containsProfanity: boolean;
|
|
340
|
-
profaneWords: string[];
|
|
341
|
-
};
|
|
342
|
-
/** ML-based detection result (null if ML not enabled) */
|
|
343
|
-
mlResult: MLAnalysisResult | null;
|
|
344
|
-
/** Combined decision */
|
|
345
|
-
isToxic: boolean;
|
|
346
|
-
/** Confidence score for the decision */
|
|
347
|
-
confidence: number;
|
|
348
|
-
/** Reason for the decision */
|
|
349
|
-
reason: string;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export { type CheckProfanityResult as C, type FilterConfig as F, type HybridAnalysisResult as H, type Language as L, type Match as M, SeverityLevel as S, type ToxicityLabel as T, Filter as a, type FilteredProfanityResult as b, type ContextAwareConfig as c, type ToxicityPrediction as d, type MLAnalysisResult as e, type MLDetectorConfig as f };
|
|
192
|
+
export { Filter as F };
|
|
@@ -1,89 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Type definitions for glin-profanity JavaScript/TypeScript package.
|
|
3
|
-
* Unified API that mirrors the Python package structure.
|
|
4
|
-
*/
|
|
5
|
-
/** Severity levels for profanity matches - unified with Python */
|
|
6
|
-
declare enum SeverityLevel {
|
|
7
|
-
EXACT = 1,
|
|
8
|
-
FUZZY = 2
|
|
9
|
-
}
|
|
10
|
-
/** Supported languages - unified list with Python */
|
|
11
|
-
type Language = 'arabic' | 'chinese' | 'czech' | 'danish' | 'dutch' | 'english' | 'esperanto' | 'finnish' | 'french' | 'german' | 'hindi' | 'hungarian' | 'italian' | 'japanese' | 'korean' | 'norwegian' | 'persian' | 'polish' | 'portuguese' | 'russian' | 'spanish' | 'swedish' | 'thai' | 'turkish';
|
|
12
|
-
/** Represents a profanity match in text - unified with Python */
|
|
13
|
-
interface Match {
|
|
14
|
-
word: string;
|
|
15
|
-
index: number;
|
|
16
|
-
severity: SeverityLevel;
|
|
17
|
-
contextScore?: number;
|
|
18
|
-
reason?: string;
|
|
19
|
-
isWhitelisted?: boolean;
|
|
20
|
-
}
|
|
21
|
-
/** Result of profanity check operation - unified field names */
|
|
22
|
-
interface CheckProfanityResult {
|
|
23
|
-
containsProfanity: boolean;
|
|
24
|
-
profaneWords: string[];
|
|
25
|
-
processedText?: string;
|
|
26
|
-
severityMap?: Record<string, SeverityLevel>;
|
|
27
|
-
matches?: Match[];
|
|
28
|
-
contextScore?: number;
|
|
29
|
-
reason?: string;
|
|
30
|
-
}
|
|
31
|
-
/** Configuration for context-aware filtering - unified with Python */
|
|
32
|
-
interface ContextAwareConfig {
|
|
33
|
-
enableContextAware?: boolean;
|
|
34
|
-
contextWindow?: number;
|
|
35
|
-
confidenceThreshold?: number;
|
|
36
|
-
domainWhitelists?: Record<string, string[]>;
|
|
37
|
-
}
|
|
38
|
-
/** Leetspeak detection intensity levels */
|
|
39
|
-
type LeetspeakLevel = 'basic' | 'moderate' | 'aggressive';
|
|
40
|
-
/** Main filter configuration options - unified with Python */
|
|
41
|
-
interface FilterConfig extends ContextAwareConfig {
|
|
42
|
-
languages?: Language[];
|
|
43
|
-
allLanguages?: boolean;
|
|
44
|
-
caseSensitive?: boolean;
|
|
45
|
-
wordBoundaries?: boolean;
|
|
46
|
-
customWords?: string[];
|
|
47
|
-
replaceWith?: string;
|
|
48
|
-
severityLevels?: boolean;
|
|
49
|
-
ignoreWords?: string[];
|
|
50
|
-
logProfanity?: boolean;
|
|
51
|
-
allowObfuscatedMatch?: boolean;
|
|
52
|
-
fuzzyToleranceLevel?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Enable leetspeak detection (e.g., "f4ck" → "fuck").
|
|
55
|
-
* @default false
|
|
56
|
-
*/
|
|
57
|
-
detectLeetspeak?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Leetspeak detection intensity level.
|
|
60
|
-
* - `basic`: Numbers only (0→o, 1→i, 3→e, 4→a, 5→s)
|
|
61
|
-
* - `moderate`: Basic + symbols (@→a, $→s, !→i)
|
|
62
|
-
* - `aggressive`: All known substitutions
|
|
63
|
-
* @default 'moderate'
|
|
64
|
-
*/
|
|
65
|
-
leetspeakLevel?: LeetspeakLevel;
|
|
66
|
-
/**
|
|
67
|
-
* Enable Unicode normalization to detect homoglyphs and obfuscation.
|
|
68
|
-
* @default true
|
|
69
|
-
*/
|
|
70
|
-
normalizeUnicode?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Cache profanity check results for repeated strings.
|
|
73
|
-
* @default false
|
|
74
|
-
*/
|
|
75
|
-
cacheResults?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Maximum cache size when caching is enabled.
|
|
78
|
-
* @default 1000
|
|
79
|
-
*/
|
|
80
|
-
maxCacheSize?: number;
|
|
81
|
-
}
|
|
82
|
-
/** Result with minimum severity filtering */
|
|
83
|
-
interface FilteredProfanityResult {
|
|
84
|
-
result: CheckProfanityResult;
|
|
85
|
-
filteredWords: string[];
|
|
86
|
-
}
|
|
1
|
+
import { F as FilterConfig, C as CheckProfanityResult, S as SeverityLevel } from './types-B9c_ik4k.cjs';
|
|
87
2
|
|
|
88
3
|
/**
|
|
89
4
|
* Core profanity filter class.
|
|
@@ -274,79 +189,4 @@ declare class Filter {
|
|
|
274
189
|
};
|
|
275
190
|
}
|
|
276
191
|
|
|
277
|
-
|
|
278
|
-
* Type definitions for ML-based profanity detection.
|
|
279
|
-
*/
|
|
280
|
-
/**
|
|
281
|
-
* Toxicity categories detected by the TensorFlow.js model.
|
|
282
|
-
* These map to the civil comments dataset labels.
|
|
283
|
-
*/
|
|
284
|
-
type ToxicityLabel = 'identity_attack' | 'insult' | 'obscene' | 'severe_toxicity' | 'sexual_explicit' | 'threat' | 'toxicity';
|
|
285
|
-
/**
|
|
286
|
-
* Result from a single toxicity prediction.
|
|
287
|
-
*/
|
|
288
|
-
interface ToxicityPrediction {
|
|
289
|
-
/** The toxicity category */
|
|
290
|
-
label: ToxicityLabel;
|
|
291
|
-
/** Whether the text matches this category (null if below threshold) */
|
|
292
|
-
match: boolean | null;
|
|
293
|
-
/** Probability scores [non-toxic, toxic] */
|
|
294
|
-
probabilities: [number, number];
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Result from ML-based toxicity analysis.
|
|
298
|
-
*/
|
|
299
|
-
interface MLAnalysisResult {
|
|
300
|
-
/** Whether any toxicity was detected */
|
|
301
|
-
isToxic: boolean;
|
|
302
|
-
/** Overall toxicity score (0-1) */
|
|
303
|
-
overallScore: number;
|
|
304
|
-
/** Predictions for each category */
|
|
305
|
-
predictions: ToxicityPrediction[];
|
|
306
|
-
/** Categories that matched */
|
|
307
|
-
matchedCategories: ToxicityLabel[];
|
|
308
|
-
/** Processing time in milliseconds */
|
|
309
|
-
processingTimeMs: number;
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Configuration for the ML toxicity detector.
|
|
313
|
-
*/
|
|
314
|
-
interface MLDetectorConfig {
|
|
315
|
-
/**
|
|
316
|
-
* Minimum confidence threshold for predictions.
|
|
317
|
-
* Values below this threshold will return null for match.
|
|
318
|
-
* @default 0.85
|
|
319
|
-
*/
|
|
320
|
-
threshold?: number;
|
|
321
|
-
/**
|
|
322
|
-
* Specific toxicity categories to check.
|
|
323
|
-
* If not specified, all categories are checked.
|
|
324
|
-
*/
|
|
325
|
-
labels?: ToxicityLabel[];
|
|
326
|
-
/**
|
|
327
|
-
* Whether to load the model immediately on instantiation.
|
|
328
|
-
* If false, model will be loaded on first use.
|
|
329
|
-
* @default false
|
|
330
|
-
*/
|
|
331
|
-
preloadModel?: boolean;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Combined result from both rule-based and ML detection.
|
|
335
|
-
*/
|
|
336
|
-
interface HybridAnalysisResult {
|
|
337
|
-
/** Rule-based detection result */
|
|
338
|
-
ruleBasedResult: {
|
|
339
|
-
containsProfanity: boolean;
|
|
340
|
-
profaneWords: string[];
|
|
341
|
-
};
|
|
342
|
-
/** ML-based detection result (null if ML not enabled) */
|
|
343
|
-
mlResult: MLAnalysisResult | null;
|
|
344
|
-
/** Combined decision */
|
|
345
|
-
isToxic: boolean;
|
|
346
|
-
/** Confidence score for the decision */
|
|
347
|
-
confidence: number;
|
|
348
|
-
/** Reason for the decision */
|
|
349
|
-
reason: string;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export { type CheckProfanityResult as C, type FilterConfig as F, type HybridAnalysisResult as H, type Language as L, type Match as M, SeverityLevel as S, type ToxicityLabel as T, Filter as a, type FilteredProfanityResult as b, type ContextAwareConfig as c, type ToxicityPrediction as d, type MLAnalysisResult as e, type MLDetectorConfig as f };
|
|
192
|
+
export { Filter as F };
|