@sideid/id-profanity-filter 1.9.6 → 1.10.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.
Files changed (50) hide show
  1. package/.eslintrc.js +44 -16
  2. package/.github/workflows/release.yml +62 -0
  3. package/CONTRIBUTING.md +150 -150
  4. package/LICENSE +21 -21
  5. package/README.md +548 -506
  6. package/dist/config/options.d.ts +24 -0
  7. package/dist/constants/categories/blasphemy.d.ts +4 -0
  8. package/dist/constants/categories/disgusting.d.ts +4 -0
  9. package/dist/constants/categories/drugs.d.ts +4 -0
  10. package/dist/constants/categories/profanity.d.ts +4 -0
  11. package/dist/constants/categories/slur.d.ts +4 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.esm.js +923 -94
  14. package/dist/index.esm.js.map +1 -1
  15. package/dist/index.js +924 -93
  16. package/dist/index.js.map +1 -1
  17. package/dist/types/index.d.ts +2 -0
  18. package/dist/utils/ahoCorasick.d.ts +36 -0
  19. package/dist/utils/similarityUtils.d.ts +35 -0
  20. package/eslint.config.mjs +40 -0
  21. package/examples/advanced.ts +120 -120
  22. package/examples/basic.ts +71 -71
  23. package/examples/custom-list.ts +140 -140
  24. package/jest.config.mjs +10 -10
  25. package/package.json +3 -2
  26. package/prettierrc +6 -6
  27. package/rollup.config.mjs +35 -35
  28. package/src/config/options.ts +2 -0
  29. package/src/constants/categories/blasphemy.ts +25 -0
  30. package/src/constants/categories/disgusting.ts +82 -0
  31. package/src/constants/categories/drugs.ts +72 -0
  32. package/src/constants/categories/profanity.ts +139 -0
  33. package/src/constants/categories/slur.ts +102 -0
  34. package/src/constants/regions/general.ts +111 -2
  35. package/src/constants/regions/jawa.ts +257 -3
  36. package/src/constants/wordList.ts +15 -8
  37. package/src/core/analyzer.ts +28 -13
  38. package/src/core/filter.ts +178 -37
  39. package/src/core/matcher.ts +146 -69
  40. package/src/index.ts +21 -2
  41. package/src/types/index.ts +4 -2
  42. package/src/utils/ahoCorasick.ts +179 -0
  43. package/src/utils/regexUtils.ts +0 -1
  44. package/src/utils/similarityUtils.ts +239 -7
  45. package/tsconfig.json +115 -115
  46. package/.github/workflows/ci.yml +0 -0
  47. package/dist/constants/categories/index.d.ts +0 -9
  48. package/dist/constants/regions/index.d.ts +0 -8
  49. package/src/constants/categories/index.ts +0 -31
  50. package/src/constants/regions/index.ts +0 -62
@@ -17,6 +17,8 @@ export declare const FILTER_PRESETS: {
17
17
  detectSimilarity?: boolean;
18
18
  similarityThreshold?: number;
19
19
  detectSplit?: boolean;
20
+ useLevenshtein?: boolean;
21
+ maxLevenshteinDistance?: number;
20
22
  };
21
23
  moderate: {
22
24
  severityThreshold: number;
@@ -34,6 +36,8 @@ export declare const FILTER_PRESETS: {
34
36
  detectSimilarity?: boolean;
35
37
  similarityThreshold?: number;
36
38
  detectSplit?: boolean;
39
+ useLevenshtein?: boolean;
40
+ maxLevenshteinDistance?: number;
37
41
  };
38
42
  light: {
39
43
  severityThreshold: number;
@@ -51,6 +55,8 @@ export declare const FILTER_PRESETS: {
51
55
  detectSimilarity?: boolean;
52
56
  similarityThreshold?: number;
53
57
  detectSplit?: boolean;
58
+ useLevenshtein?: boolean;
59
+ maxLevenshteinDistance?: number;
54
60
  };
55
61
  childSafe: {
56
62
  checkSubstring: boolean;
@@ -68,6 +74,8 @@ export declare const FILTER_PRESETS: {
68
74
  detectSimilarity?: boolean;
69
75
  similarityThreshold?: number;
70
76
  detectSplit?: boolean;
77
+ useLevenshtein?: boolean;
78
+ maxLevenshteinDistance?: number;
71
79
  };
72
80
  };
73
81
  export declare const CATEGORY_PRESETS: {
@@ -87,6 +95,8 @@ export declare const CATEGORY_PRESETS: {
87
95
  detectSimilarity?: boolean;
88
96
  similarityThreshold?: number;
89
97
  detectSplit?: boolean;
98
+ useLevenshtein?: boolean;
99
+ maxLevenshteinDistance?: number;
90
100
  };
91
101
  insults: {
92
102
  categories: ProfanityCategory[];
@@ -104,6 +114,8 @@ export declare const CATEGORY_PRESETS: {
104
114
  detectSimilarity?: boolean;
105
115
  similarityThreshold?: number;
106
116
  detectSplit?: boolean;
117
+ useLevenshtein?: boolean;
118
+ maxLevenshteinDistance?: number;
107
119
  };
108
120
  profanity: {
109
121
  categories: ProfanityCategory[];
@@ -121,6 +133,8 @@ export declare const CATEGORY_PRESETS: {
121
133
  detectSimilarity?: boolean;
122
134
  similarityThreshold?: number;
123
135
  detectSplit?: boolean;
136
+ useLevenshtein?: boolean;
137
+ maxLevenshteinDistance?: number;
124
138
  };
125
139
  };
126
140
  export declare const REGION_PRESETS: {
@@ -140,6 +154,8 @@ export declare const REGION_PRESETS: {
140
154
  detectSimilarity?: boolean;
141
155
  similarityThreshold?: number;
142
156
  detectSplit?: boolean;
157
+ useLevenshtein?: boolean;
158
+ maxLevenshteinDistance?: number;
143
159
  };
144
160
  jawa: {
145
161
  regions: Region[];
@@ -157,6 +173,8 @@ export declare const REGION_PRESETS: {
157
173
  detectSimilarity?: boolean;
158
174
  similarityThreshold?: number;
159
175
  detectSplit?: boolean;
176
+ useLevenshtein?: boolean;
177
+ maxLevenshteinDistance?: number;
160
178
  };
161
179
  sunda: {
162
180
  regions: Region[];
@@ -174,6 +192,8 @@ export declare const REGION_PRESETS: {
174
192
  detectSimilarity?: boolean;
175
193
  similarityThreshold?: number;
176
194
  detectSplit?: boolean;
195
+ useLevenshtein?: boolean;
196
+ maxLevenshteinDistance?: number;
177
197
  };
178
198
  betawi: {
179
199
  regions: Region[];
@@ -191,6 +211,8 @@ export declare const REGION_PRESETS: {
191
211
  detectSimilarity?: boolean;
192
212
  similarityThreshold?: number;
193
213
  detectSplit?: boolean;
214
+ useLevenshtein?: boolean;
215
+ maxLevenshteinDistance?: number;
194
216
  };
195
217
  batak: {
196
218
  regions: Region[];
@@ -208,6 +230,8 @@ export declare const REGION_PRESETS: {
208
230
  detectSimilarity?: boolean;
209
231
  similarityThreshold?: number;
210
232
  detectSplit?: boolean;
233
+ useLevenshtein?: boolean;
234
+ maxLevenshteinDistance?: number;
211
235
  };
212
236
  };
213
237
  export declare const REPLACEMENT_CHARS: {
@@ -0,0 +1,4 @@
1
+ import { ProfanityWord } from "../../types";
2
+ export declare const blasphemy: ProfanityWord[];
3
+ export declare const blasphemyWords: string[];
4
+ export default blasphemy;
@@ -0,0 +1,4 @@
1
+ import { ProfanityWord } from "../../types";
2
+ export declare const disgusting: ProfanityWord[];
3
+ export declare const disgustingWords: string[];
4
+ export default disgusting;
@@ -0,0 +1,4 @@
1
+ import { ProfanityWord } from "../../types";
2
+ export declare const drugs: ProfanityWord[];
3
+ export declare const drugsWords: string[];
4
+ export default drugs;
@@ -0,0 +1,4 @@
1
+ import { ProfanityWord } from "../../types";
2
+ export declare const profanity: ProfanityWord[];
3
+ export declare const profanityWords: string[];
4
+ export default profanity;
@@ -0,0 +1,4 @@
1
+ import { ProfanityWord } from "../../types";
2
+ export declare const slur: ProfanityWord[];
3
+ export declare const slurWords: string[];
4
+ export default slur;
package/dist/index.d.ts CHANGED
@@ -25,6 +25,8 @@ interface FilterOptions {
25
25
  detectSimilarity?: boolean;
26
26
  similarityThreshold?: number;
27
27
  detectSplit?: boolean;
28
+ useLevenshtein?: boolean;
29
+ maxLevenshteinDistance?: number;
28
30
  }
29
31
  interface FilterResult {
30
32
  filtered: string;