Giter Site home page Giter Site logo

jojoee / leo-profanity-python Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 15 KB

:tiger: Profanity filter, based on "Shutterstock" dictionary (Python version)

Home Page: https://pypi.org/project/leoprofanity/

License: MIT License

Python 100.00%
curse bad profanity swear dirty obscene

leo-profanity-python's Introduction

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

leo-profanity-python's People

Contributors

jojoee avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.