glin-profanity 2.1.0 → 2.3.5

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.
Files changed (82) hide show
  1. package/README.md +205 -55
  2. package/dist/index.cjs +5590 -0
  3. package/dist/index.d.cts +120 -0
  4. package/dist/index.d.ts +120 -0
  5. package/dist/index.js +5572 -0
  6. package/package.json +37 -13
  7. package/lib/cjs/data/Norwegian.json +0 -17
  8. package/lib/cjs/data/arabic.json +0 -157
  9. package/lib/cjs/data/chinese.json +0 -298
  10. package/lib/cjs/data/czech.json +0 -45
  11. package/lib/cjs/data/danish.json +0 -24
  12. package/lib/cjs/data/dictionary.d.ts +0 -25
  13. package/lib/cjs/data/dictionary.js +0 -52
  14. package/lib/cjs/data/dictionary.js.map +0 -1
  15. package/lib/cjs/data/english.json +0 -410
  16. package/lib/cjs/data/esperanto.json +0 -41
  17. package/lib/cjs/data/finnish.json +0 -134
  18. package/lib/cjs/data/french.json +0 -99
  19. package/lib/cjs/data/german.json +0 -69
  20. package/lib/cjs/data/globalWhitelist.json +0 -31
  21. package/lib/cjs/data/hindi.json +0 -100
  22. package/lib/cjs/data/hungarian.json +0 -100
  23. package/lib/cjs/data/italian.json +0 -184
  24. package/lib/cjs/data/japanese.json +0 -189
  25. package/lib/cjs/data/korean.json +0 -76
  26. package/lib/cjs/data/persian.json +0 -49
  27. package/lib/cjs/data/polish.json +0 -57
  28. package/lib/cjs/data/portuguese.json +0 -78
  29. package/lib/cjs/data/russian.json +0 -156
  30. package/lib/cjs/data/swedish.json +0 -47
  31. package/lib/cjs/data/thai.json +0 -35
  32. package/lib/cjs/data/turkish.json +0 -195
  33. package/lib/cjs/filters/Filter.d.ts +0 -39
  34. package/lib/cjs/filters/Filter.js +0 -162
  35. package/lib/cjs/filters/Filter.js.map +0 -1
  36. package/lib/cjs/hooks/useProfanityChecker.d.ts +0 -34
  37. package/lib/cjs/hooks/useProfanityChecker.js +0 -68
  38. package/lib/cjs/hooks/useProfanityChecker.js.map +0 -1
  39. package/lib/cjs/index.d.ts +0 -4
  40. package/lib/cjs/index.js +0 -10
  41. package/lib/cjs/index.js.map +0 -1
  42. package/lib/cjs/types/types.d.ts +0 -21
  43. package/lib/cjs/types/types.js +0 -11
  44. package/lib/cjs/types/types.js.map +0 -1
  45. package/lib/esm/data/Norwegian.json +0 -17
  46. package/lib/esm/data/arabic.json +0 -157
  47. package/lib/esm/data/chinese.json +0 -298
  48. package/lib/esm/data/czech.json +0 -45
  49. package/lib/esm/data/danish.json +0 -24
  50. package/lib/esm/data/dictionary.d.ts +0 -25
  51. package/lib/esm/data/dictionary.js +0 -47
  52. package/lib/esm/data/dictionary.js.map +0 -1
  53. package/lib/esm/data/english.json +0 -410
  54. package/lib/esm/data/esperanto.json +0 -41
  55. package/lib/esm/data/finnish.json +0 -134
  56. package/lib/esm/data/french.json +0 -99
  57. package/lib/esm/data/german.json +0 -69
  58. package/lib/esm/data/globalWhitelist.json +0 -31
  59. package/lib/esm/data/hindi.json +0 -100
  60. package/lib/esm/data/hungarian.json +0 -100
  61. package/lib/esm/data/italian.json +0 -184
  62. package/lib/esm/data/japanese.json +0 -189
  63. package/lib/esm/data/korean.json +0 -76
  64. package/lib/esm/data/persian.json +0 -49
  65. package/lib/esm/data/polish.json +0 -57
  66. package/lib/esm/data/portuguese.json +0 -78
  67. package/lib/esm/data/russian.json +0 -156
  68. package/lib/esm/data/swedish.json +0 -47
  69. package/lib/esm/data/thai.json +0 -35
  70. package/lib/esm/data/turkish.json +0 -195
  71. package/lib/esm/filters/Filter.d.ts +0 -39
  72. package/lib/esm/filters/Filter.js +0 -156
  73. package/lib/esm/filters/Filter.js.map +0 -1
  74. package/lib/esm/hooks/useProfanityChecker.d.ts +0 -34
  75. package/lib/esm/hooks/useProfanityChecker.js +0 -61
  76. package/lib/esm/hooks/useProfanityChecker.js.map +0 -1
  77. package/lib/esm/index.d.ts +0 -4
  78. package/lib/esm/index.js +0 -4
  79. package/lib/esm/index.js.map +0 -1
  80. package/lib/esm/types/types.d.ts +0 -21
  81. package/lib/esm/types/types.js +0 -8
  82. package/lib/esm/types/types.js.map +0 -1
@@ -0,0 +1,120 @@
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' | '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
+ /** Main filter configuration options - unified with Python */
39
+ interface FilterConfig extends ContextAwareConfig {
40
+ languages?: Language[];
41
+ allLanguages?: boolean;
42
+ caseSensitive?: boolean;
43
+ wordBoundaries?: boolean;
44
+ customWords?: string[];
45
+ replaceWith?: string;
46
+ severityLevels?: boolean;
47
+ ignoreWords?: string[];
48
+ logProfanity?: boolean;
49
+ allowObfuscatedMatch?: boolean;
50
+ fuzzyToleranceLevel?: number;
51
+ }
52
+ /** Result with minimum severity filtering */
53
+ interface FilteredProfanityResult {
54
+ result: CheckProfanityResult;
55
+ filteredWords: string[];
56
+ }
57
+
58
+ interface ProfanityCheckerConfig {
59
+ languages?: Language[];
60
+ allLanguages?: boolean;
61
+ caseSensitive?: boolean;
62
+ wordBoundaries?: boolean;
63
+ customWords?: string[];
64
+ replaceWith?: string;
65
+ severityLevels?: boolean;
66
+ allowObfuscatedMatch?: boolean;
67
+ fuzzyToleranceLevel?: number;
68
+ minSeverity?: SeverityLevel;
69
+ autoReplace?: boolean;
70
+ customActions?: (result: CheckProfanityResult) => void;
71
+ }
72
+ interface ProfanityCheckResult extends CheckProfanityResult {
73
+ filteredWords: string[];
74
+ autoReplaced: string;
75
+ }
76
+
77
+ declare function checkProfanity(text: string, config?: ProfanityCheckerConfig): ProfanityCheckResult;
78
+ declare function checkProfanityAsync(text: string, config?: ProfanityCheckerConfig): Promise<ProfanityCheckResult>;
79
+ declare function isWordProfane(word: string, config?: ProfanityCheckerConfig): boolean;
80
+
81
+ declare const useProfanityChecker: (config?: ProfanityCheckerConfig) => {
82
+ result: CheckProfanityResult;
83
+ checkText: (text: string) => ProfanityCheckResult;
84
+ checkTextAsync: (text: string) => Promise<ProfanityCheckResult>;
85
+ reset: () => void;
86
+ isDirty: boolean;
87
+ isWordProfane: (word: string) => boolean;
88
+ };
89
+
90
+ declare class Filter {
91
+ private words;
92
+ private caseSensitive;
93
+ private wordBoundaries;
94
+ private replaceWith?;
95
+ private severityLevels;
96
+ private ignoreWords;
97
+ private logProfanity;
98
+ private allowObfuscatedMatch;
99
+ private fuzzyToleranceLevel;
100
+ private enableContextAware;
101
+ private contextWindow;
102
+ private confidenceThreshold;
103
+ private contextAnalyzer?;
104
+ private primaryLanguage;
105
+ constructor(config?: FilterConfig);
106
+ private debugLog;
107
+ private normalizeObfuscated;
108
+ private getRegex;
109
+ private isFuzzyToleranceMatch;
110
+ private evaluateSeverity;
111
+ isProfane(value: string): boolean;
112
+ matches(word: string): boolean;
113
+ checkProfanity(text: string): CheckProfanityResult;
114
+ checkProfanityWithMinSeverity(text: string, minSeverity?: SeverityLevel): {
115
+ filteredWords: string[];
116
+ result: CheckProfanityResult;
117
+ };
118
+ }
119
+
120
+ export { type CheckProfanityResult, type ContextAwareConfig, Filter, type FilterConfig, type FilteredProfanityResult, type Language, type Match, type ProfanityCheckResult, type ProfanityCheckerConfig, SeverityLevel, checkProfanity, checkProfanityAsync, isWordProfane, useProfanityChecker };
@@ -0,0 +1,120 @@
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' | '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
+ /** Main filter configuration options - unified with Python */
39
+ interface FilterConfig extends ContextAwareConfig {
40
+ languages?: Language[];
41
+ allLanguages?: boolean;
42
+ caseSensitive?: boolean;
43
+ wordBoundaries?: boolean;
44
+ customWords?: string[];
45
+ replaceWith?: string;
46
+ severityLevels?: boolean;
47
+ ignoreWords?: string[];
48
+ logProfanity?: boolean;
49
+ allowObfuscatedMatch?: boolean;
50
+ fuzzyToleranceLevel?: number;
51
+ }
52
+ /** Result with minimum severity filtering */
53
+ interface FilteredProfanityResult {
54
+ result: CheckProfanityResult;
55
+ filteredWords: string[];
56
+ }
57
+
58
+ interface ProfanityCheckerConfig {
59
+ languages?: Language[];
60
+ allLanguages?: boolean;
61
+ caseSensitive?: boolean;
62
+ wordBoundaries?: boolean;
63
+ customWords?: string[];
64
+ replaceWith?: string;
65
+ severityLevels?: boolean;
66
+ allowObfuscatedMatch?: boolean;
67
+ fuzzyToleranceLevel?: number;
68
+ minSeverity?: SeverityLevel;
69
+ autoReplace?: boolean;
70
+ customActions?: (result: CheckProfanityResult) => void;
71
+ }
72
+ interface ProfanityCheckResult extends CheckProfanityResult {
73
+ filteredWords: string[];
74
+ autoReplaced: string;
75
+ }
76
+
77
+ declare function checkProfanity(text: string, config?: ProfanityCheckerConfig): ProfanityCheckResult;
78
+ declare function checkProfanityAsync(text: string, config?: ProfanityCheckerConfig): Promise<ProfanityCheckResult>;
79
+ declare function isWordProfane(word: string, config?: ProfanityCheckerConfig): boolean;
80
+
81
+ declare const useProfanityChecker: (config?: ProfanityCheckerConfig) => {
82
+ result: CheckProfanityResult;
83
+ checkText: (text: string) => ProfanityCheckResult;
84
+ checkTextAsync: (text: string) => Promise<ProfanityCheckResult>;
85
+ reset: () => void;
86
+ isDirty: boolean;
87
+ isWordProfane: (word: string) => boolean;
88
+ };
89
+
90
+ declare class Filter {
91
+ private words;
92
+ private caseSensitive;
93
+ private wordBoundaries;
94
+ private replaceWith?;
95
+ private severityLevels;
96
+ private ignoreWords;
97
+ private logProfanity;
98
+ private allowObfuscatedMatch;
99
+ private fuzzyToleranceLevel;
100
+ private enableContextAware;
101
+ private contextWindow;
102
+ private confidenceThreshold;
103
+ private contextAnalyzer?;
104
+ private primaryLanguage;
105
+ constructor(config?: FilterConfig);
106
+ private debugLog;
107
+ private normalizeObfuscated;
108
+ private getRegex;
109
+ private isFuzzyToleranceMatch;
110
+ private evaluateSeverity;
111
+ isProfane(value: string): boolean;
112
+ matches(word: string): boolean;
113
+ checkProfanity(text: string): CheckProfanityResult;
114
+ checkProfanityWithMinSeverity(text: string, minSeverity?: SeverityLevel): {
115
+ filteredWords: string[];
116
+ result: CheckProfanityResult;
117
+ };
118
+ }
119
+
120
+ export { type CheckProfanityResult, type ContextAwareConfig, Filter, type FilterConfig, type FilteredProfanityResult, type Language, type Match, type ProfanityCheckResult, type ProfanityCheckerConfig, SeverityLevel, checkProfanity, checkProfanityAsync, isWordProfane, useProfanityChecker };