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()
# add_custom_words(words: list) -> None
filter.add_custom_words(["happy", "hello"])
# add_custom_wordlist(filepath: str) -> None
filter.add_custom_wordlist("./wordlist.txt")
# set_censor_symbol(censor_symbol: str) -> None
filter.set_censor_symbol("-")
# is_profanity(txt: str) -> bool
filter.is_profanity("my name is Lime") # False
filter.is_profanity("shut the fuck up") # True
# censor_text(txt: str, censor_symbol: str = None) -> str
filter.censor_text("what the fuck is this") # Output: what the ---- is this
# Without set_censor_symbol(): what the **** is this
# full_detection(txt: str) -> list[dict]
# [
# {
# string_match,
# start_index,
# end_index,
# found_word
# }, ...
# ]
filter.full_detection("you fuck1ng bitch") # [["fuck1ng", 4, 11, "fucking"], ["bitch", 12, 17, "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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file no_profanity-1.1.0.tar.gz.
File metadata
- Download URL: no_profanity-1.1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a8658844785e976cdab95b6ce4c8a7c95c99c3508225319805aedd3c97ed9cd
|
|
| MD5 |
9cf6a19cf8622b105b360341d8678ae3
|
|
| BLAKE2b-256 |
69d710058431ec872439935b44de61b6972963b3cfc52b3af9cb88e3603095e4
|
File details
Details for the file no_profanity-1.1.0-py3-none-any.whl.
File metadata
- Download URL: no_profanity-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e58ba89c2c4dd6d250bd985351cd1f24982a22eae7e3b4aeade381f8f4142411
|
|
| MD5 |
9e408035eaa85af9a2ab230bb7c1c6a3
|
|
| BLAKE2b-256 |
b1cabd606b22cdbb16782c57ed59a37dc2d7e5457000ceed8dbbfbf72c1385f4
|