Skip to main content

A package for censoring profanity in text

Project description

Banner

censore

A tool for censoring obscene language

Report Bug · Request Feature

About The Project

This tool helps identify and censor profanity

It can be used in any cases, for example for text censorship, for audio and video censorship, etc.

⚙️ Installation

Just run this command in the terminal:

pip3 install censore

🚀 Usage

Before you can start working with the text, you need to initialize the Censor class with the preloaded languages:

from censore import Censor

censor = Censor(languages=["en", "uk"])

If no language was specified, English (en) will be loaded by default

censor_text

To censor text, use the censor_text method:

censor.censor_text("fuck you")
# **** you

If you initialized the Censor class with preloaded languages ​​(in our case, with English and Ukrainian), then it will be able to censor in different languages ​​at the same time, here is an example:

censor.censor_text("fuck you хуєсос")
# **** you ******

[!TIP] The tool also recognizes masked words such as @ssh0le (asshole) and censors them

censoring_char parameter

As you can see, this function replaced the bad word with asterisks (*)

You can choose any other character to censor, such as monkey 🙈:

censor.censor_text("fuck you", censoring_char="🙈")
# 🙈🙈🙈🙈 you

languages and additional_languages parameters

If you have a special case and you need to censor the text in some specific languages ​​other than the preloaded ones, you can specify them in the languages parameter:

censor.censor_text("fuck you хуєсос kapullo", languages=["en", "es"])
# **** you хуєсос *******

Oh, the Ukrainian word хуєсос was not censored 😨

We could add Ukrainian to the languages parameter, but would you like to enter there every time the standard languages ​​and additional ones that should be used only in this case (in this case Spanish) ?

I think not, then we can just use the additional_languages option:

censor.censor_text("fuck you хуєсос kapullo", additional_languages=["es"])
# **** you ****** *******

✨ Perfectly! Now, in addition to English and Ukrainian, Spanish will be used in this operation


partial_censor parameter

You can use partial censoring to leave only the first and last letters:

censor.censor_text("assfucker", partial_censor=True)
# as#####er

custom_words parameter

This parameter allows you to add custom words for censore

Here is an example:

censor.censor_text("fuck you lololo, abc", custom_words=["lololo", "abc"])
# #### you ######, ###

This can be useful if the tool does not define a word or if you have some specific words

If you do notice any missing word, please make an issue or PR with a new word in the repository with lists of these words, we will be very grateful 😉

🤝 Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

Distributed under the MIT License. See LICENSE for more information.

📨 Contact

Telegram - @Okinea

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

censore-0.1.5.tar.gz (28.1 kB view hashes)

Uploaded Source

Built Distribution

censore-0.1.5-py3-none-any.whl (28.2 kB view hashes)

Uploaded Python 3

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