@tekdi/multilingual-profanity-filter
v1.0.1
Published
A multilingual profanity filter library for React applications.
Downloads
39
Readme
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 @tekdi/multilingual-profanity-filter
Usage
Basic Usage
Import the Library
import { filterBadWords } from '@tekdi/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.const inputText = "I am so tired of these idiots. This is complete bullshit"; const languageCode = "en"; // Use "en" for English const filteredText = filterBadWords(inputText, languageCode); 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"]
}
Contributing
We welcome contributions to this project! Follow the steps below to get started:
Fork the Repository: Click the "Fork" button at the top right corner of the repository page.
Clone the Repository: Use the following command to clone the repository to your local machine.
git clone https://github.com/Sunbird-ALL/all-multilingual-profanity-filter.git
Navigate to the Project Directory:
cd all-multilingual-profanity-filter
Create a New Branch: Create a new branch for your feature or bugfix.
git checkout -b feature/your-feature-name
Make Changes: Implement your feature or bugfix.
Commit Your Changes: Commit your changes with a descriptive commit message.
git commit -m "Add feature: description of the feature"
Push to Your Branch:
git push origin feature/your-feature-name
Submit a Pull Request: Go to the original repository and click "New Pull Request".
License
This library is licensed under the MIT License.
Contact
For any questions or support, please contact Ajinkya Pande.