{"id":8822,"library":"alt-profanity-check","title":"Alt Profanity Check","description":"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.","status":"active","version":"1.8.0","language":"en","source_language":"en","source_url":"https://github.com/dimitrismistriotis/alt-profanity-check","tags":["natural language processing","nlp","profanity detection","text analysis","machine learning","moderation"],"install":[{"cmd":"pip install alt-profanity-check","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core machine learning library for the SVM model. Version 1.8.0 of alt-profanity-check specifically requires scikit-learn==1.8.0.","package":"scikit-learn","optional":false},{"reason":"Used for efficient loading/saving of the pre-trained model. Version 1.8.0 of alt-profanity-check specifically requires joblib==1.5.3.","package":"joblib","optional":false}],"imports":[{"note":"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.","wrong":"from alt_profanity_check import predict","symbol":"predict","correct":"from profanity_check import predict"},{"note":"The library is designed as a drop-in replacement for 'profanity-check', hence imports are from 'profanity_check' internally.","wrong":"from alt_profanity_check import predict_prob","symbol":"predict_prob","correct":"from profanity_check import predict_prob"}],"quickstart":{"code":"from profanity_check import predict, predict_prob\n\n# Predict profanity (returns 1 for profane, 0 for clean)\ntexts = ['hello world', 'go to hell', 'this is a bad word']\npredictions = predict(texts)\nprint(f\"Predictions: {predictions}\")\n\n# Predict probability of profanity\nprobabilities = predict_prob(texts)\nprint(f\"Probabilities: {probabilities}\")","lang":"python","description":"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."},"warnings":[{"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).","message":"Python 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.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Always use `from profanity_check import ...` in your code, even though the installed package name is `alt-profanity-check`.","message":"The 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.","severity":"gotcha","affected_versions":"all"},{"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`.","message":"Major 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.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `alt-profanity-check` is installed in your active Python environment using `pip install alt-profanity-check`.","cause":"The `alt-profanity-check` library is not installed, or Python cannot find the installed package.","error":"ModuleNotFoundError: No module named 'profanity_check'"},{"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`.","cause":"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`.","error":"AttributeError: module 'profanity_check' has no attribute 'predict'"},{"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).","cause":"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.","error":"RuntimeError: Python version 3.10.x is not supported by scikit-learn 1.8.0"}]}