Skip to main content

Profanity filter, based on Shutterstock dictionary

Project description

LeoProfanity

Travis PyPI version fury.io PyPI license PyPI pyversions

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

Installation

pip install leoprofanity

# or
git clone https://github.com/jojoee/leo-profanity-python
cd leo-profanity-python
python setup.py install

Usage

CLI

python -m leoprofanity "I have boob"

Python

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])
fil.list()

# remove word form the list
fil.remove_word("boob")

# 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("b00b")
fil.add(["b@@b", "b##b"])

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

# reset word list by using en dictionary
fil.reset()

# remove all words inside an existing list
fil.clear_list()

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

# reset word list by using en dictionary
fil.load_dictionary()
fil.load_dictionary("en")

Contribution

# 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 setup.py 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 https://test.pypi.org/legacy/ 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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file leoprofanity-0.0.4.tar.gz.

File metadata

  • Download URL: leoprofanity-0.0.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for leoprofanity-0.0.4.tar.gz
Algorithm Hash digest
SHA256 98a34ac88d2445043705d4c0ce81d6f303abdda7e1309619b591744f48e14077
MD5 6adad48e090a586031af7ed75479eb4a
BLAKE2b-256 9003cc3cc655e6d3daf21ab4476c5ab18a6fab5c27adf55e656e6168408075f8

See more details on using hashes here.

File details

Details for the file leoprofanity-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: leoprofanity-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for leoprofanity-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 96267bdb4d69d302ff00305b4cc51a2b598015143bee59b5d6da48e72167ea6e
MD5 6ff25b0bc0d2a0edc11a79a7c6f697a1
BLAKE2b-256 82e4b4fd4dce56d45916f88d7e56d2eadb67235331352e59e612e0375724d62d

See more details on using hashes here.

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