Skip to content

AarontheGalaxy/python-text-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 Text Analysis Application

A Python-based text processing program with dual implementation modes (Functional & OOP)

Python License Status GitHub


📋 Project Description

This Text Analysis Application is a Python-based tool that analyzes blocks of text and produces useful statistics including word counts, character counts, sentence detection, and word frequency analysis with visualization.

Key Highlights

  • Two Implementation Versions in a single file
  • Modern GUI with drag-and-drop support
  • Data Visualization using matplotlib
  • Multi-format file support (TXT, PDF, DOCX, RTF)

🎯 Features

Input Options

Option Description
Type/Paste Enter text directly into the text area
Browse File Load text from .txt, .pdf, .docx, .rtf files
Drag & Drop Drop files directly onto the application window

Text Processing

  • Character Count (with and without spaces)
  • Word Count (punctuation ignored)
  • Sentence Count (based on ., !, ?)
  • Paragraph Count (separated by empty lines)
  • Unique Word Frequency Analysis

Visualization

  • Bar chart showing:
    • Total Words
    • Total Sentences
    • Total Paragraphs
    • Total Unique Words
  • Top 10 Most Common Words display

🔧 Implementation

Version 1: Functional/Modular

# Standalone functions for each operation
count_characters_with_spaces(text_lines)
count_characters_without_spaces(text_lines)
count_words(text_lines)
count_sentences(text_lines)
count_paragraphs(text_lines)
analyze_word_frequency(text_lines)
get_text_statistics_functional(text_lines)  # Main function

Version 2: Object-Oriented (TextAnalyzer Class)

class TextAnalyzer:
    def __init__(self, text_lines):
        self.text_lines = text_lines
        self.stats = {}
        self.word_freq = {}

    def count_characters_with_spaces(self)
    def count_characters_without_spaces(self)
    def count_words(self)
    def count_sentences(self)
    def count_paragraphs(self)
    def analyze_word_frequency(self)
    def calculate_statistics(self)  # Main method

📦 Installation

Requirements

  • Python 3.x
  • tkinter (usually included with Python)

Install Dependencies

pip install matplotlib

Optional Dependencies (for additional file formats)

pip install python-docx    # For .docx files
pip install PyPDF2         # For .pdf files
pip install striprtf       # For .rtf files
pip install tkinterdnd2    # For drag-and-drop support

🚀 Usage

Run the Application

python text_analyzer.py

Steps

  1. Enter text by typing, pasting, or loading a file
  2. Select analysis method: Functional or OOP
  3. Click "Analyze Text" button
  4. View results in the results area and visualization window

Output Format

Total characters (with spaces): x
Total characters (without spaces): y
Total words: z
Total sentences: k
Total paragraphs: s

Top 10 Most Common Words:
Word : Frequency

📁 Project Structure

python-text-analyzer/
├── text_analyzer.py            # Main application (all code in one file)
├── README.md                   # Project documentation
├── requirements.txt            # Python dependencies
├── sample.txt                  # Sample text for testing
├── LICENSE                     # MIT License
└── .gitignore                  # Git ignore rules

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

👨‍💻 Author

AarontheGalaxy
GitHub

🔗 GitHub Profile: https://github.com/AarontheGalaxy


📄 License

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


🐢

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages