Skip to main content

A library using regex manipulation to detect and block profanity in strings.

Project description

No-Profanity

No-Profanity is a simple library that uses regexes to detect and block profanity in strings. It's designed to detect even the most creative modifications of profanity.

How to use?

The library contains 1 class. This class contains 5 functions.

from no_profanity import ProfanityFilter

# ProfanityFilter(censor_symbol: str = "*")
filter = ProfanityFilter()

# 1. Add Custom Words
filter.add_custom_words(["happy", "hello"])

# 2. Set Censor Symbol
filter.set_censor_symbol("-")

# 3. is_profanity(txt: str) -> bool
filter.is_profanity("my name is Lime") # False
filter.is_profanity("shut the fuck up") # True

# 4. censor_text(txt: str, censor_symbol: str = None) -> str
filter.censor_text("what the fuck is this") # what the ---- is this

# Without set_censor_symbol(): what the **** is this

# 5. full_detection(txt: str) -> list
# [[match_in_string, start_index, end_index, found_word], ...]
filter.full_detection("you fuck1ng bitch") # [["fuck1ng", 4, 10, "fucking"], ["bitch", 12, 16, "bitch"]]

Pros

The library can detect modified profanity. Examples:

filter.is_profanity("fuckfuck") # True
filter.is_profanity("niggafuck") # True
filter.is_profanity("b i t c h") # True
filter.is_profanity("sexx") # True

filter.is_profanity("n1@@a") # True
filter.is_profanity("f u cckbitch es") # True

filter.is_profanity("@fuck@") # True

Cons

The filter can be bypassed by putting an extra letter(s) that isn't part of profanity. This will be fixed in the future! :D

filter.is_profanity("afuck") # False

This library has originally been made for my Discord bot AutoProtection, but now it's released for everyone to use! If you have more questions, please contact me on my Discord server.

Thank you for reading this! I hope you'll like my first library. I'm always opened to new ideas for improvements! ^^

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

no_profanity-1.0.5.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

no_profanity-1.0.5-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file no_profanity-1.0.5.tar.gz.

File metadata

  • Download URL: no_profanity-1.0.5.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for no_profanity-1.0.5.tar.gz
Algorithm Hash digest
SHA256 89d887a7422d8c7bc334919026d34742723b681fbf9852a8053cf18194c32da3
MD5 f3d96435fe132e0cea30d5a54dbb48c6
BLAKE2b-256 318469d019f0c6a00fd498cd0f4dda6cb996be9a4426ec767e044da8548c4819

See more details on using hashes here.

File details

Details for the file no_profanity-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: no_profanity-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for no_profanity-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 02e850c72ae27668b53dde9639fd7381ef48d97cbdb7e2e72f735298d059ad4d
MD5 13bf1d62b73d1bb315c9857a63fbbfab
BLAKE2b-256 7e2af7952fed0c07f37cea6903b0619f8cdf1cae76ac0cdc5fc1a70bc44bfcb4

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