Skip to main content

A Python profanity filter forked from Blaspsoft/blasp.

Project description

Profy

Profy is a Python fork of Blaspsoft/blasp, focused on the core profanity filtering engine rather than Laravel integration. It ports Blasp's dictionary-driven, obfuscation-aware matching into a standalone Python package.

The repository lives at mantleCurve/profy.

Install

pip install profy-filter

The import package is profy:

from profy import filter_text, clean_text, check_text

result = filter_text("This is f-uuck!ng noisy")

print(result.is_offensive)      # True
print(result.clean)             # This is ********* noisy
print(result.unique_words)      # ['fucking']
print(result.score)             # severity-weighted score from 0 to 100

assert check_text("f**k")
assert clean_text("shit") == "****"

Development

python -m pip install -e ".[dev]"
python -m pytest

Reuse a Filter

Create a ProfanityFilter when you need to process many strings with the same options.

from profy import ProfanityFilter, Severity

shield = ProfanityFilter(
    languages=["english", "spanish"],
    mask="#",
    minimum_severity=Severity.MODERATE,
    allow=["heck"],
    block=["internal-ban-word"],
)

result = shield.check("clean this text")
print(result.to_dict())

Options

filter_text() and ProfanityFilter() accept:

  • languages: a language name or iterable. Bundled data includes english, spanish, german, and french.
  • all_languages: use every bundled language dictionary.
  • allow: words that should never be flagged.
  • block: extra words that should always be flagged.
  • mask: a replacement character or callback (word, length) -> str.
  • minimum_severity: mild, moderate, high, or extreme.

Result Shape

{
    "original": "This is shit",
    "clean": "This is ****",
    "is_offensive": True,
    "score": 40,
    "count": 1,
    "unique_words": ["shit"],
    "severity": "high",
    "words": [
        {
            "text": "shit",
            "base": "shit",
            "severity": "high",
            "position": 8,
            "length": 4,
            "language": "english",
        }
    ],
}

Scope

This fork intentionally ports the profanity filter itself, not Blasp's Laravel service provider, middleware, Eloquent helpers, events, facades, or cache layer.

Upstream Sync

Use scripts/sync_from_blasp.py to fetch the latest Blasp PHP repository, export updated dictionary/config data into Profy's Python package, and generate an implementation-change report for PHP files that need manual port review.

python scripts/sync_from_blasp.py

Release

Alpha releases use PEP 440 versions such as 0.1.0a1 and Git tags such as v0.1.0a1. The GitHub Actions release workflow runs tests, builds the source distribution and wheel, uploads them as artifacts, and attaches them to the GitHub Release.

Attribution

Profy is a Python fork of Blaspsoft/blasp, originally authored by Michael Deeming and released under the MIT license.

License

MIT. See LICENSE.md.

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

profy_filter-0.1.0a2.tar.gz (50.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

profy_filter-0.1.0a2-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

Details for the file profy_filter-0.1.0a2.tar.gz.

File metadata

  • Download URL: profy_filter-0.1.0a2.tar.gz
  • Upload date:
  • Size: 50.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for profy_filter-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 d1302f7a0f26c3bf998ce3dc95a4ae6db60b159e7f6a7e7a469aee3ab1c1badd
MD5 58f7453b9d9d27c581098f4de809f6a3
BLAKE2b-256 22d1ad37969c56b6c0a9b67950ad59a3dfe223fd7d32eee45f914b16dda17646

See more details on using hashes here.

Provenance

The following attestation bundles were made for profy_filter-0.1.0a2.tar.gz:

Publisher: release.yml on mantleCurve/profy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file profy_filter-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: profy_filter-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for profy_filter-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 1f2bba5bd13dbfbb47733e488d74891021239d6c4a924b4fe7b6d0d2efe7ee50
MD5 1f9e2897be1041a68ebbb277fe9a82ff
BLAKE2b-256 ee33dad40e33b18c8c16cae448a3116c26ded1d599d9fed8281b4bdb033c7a47

See more details on using hashes here.

Provenance

The following attestation bundles were made for profy_filter-0.1.0a2-py3-none-any.whl:

Publisher: release.yml on mantleCurve/profy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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