A Python-based text processing program with dual implementation modes (Functional & OOP)
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.
- ✅ 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)
| 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 |
- Character Count (with and without spaces)
- Word Count (punctuation ignored)
- Sentence Count (based on
.,!,?) - Paragraph Count (separated by empty lines)
- Unique Word Frequency Analysis
- Bar chart showing:
- Total Words
- Total Sentences
- Total Paragraphs
- Total Unique Words
- Top 10 Most Common Words display
# 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 functionclass 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- Python 3.x
- tkinter (usually included with Python)
pip install matplotlibpip 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 supportpython text_analyzer.py- Enter text by typing, pasting, or loading a file
- Select analysis method: Functional or OOP
- Click "Analyze Text" button
- View results in the results area and visualization window
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
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
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
🔗 GitHub Profile: https://github.com/AarontheGalaxy
This project is licensed under the MIT License - see the LICENSE file for details.
🐢