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 Hindi only
pf_hi = ProfanityFilter("hi")

# For English and Hindi
pf_multi = ProfanityFilter(["en", "hi"])

# Add a custom language
pf.add_language("fr", ["merde", "putain"])

# if no argument provided "en' will be default
pf = ProfanityFilter()

Methods

Usage

#Replaces each character of any detected profanity with the replacement character.
censored = pf.censor_profanity("This text contains shit.")
print(censored)  # Output: This text contains ****

# Checks whether the given text contains any profane words.
is_dirty = pf.is_profanity("This text contain Shit")
print(is_dirty)  # Output: True


# Removes all profane words from the given text.
cleaned = pf.remove_profanity("Some fucking text")
print(cleaned)  # Output: Some  text

# List avilable language
print(pf.list_languages())

# Show available methods
print(pf.list_methods())

Command Line

# Censor profanity in text
anti_profanity.cli --action censor --text "Your text here" --lang en

# Check if a file contains profanity
anti_profanity.cli --action check --file input.txt --lang en hi

# Remove profanity from a file and save to another file
anti_profanity.cli --action remove --file input.txt --output clean.txt --lang bn

# List supported languages
anti_profanity.cli --action list_langs

# List available methods
anti_profanity.cli --action list_methods

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_en.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.2.5.tar.gz (10.8 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.2.5-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anti_profanity-0.2.5.tar.gz
  • Upload date:
  • Size: 10.8 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.2.5.tar.gz
Algorithm Hash digest
SHA256 46ffa309d083a9b3090e050f1e3ec23152024f9e12ab4321b8b4ac860e1cdfde
MD5 6bbd39c11bc6ebc20d4b0039f25fc9dc
BLAKE2b-256 d9bf8c93b9ac5457856d075c5a6e548d029fe8c3c67b2a1b7187b783fad367ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: anti_profanity-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 10.9 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.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7c2b1d1b1138652a6674a234b6a839e8aa96e9095799348e96803bb71b6627fc
MD5 4fe22b4ea650f16dd52f71dfa2f31161
BLAKE2b-256 44de220dad0ca2f67c3c2938fa731f5661618d95f5658de2ec883682bc849478

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