A library to censor and detect offensive words in strings.
Project description
PyProfane
Why I made this?
I went through a few libraries for profane languages like profanity
, profanity-check
and profanity-filter
. While they're all good in their own right, I couldn't find one that suited my needs.
Installation
pip install PyProfane
Features
The special thing about this python library is that it uses soundex to detect even slightly misspelled words to detect if they're profane or not. Of course this is not a mighty addition but I feel like this can be useful.
Please note that it uses an explicit blacklist which can be modified as when you need as I have included a function updateSwearwords(filename)
Usage
from PyProfane import censorWord, censorSentences, isProfane
sentence = "you're a piece of shit"
word = "slutty"
sentences = ["you're a piece of shit",
'fucking whore',
'why you such a cumslut',
'an online whore',
'fucking wanker',
'hey, hope you do great!',
'sluttyyyy whoreeee',
'wear a dress']
print(isProfane(sentence)) # returns True
print(censorWord(word)) # returns 's%!$ty'
print(censorSentences(sentences))
#["you're a piece of s#it",
# 'fucking w&!re',
# 'why you such a c&m&%ut',
# 'an online w%$re',
# 'fucking w#$$er',
# 'hey, hope you do great!',
# 's#&t$#yyy w&o$%$ee',
# 'wear a dress']
Data
The data for swear words has been taken from a subset of:
I just randomly included and deleted some of the words as I felt like, but please feel free to add more words by making pull requests.
Caveats
Like I said, this is exclusive to the swear words blacklist i.e. the data.
Contributing
Feel free to make suggestions, raise pull requests, and report issues. After all we're human and there can be problems with this bot.
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
File details
Details for the file PyProfane-1.0.3.post1.tar.gz
.
File metadata
- Download URL: PyProfane-1.0.3.post1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6ed3825f4f9489f5ae61766b68c3a769a4634b6c084ef6411964094d2bae5f0 |
|
MD5 | 34add4c863e37c5b47d92a638db74a34 |
|
BLAKE2b-256 | 2207864ed8c14c70a43ae6153aed37c2046da2a53d8d5a134f1963232872600c |