kea-cyberbully 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KEA MINDZ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,13 @@
1
+ include README.md
2
+ include requirements.txt
3
+ include pyproject.toml
4
+ include LICENSE
5
+
6
+
7
+ recursive-exclude models *
8
+ recursive-exclude research *
9
+ recursive-exclude tests *
10
+ recursive-exclude * __pycache__
11
+ recursive-exclude * *.py[co]
12
+ recursive-exclude * *.pt
13
+ recursive-exclude * *.keras
@@ -0,0 +1,247 @@
1
+ Metadata-Version: 2.4
2
+ Name: kea-cyberbully
3
+ Version: 0.1.0
4
+ Summary: Production-grade cyberbullying detection powered by transformer classifiers and nuance-aware multi-task learning.
5
+ Author: KEA MINDZ
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/KEA-Mindz/Cyberbully
8
+ Project-URL: Repository, https://github.com/KEA-Mindz/Cyberbully
9
+ Keywords: cyberbullying,nlp,transformers,pytorch,toxicity,moderation,deep-learning
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Text Processing :: Linguistic
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: torch>=2.0.0
25
+ Requires-Dist: transformers>=4.30.0
26
+ Requires-Dist: numpy>=1.20.0
27
+ Requires-Dist: demoji>=1.1.0
28
+ Requires-Dist: gdown>=5.0.0
29
+ Requires-Dist: tqdm>=4.60.0
30
+ Provides-Extra: eval
31
+ Requires-Dist: scikit-learn>=1.0.0; extra == "eval"
32
+ Requires-Dist: matplotlib>=3.5.0; extra == "eval"
33
+ Requires-Dist: pandas>=1.4.0; extra == "eval"
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
36
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ # kea-cyberbully
40
+
41
+ [![PyPI Version](https://img.shields.io/pypi/v/kea-cyberbully.svg)](https://pypi.org/project/kea-cyberbully/)
42
+ [![Python Package](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg)](https://pypi.org/project/kea-cyberbully/)
43
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44
+ [![PyTorch](https://img.shields.io/badge/PyTorch-2.0+-ee4c2c.svg)](https://pytorch.org/)
45
+ [![Transformers](https://img.shields.io/badge/Transformers-HuggingFace-orange.svg)](https://huggingface.co/)
46
+
47
+ Production-grade **Cyberbullying Text Detection** powered by transformer neural networks and nuance-aware multi-task learning. Developed by **KEA MINDZ**.
48
+
49
+ Designed for social media moderation, chat moderation, comment screening, and trust & safety workflows.
50
+
51
+ ---
52
+
53
+ ## Key Features
54
+
55
+ - **Multi-Task Neural Architecture**: Joint binary classifier (cyberbullying vs. safe) with a 20-way auxiliary intent head (threats, targeted insults, implicit mockery, backhanded compliments, sarcasm among friends, venting, etc.).
56
+ - **Context & Nuance Aware**: Distinguishes harmful bullying from benign sarcasm among friends, self-venting, or constructive criticism.
57
+ - **Adversarial Robustness**: Handles leetspeak (e.g. `@$$h0le`, `sna7ch`), typo variations, and emoji sentiment without breaking casing or punctuation.
58
+ - **Lightweight Package (<15 KB)**: Compliant with PyPI upload limits by decoupling heavy 260MB model checkpoints and providing automatic background caching to `~/.cache/cyberbully/models/`.
59
+ - **Flexible Interface**: Simple Python API and a rich interactive CLI.
60
+
61
+ ---
62
+
63
+ ## Installation
64
+
65
+ ### From PyPI
66
+
67
+ ```bash
68
+ pip install kea-cyberbully
69
+ ```
70
+
71
+ ### From Source / Development
72
+
73
+ ```bash
74
+ git clone https://github.com/KEA-Mindz/Cyberbully.git
75
+ cd Cyberbully
76
+ pip install -e .
77
+ ```
78
+
79
+ ### Optional Dependencies
80
+
81
+ For running model evaluations and plotting metrics:
82
+ ```bash
83
+ pip install -e ".[eval]"
84
+ ```
85
+
86
+ For testing:
87
+ ```bash
88
+ pip install -e ".[dev]"
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Quickstart (Python API)
94
+
95
+ ### 1. Simple Boolean Check
96
+
97
+ ```python
98
+ import cyberbully
99
+
100
+ # True
101
+ print(cyberbully.is_cyberbullying("Go jump off a cliff you loser"))
102
+
103
+ # False
104
+ print(cyberbully.is_cyberbullying("You are a wonderful person!"))
105
+ ```
106
+
107
+ ### 2. Detailed Prediction
108
+
109
+ ```python
110
+ import cyberbully
111
+
112
+ result = cyberbully.predict("Nobody likes you, you are ugly and pathetic")
113
+
114
+ print(result.label) # 'cyberbullying'
115
+ print(result.score) # 0.9996
116
+ print(result.confidence) # 0.9996
117
+ print(result.category) # 'targeted_insult_general'
118
+ print(result.category_scores)
119
+ # {
120
+ # 'targeted_insult_general': 0.8227,
121
+ # 'threat': 0.1511,
122
+ # ...
123
+ # }
124
+ ```
125
+
126
+ ### 3. Explainability Diagnostics
127
+
128
+ ```python
129
+ import cyberbully
130
+
131
+ explanation = cyberbully.explain("You are so annoying")
132
+ print(explanation)
133
+ # {
134
+ # 'text': 'You are so annoying',
135
+ # 'prediction': 'cyberbullying',
136
+ # 'cyberbullying_score': '0.9412',
137
+ # 'threshold': '0.2300',
138
+ # 'primary_intent_category': 'targeted_insult_general',
139
+ # 'assessment': 'Flagged as cyberbullying (94.1% probability exceeds threshold 23.0%)'
140
+ # }
141
+ ```
142
+
143
+ ### 4. Custom Model Instance & Batch Processing
144
+
145
+ ```python
146
+ from cyberbully import CyberbullyingDetector
147
+
148
+ # Automatically detects local models/ or downloads to cache on first use
149
+ detector = CyberbullyingDetector()
150
+
151
+ texts = [
152
+ "Have a fantastic day!",
153
+ "You are an idiot.",
154
+ "Can you please help review this PR?"
155
+ ]
156
+
157
+ results = detector.predict(texts, batch_size=32)
158
+ for res in results:
159
+ print(f"[{res.label.upper():17s}] ({res.score:.3f}) {res.text}")
160
+ ```
161
+
162
+ ---
163
+
164
+ ## Command-Line Interface (CLI)
165
+
166
+ The package provides two alias commands: `kea-cyberbully` and `cyberbully`:
167
+
168
+ ### Classify Single or Multiple Texts
169
+
170
+ ```bash
171
+ kea-cyberbully "You are a wonderful person"
172
+ kea-cyberbully "Nobody likes you" --threshold 0.30
173
+ ```
174
+
175
+ ### Interactive Mode
176
+
177
+ Launch an interactive evaluation console:
178
+
179
+ ```bash
180
+ kea-cyberbully -i
181
+ ```
182
+
183
+ ### Batch Processing from CSV or Text Files
184
+
185
+ ```bash
186
+ kea-cyberbully --file comments.csv --output flagged_results.csv
187
+ ```
188
+
189
+ ### Check Model Info & Cache
190
+
191
+ ```bash
192
+ kea-cyberbully --info
193
+ ```
194
+
195
+ ### Pre-download Model Checkpoint
196
+
197
+ ```bash
198
+ kea-cyberbully --download
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Model Weights & Distribution
204
+
205
+ The trained checkpoint (`best_model.pt`, ~265MB) is decoupled from the PyPI wheel for fast installation:
206
+
207
+ 1. **Local Search**: The detector first inspects:
208
+ - `models/cyberbully_v0.1_run`
209
+ - Explicit path specified via `--model-dir` or `CYBERBULLY_MODEL_DIR`
210
+ 2. **Cache Fallback**: If not found in local directories, it checks `~/.cache/cyberbully/models/cyberbully_v0.1_run`.
211
+ 3. **Auto-Download**: If missing, it downloads the checkpoint and tokenizer directly from Google Drive upon first execution.
212
+
213
+ ---
214
+
215
+ ## Repository Structure
216
+
217
+ ```text
218
+ Cyberbully/
219
+ ├── .github/
220
+ │ └── workflows/
221
+ │ └── release.yaml # Automated release & PyPI publishing workflow
222
+ ├── src/
223
+ │ └── cyberbully/ # Core Python package
224
+ │ ├── __init__.py # Package exports & convenience API
225
+ │ ├── __main__.py # python -m cyberbully entrypoint
226
+ │ ├── cli.py # Command-line interface
227
+ │ ├── detector.py # CyberbullyingDetector engine
228
+ │ ├── downloader.py # Model downloader & cache management
229
+ │ ├── model.py # PyTorch MultiTaskClassifier architecture
230
+ │ └── preprocessing.py # Adversarial & social media text cleaner
231
+ ├── models/
232
+ │ └── cyberbully_v0.1_run/ # Trained PyTorch model, tokenizer, and config
233
+ ├── tests/
234
+ │ ├── test_detector.py # Pytest suite for model inference
235
+ │ └── test_preprocessing.py # Unit tests for text normalization
236
+ ├── LICENSE # MIT License
237
+ ├── MANIFEST.in # Packaging exclusions
238
+ ├── pyproject.toml # Modern PEP 621 / setuptools packaging
239
+ ├── requirements.txt # Environment dependencies
240
+ └── README.md # Documentation
241
+ ```
242
+
243
+ ---
244
+
245
+ ## License
246
+
247
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,209 @@
1
+ # kea-cyberbully
2
+
3
+ [![PyPI Version](https://img.shields.io/pypi/v/kea-cyberbully.svg)](https://pypi.org/project/kea-cyberbully/)
4
+ [![Python Package](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg)](https://pypi.org/project/kea-cyberbully/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![PyTorch](https://img.shields.io/badge/PyTorch-2.0+-ee4c2c.svg)](https://pytorch.org/)
7
+ [![Transformers](https://img.shields.io/badge/Transformers-HuggingFace-orange.svg)](https://huggingface.co/)
8
+
9
+ Production-grade **Cyberbullying Text Detection** powered by transformer neural networks and nuance-aware multi-task learning. Developed by **KEA MINDZ**.
10
+
11
+ Designed for social media moderation, chat moderation, comment screening, and trust & safety workflows.
12
+
13
+ ---
14
+
15
+ ## Key Features
16
+
17
+ - **Multi-Task Neural Architecture**: Joint binary classifier (cyberbullying vs. safe) with a 20-way auxiliary intent head (threats, targeted insults, implicit mockery, backhanded compliments, sarcasm among friends, venting, etc.).
18
+ - **Context & Nuance Aware**: Distinguishes harmful bullying from benign sarcasm among friends, self-venting, or constructive criticism.
19
+ - **Adversarial Robustness**: Handles leetspeak (e.g. `@$$h0le`, `sna7ch`), typo variations, and emoji sentiment without breaking casing or punctuation.
20
+ - **Lightweight Package (<15 KB)**: Compliant with PyPI upload limits by decoupling heavy 260MB model checkpoints and providing automatic background caching to `~/.cache/cyberbully/models/`.
21
+ - **Flexible Interface**: Simple Python API and a rich interactive CLI.
22
+
23
+ ---
24
+
25
+ ## Installation
26
+
27
+ ### From PyPI
28
+
29
+ ```bash
30
+ pip install kea-cyberbully
31
+ ```
32
+
33
+ ### From Source / Development
34
+
35
+ ```bash
36
+ git clone https://github.com/KEA-Mindz/Cyberbully.git
37
+ cd Cyberbully
38
+ pip install -e .
39
+ ```
40
+
41
+ ### Optional Dependencies
42
+
43
+ For running model evaluations and plotting metrics:
44
+ ```bash
45
+ pip install -e ".[eval]"
46
+ ```
47
+
48
+ For testing:
49
+ ```bash
50
+ pip install -e ".[dev]"
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Quickstart (Python API)
56
+
57
+ ### 1. Simple Boolean Check
58
+
59
+ ```python
60
+ import cyberbully
61
+
62
+ # True
63
+ print(cyberbully.is_cyberbullying("Go jump off a cliff you loser"))
64
+
65
+ # False
66
+ print(cyberbully.is_cyberbullying("You are a wonderful person!"))
67
+ ```
68
+
69
+ ### 2. Detailed Prediction
70
+
71
+ ```python
72
+ import cyberbully
73
+
74
+ result = cyberbully.predict("Nobody likes you, you are ugly and pathetic")
75
+
76
+ print(result.label) # 'cyberbullying'
77
+ print(result.score) # 0.9996
78
+ print(result.confidence) # 0.9996
79
+ print(result.category) # 'targeted_insult_general'
80
+ print(result.category_scores)
81
+ # {
82
+ # 'targeted_insult_general': 0.8227,
83
+ # 'threat': 0.1511,
84
+ # ...
85
+ # }
86
+ ```
87
+
88
+ ### 3. Explainability Diagnostics
89
+
90
+ ```python
91
+ import cyberbully
92
+
93
+ explanation = cyberbully.explain("You are so annoying")
94
+ print(explanation)
95
+ # {
96
+ # 'text': 'You are so annoying',
97
+ # 'prediction': 'cyberbullying',
98
+ # 'cyberbullying_score': '0.9412',
99
+ # 'threshold': '0.2300',
100
+ # 'primary_intent_category': 'targeted_insult_general',
101
+ # 'assessment': 'Flagged as cyberbullying (94.1% probability exceeds threshold 23.0%)'
102
+ # }
103
+ ```
104
+
105
+ ### 4. Custom Model Instance & Batch Processing
106
+
107
+ ```python
108
+ from cyberbully import CyberbullyingDetector
109
+
110
+ # Automatically detects local models/ or downloads to cache on first use
111
+ detector = CyberbullyingDetector()
112
+
113
+ texts = [
114
+ "Have a fantastic day!",
115
+ "You are an idiot.",
116
+ "Can you please help review this PR?"
117
+ ]
118
+
119
+ results = detector.predict(texts, batch_size=32)
120
+ for res in results:
121
+ print(f"[{res.label.upper():17s}] ({res.score:.3f}) {res.text}")
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Command-Line Interface (CLI)
127
+
128
+ The package provides two alias commands: `kea-cyberbully` and `cyberbully`:
129
+
130
+ ### Classify Single or Multiple Texts
131
+
132
+ ```bash
133
+ kea-cyberbully "You are a wonderful person"
134
+ kea-cyberbully "Nobody likes you" --threshold 0.30
135
+ ```
136
+
137
+ ### Interactive Mode
138
+
139
+ Launch an interactive evaluation console:
140
+
141
+ ```bash
142
+ kea-cyberbully -i
143
+ ```
144
+
145
+ ### Batch Processing from CSV or Text Files
146
+
147
+ ```bash
148
+ kea-cyberbully --file comments.csv --output flagged_results.csv
149
+ ```
150
+
151
+ ### Check Model Info & Cache
152
+
153
+ ```bash
154
+ kea-cyberbully --info
155
+ ```
156
+
157
+ ### Pre-download Model Checkpoint
158
+
159
+ ```bash
160
+ kea-cyberbully --download
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Model Weights & Distribution
166
+
167
+ The trained checkpoint (`best_model.pt`, ~265MB) is decoupled from the PyPI wheel for fast installation:
168
+
169
+ 1. **Local Search**: The detector first inspects:
170
+ - `models/cyberbully_v0.1_run`
171
+ - Explicit path specified via `--model-dir` or `CYBERBULLY_MODEL_DIR`
172
+ 2. **Cache Fallback**: If not found in local directories, it checks `~/.cache/cyberbully/models/cyberbully_v0.1_run`.
173
+ 3. **Auto-Download**: If missing, it downloads the checkpoint and tokenizer directly from Google Drive upon first execution.
174
+
175
+ ---
176
+
177
+ ## Repository Structure
178
+
179
+ ```text
180
+ Cyberbully/
181
+ ├── .github/
182
+ │ └── workflows/
183
+ │ └── release.yaml # Automated release & PyPI publishing workflow
184
+ ├── src/
185
+ │ └── cyberbully/ # Core Python package
186
+ │ ├── __init__.py # Package exports & convenience API
187
+ │ ├── __main__.py # python -m cyberbully entrypoint
188
+ │ ├── cli.py # Command-line interface
189
+ │ ├── detector.py # CyberbullyingDetector engine
190
+ │ ├── downloader.py # Model downloader & cache management
191
+ │ ├── model.py # PyTorch MultiTaskClassifier architecture
192
+ │ └── preprocessing.py # Adversarial & social media text cleaner
193
+ ├── models/
194
+ │ └── cyberbully_v0.1_run/ # Trained PyTorch model, tokenizer, and config
195
+ ├── tests/
196
+ │ ├── test_detector.py # Pytest suite for model inference
197
+ │ └── test_preprocessing.py # Unit tests for text normalization
198
+ ├── LICENSE # MIT License
199
+ ├── MANIFEST.in # Packaging exclusions
200
+ ├── pyproject.toml # Modern PEP 621 / setuptools packaging
201
+ ├── requirements.txt # Environment dependencies
202
+ └── README.md # Documentation
203
+ ```
204
+
205
+ ---
206
+
207
+ ## License
208
+
209
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,62 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "kea-cyberbully"
7
+ version = "0.1.0"
8
+
9
+ description = "Production-grade cyberbullying detection powered by transformer classifiers and nuance-aware multi-task learning."
10
+ readme = "README.md"
11
+ requires-python = ">=3.9"
12
+ license = "MIT"
13
+ keywords = ["cyberbullying", "nlp", "transformers", "pytorch", "toxicity", "moderation", "deep-learning"]
14
+ authors = [
15
+ { name = "KEA MINDZ" }
16
+ ]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "Intended Audience :: Science/Research",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
28
+ "Topic :: Text Processing :: Linguistic",
29
+ ]
30
+ dependencies = [
31
+ "torch>=2.0.0",
32
+ "transformers>=4.30.0",
33
+ "numpy>=1.20.0",
34
+ "demoji>=1.1.0",
35
+ "gdown>=5.0.0",
36
+ "tqdm>=4.60.0",
37
+ ]
38
+
39
+ [project.optional-dependencies]
40
+ eval = [
41
+ "scikit-learn>=1.0.0",
42
+ "matplotlib>=3.5.0",
43
+ "pandas>=1.4.0",
44
+ ]
45
+ dev = [
46
+ "pytest>=7.0.0",
47
+ "flake8>=6.0.0",
48
+ ]
49
+
50
+ [project.scripts]
51
+ cyberbully = "cyberbully.cli:main"
52
+ kea-cyberbully = "cyberbully.cli:main"
53
+
54
+
55
+ [project.urls]
56
+ Homepage = "https://github.com/KEA-Mindz/Cyberbully"
57
+ Repository = "https://github.com/KEA-Mindz/Cyberbully"
58
+
59
+
60
+ [tool.setuptools.packages.find]
61
+ where = ["src"]
62
+ include = ["cyberbully*"]
@@ -0,0 +1,33 @@
1
+
2
+
3
+ gdown
4
+ seaborn
5
+
6
+
7
+
8
+
9
+
10
+ # ============================================================
11
+ # Cyberbullying Detection - DistilBERT fine-tuning pipeline
12
+ # Install with: pip install -r requirements.txt
13
+ # ============================================================
14
+
15
+ # --- core deep learning ---
16
+ torch>=2.1.0 # if you have an NVIDIA GPU, instead install the CUDA build from
17
+ # https://pytorch.org/get-started/locally/ (pick your CUDA version)
18
+ transformers>=4.38.0 # AutoTokenizer / AutoModel / get_linear_schedule_with_warmup
19
+
20
+ # --- data + metrics ---
21
+ pandas>=2.0.0
22
+ numpy>=1.24.0
23
+ scikit-learn>=1.3.0 # StratifiedGroupKFold, F1/precision/recall/ROC-AUC/PR-AUC
24
+
25
+ # --- utilities used by the script ---
26
+ tqdm>=4.66.0 # progress bars + ETA during training/eval
27
+ demoji>=1.1.0 # emoji -> text description (optional but recommended, script
28
+ # auto-detects if missing and just skips emoji handling)
29
+ matplotlib>=3.7.0 # confusion_matrix.png and training_history.png
30
+
31
+ # --- only needed if you switch --model to a deberta-v3 checkpoint ---
32
+ # sentencepiece>=0.1.99
33
+ # tiktoken>=0.5.0
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,70 @@
1
+ """Cyberbully: Production-ready Cyberbullying Text Detection package.
2
+
3
+ Detects cyberbullying, toxic harassment, threats, and subtle mockery with
4
+ adversarial leetspeak and nuance robustness.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any, Sequence
10
+
11
+ from cyberbully.detector import CyberbullyingDetector, PredictionResult
12
+ from cyberbully.downloader import download_model
13
+ from cyberbully.preprocessing import clean_text
14
+
15
+ __version__ = "0.1.0"
16
+ __all__ = [
17
+ "CyberbullyingDetector",
18
+ "PredictionResult",
19
+ "clean_text",
20
+ "download_model",
21
+ "predict",
22
+ "is_cyberbullying",
23
+ "explain",
24
+ "__version__",
25
+ ]
26
+
27
+ _DEFAULT_DETECTOR: CyberbullyingDetector | None = None
28
+
29
+
30
+ def get_default_detector() -> CyberbullyingDetector:
31
+ """Retrieve or lazily initialize the shared global detector instance."""
32
+ global _DEFAULT_DETECTOR
33
+ if _DEFAULT_DETECTOR is None:
34
+ _DEFAULT_DETECTOR = CyberbullyingDetector()
35
+ return _DEFAULT_DETECTOR
36
+
37
+
38
+ def predict(
39
+ texts: str | Sequence[str],
40
+ threshold: float | None = None,
41
+ batch_size: int = 32,
42
+ ) -> PredictionResult | list[PredictionResult]:
43
+ """Classify text using the default detector instance.
44
+
45
+ Example:
46
+ >>> import cyberbully
47
+ >>> res = cyberbully.predict("you are awesome!")
48
+ >>> print(res.label)
49
+ 'not_cyberbullying'
50
+ """
51
+ detector = get_default_detector()
52
+ return detector.predict(texts, threshold=threshold, batch_size=batch_size)
53
+
54
+
55
+ def is_cyberbullying(text: str, threshold: float | None = None) -> bool:
56
+ """Check if a text is cyberbullying using the default detector instance.
57
+
58
+ Example:
59
+ >>> import cyberbully
60
+ >>> cyberbully.is_cyberbullying("you are so ugly")
61
+ True
62
+ """
63
+ detector = get_default_detector()
64
+ return detector.is_cyberbullying(text, threshold=threshold)
65
+
66
+
67
+ def explain(text: str, threshold: float | None = None) -> dict[str, Any]:
68
+ """Generate detailed breakdown and top category scores for a text."""
69
+ detector = get_default_detector()
70
+ return detector.explain(text, threshold=threshold)
@@ -0,0 +1,7 @@
1
+ """Module entry point for python -m cyberbully."""
2
+
3
+ import sys
4
+ from cyberbully.cli import main
5
+
6
+ if __name__ == "__main__":
7
+ sys.exit(main())