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.
pip install alt-profanity-checkVerified import paths — ran on the pinned version, not inferred.
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.
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).
Always use `from profanity_check import ...` in your code, even though the installed package name is `alt-profanity-check`.
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`.
Ensure `alt-profanity-check` is installed in your active Python environment using `pip install alt-profanity-check`.
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`.
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).