Registry / ai-ml / alt-profanity-check

alt-profanity-check

JSON →
library1.8.0pypypi✓ verified 49d ago

Alt Profanity Check is a fast, robust Python library designed to detect offensive language in strings, serving as a drop-in replacement for the unmaintained `profanity-check` library. It utilizes a linear Support Vector Machine (SVM) model trained on a large dataset of human-labeled text. The library is actively maintained, with frequent updates that align with its primary dependency, `scikit-learn`. The current version is 1.8.0, supporting Python 3.11 and newer.

ai-ml
pip install alt-profanity-check
Install & Compatibility
Where this runs
tested against v1.7.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 9.5s · import 3.708s · 271MB
281MB installed
● package 281MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

predict
from profanity_check import predict
from alt_profanity_check import predict
Despite the package name being 'alt-profanity-check', it is a drop-in replacement for 'profanity-check' and maintains the original internal module structure for imports.
predict_prob
from profanity_check import predict_prob
from alt_profanity_check import predict_prob
The library is designed as a drop-in replacement for 'profanity-check', hence imports are from 'profanity_check' internally.

This example demonstrates how to import and use the `predict` and `predict_prob` functions to check a list of strings for offensive language and get their respective profanity probabilities.

from profanity_check import predict, predict_prob # Predict profanity (returns 1 for profane, 0 for clean) texts = ['hello world', 'go to hell', 'this is a bad word'] predictions = predict(texts) print(f"Predictions: {predictions}") # Predict probability of profanity probabilities = predict_prob(texts) print(f"Probabilities: {probabilities}")
Debug
Known issues
breakingPython version requirements have changed significantly across minor versions of `alt-profanity-check` due to its tight coupling with `scikit-learn` dependencies. For `alt-profanity-check` v1.8.0, Python >= 3.11 is strictly required.
fix
Ensure your Python environment meets the `python_requires` specification for the `alt-profanity-check` version you are installing. For v1.8.0, use Python 3.11 or newer. For older Python versions, pin `alt-profanity-check` to an earlier compatible version (e.g., v1.7.x for Python >=3.10, v1.4.x for Python >=3.8).
affects: >=1.5.0
gotchaThe library is installed via `pip install alt-profanity-check`, but imports use the original module name `profanity_check` (e.g., `from profanity_check import predict`). This is by design, as it's a drop-in replacement.
fix
Always use `from profanity_check import ...` in your code, even though the installed package name is `alt-profanity-check`.
affects: all
breakingMajor underlying dependency (`scikit-learn`) version upgrades can introduce breaking changes. `alt-profanity-check` explicitly pins `scikit-learn` versions per release. Mismatched `scikit-learn` versions between what `alt-profanity-check` expects and what is installed in your environment can lead to runtime errors or incorrect predictions.
fix
Always install `alt-profanity-check` in a clean virtual environment to ensure its `scikit-learn` and `joblib` dependencies are correctly installed and matched. Avoid manually upgrading `scikit-learn` independently of `alt-profanity-check`.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'profanity_check'
The `alt-profanity-check` library is not installed, or Python cannot find the installed package.
fix
Ensure `alt-profanity-check` is installed in your active Python environment using `pip install alt-profanity-check`.
AttributeError: module 'profanity_check' has no attribute 'predict'
This typically occurs if `alt-profanity-check` failed to install correctly or its internal data files (`model.joblib`, `vectorizer.joblib`) are missing/corrupted, often due to dependency conflicts with `scikit-learn` or `joblib`.
fix
Reinstall `alt-profanity-check` in a fresh virtual environment to ensure all dependencies are correctly resolved: `python -m venv .venv && source .venv/bin/activate && pip install alt-profanity-check`.
RuntimeError: Python version 3.10.x is not supported by scikit-learn 1.8.0
You are trying to use `alt-profanity-check` v1.8.0 (or newer) with an unsupported Python version. `alt-profanity-check` v1.8.0 requires Python >= 3.11.
fix
Upgrade your Python environment to 3.11 or newer, or downgrade `alt-profanity-check` to a version compatible with your current Python (e.g., `pip install alt-profanity-check==1.7.2` for Python 3.10).
Upgrade
Version history
1.9.0latest on PyPI
Audit
Dependencies
scikit-learnrequiredCore machine learning library for the SVM model. Version 1.8.0 of alt-profanity-check specifically requires scikit-learn==1.8.0.
joblibrequiredUsed for efficient loading/saving of the pre-trained model. Version 1.8.0 of alt-profanity-check specifically requires joblib==1.5.3.
Agent activity
101 hits · last 30 days
node
12
claudebot
4
mj12bot
3
ahrefsbot
3
amazonbot
1
Google (AI)
1
Resources