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"])

# 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 --action censor --text "Your text here" --lang en

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

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

# List supported languages
anti_profanity --action list_langs

# List available methods
anti_profanity --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.0.tar.gz (10.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.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anti_profanity-0.2.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for anti_profanity-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3c738670adb65e01b07195b5b7ebc54ab6acf694658ccb5a6658f29ecad534f2
MD5 c08cd492bdeefc3b05d4ff614f7c2413
BLAKE2b-256 01ede1c8447311c7608651c1808a84a47b263e7771f9e3712dca6a2db090c771

See more details on using hashes here.

File details

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

File metadata

  • Download URL: anti_profanity-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for anti_profanity-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3166e2da9b96e6d9e6c48abdfaec1ed02281b6aa51784234190879db63cbd10
MD5 686a944abfa5c627082a594446ff8d61
BLAKE2b-256 c32cda1daf9f0e5623c051c35e8665de9c777cc8c5e9f7af112860eeb9181e7c

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