BookBot is a command-line interface (CLI) tool that analyzes text files (like books!) to gather interesting statistics. It reports the total number of words and the frequency of each character found in the document.
This project is part of the Boot.dev guided project curriculum, specifically the "Build a BookBot in Python" course.
- Word Count Analysis: Calculates and displays the total number of words in a text file.
- Character Frequency: Counts the occurrence of every character (case-insensitive) and sorts them by frequency.
- Clean Reporting: Generates a structured report in the terminal.
To run this project, you need to have Python 3 installed on your machine.
-
Clone the repository:
git clone https://github.com/PeterNex14/bookbot.git cd bookbot(Note: Replace the URL with your actual repository URL if different)
-
Verify files: Ensure you have
main.py,stats.py, and abooks/directory (or any text file you wish to analyze).
Run the main.py script from your terminal, providing the path to the text file you want to analyze as an argument.
Command syntax:
python3 main.py <path_to_book_file>Example:
To analyze the text of Frankenstein (assuming it's located in books/frankenstein.txt):
python3 main.py books/frankenstein.txt========== BOOKBOT ==========
Analyzing book found at books/frankenstein.txt...
========== Word Count ==========
Found 75767 total words
========== Character Count ==========
e: 44594
t: 29565
a: 26038
o: 24332
...
========== END ==========
In this project, I practiced:
- Reading files in Python.
- String manipulation (splitting, lowercasing).
- Using dictionaries for frequency counting.
- Sorting lists of dictionaries.
- structuring a Python project with multiple modules (
main.pyimporting fromstats.py). - Handling command-line arguments with
sys.argv.
Built with Python as part of the Boot.dev backend learning path.