Metadata-Version: 2.4
Name: arabic-toxic
Version: 0.2.2
Summary: Arabic multi-label toxic content classifier
Author-email: Faisal Alshargi <alshargi@hotmail.de>
License-Expression: MIT
Project-URL: Homepage, https://github.com/alshargi/arabic-toxic
Project-URL: Repository, https://github.com/alshargi/arabic-toxic
Project-URL: Issues, https://github.com/alshargi/arabic-toxic/issues
Keywords: arabic,toxicity,harassment,nlp,text-classification,content-moderation
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: joblib>=1.2
Requires-Dist: numpy>=1.23
Requires-Dist: scikit-learn<1.8.0,>=1.4.0
Dynamic: license-file

# 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

```bash
pip install arabic-toxic
```

---

## Quick Start

### Single Text Classification

```python
from arabic_toxic import classify

result = classify("يلعن امك يا ابن الحمار")

print(result)
```

### Output

```python
{
    "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

```python
from arabic_toxic import classify

print(classify("أنت إنسان محترم"))
print(classify("شكراً لك على المساعدة"))
```

### Output

```python
{
    "text": "أنت إنسان محترم",
    "labels": ["NOT"],
    "top_label": "NOT",
    "is_toxic": False
}

{
    "text": "شكراً لك على المساعدة",
    "labels": ["NOT"],
    "top_label": "NOT",
    "is_toxic": False
}
```

---

## Batch Classification

```python
from arabic_toxic import classify_many

texts = [
    "أنت إنسان محترم",
    "يلعن امك يا ابن الحمار",
    "الشكل والتفكير حمار",
    "ليبرالية شوية صعاليك"
]

results = classify_many(texts)

for r in results:
    print(r)
```

---

## Probability Scores

```python
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](https://github.com/alshargi)

PyPI: [https://pypi.org/project/arabic-toxic/](https://pypi.org/project/arabic-toxic/)
