A multilingual profanity filter supporting English, Hindi, and Bengali
Project description
ProfanityFilter
A simple and customizable profanity filtering class supporting multiple languages: English (en), Hindi (hi), and Bengali (bn). It allows you to censor, detect, or remove profane words from a given text.
Features
- 🔍 Detect profanity in text
- ✂️ Remove profanity completely
- ✳️ Censor profanity with a customizable replacement character
- 🌐 Multilingual support (English, Hindi, Bengali)
- 💡 Easy to integrate and extend
Installation
Make sure your profanity word lists are properly structured and located in the appropriate data subdirectory:
project/
├── Anti-Profanity/
│ ├── init.py
│ ├── main.py
│ └── data /
│ ├── en_profanity.py
│ ├── hi_profanity.py
│ └── bn_profanity.py
├── readme.md
└── setup.py
Each language file (e.g., en_profanity.py) should export a list of profane words:
from anti-profanity import ProfanityFilter
# For English only
pf_en = ProfanityFilter("en")
# For English and Hindi
pf_multi = ProfanityFilter(["en", "hi"])
# For all supported languages
pf_all = ProfanityFilter()
Methods
Example 1
censor_profanity(text, replacement="*", lang=None)
Replaces each character of any detected profanity with the replacement character.
text = "This contains badword1."
censored = pf_en.censor_profanity(text)
print(censored) # Output: This contains ********
Example 2
is_profanity(text, lang=None)
Checks whether the given text contains any profane words.
is_dirty = pf_multi.is_profanity("Text with badword2")
print(is_dirty) # Output: True
Example 3
remove_profanity(text, lang=None)
Removes all profane words from the given text.
cleaned = pf_en.remove_profanity("Some badword1 text")
print(cleaned) # Output: Some text
Customization
You can extend the filter by adding your own languages or editing the existing profanity lists in the data directory.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anti_profanity-0.1.6.tar.gz.
File metadata
- Download URL: anti_profanity-0.1.6.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec10c324600d42e1cd4b15adcad932f67e005cea6784dc1fbcd9a7ea7aa427ea
|
|
| MD5 |
bef0a01205eb638ef005d34f1defecec
|
|
| BLAKE2b-256 |
155a56bcfc7bf5bf28d80e50f5d52d1a82561625a6bd0badcebfd967145b19a3
|
File details
Details for the file anti_profanity-0.1.6-py3-none-any.whl.
File metadata
- Download URL: anti_profanity-0.1.6-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a270d07957f1d3f94446f33d7f7dd3b737bf1420e718fbc78de23d755a51c84
|
|
| MD5 |
e1d3f6d27cc18ad827844a5dcc9f3ce5
|
|
| BLAKE2b-256 |
d6346a2ee39baa6839df8966d0cbd26b35bdad8c78b769fda568d6fe3c4a68ca
|