Skip to main content

A Python package for analyzing WhatsApp group chats.

Project description

WhatsApp Chat Analyzer

Introduction

The WhatsApp Chat Analyzer is a Python project designed to parse and analyze WhatsApp chat exports. It generates detailed HTML reports for each user, providing statistics, various visualizations (like activity heatmaps, sentiment trends, word clouds), and behavioral insights based on the chat data. This tool helps users understand communication patterns, sentiment dynamics, language complexity, and more from their WhatsApp conversations.

Features

  • Group Summary Report: Generates a central index.html with group-wide statistics and links to all participant reports.
  • General Statistics:
    • Total messages, words, emojis, media files shared, and URLs.
    • Counts of edited and deleted messages.
  • Activity Analysis:
    • Activity heatmaps showing message frequency by day of the week and hour.
    • Most active hours and overall activity trends.
    • Average response time distribution.
  • Sentiment Analysis:
    • Distribution of message sentiment (positive, negative, neutral).
    • Sentiment trends over time.
    • Sentiment bubble charts (polarity vs. subjectivity).
  • Emotion Analysis:
    • Emotion trends (joy, surprise, sadness, anger, neutral) over time based on message content.
  • Language Analysis:
    • Word clouds to visualize the most frequent words.
    • Commonly used N-grams (unigrams, bigrams, trigrams).
    • Language complexity metrics (average word length, average sentence length).
    • Vocabulary diversity.
    • Part-of-Speech (POS) tagging distribution.
  • Behavioral Insights:
    • Keyword-based analysis for skills (e.g., communication, technical, leadership).
    • Detection of Hindi abusive words.
    • Generated textual insights based on analyzed traits.
  • User Relationship Graphs:
    • Network graphs visualizing interactions between users.
  • Individual HTML Reports:
    • Generates a separate, comprehensive HTML report for each user in the chat.

Installation

  1. Install the package:
    pip install whatsapp-groupchat-analyzer
    
  2. Python Version:
    • Recommended: Python 3.8 or higher.
  3. Emoji Fonts:
    • For the best display of emojis in generated reports and visualizations, it is highly recommended to have emoji-supporting fonts installed on your system. Examples include "Segoe UI Emoji" (Windows), "Apple Color Emoji" (macOS), or "Noto Color Emoji" (Linux).

How to Use

Using the Command Line Interface (CLI)

The easiest way to use the analyzer is via the built-in CLI command:

# Analyze a chat file and save reports to the 'my_reports' directory
whatsapp-analyzer path/to/chat.txt -o my_reports

# Generate reports for specific users only
whatsapp-analyzer path/to/chat.txt -o my_reports -u "John Doe" "Jane Smith"

If you haven't installed the package yet, you can also run it using:

python -m whatsapp_analyzer.run path/to/chat.txt -o my_reports

As a Python library

from whatsapp_analyzer.analyzer import WhatsAppAnalyzer

# Initialize with the path to your WhatsApp chat file and desired output directory
chat_file_path = "path/to/your/whatsapp_chat.txt" 
output_directory_path = "path/to/output_directory"

analyzer = WhatsAppAnalyzer(chat_file=chat_file_path, 
                            out_dir=output_directory_path)

# Generate reports for all users and a group summary (index.html)
analyzer.generate_report()

Anonymizing Chat Data

If you need to anonymize chat data before analysis, you can use the anonymize utility function:

from whatsapp_analyzer.utils import anonymize

anonymize("original_chat.txt", "anonymized_chat.txt")

Understanding the Output

The analyzer generates a folder containing:

  1. index.html: A central dashboard showing group-level statistics, activity heatmaps, and links to each individual's report.
  2. User_Name_report.html: Detailed reports for each participant, including:
    • Key Statistics: Tables with message counts, averages, and linguistic metrics.
    • Common Words: Most frequent n-grams and detected Hindi abuse words.
    • Visualizations: A rich set of charts (Heatmaps, Sentiment Trends, Emotion Trends, Word Clouds, etc.).
    • Behavioral Insights: Inferred traits like communication style and technical skills.

Troubleshooting/Notes

  • Emoji Display: If icons look like boxes, ensure you have an emoji-supporting font installed. The tool will attempt to use "Segoe UI Emoji", "Apple Color Emoji", or "Noto Color Emoji" if available.
  • Large Chats: Analysis of very large chat files can be memory-intensive.
  • Font Setup: On some Linux/WSL systems, matplotlib might struggle with font caches. The tool is designed to catch these errors and fallback gracefully.

Contributing

Contributions are welcome! Please follow standard fork/pull-request workflows.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

whatsapp_groupchat_analyzer-2.0.0.tar.gz (62.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whatsapp_groupchat_analyzer-2.0.0-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

Details for the file whatsapp_groupchat_analyzer-2.0.0.tar.gz.

File metadata

File hashes

Hashes for whatsapp_groupchat_analyzer-2.0.0.tar.gz
Algorithm Hash digest
SHA256 707f2e93189f02b344852e338dc81b187747d219e51aa34ef487e895d4e97a25
MD5 9137dedd8b1bf550af42cb612b4e98ec
BLAKE2b-256 b531041ec7c4a94489d15762a93dfbffb99f09a4c87a7b334c74bc41ed6d9650

See more details on using hashes here.

Provenance

The following attestation bundles were made for whatsapp_groupchat_analyzer-2.0.0.tar.gz:

Publisher: python-publish.yml on gauravmeena0708/whatsapp-analyzer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file whatsapp_groupchat_analyzer-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for whatsapp_groupchat_analyzer-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5446337db106f1b1b8bc6296660afe35a4c6de870e49d2673aed4ec7baac9a5
MD5 a2c966ba00c0dffaf9b6a8205368e1e9
BLAKE2b-256 f146606e0cd9b2edec270a4b88a592aa2a665dedd2acd78fefeac9b0fef1b99d

See more details on using hashes here.

Provenance

The following attestation bundles were made for whatsapp_groupchat_analyzer-2.0.0-py3-none-any.whl:

Publisher: python-publish.yml on gauravmeena0708/whatsapp-analyzer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page