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

pip3 install anti-profanity
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 shit."
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 fucking 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 subdirectory: Each language file (e.g., english.py) should export a list of profane words:

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.8.tar.gz (8.2 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.8-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anti_profanity-0.1.8.tar.gz
  • Upload date:
  • Size: 8.2 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.8.tar.gz
Algorithm Hash digest
SHA256 ba9135a89b9b8749e4825b0a22ee299355bfbe3d5f3185bd1a636e404fa7639c
MD5 98c9645c1f00f55ee49aa20c1d4a49f9
BLAKE2b-256 82cb389510034ce109a4f02fef08c5373ea7180c763980b71f460d128f59f4a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: anti_profanity-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 8.3 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ff95d250aee846f3e773e4e55dc2a7cfc2121b12b070c7ad254b3117f68df9e5
MD5 9681cc3a0aa346ce3c31db063bdc7e8f
BLAKE2b-256 e3f78ec2e7cdfec13da53221bb097da8fc189d6c2955888e7dfbbb219cd65b2c

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