Arabic multi-label toxic content classifier
Project description
arabic-toxic
Arabic Multi-Label Toxic Content Classifier
A fast and lightweight Arabic NLP package for toxic content detection, content moderation, social media analysis, and Arabic text safety classification.
The package supports multi-label classification and can detect several categories of toxic and harmful content in Arabic text.
Installation
pip install arabic-toxic
Quick Start
Single Text Classification
from arabic_toxic import classify
result = classify("يلعن امك يا ابن الحمار")
print(result)
Output
{
"text": "يلعن امك يا ابن الحمار",
"labels": ["Cussing", "Hatred"],
"top_label": "Cussing",
"is_toxic": True,
"scores": {
"Cussing": 99.999,
"Hatred": 94.404,
"Sexual": 2.938,
"Racial": 0.762,
"Appearance": 0.033,
"Violence": 0.027,
"NOT": 0.001
}
}
Toxic / Non-Toxic Detection
from arabic_toxic import classify
print(classify("أنت إنسان محترم"))
print(classify("شكراً لك على المساعدة"))
Output
{
"text": "أنت إنسان محترم",
"labels": ["NOT"],
"top_label": "NOT",
"is_toxic": False
}
{
"text": "شكراً لك على المساعدة",
"labels": ["NOT"],
"top_label": "NOT",
"is_toxic": False
}
Batch Classification
from arabic_toxic import classify_many
texts = [
"أنت إنسان محترم",
"يلعن امك يا ابن الحمار",
"الشكل والتفكير حمار",
"ليبرالية شوية صعاليك"
]
results = classify_many(texts)
for r in results:
print(r)
Probability Scores
from arabic_toxic import predict_proba
scores = predict_proba("يلعن امك يا ابن الحمار")
print(scores)
Supported Labels
| Label | Description |
|---|---|
| Appearance | Appearance-based insults |
| Cussing | Profanity and offensive language |
| Hatred | Hate and hostility |
| NOT | Non-toxic content |
| Racial | Ethnic or racial attacks |
| Sexual | Sexual harassment or abuse |
| Violence | Violent threats or content |
Model Architecture
The model uses:
- Arabic text normalization
- TF-IDF word n-grams
- TF-IDF character n-grams
- Multi-label classification
- One-vs-Rest strategy
- SGD Logistic Classifier
Designed for:
- Content Moderation
- Social Media Monitoring
- Arabic NLP Research
- Online Community Safety
- AI Safety Applications
Evaluation Results
Test-set performance:
| Metric | Score |
|---|---|
| Macro F1 | 0.9109 |
| Micro F1 | 0.9205 |
| Subset Accuracy | 0.8433 |
| Hamming Loss | 0.0307 |
Notes
This package is intended for Arabic content moderation, research, and production prototyping.
Performance may vary depending on dialect, domain, and writing style. Always validate the model on your own data before using it in production decision systems.
Author
Dr. Faisal Alshargi
AI Researcher • NLP Engineer • Data Scientist
GitHub: https://github.com/alshargi
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arabic_toxic-0.2.1.tar.gz.
File metadata
- Download URL: arabic_toxic-0.2.1.tar.gz
- Upload date:
- Size: 3.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00cbd9cffddbe01d7500259c4c038906679b5a0e76010339ddfd706d18463bce
|
|
| MD5 |
9020f7e74f2906a5e75ce25adac69532
|
|
| BLAKE2b-256 |
6162277908927a85bcce7085c3449ba49741ecf59494e18d76efc6170a25d8eb
|
File details
Details for the file arabic_toxic-0.2.1-py3-none-any.whl.
File metadata
- Download URL: arabic_toxic-0.2.1-py3-none-any.whl
- Upload date:
- Size: 3.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91c2363dfca328031e5c7935498a3e9f08862b3988f63861c05d9ee31c18040e
|
|
| MD5 |
f4ac3183ade750abd25f09a7fbbb9b6b
|
|
| BLAKE2b-256 |
17f06674968e3b02ae0432283d5c9a37f4160caa46d083d4a47f0da52cd38313
|