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 ProfanityFilter

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

If no language was specified, all languages will be loaded by default

censor_text

To censor text, use the censor_text method:

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

It can censor 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 #

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

censor.censor_text("fuck you", censor_symbol="🙈")
# 🙈🙈🙈🙈 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("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_patterns=["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 - @okineadev

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.2.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

censore-0.2.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file censore-0.2.0.tar.gz.

File metadata

  • Download URL: censore-0.2.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for censore-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8ba88fd239ef6ba2ebcc215d4467ca603a4ce95ce88d9014408c3072fbc8fb60
MD5 f30b5093ba87896bb3f23700d60aff5d
BLAKE2b-256 5ba65ba0592d3b898fcc558593f699c0cd7109c317581ccacb01ae2a8a876266

See more details on using hashes here.

File details

Details for the file censore-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: censore-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for censore-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0107ce5675c5883f8594148f0ec97adf0ed73abc658f2d676d646e5535ba3cc
MD5 fc862e560c3367ef63c018a1245d20cf
BLAKE2b-256 74a1107d6e9328cb1d3ba95c2d513f0a26794f30cfa1e0cfebad794e252b8c8d

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