allprofanity 2.0.0 → 2.1.0

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 CHANGED
@@ -1,29 +1,28 @@
1
1
  # AllProfanity
2
2
 
3
- A comprehensive, zero-dependency, multi-language profanity filter for JavaScript/TypeScript applications with built-in support for English, Hindi, Hinglish, Bengali, Tamil, Telugu, French, German, and Spanish content.
3
+ A blazing-fast, multi-language, enterprise-grade profanity filter for JavaScript/TypeScript with advanced leet-speak normalization, Unicode support, and a robust, modern API.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/allprofanity.svg)](https://www.npmjs.com/package/allprofanity)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
+ ---
9
+
8
10
  ## Features
9
11
 
10
- - **Multi-language Support**: Built-in dictionaries for English, Hindi/Hinglish, Bengali, Tamil, Telugu, French, German, and Spanish.
11
- - **Multiple Scripts**: Detects profanity in both Latin/Roman and native scripts (Devanagari, Bengali, Tamil, Telugu).
12
- - **Case Insensitive (configurable)**: By default, not case sensitive, but can be configured to be case sensitive.
13
- - **Leet Speak Detection**: Optionally detects leet speak and obfuscated profanities.
14
- - **Flexible Cleaning Options**:
15
- - Character-level replacement (each character of a profane word becomes a placeholder).
16
- - Word-level replacement (entire profane word becomes a single placeholder).
17
- - **Customizable & Extensible**:
18
- - Dynamically add/remove words or whole dictionaries.
19
- - Set custom placeholder characters or strings.
20
- - Supports custom language packs.
21
- - Whitelist words to avoid false positives.
22
- - Strict mode and partial word detection options.
23
- - **Severity Levels**: Detects severity of profanities (MILD, MODERATE, SEVERE, EXTREME).
24
- - **Zero External Dependencies**: Fully built from scratch for maximum performance and control.
25
- - **TypeScript Support**: Full TypeScript type definitions included.
26
- - **Exportable Dictionaries**: Language word lists are exportable for direct use or extension.
12
+ - **Ultra-Fast O(n) Detection:** TRIE-based, single-pass algorithm for massive performance gains over regex/set-based filters.
13
+ - **Multi-Language Support:** Built-in dictionaries for English, Hindi, French, German, Spanish, Bengali, Tamil, Telugu. Load multiple at once.
14
+ - **Multiple Scripts:** Detects profanity in Latin/Roman (Hinglish) and native scripts (e.g., Devanagari, Tamil, Telugu).
15
+ - **Advanced Leet-Speak Normalization:** Detects obfuscated profanities (`f#ck`, `a55hole`, etc.) with context-aware mapping.
16
+ - **Unicode & Punctuation Robustness:** Handles word boundaries and mixed language content with near-zero false positives.
17
+ - **Flexible Cleaning:** Replace matches character-by-character or as whole words, with configurable placeholders.
18
+ - **Custom Dictionaries:** Add/remove words or entire lists at runtime, including your own language packs.
19
+ - **Whitelisting:** Exclude safe words or false positives from detection.
20
+ - **Severity Levels:** Assess how offensive a string is (`MILD`, `MODERATE`, `SEVERE`, `EXTREME`).
21
+ - **No Dictionary Exposure:** For security, the full list of loaded profanities is never exposed.
22
+ - **TypeScript Support:** Typed, documented API and result objects.
23
+ - **Zero 3rd-Party Dependencies:** Only internal code and data.
24
+
25
+ ---
27
26
 
28
27
  ## Installation
29
28
 
@@ -31,366 +30,373 @@ A comprehensive, zero-dependency, multi-language profanity filter for JavaScript
31
30
  npm install allprofanity
32
31
  # or
33
32
  yarn add allprofanity
34
- # or
35
- pnpm add allprofanity
36
33
  ```
37
34
 
38
- ## Basic Usage
35
+ ---
39
36
 
40
- ```javascript
41
- import profanity from 'allprofanity';
42
-
43
- // Check if a string contains profanity
44
- profanity.check('This is a clean sentence.'); // false
45
- profanity.check('This is a fucking test.'); // true
46
- profanity.check('यह एक चूतिया परीक्षण है।'); // true (Hindi example)
47
- profanity.check('Ye ek chutiya test hai.'); // true (Hinglish example)
37
+ ## Quick Start
48
38
 
49
- // Clean profanity (character by character replacement)
50
- profanity.clean('This is a fucking test.');
51
- // => "This is a ****ing test."
39
+ ```typescript
40
+ import profanity from 'allprofanity';
52
41
 
53
- // Clean profanity (whole word replacement)
54
- profanity.cleanWithWord('This is a fucking test.');
55
- // => "This is a *** test."
42
+ // Simple check
43
+ profanity.check('This is a clean sentence.'); // false
44
+ profanity.check('What the f#ck is this?'); // true (leet-speak detected)
45
+ profanity.check('यह एक चूतिया परीक्षण है।'); // true (Hindi)
46
+ profanity.check('Ye ek chutiya test hai.'); // true (Hinglish Roman script)
56
47
  ```
57
48
 
58
- ## API Reference
59
-
60
- ### `check(string: string): boolean`
49
+ ---
61
50
 
62
- Checks if a string contains any profanity from the loaded dictionaries.
63
-
64
- ```javascript
65
- profanity.check('This contains bullshit.'); // true
66
- profanity.check('This is clean.'); // false
67
- ```
51
+ ## API Reference & Examples
68
52
 
69
- ### `detect(string: string): ProfanityDetectionResult`
53
+ ### `check(text: string): boolean`
70
54
 
71
- Advanced detection with details about profanities found, severity, cleaned text, and word positions.
55
+ Returns `true` if the text contains any profanity.
72
56
 
73
- ```javascript
74
- const result = profanity.detect('This contains bullshit.');
75
- // result: {
76
- // hasProfanity: true,
77
- // detectedWords: [...],
78
- // cleanedText: ...,
79
- // severity: ...,
80
- // positions: [...]
81
- // }
57
+ ```typescript
58
+ profanity.check('This is a clean sentence.'); // false
59
+ profanity.check('This is a bullshit sentence.'); // true
60
+ profanity.check('What the f#ck is this?'); // true (leet-speak)
61
+ profanity.check('यह एक चूतिया परीक्षण है।'); // true (Hindi)
82
62
  ```
83
63
 
84
- ### `clean(string: string, placeholder?: string): string`
64
+ ---
65
+
66
+ ### `detect(text: string): ProfanityDetectionResult`
85
67
 
86
- Cleans a string by replacing each character of profane words with a placeholder character.
68
+ Returns a detailed result:
87
69
 
88
- ```javascript
89
- // Default placeholder is "*"
90
- profanity.clean('This contains bullshit.');
91
- // => "This contains ********."
70
+ - `hasProfanity: boolean`
71
+ - `detectedWords: string[]` (actual matched words)
72
+ - `cleanedText: string` (character-masked)
73
+ - `severity: ProfanitySeverity` (`MILD`, `MODERATE`, `SEVERE`, `EXTREME`)
74
+ - `positions: Array<{ word: string, start: number, end: number }>`
92
75
 
93
- // Custom placeholder character
94
- profanity.clean('This contains bullshit.', '#');
95
- // => "This contains ########."
76
+ ```typescript
77
+ const result = profanity.detect('This is fucking bullshit and chutiya.');
78
+ console.log(result.hasProfanity); // true
79
+ console.log(result.detectedWords); // ['fucking', 'bullshit', 'chutiya']
80
+ console.log(result.severity); // 3 (SEVERE)
81
+ console.log(result.cleanedText); // "This is ******* ******** and ******."
82
+ console.log(result.positions); // e.g. [{word: 'fucking', start: 8, end: 15}, ...]
96
83
  ```
97
84
 
98
- ### `cleanWithWord(string: string, placeholder?: string): string`
85
+ ---
99
86
 
100
- Cleans a string by replacing entire profane words with a single placeholder string.
87
+ ### `clean(text: string, placeholder?: string): string`
101
88
 
102
- ```javascript
103
- // Default placeholder is "***"
104
- profanity.cleanWithWord('This contains bullshit.');
105
- // => "This contains ***."
89
+ Replace each character of profane words with a placeholder (default: `*`).
106
90
 
107
- // Custom placeholder string
108
- profanity.cleanWithWord('This contains bullshit.', '[CENSORED]');
109
- // => "This contains [CENSORED]."
91
+ ```typescript
92
+ profanity.clean('This contains bullshit.'); // "This contains ********."
93
+ profanity.clean('This contains bullshit.', '#'); // "This contains ########."
94
+ profanity.clean('यह एक चूतिया परीक्षण है।'); // e.g. "यह एक ***** परीक्षण है।"
110
95
  ```
111
96
 
112
- ### `list(): string[]`
97
+ ---
113
98
 
114
- Returns an array of all the profanity words currently in the filter.
99
+ ### `cleanWithPlaceholder(text: string, placeholder?: string): string`
115
100
 
116
- ```javascript
117
- const words = profanity.list();
118
- console.log(words); // ["fuck", "bullshit", "chutiya", ...]
101
+ Replace each profane word with a single placeholder (default: `***`).
102
+ (If the placeholder is omitted, uses `***`.)
103
+
104
+ ```typescript
105
+ profanity.cleanWithPlaceholder('This contains bullshit.'); // "This contains ***."
106
+ profanity.cleanWithPlaceholder('This contains bullshit.', '[CENSORED]'); // "This contains [CENSORED]."
107
+ profanity.cleanWithPlaceholder('यह एक चूतिया परीक्षण है।', '####'); // e.g. "यह एक #### परीक्षण है।"
119
108
  ```
120
109
 
110
+ ---
111
+
121
112
  ### `add(word: string | string[]): void`
122
113
 
123
- Adds one or more words to the profanity filter.
114
+ Add a word or an array of words to the profanity filter.
124
115
 
125
- ```javascript
126
- // Add a single word
127
- profanity.add('badword');
116
+ ```typescript
117
+ profanity.add('badword123');
118
+ profanity.check('This is badword123.'); // true
128
119
 
129
- // Add multiple words
130
- profanity.add(['badword1', 'badword2', 'बुराशब्द']);
120
+ profanity.add(['mierda', 'puta']);
121
+ profanity.check('Esto es mierda.'); // true (Spanish)
122
+ profanity.check('Qué puta situación.'); // true
131
123
  ```
132
124
 
125
+ ---
126
+
133
127
  ### `remove(word: string | string[]): void`
134
128
 
135
- Removes one or more words from the profanity filter.
129
+ Remove a word or an array of words from the profanity filter.
136
130
 
137
- ```javascript
138
- // Remove a single word
131
+ ```typescript
139
132
  profanity.remove('bullshit');
133
+ profanity.check('This is bullshit.'); // false
140
134
 
141
- // Remove multiple words
142
- profanity.remove(['fuck', 'chutiya']);
135
+ profanity.remove(['mierda', 'puta']);
136
+ profanity.check('Esto es mierda.'); // false
143
137
  ```
144
138
 
145
- ### `clearList(): void`
139
+ ---
146
140
 
147
- Removes all words from the profanity filter, resetting it to an empty list.
141
+ ### `addToWhitelist(words: string[]): void`
148
142
 
149
- ```javascript
150
- profanity.clearList();
143
+ Whitelist words so they are never flagged as profane.
144
+
145
+ ```typescript
146
+ profanity.addToWhitelist(['anal', 'ass']);
147
+ profanity.check('He is an associate professor.'); // false
148
+ profanity.check('I work as an analyst.'); // false
149
+ // Remove from whitelist to restore detection
150
+ profanity.removeFromWhitelist(['anal', 'ass']);
151
151
  ```
152
152
 
153
- ### `setPlaceholder(placeholder: string): void`
153
+ ---
154
154
 
155
- Sets the default placeholder character for the `clean` method.
155
+ ### `removeFromWhitelist(words: string[]): void`
156
156
 
157
- ```javascript
158
- // Set "#" as the default placeholder character
159
- profanity.setPlaceholder('#');
157
+ Remove words from the whitelist so they can be detected again.
158
+
159
+ ```typescript
160
+ profanity.removeFromWhitelist(['anal']);
160
161
  ```
161
162
 
162
- ### `getLoadedLanguages(): string[]`
163
+ ---
164
+
165
+ ### `setPlaceholder(placeholder: string): void`
163
166
 
164
- Returns the list of currently loaded languages.
167
+ Set the default placeholder character for `clean()`.
165
168
 
166
- ```javascript
167
- const loaded = profanity.getLoadedLanguages();
168
- // => ['english', 'hindi', ...]
169
+ ```typescript
170
+ profanity.setPlaceholder('#');
171
+ profanity.clean('This is bullshit.'); // "This is ########."
172
+ profanity.setPlaceholder('*'); // Reset to default
169
173
  ```
170
174
 
171
- ### `getAvailableLanguages(): string[]`
175
+ ---
176
+
177
+ ### `updateConfig(options: Partial<AllProfanityOptions>): void`
172
178
 
173
- Returns the list of all available built-in languages.
179
+ Change configuration at runtime.
180
+ Options include: `enableLeetSpeak`, `caseSensitive`, `strictMode`, `detectPartialWords`, `defaultPlaceholder`, `languages`, `whitelistWords`.
174
181
 
175
- ```javascript
176
- const available = profanity.getAvailableLanguages();
177
- // => ['english', 'hindi', 'bengali', 'tamil', 'telugu', 'french', 'german', 'spanish']
182
+ ```typescript
183
+ profanity.updateConfig({ caseSensitive: true, enableLeetSpeak: false });
184
+ profanity.check('FUCK'); // false (if caseSensitive)
185
+ profanity.updateConfig({ caseSensitive: false, enableLeetSpeak: true });
186
+ profanity.check('f#ck'); // true
178
187
  ```
179
188
 
189
+ ---
190
+
180
191
  ### `loadLanguage(language: string): boolean`
181
192
 
182
- Loads a built-in language dictionary by name.
193
+ Load a built-in language.
183
194
 
184
- ```javascript
185
- profanity.loadLanguage('bengali');
195
+ ```typescript
186
196
  profanity.loadLanguage('french');
197
+ profanity.check('Ce mot est merde.'); // true
187
198
  ```
188
199
 
200
+ ---
201
+
189
202
  ### `loadLanguages(languages: string[]): number`
190
203
 
191
- Loads multiple languages at once.
204
+ Load multiple built-in languages at once.
192
205
 
193
- ```javascript
194
- profanity.loadLanguages(['tamil', 'german', 'spanish']);
206
+ ```typescript
207
+ profanity.loadLanguages(['english', 'french', 'german']);
208
+ profanity.check('Das ist scheiße.'); // true (German)
195
209
  ```
196
210
 
211
+ ---
212
+
197
213
  ### `loadIndianLanguages(): number`
198
214
 
199
- Loads Hindi, Bengali, Tamil, and Telugu dictionaries.
215
+ Convenience: Load all major Indian language packs.
200
216
 
201
- ```javascript
217
+ ```typescript
202
218
  profanity.loadIndianLanguages();
219
+ profanity.check('यह एक बेंगाली गाली है।'); // true (Bengali)
220
+ profanity.check('This is a Tamil profanity: புண்டை'); // true
203
221
  ```
204
222
 
223
+ ---
224
+
205
225
  ### `loadCustomDictionary(name: string, words: string[]): void`
206
226
 
207
- Loads a custom dictionary under the given name.
227
+ Add your own dictionary as an additional language.
208
228
 
209
- ```javascript
210
- profanity.loadCustomDictionary('myLanguage', ['word1', 'word2']);
211
- profanity.loadLanguage('myLanguage');
229
+ ```typescript
230
+ profanity.loadCustomDictionary('swedish', ['fan', 'jävla', 'skit']);
231
+ profanity.loadLanguage('swedish');
232
+ profanity.check('Det här är skit.'); // true
212
233
  ```
213
234
 
214
- ### `addToWhitelist(words: string[]): void` / `removeFromWhitelist(words: string[]): void`
235
+ ---
215
236
 
216
- Add or remove words from the whitelist (words never flagged as profanity).
237
+ ### `getLoadedLanguages(): string[]`
217
238
 
218
- ```javascript
219
- profanity.addToWhitelist(['anal', 'ass']);
220
- profanity.removeFromWhitelist(['anal']);
221
- ```
239
+ Returns the names of all currently loaded language packs.
222
240
 
223
- ### `getConfig(): AllProfanityOptions`
241
+ ```typescript
242
+ console.log(profanity.getLoadedLanguages()); // ['english', 'hindi', ...]
243
+ ```
224
244
 
225
- Get current configuration.
245
+ ---
226
246
 
227
- ### `updateConfig(options: Partial<AllProfanityOptions>): void`
247
+ ### `getAvailableLanguages(): string[]`
228
248
 
229
- Update configuration (enable/disable leet speak, case sensitivity, etc.).
249
+ Returns the names of all available built-in language packs.
230
250
 
231
- ## Word Boundary Detection
251
+ ```typescript
252
+ console.log(profanity.getAvailableLanguages());
253
+ // ['english', 'hindi', 'french', 'german', 'spanish', 'bengali', 'tamil', 'telugu']
254
+ ```
232
255
 
233
- The library handles word boundaries and reduces false positives:
256
+ ---
234
257
 
235
- ```javascript
236
- profanity.check('He is an associate professor.'); // false, even though 'ass' is a profane word
237
- profanity.check('I\'m an analyst at this company.'); // false, even though 'anal' is a profane word
238
- profanity.check('This is ass and that\'s bad.'); // true
239
- ```
258
+ ### `clearList(): void`
240
259
 
241
- ## Language Support
260
+ Remove all loaded languages and dynamic words (start with a clean filter).
242
261
 
243
- ### Current Languages
262
+ ```typescript
263
+ profanity.clearList();
264
+ profanity.check('fuck'); // false
265
+ profanity.loadLanguage('english');
266
+ profanity.check('fuck'); // true
267
+ ```
244
268
 
245
- - **English** (imported from `./languages/english-words.js`)
246
- - **Hindi/Hinglish** (`./languages/hindi-words.js`)
247
- - **Bengali** (`./languages/bengali-words.js`)
248
- - **Tamil** (`./languages/tamil-words.js`)
249
- - **Telugu** (`./languages/telugu-words.js`)
250
- - **French** (`./languages/french-words.js`)
251
- - **German** (`./languages/german-words.js`)
252
- - **Spanish** (`./languages/spanish-words.js`)
269
+ ---
253
270
 
254
- > **Note:** All dictionaries are exported for direct access/import.
271
+ ### `getConfig(): Partial<AllProfanityOptions>`
255
272
 
256
- #### Usage Examples
273
+ Get the current configuration.
257
274
 
258
- ```javascript
259
- profanity.check('इस वाक्य में लंड शब्द है।'); // true (Hindi)
260
- profanity.check('Is vakya mein lund shabd hai.'); // true (Hinglish)
261
- profanity.check('এই বাক্যে বাল শব্দ আছে।'); // true (Bengali)
262
- profanity.check('இந்த வாக்கியத்தில் கூதி உள்ளது.'); // true (Tamil)
263
- profanity.check('Cette phrase contient le mot merde.'); // true (French)
275
+ ```typescript
276
+ console.log(profanity.getConfig());
277
+ /*
278
+ {
279
+ defaultPlaceholder: '*',
280
+ enableLeetSpeak: true,
281
+ caseSensitive: false,
282
+ strictMode: false,
283
+ detectPartialWords: false,
284
+ languages: [...],
285
+ whitelistWords: [...]
286
+ }
287
+ */
264
288
  ```
265
289
 
266
- ### Mixed Language Content
290
+ ---
267
291
 
268
- AllProfanity can detect profanities from multiple languages in a single string:
292
+ ## Severity Levels
269
293
 
270
- ```javascript
271
- profanity.check('This English sentence has chutiya which is bad.'); // true
272
- profanity.check('I\'m saying मादरचोद and bullshit in one sentence.'); // true
273
- ```
294
+ Severity reflects the number and variety of detected profanities:
274
295
 
275
- ### Loading Additional or Custom Languages
296
+ | Level | Enum Value | Description |
297
+ |-----------|------------|-----------------------------------------|
298
+ | MILD | 1 | 1 unique/total word |
299
+ | MODERATE | 2 | 2 unique or total words |
300
+ | SEVERE | 3 | 3 unique/total words |
301
+ | EXTREME | 4 | 4+ unique or 5+ total profane words |
276
302
 
277
- By default, only English and Hindi are loaded. You can load additional languages as needed:
303
+ ---
278
304
 
279
- ```javascript
280
- profanity.loadLanguage('bengali');
281
- profanity.loadLanguages(['tamil', 'french']);
282
- ```
305
+ ## Language Support
283
306
 
284
- You can also load custom dictionaries:
307
+ - **Built-in:** English, Hindi, French, German, Spanish, Bengali, Tamil, Telugu
308
+ - **Scripts:** Latin/Roman, Devanagari, Tamil, Telugu, Bengali, etc.
309
+ - **Mixed Content:** Handles mixed-language and code-switched sentences.
285
310
 
286
- ```javascript
287
- profanity.loadCustomDictionary('swedish', ['fulord1', 'fulord2']);
288
- profanity.loadLanguage('swedish');
311
+ ```typescript
312
+ profanity.check('This is bullshit and चूतिया.'); // true (mixed English/Hindi)
313
+ profanity.check('Ce mot est merde and पागल.'); // true (French/Hindi)
289
314
  ```
290
315
 
291
- ## Customizing The Library
316
+ ---
292
317
 
293
- ### Adding Custom Profanity Lists
318
+ ## Use Exported Wordlists
294
319
 
295
- You can add your own profanity words to extend support for other languages or add additional words to existing languages:
320
+ For sample words in a language (for UIs, admin, etc):
296
321
 
297
- ```javascript
298
- // Add custom profanity words
299
- profanity.add([
300
- 'customword1',
301
- 'customword2',
302
- 'customword3'
303
- ]);
322
+ ```typescript
323
+ import { englishBadWords, hindiBadWords } from 'allprofanity';
324
+ console.log(englishBadWords.slice(0, 5)); // ["fuck", "shit", ...]
304
325
  ```
305
326
 
306
- ## Creating a Custom-Configured Instance
307
-
308
- If you need multiple differently-configured filters, import the `AllProfanity` class directly:
327
+ ---
309
328
 
310
- ```javascript
311
- import { AllProfanity } from 'allprofanity';
329
+ ## Security
312
330
 
313
- const kidSafeFilter = new AllProfanity({ enableLeetSpeak: true, strictMode: true });
314
- const adultFilter = new AllProfanity({ enableLeetSpeak: false, detectPartialWords: false });
315
- ```
331
+ - **No wordlist exposure:** There is no `.list()` function for security and encapsulation. Use exported word arrays for samples.
332
+ - **TRIE-based:** Scales easily to 50,000+ words.
333
+ - **Handles leet-speak:** Catches obfuscated variants like `f#ck`, `a55hole`.
316
334
 
317
- ## Advanced Use Cases
335
+ ---
318
336
 
319
- ### Performance Optimization
337
+ ## Full Example
320
338
 
321
- For high-throughput applications:
339
+ ```typescript
340
+ import profanity, { ProfanitySeverity } from 'allprofanity';
322
341
 
323
- ```javascript
324
- const badWordsList = profanity.list();
325
- const preCompiledRegex = new RegExp('\\b(' + badWordsList.join('|') + ')\\b', 'i');
342
+ // Multi-language detection
343
+ profanity.loadLanguages(['english', 'french', 'tamil']);
344
+ console.log(profanity.check('Ce mot est merde.')); // true
326
345
 
327
- function quickCheck(text) {
328
- return preCompiledRegex.test(text);
329
- }
330
- ```
346
+ // Leet-speak detection
347
+ console.log(profanity.check('You a f#cking a55hole!')); // true
331
348
 
332
- ### Content Moderation Systems
333
-
334
- ```javascript
335
- function moderateContent(content) {
336
- if (profanity.check(content)) {
337
- return {
338
- isApproved: false,
339
- cleanedContent: profanity.cleanWithWord(content, '[INAPPROPRIATE]'),
340
- reason: 'Contains profanity'
341
- };
342
- }
343
- return { isApproved: true, cleanedContent: content };
344
- }
345
- ```
349
+ // Whitelisting
350
+ profanity.addToWhitelist(['anal', 'ass']);
351
+ console.log(profanity.check('He is an associate professor.')); // false
346
352
 
347
- ## Use Cases
353
+ // Severity
354
+ const result = profanity.detect('This is fucking bullshit and chutiya.');
355
+ console.log(ProfanitySeverity[result.severity]); // "SEVERE"
348
356
 
349
- - Content moderation systems
350
- - Chat applications
351
- - User-generated content platforms
352
- - Educational software
353
- - Forums and community platforms
354
- - Social media content filtering
355
- - Comment sections
356
- - Gaming chat filters
357
- - Email filtering
358
- - Document processing systems
357
+ // Custom dictionary
358
+ profanity.loadCustomDictionary('pirate', ['barnacle-head', 'landlubber']);
359
+ profanity.loadLanguage('pirate');
360
+ console.log(profanity.check('You barnacle-head!')); // true
359
361
 
360
- ## Browser Support
362
+ // Placeholder configuration
363
+ profanity.setPlaceholder('#');
364
+ console.log(profanity.clean('This is bullshit.')); // "This is ########."
365
+ profanity.setPlaceholder('*'); // Reset
366
+ ```
361
367
 
362
- AllProfanity works in all modern browsers and Node.js environments.
368
+ ---
363
369
 
364
- ## Roadmap
370
+ ## FAQ
365
371
 
366
- - Add support for more languages (Arabic, Chinese, Russian, etc.)
367
- - Contextual profanity detection
368
- - Severity levels for different categories of profanity
369
- - Phonetic matching for evasion attempts
370
- - Plugin system for custom detection strategies
372
+ **Q: How do I see all loaded profanities?**
373
+ A: For security, the internal word list is not exposed. Use `englishBadWords` etc. for samples.
371
374
 
372
- ## License
375
+ **Q: How do I reset the filter?**
376
+ A: Use `clearList()` and reload languages/dictionaries.
373
377
 
374
- This project is licensed under the MIT License - see the [LICENSE](https://github.com/ayush-jadaun/allprofanity/blob/main/LICENSE) file for details.
378
+ **Q: Is this safe for browser and Node.js?**
379
+ A: Yes! AllProfanity is universal.
375
380
 
376
- ## Contributing
381
+ ---
377
382
 
378
- Contributions are welcome! Whether it's adding new language support, improving detection algorithms, or enhancing documentation.
383
+ ## Roadmap
379
384
 
380
- Please feel free to submit a Pull Request or open an Issue on GitHub.
385
+ - More language packs (Arabic, Russian, etc.)
386
+ - Contextual detection & severity scoring
387
+ - Phonetic/typo/obfuscation resilience
388
+ - Plugin system for custom detection
381
389
 
382
- ### Adding a New Language
390
+ ---
383
391
 
384
- To add support for a new language:
392
+ ## License
385
393
 
386
- 1. Create a new file in the `src/languages` directory (e.g., `french-words.ts`)
387
- 2. Follow the format of the existing word lists
388
- 3. Submit a pull request with your changes
394
+ MIT See [LICENSE](https://github.com/ayush-jadaun/allprofanity/blob/main/LICENSE)
389
395
 
390
- ## Acknowledgements
396
+ ---
391
397
 
392
- - Inspired by [leo-profanity](https://github.com/jojoee/leo-profanity), but fully rebuilt for extensibility and multi-language support.
398
+ ## Contributing
393
399
 
394
- ```diff
395
- - Note: As of v2+, AllProfanity is zero-dependency and does not use leo-profanity internally.
396
- ```
400
+ We welcome new language packs, detection improvements, and docs!
401
+ To add a new language, create a file in `src/languages/` and export a string array.
402
+ Open a PR or issue for bugs, features, or suggestions.