@sideid/id-profanity-filter 1.11.0 → 1.11.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.
- package/.eslintrc.js +44 -44
- package/.github/workflows/release.yml +62 -0
- package/CONTRIBUTING.md +150 -150
- package/LICENSE +21 -21
- package/README.md +548 -548
- package/dist/index.d.ts +989 -0
- package/dist/index.esm.js +9 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +375 -57
- package/dist/types/types/index.d.ts +59 -0
- package/eslint.config.mjs +40 -40
- package/examples/advanced.ts +120 -120
- package/examples/basic.ts +71 -71
- package/examples/custom-list.ts +140 -140
- package/jest.config.mjs +10 -10
- package/package.json +2 -1
- package/prettierrc +6 -6
- package/rollup.config.mjs +40 -35
- package/src/constants/regions/general.ts +9 -0
- package/src/index.ts +15 -15
- package/tsconfig.json +115 -115
- package/.github/workflows/ci.yml +0 -0
- package/dist/constants/categories/index.d.ts +0 -9
- package/dist/constants/regions/index.d.ts +0 -8
- /package/dist/{config → types/config}/options.d.ts +0 -0
- /package/dist/{constants → types/constants}/categories/blasphemy.d.ts +0 -0
- /package/dist/{constants → types/constants}/categories/disgusting.d.ts +0 -0
- /package/dist/{constants → types/constants}/categories/drugs.d.ts +0 -0
- /package/dist/{constants → types/constants}/categories/insult.d.ts +0 -0
- /package/dist/{constants → types/constants}/categories/profanity.d.ts +0 -0
- /package/dist/{constants → types/constants}/categories/sexual.d.ts +0 -0
- /package/dist/{constants → types/constants}/categories/slur.d.ts +0 -0
- /package/dist/{constants → types/constants}/regions/batak.d.ts +0 -0
- /package/dist/{constants → types/constants}/regions/betawi.d.ts +0 -0
- /package/dist/{constants → types/constants}/regions/general.d.ts +0 -0
- /package/dist/{constants → types/constants}/regions/jawa.d.ts +0 -0
- /package/dist/{constants → types/constants}/regions/sunda.d.ts +0 -0
- /package/dist/{constants → types/constants}/wordList.d.ts +0 -0
- /package/dist/{core → types/core}/analyzer.d.ts +0 -0
- /package/dist/{core → types/core}/filter.d.ts +0 -0
- /package/dist/{core → types/core}/matcher.d.ts +0 -0
- /package/dist/{utils → types/utils}/ahoCorasick.d.ts +0 -0
- /package/dist/{utils → types/utils}/regexUtils.d.ts +0 -0
- /package/dist/{utils → types/utils}/similarityUtils.d.ts +0 -0
- /package/dist/{utils → types/utils}/stringUtils.d.ts +0 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -1,59 +1,377 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './core/matcher';
|
|
3
|
+
export * from './core/filter';
|
|
4
|
+
export * from './core/analyzer';
|
|
5
|
+
export * from './utils/stringUtils';
|
|
6
|
+
export * from './utils/regexUtils';
|
|
7
|
+
export * from './utils/similarityUtils';
|
|
8
|
+
export * from './config/options';
|
|
9
|
+
import { FilterOptions, FilterResult, AnalysisResult } from './types';
|
|
10
|
+
import { getPresetOptions } from './config/options';
|
|
11
|
+
export declare class IDProfanityFilter {
|
|
12
|
+
private options;
|
|
13
|
+
/**
|
|
14
|
+
* Membuat instance filter baru
|
|
15
|
+
* @param options Opsi untuk filter
|
|
16
|
+
*/
|
|
17
|
+
constructor(options?: FilterOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Menyensor teks yang diberikan
|
|
20
|
+
* @param text Teks yang akan disensor
|
|
21
|
+
* @returns Hasil filter
|
|
22
|
+
*/
|
|
23
|
+
filter(text: string): FilterResult;
|
|
24
|
+
/**
|
|
25
|
+
* Memeriksa apakah teks mengandung kata kotor
|
|
26
|
+
* @param text Teks yang akan diperiksa
|
|
27
|
+
* @returns Boolean apakah teks mengandung kata kotor
|
|
28
|
+
*/
|
|
29
|
+
isProfane(text: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Menganalisis teks untuk kata kotor
|
|
32
|
+
* @param text Teks yang akan dianalisis
|
|
33
|
+
* @returns Hasil analisis
|
|
34
|
+
*/
|
|
35
|
+
analyze(text: string): AnalysisResult;
|
|
36
|
+
/**
|
|
37
|
+
* Menganalisis batch teks untuk kata kotor
|
|
38
|
+
* @param texts Array dari teks yang akan dianalisis
|
|
39
|
+
* @returns Hasil analisis batch
|
|
40
|
+
*/
|
|
41
|
+
batchAnalyze(texts: string[]): {
|
|
42
|
+
totalTexts: number;
|
|
43
|
+
profaneTexts: number;
|
|
44
|
+
cleanTexts: number;
|
|
45
|
+
averageSeverity: number;
|
|
46
|
+
topCategories: import("./types").ProfanityCategory[];
|
|
47
|
+
topRegions: import("./types").Region[];
|
|
48
|
+
mostFrequentWords: Array<{
|
|
49
|
+
word: string;
|
|
50
|
+
count: number;
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Menganalisis teks per-kalimat
|
|
55
|
+
* @param text Teks yang akan dianalisis
|
|
56
|
+
* @returns Array hasil analisis per-kalimat
|
|
57
|
+
*/
|
|
58
|
+
analyzeBySentence(text: string): (AnalysisResult & {
|
|
59
|
+
sentence: string;
|
|
60
|
+
})[];
|
|
61
|
+
/**
|
|
62
|
+
* Menganalisis teks dengan konteks di sekitar kata kotor
|
|
63
|
+
* @param text Teks yang akan dianalisis
|
|
64
|
+
* @param contextWindowSize Jumlah kata konteks
|
|
65
|
+
* @returns Konteks di dekat kata kotor
|
|
66
|
+
*/
|
|
67
|
+
analyzeWithContext(text: string, contextWindowSize?: number): {
|
|
48
68
|
word: string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
context: string;
|
|
70
|
+
position: {
|
|
71
|
+
start: number;
|
|
72
|
+
end: number;
|
|
73
|
+
};
|
|
74
|
+
}[];
|
|
75
|
+
/**
|
|
76
|
+
* Mengubah opsi filter
|
|
77
|
+
* @param options Opsi baru untuk filter
|
|
78
|
+
*/
|
|
79
|
+
setOptions(options: Partial<FilterOptions>): void;
|
|
80
|
+
/**
|
|
81
|
+
* Menggunakan preset yang telah ditentukan
|
|
82
|
+
* @param presetName Nama preset yang akan digunakan
|
|
83
|
+
* @param additionalOptions Opsi tambahan untuk override
|
|
84
|
+
*/
|
|
85
|
+
usePreset(presetName: string, additionalOptions?: Partial<FilterOptions>): void;
|
|
86
|
+
/**
|
|
87
|
+
* Menetapkan daftar kata kustom
|
|
88
|
+
* @param wordList Daftar kata untuk digunakan
|
|
89
|
+
*/
|
|
90
|
+
setWordList(wordList: string[]): void;
|
|
91
|
+
/**
|
|
92
|
+
* Menambahkan kata ke whitelist
|
|
93
|
+
* @param word Kata yang akan diabaikan
|
|
94
|
+
*/
|
|
95
|
+
addToWhitelist(word: string): void;
|
|
96
|
+
/**
|
|
97
|
+
* Menghapus kata dari whitelist
|
|
98
|
+
* @param word Kata yang akan dihapus dari whitelist
|
|
99
|
+
*/
|
|
100
|
+
removeFromWhitelist(word: string): void;
|
|
101
|
+
/**
|
|
102
|
+
* Mengaktifkan deteksi variasi ejaan Indonesia
|
|
103
|
+
*/
|
|
104
|
+
enableIndonesianVariations(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Mengaktifkan deteksi kata yang dipisah
|
|
107
|
+
*/
|
|
108
|
+
enableSplitWordDetection(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Mengaktifkan deteksi berdasarkan kesamaan
|
|
111
|
+
* @param threshold Threshold kesamaan (0-1)
|
|
112
|
+
* @param useLevenshtein Gunakan algoritma Levenshtein untuk deteksi
|
|
113
|
+
* @param maxLevenshteinDistance Jarak maksimal Levenshtein (default: 2)
|
|
114
|
+
*/
|
|
115
|
+
enableSimilarityDetection(threshold?: number, useLevenshtein?: boolean, maxLevenshteinDistance?: number): void;
|
|
116
|
+
/**
|
|
117
|
+
* Mengaktifkan deteksi berbasis Levenshtein distance
|
|
118
|
+
* @param threshold Threshold kesamaan (0-1)
|
|
119
|
+
* @param maxDistance Jarak maksimal Levenshtein (default: 2)
|
|
120
|
+
*/
|
|
121
|
+
enableLevenshteinDetection(threshold?: number, maxDistance?: number): void;
|
|
59
122
|
}
|
|
123
|
+
export declare const idFilter: {
|
|
124
|
+
filter: (text: string, options?: FilterOptions) => FilterResult;
|
|
125
|
+
isProfane: (text: string, options?: FilterOptions) => boolean;
|
|
126
|
+
analyze: (text: string, options?: FilterOptions) => AnalysisResult;
|
|
127
|
+
batchAnalyze: (texts: string[], options?: FilterOptions) => {
|
|
128
|
+
totalTexts: number;
|
|
129
|
+
profaneTexts: number;
|
|
130
|
+
cleanTexts: number;
|
|
131
|
+
averageSeverity: number;
|
|
132
|
+
topCategories: import("./types").ProfanityCategory[];
|
|
133
|
+
topRegions: import("./types").Region[];
|
|
134
|
+
mostFrequentWords: Array<{
|
|
135
|
+
word: string;
|
|
136
|
+
count: number;
|
|
137
|
+
}>;
|
|
138
|
+
};
|
|
139
|
+
getPresetOptions: typeof getPresetOptions;
|
|
140
|
+
presets: {
|
|
141
|
+
filter: {
|
|
142
|
+
strict: {
|
|
143
|
+
checkSubstring: boolean;
|
|
144
|
+
detectLeetSpeak: boolean;
|
|
145
|
+
severityThreshold: number;
|
|
146
|
+
replaceWith?: string;
|
|
147
|
+
fullWordCensor?: boolean;
|
|
148
|
+
wordList?: string[];
|
|
149
|
+
whitelist?: string[];
|
|
150
|
+
categories?: import("./types").ProfanityCategory[];
|
|
151
|
+
regions?: import("./types").Region[];
|
|
152
|
+
useRandomGrawlix?: boolean;
|
|
153
|
+
keepFirstAndLast?: boolean;
|
|
154
|
+
indonesianVariation?: boolean;
|
|
155
|
+
detectSimilarity?: boolean;
|
|
156
|
+
similarityThreshold?: number;
|
|
157
|
+
detectSplit?: boolean;
|
|
158
|
+
useLevenshtein?: boolean;
|
|
159
|
+
maxLevenshteinDistance?: number;
|
|
160
|
+
};
|
|
161
|
+
moderate: {
|
|
162
|
+
severityThreshold: number;
|
|
163
|
+
replaceWith?: string;
|
|
164
|
+
fullWordCensor?: boolean;
|
|
165
|
+
detectLeetSpeak?: boolean;
|
|
166
|
+
checkSubstring?: boolean;
|
|
167
|
+
wordList?: string[];
|
|
168
|
+
whitelist?: string[];
|
|
169
|
+
categories?: import("./types").ProfanityCategory[];
|
|
170
|
+
regions?: import("./types").Region[];
|
|
171
|
+
useRandomGrawlix?: boolean;
|
|
172
|
+
keepFirstAndLast?: boolean;
|
|
173
|
+
indonesianVariation?: boolean;
|
|
174
|
+
detectSimilarity?: boolean;
|
|
175
|
+
similarityThreshold?: number;
|
|
176
|
+
detectSplit?: boolean;
|
|
177
|
+
useLevenshtein?: boolean;
|
|
178
|
+
maxLevenshteinDistance?: number;
|
|
179
|
+
};
|
|
180
|
+
light: {
|
|
181
|
+
severityThreshold: number;
|
|
182
|
+
categories: import("./types").ProfanityCategory[];
|
|
183
|
+
replaceWith?: string;
|
|
184
|
+
fullWordCensor?: boolean;
|
|
185
|
+
detectLeetSpeak?: boolean;
|
|
186
|
+
checkSubstring?: boolean;
|
|
187
|
+
wordList?: string[];
|
|
188
|
+
whitelist?: string[];
|
|
189
|
+
regions?: import("./types").Region[];
|
|
190
|
+
useRandomGrawlix?: boolean;
|
|
191
|
+
keepFirstAndLast?: boolean;
|
|
192
|
+
indonesianVariation?: boolean;
|
|
193
|
+
detectSimilarity?: boolean;
|
|
194
|
+
similarityThreshold?: number;
|
|
195
|
+
detectSplit?: boolean;
|
|
196
|
+
useLevenshtein?: boolean;
|
|
197
|
+
maxLevenshteinDistance?: number;
|
|
198
|
+
};
|
|
199
|
+
childSafe: {
|
|
200
|
+
checkSubstring: boolean;
|
|
201
|
+
detectLeetSpeak: boolean;
|
|
202
|
+
fullWordCensor: boolean;
|
|
203
|
+
severityThreshold: number;
|
|
204
|
+
replaceWith?: string;
|
|
205
|
+
wordList?: string[];
|
|
206
|
+
whitelist?: string[];
|
|
207
|
+
categories?: import("./types").ProfanityCategory[];
|
|
208
|
+
regions?: import("./types").Region[];
|
|
209
|
+
useRandomGrawlix?: boolean;
|
|
210
|
+
keepFirstAndLast?: boolean;
|
|
211
|
+
indonesianVariation?: boolean;
|
|
212
|
+
detectSimilarity?: boolean;
|
|
213
|
+
similarityThreshold?: number;
|
|
214
|
+
detectSplit?: boolean;
|
|
215
|
+
useLevenshtein?: boolean;
|
|
216
|
+
maxLevenshteinDistance?: number;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
category: {
|
|
220
|
+
sexual: {
|
|
221
|
+
categories: import("./types").ProfanityCategory[];
|
|
222
|
+
replaceWith?: string;
|
|
223
|
+
fullWordCensor?: boolean;
|
|
224
|
+
detectLeetSpeak?: boolean;
|
|
225
|
+
checkSubstring?: boolean;
|
|
226
|
+
wordList?: string[];
|
|
227
|
+
whitelist?: string[];
|
|
228
|
+
regions?: import("./types").Region[];
|
|
229
|
+
severityThreshold?: number;
|
|
230
|
+
useRandomGrawlix?: boolean;
|
|
231
|
+
keepFirstAndLast?: boolean;
|
|
232
|
+
indonesianVariation?: boolean;
|
|
233
|
+
detectSimilarity?: boolean;
|
|
234
|
+
similarityThreshold?: number;
|
|
235
|
+
detectSplit?: boolean;
|
|
236
|
+
useLevenshtein?: boolean;
|
|
237
|
+
maxLevenshteinDistance?: number;
|
|
238
|
+
};
|
|
239
|
+
insults: {
|
|
240
|
+
categories: import("./types").ProfanityCategory[];
|
|
241
|
+
replaceWith?: string;
|
|
242
|
+
fullWordCensor?: boolean;
|
|
243
|
+
detectLeetSpeak?: boolean;
|
|
244
|
+
checkSubstring?: boolean;
|
|
245
|
+
wordList?: string[];
|
|
246
|
+
whitelist?: string[];
|
|
247
|
+
regions?: import("./types").Region[];
|
|
248
|
+
severityThreshold?: number;
|
|
249
|
+
useRandomGrawlix?: boolean;
|
|
250
|
+
keepFirstAndLast?: boolean;
|
|
251
|
+
indonesianVariation?: boolean;
|
|
252
|
+
detectSimilarity?: boolean;
|
|
253
|
+
similarityThreshold?: number;
|
|
254
|
+
detectSplit?: boolean;
|
|
255
|
+
useLevenshtein?: boolean;
|
|
256
|
+
maxLevenshteinDistance?: number;
|
|
257
|
+
};
|
|
258
|
+
profanity: {
|
|
259
|
+
categories: import("./types").ProfanityCategory[];
|
|
260
|
+
replaceWith?: string;
|
|
261
|
+
fullWordCensor?: boolean;
|
|
262
|
+
detectLeetSpeak?: boolean;
|
|
263
|
+
checkSubstring?: boolean;
|
|
264
|
+
wordList?: string[];
|
|
265
|
+
whitelist?: string[];
|
|
266
|
+
regions?: import("./types").Region[];
|
|
267
|
+
severityThreshold?: number;
|
|
268
|
+
useRandomGrawlix?: boolean;
|
|
269
|
+
keepFirstAndLast?: boolean;
|
|
270
|
+
indonesianVariation?: boolean;
|
|
271
|
+
detectSimilarity?: boolean;
|
|
272
|
+
similarityThreshold?: number;
|
|
273
|
+
detectSplit?: boolean;
|
|
274
|
+
useLevenshtein?: boolean;
|
|
275
|
+
maxLevenshteinDistance?: number;
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
region: {
|
|
279
|
+
general: {
|
|
280
|
+
regions: import("./types").Region[];
|
|
281
|
+
replaceWith?: string;
|
|
282
|
+
fullWordCensor?: boolean;
|
|
283
|
+
detectLeetSpeak?: boolean;
|
|
284
|
+
checkSubstring?: boolean;
|
|
285
|
+
wordList?: string[];
|
|
286
|
+
whitelist?: string[];
|
|
287
|
+
categories?: import("./types").ProfanityCategory[];
|
|
288
|
+
severityThreshold?: number;
|
|
289
|
+
useRandomGrawlix?: boolean;
|
|
290
|
+
keepFirstAndLast?: boolean;
|
|
291
|
+
indonesianVariation?: boolean;
|
|
292
|
+
detectSimilarity?: boolean;
|
|
293
|
+
similarityThreshold?: number;
|
|
294
|
+
detectSplit?: boolean;
|
|
295
|
+
useLevenshtein?: boolean;
|
|
296
|
+
maxLevenshteinDistance?: number;
|
|
297
|
+
};
|
|
298
|
+
jawa: {
|
|
299
|
+
regions: import("./types").Region[];
|
|
300
|
+
replaceWith?: string;
|
|
301
|
+
fullWordCensor?: boolean;
|
|
302
|
+
detectLeetSpeak?: boolean;
|
|
303
|
+
checkSubstring?: boolean;
|
|
304
|
+
wordList?: string[];
|
|
305
|
+
whitelist?: string[];
|
|
306
|
+
categories?: import("./types").ProfanityCategory[];
|
|
307
|
+
severityThreshold?: number;
|
|
308
|
+
useRandomGrawlix?: boolean;
|
|
309
|
+
keepFirstAndLast?: boolean;
|
|
310
|
+
indonesianVariation?: boolean;
|
|
311
|
+
detectSimilarity?: boolean;
|
|
312
|
+
similarityThreshold?: number;
|
|
313
|
+
detectSplit?: boolean;
|
|
314
|
+
useLevenshtein?: boolean;
|
|
315
|
+
maxLevenshteinDistance?: number;
|
|
316
|
+
};
|
|
317
|
+
sunda: {
|
|
318
|
+
regions: import("./types").Region[];
|
|
319
|
+
replaceWith?: string;
|
|
320
|
+
fullWordCensor?: boolean;
|
|
321
|
+
detectLeetSpeak?: boolean;
|
|
322
|
+
checkSubstring?: boolean;
|
|
323
|
+
wordList?: string[];
|
|
324
|
+
whitelist?: string[];
|
|
325
|
+
categories?: import("./types").ProfanityCategory[];
|
|
326
|
+
severityThreshold?: number;
|
|
327
|
+
useRandomGrawlix?: boolean;
|
|
328
|
+
keepFirstAndLast?: boolean;
|
|
329
|
+
indonesianVariation?: boolean;
|
|
330
|
+
detectSimilarity?: boolean;
|
|
331
|
+
similarityThreshold?: number;
|
|
332
|
+
detectSplit?: boolean;
|
|
333
|
+
useLevenshtein?: boolean;
|
|
334
|
+
maxLevenshteinDistance?: number;
|
|
335
|
+
};
|
|
336
|
+
betawi: {
|
|
337
|
+
regions: import("./types").Region[];
|
|
338
|
+
replaceWith?: string;
|
|
339
|
+
fullWordCensor?: boolean;
|
|
340
|
+
detectLeetSpeak?: boolean;
|
|
341
|
+
checkSubstring?: boolean;
|
|
342
|
+
wordList?: string[];
|
|
343
|
+
whitelist?: string[];
|
|
344
|
+
categories?: import("./types").ProfanityCategory[];
|
|
345
|
+
severityThreshold?: number;
|
|
346
|
+
useRandomGrawlix?: boolean;
|
|
347
|
+
keepFirstAndLast?: boolean;
|
|
348
|
+
indonesianVariation?: boolean;
|
|
349
|
+
detectSimilarity?: boolean;
|
|
350
|
+
similarityThreshold?: number;
|
|
351
|
+
detectSplit?: boolean;
|
|
352
|
+
useLevenshtein?: boolean;
|
|
353
|
+
maxLevenshteinDistance?: number;
|
|
354
|
+
};
|
|
355
|
+
batak: {
|
|
356
|
+
regions: import("./types").Region[];
|
|
357
|
+
replaceWith?: string;
|
|
358
|
+
fullWordCensor?: boolean;
|
|
359
|
+
detectLeetSpeak?: boolean;
|
|
360
|
+
checkSubstring?: boolean;
|
|
361
|
+
wordList?: string[];
|
|
362
|
+
whitelist?: string[];
|
|
363
|
+
categories?: import("./types").ProfanityCategory[];
|
|
364
|
+
severityThreshold?: number;
|
|
365
|
+
useRandomGrawlix?: boolean;
|
|
366
|
+
keepFirstAndLast?: boolean;
|
|
367
|
+
indonesianVariation?: boolean;
|
|
368
|
+
detectSimilarity?: boolean;
|
|
369
|
+
similarityThreshold?: number;
|
|
370
|
+
detectSplit?: boolean;
|
|
371
|
+
useLevenshtein?: boolean;
|
|
372
|
+
maxLevenshteinDistance?: number;
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
export default IDProfanityFilter;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type ProfanityCategory = "sexual" | "insult" | "profanity" | "slur" | "drugs" | "disgusting" | "blasphemy";
|
|
2
|
+
export type Region = "general" | "jawa" | "sunda" | "betawi" | "batak" | "minang" | "bali" | "madura" | "bugis" | "aceh" | "ambon" | "papua" | "manado" | "banjar" | "palembang" | "lampung" | "ntt" | "ntb";
|
|
3
|
+
export interface ProfanityWord {
|
|
4
|
+
word: string;
|
|
5
|
+
category: ProfanityCategory;
|
|
6
|
+
region: Region;
|
|
7
|
+
severity: number;
|
|
8
|
+
aliases?: string[];
|
|
9
|
+
description?: string;
|
|
10
|
+
context?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface FilterOptions {
|
|
13
|
+
replaceWith?: string;
|
|
14
|
+
fullWordCensor?: boolean;
|
|
15
|
+
detectLeetSpeak?: boolean;
|
|
16
|
+
checkSubstring?: boolean;
|
|
17
|
+
wordList?: string[];
|
|
18
|
+
whitelist?: string[];
|
|
19
|
+
categories?: ProfanityCategory[];
|
|
20
|
+
regions?: Region[];
|
|
21
|
+
severityThreshold?: number;
|
|
22
|
+
useRandomGrawlix?: boolean;
|
|
23
|
+
keepFirstAndLast?: boolean;
|
|
24
|
+
indonesianVariation?: boolean;
|
|
25
|
+
detectSimilarity?: boolean;
|
|
26
|
+
similarityThreshold?: number;
|
|
27
|
+
detectSplit?: boolean;
|
|
28
|
+
useLevenshtein?: boolean;
|
|
29
|
+
maxLevenshteinDistance?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface FilterResult {
|
|
32
|
+
filtered: string;
|
|
33
|
+
censored: number;
|
|
34
|
+
replacements: Array<{
|
|
35
|
+
original: string;
|
|
36
|
+
censored: string;
|
|
37
|
+
metadata?: ProfanityWord;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export interface AnalysisResult {
|
|
41
|
+
hasProfanity: boolean;
|
|
42
|
+
matches: string[];
|
|
43
|
+
matchDetails: ProfanityWord[];
|
|
44
|
+
categories: ProfanityCategory[];
|
|
45
|
+
regions: Region[];
|
|
46
|
+
severityScore: number;
|
|
47
|
+
similarWords?: Array<{
|
|
48
|
+
word: string;
|
|
49
|
+
original: string;
|
|
50
|
+
similarity: number;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
export interface RegexOptions {
|
|
54
|
+
wholeWord?: boolean;
|
|
55
|
+
caseSensitive?: boolean;
|
|
56
|
+
leetSpeak?: boolean;
|
|
57
|
+
detectSplit?: boolean;
|
|
58
|
+
indonesianVariation?: boolean;
|
|
59
|
+
}
|
package/eslint.config.mjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
2
|
-
import tsParser from '@typescript-eslint/parser';
|
|
3
|
-
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
4
|
-
|
|
5
|
-
export default [
|
|
6
|
-
{
|
|
7
|
-
ignores: ['dist/', 'node_modules/', '*.js', '*.mjs', '*.d.ts'],
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
languageOptions: {
|
|
11
|
-
parser: tsParser,
|
|
12
|
-
parserOptions: {
|
|
13
|
-
ecmaVersion: 2020,
|
|
14
|
-
sourceType: 'module',
|
|
15
|
-
project: './tsconfig.json',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
plugins: {
|
|
19
|
-
'@typescript-eslint': tseslint,
|
|
20
|
-
},
|
|
21
|
-
rules: {
|
|
22
|
-
// Enforce consistent code style
|
|
23
|
-
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
24
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
25
|
-
'@typescript-eslint/no-unused-vars': [
|
|
26
|
-
'warn',
|
|
27
|
-
{ argsIgnorePattern: '^_' },
|
|
28
|
-
],
|
|
29
|
-
|
|
30
|
-
// Allow certain TypeScript patterns
|
|
31
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
32
|
-
|
|
33
|
-
// General ESLint rules
|
|
34
|
-
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
35
|
-
'prefer-const': 'warn',
|
|
36
|
-
'no-var': 'error',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
eslintConfigPrettier,
|
|
40
|
-
];
|
|
1
|
+
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
2
|
+
import tsParser from '@typescript-eslint/parser';
|
|
3
|
+
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
{
|
|
7
|
+
ignores: ['dist/', 'node_modules/', '*.js', '*.mjs', '*.d.ts'],
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parser: tsParser,
|
|
12
|
+
parserOptions: {
|
|
13
|
+
ecmaVersion: 2020,
|
|
14
|
+
sourceType: 'module',
|
|
15
|
+
project: './tsconfig.json',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
plugins: {
|
|
19
|
+
'@typescript-eslint': tseslint,
|
|
20
|
+
},
|
|
21
|
+
rules: {
|
|
22
|
+
// Enforce consistent code style
|
|
23
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
24
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
25
|
+
'@typescript-eslint/no-unused-vars': [
|
|
26
|
+
'warn',
|
|
27
|
+
{ argsIgnorePattern: '^_' },
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
// Allow certain TypeScript patterns
|
|
31
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
32
|
+
|
|
33
|
+
// General ESLint rules
|
|
34
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
35
|
+
'prefer-const': 'warn',
|
|
36
|
+
'no-var': 'error',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
eslintConfigPrettier,
|
|
40
|
+
];
|