Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Release
on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion RELEASE_CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release Checklist

## Versions (2.2.0)
## Versions (2.3.1)

| Package | File | Publication |
|---------|------|-------------|
Expand Down
47 changes: 47 additions & 0 deletions examples/python/ml_moderation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
"""ML-based toxicity detection example.

Requires: pip install 'badwords-py[ml]'

The ML model (XLM-RoBERTa) detects toxicity in multiple languages.
First run downloads the model from GitHub Releases (~135MB).
"""

import sys

try:
from badwords.ml import ToxicityPredictor
except ImportError:
print("Error: badwords-py[ml] required. Install with:", file=sys.stderr)
print(" pip install 'badwords-py[ml]'", file=sys.stderr)
sys.exit(1)


def main() -> None:
# Создаём предиктор (модель скачается при первом вызове predict)
predictor = ToxicityPredictor()

texts = [
"Hello, how are you today?",
"Have a nice day!",
"You are stupid and worthless",
"Поздравляю, теперь ты не тупой",
"Иди нахуй",
]

print("=" * 60)
print("ML Toxicity Detection (0.0 = clean, 1.0 = toxic)")
print("Threshold: 0.5")
print("=" * 60)

for text in texts:
prob = predictor.predict(text)
label = "TOXIC" if prob >= 0.5 else "clean"
bar = "█" * int(prob * 20) + "░" * (20 - int(prob * 20))
print(f" {prob:.2f} [{label:5}] {bar} {text!r}")

print("=" * 60)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "badwords-py"
version = "2.2.0"
version = "2.3.1"
requires-python = ">=3.10"
authors = [
{name = "iamlostshe", email = "vanamelcikov7275@gmail.com"},
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "badwords-py"
version = "2.2.0"
version = "2.3.1"
requires-python = ">=3.10"
authors = [
{name = "iamlostshe", email = "vanamelcikov7275@gmail.com"},
Expand Down
2 changes: 1 addition & 1 deletion rust/badwords-py/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "badwords-py"
version = "2.2.0"
version = "2.3.1"
edition = "2021"
description = "Python bindings for badwords profanity filter"
license = "MIT"
Expand Down