Skip to main content

Profanity filter, based on Shutterstock dictionary

Project description


Travis PyPI version PyPI license PyPI pyversions

Python version of leo-profanity, "Shutterstock" dictionary based filter.


pip install leoprofanity

# or
git clone
cd leo-profanity-python
python install



python -m leoprofanity "I have boob"


from leoprofanity import LeoProfanity

# example usage
fil = LeoProfanity()
fil.check("I have BoOb, etc.") # True
fil.clean("I have BoOb, etc.") # 'I have ****, etc.'

# return all profanity words (List[str])

# remove word form the list

# check whether the string contains profanity word or not
fil.check("Buy classic watches online") # False
fil.check("I have BoOb.") # True

# clean or replace profanity word in a string
fil.clean("I have boob, etc.") # "I have ****"
fil.clean("I have boob,boob, ass, and etc.") # "I have ****,****, ***, and etc."
fil.clean("I have boob", "+") # "I have ++++"
fil.clean("Buy classic watches online") # "Buy classic watches online"

# add new word(s)
fil.add(["b@@b", "b##b"])

# remove word(s) from the list
fil.remove(["boob", "boobs"])

# reset word list by using en dictionary

# remove all words inside an existing list

# return word list from dictionary
fil.get_dictionary() # returns "en" word list

# reset word list by using en dictionary


# env
conda env list
conda create --name leoprofanity python=3.7

# test
python -m unittest tests/*.py # run unit test

# format
flake8 --max-line-length=120 --exclude=__*.py
black . --check
pytype ./leoprofanity

# publishing
pip install twine # package for publishing
python sdist bdist_wheel # build the package
tar tzf dist/leoprofanity-0.0.1.tar.gz # check published file in the published package
twine check dist/* # if the package render correctly
python -m pip install dist/leoprofanity-0.0.1-py3-none-any.whl # for testing, install local to global
python -m leoprofanity "I have boob, etc." # testing the package via cli
twine upload --repository-url dist/* --verbose # publishing (test)
twine upload dist/* # publishing
pip install leoprofanity -U # force update module to test after publishing

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

leoprofanity-0.0.4.tar.gz (5.7 kB view hashes)

Uploaded source

Built Distribution

leoprofanity-0.0.4-py3-none-any.whl (7.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page