Skip to main content

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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anti_profanity-0.1.5.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anti_profanity-0.1.5-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file anti_profanity-0.1.5.tar.gz.

File metadata

  • Download URL: anti_profanity-0.1.5.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

Hashes for anti_profanity-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c52b201b1e1d93f90344746fc34bc393d62e905f41eb4405a4084bb2eed672b7
MD5 8c8b02d51ab29e6a7011a80c08d78787
BLAKE2b-256 70dec68adbee20e60b934014d946a7f78c9f42a513949d20912f315e98889d73

See more details on using hashes here.

File details

Details for the file anti_profanity-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: anti_profanity-0.1.5-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

Hashes for anti_profanity-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 108e1ac1a08540c411ab19e281997b786e5a04534da19b58c54b9f1e36ab5ad9
MD5 bbb8a95ccd97974546c46f6ed90dff89
BLAKE2b-256 618c4b6dd3cd0b26427e62a825aae4ea3c22e89fe0630c7b4d8f7ddae8d3e191

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page