Alt Profanity Check

1.8.0 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →