Skip to content

Commit ce4c51f

Browse files
authored
Merge pull request #7 from FlacSy/develop
2.3.1 — PyPI sdist fix, ML example
2 parents 271b9f2 + fa4a199 commit ce4c51f

7 files changed

Lines changed: 53 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Release
33
on:
44
release:
55
types: [published]
6+
workflow_dispatch:
67

78
permissions:
89
contents: read

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RELEASE_CHECKLIST.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release Checklist
22

3-
## Versions (2.2.0)
3+
## Versions (2.3.1)
44

55
| Package | File | Publication |
66
|---------|------|-------------|

examples/python/ml_moderation.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
"""ML-based toxicity detection example.
3+
4+
Requires: pip install 'badwords-py[ml]'
5+
6+
The ML model (XLM-RoBERTa) detects toxicity in multiple languages.
7+
First run downloads the model from GitHub Releases (~135MB).
8+
"""
9+
10+
import sys
11+
12+
try:
13+
from badwords.ml import ToxicityPredictor
14+
except ImportError:
15+
print("Error: badwords-py[ml] required. Install with:", file=sys.stderr)
16+
print(" pip install 'badwords-py[ml]'", file=sys.stderr)
17+
sys.exit(1)
18+
19+
20+
def main() -> None:
21+
# Создаём предиктор (модель скачается при первом вызове predict)
22+
predictor = ToxicityPredictor()
23+
24+
texts = [
25+
"Hello, how are you today?",
26+
"Have a nice day!",
27+
"You are stupid and worthless",
28+
"Поздравляю, теперь ты не тупой",
29+
"Иди нахуй",
30+
]
31+
32+
print("=" * 60)
33+
print("ML Toxicity Detection (0.0 = clean, 1.0 = toxic)")
34+
print("Threshold: 0.5")
35+
print("=" * 60)
36+
37+
for text in texts:
38+
prob = predictor.predict(text)
39+
label = "TOXIC" if prob >= 0.5 else "clean"
40+
bar = "█" * int(prob * 20) + "░" * (20 - int(prob * 20))
41+
print(f" {prob:.2f} [{label:5}] {bar} {text!r}")
42+
43+
print("=" * 60)
44+
45+
46+
if __name__ == "__main__":
47+
main()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "badwords-py"
7-
version = "2.2.0"
7+
version = "2.3.1"
88
requires-python = ">=3.10"
99
authors = [
1010
{name = "iamlostshe", email = "vanamelcikov7275@gmail.com"},

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "badwords-py"
7-
version = "2.2.0"
7+
version = "2.3.1"
88
requires-python = ">=3.10"
99
authors = [
1010
{name = "iamlostshe", email = "vanamelcikov7275@gmail.com"},

rust/badwords-py/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "badwords-py"
3-
version = "2.2.0"
3+
version = "2.3.1"
44
edition = "2021"
55
description = "Python bindings for badwords profanity filter"
66
license = "MIT"

0 commit comments

Comments
 (0)