multilingual-profanity-filter v1.0.5
Profanity Filter Library
A versatile library for filtering out profanity words in various languages. This library helps in cleaning up text by detecting and replacing inappropriate words based on configurable language codes.
Features
- Multilingual Support: Includes profanity lists for multiple languages.
- Customizable: Easy to extend with additional languages and words.
- Flexible Filtering: Can be integrated into various applications to ensure clean and appropriate content.
Installation
To use the library, you can install it via npm:
npm install multilingual-profanity-filter
Usage
Basic Usage
Import the Library
import { filterBadWords } from 'multilingual-profanity-filter';
Filter Text
Use the
filterBadWords
function to filter out profanity from a given text. You need to provide the text and the language code for filtering.// Example input text containing various words, including some that might be considered profane const inputText = "I am so tired of these idiots. This is complete bullshit"; // Specify the language code for filtering const languageCode = "en"; // Use "en" for English // Call the filterBadWords function to clean up the input text const filteredText = filterBadWords(inputText, languageCode); // Output the filtered text console.log(filteredText); // Expected Output: "I am so tired of these i****. This is complete b****ts"
Supported Languages
Currently, the library supports the following languages:
- English (
en
) - Hindi (
hi
) - Marathi (
mr
) - Tamil (
ta
) - Gujarati (
gu
) - Kannada (
kn
)
To add support for additional languages, you can extend the badWords.json
file with the desired language's profanity list.
Configuration
To configure or add new languages, modify the badWords.json
file located in the Badwords
directory. The file should be structured as follows:
{
"en": ["badword1", "badword2"],
"hi": ["गाली1", "गाली2"],
"mr": ["गालिच्या शब्द1", "गालिच्या शब्द2"],
"ta": ["பொய்யான சொல்1", "பொய்யான சொல்2"],
"gu": ["ગંદી શબ્દ1", "ગંદી શબ્દ2"],
"kn": ["ಕಿಡಿ ಶಬ್ದ1", "ಕಿಡಿ ಶಬ್ದ2"]
}
License
This library is licensed under the MIT License.
Contact
For any questions or support, please contact Ajinkya Pande.