This project analyzes social media comments from CSV files to detect possible cyberbullying. It uses text preprocessing and sentiment analysis to classify comments as negative, neutral, or positive, and flags cases with a high proportion of negative comments.
- Data Input: Loads comment data from CSV files (e.g.,
twitter_data.csv,twitter100_data.csv,ytcomments100list.csv). - Preprocessing: Cleans comments (lowercasing, removing punctuation & stopwords) via NLTK in
text_preprocessor.py. - Detection: Uses TextBlob for sentiment polarity → classifies as negative, neutral, positive → compares proportion of negative comments to a threshold (15% or 40%).
- Outputs: Prints summary stats, logs to
log.csvandalert_log.csv, and saves processed data inprocessed_comments.csv.
- Alert Logging: Logs alerts to
alert_log.csvand general logs tolog.csv. - Visualization: Uses Matplotlib & Seaborn (
textwm.py,unlabelledmtb.py). - Email Notifications: Sends alerts when cyberbullying is detected (
textwm.py). - Accuracy Calculation: Compares predicted sentiment to true labels (
mtb.py).
- Secure email credentials.
- Configurable thresholds (via config file or CLI).
- Better modularization (functions/classes).
- Add unit tests.
- Support more platforms/data formats.
- Upgrade to ML-based models.
- Install dependencies:
pip install -r requirements.txt
- Download NLTK resources (done automatically, but you can run manually):
import nltk nltk.download('stopwords') nltk.download('punkt')
- Place your CSV data file (e.g.,
twitter_data.csv) in the project folder. - Run the main script:
python mtb.py # or python textwm.py - Check the console output for summary and alerts.
- View logs in
log.csvandalert_log.csv. - If using
textwm.py, check your email for notifications and view the sentiment plot.
- Uses rule-based (TextBlob) and threshold-based detection.
- Automated alerting via email.
- Visualization for quick insight.
- Modular preprocessing for text cleaning.
Feel free to contribute or suggest improvements!
This project is licensed under the MIT License.
Copyright © 2025 Kona Shiny Phoenix.