BookBot is my first Boot.dev project: a small command-line tool that analyzes a plain-text book and prints a report with the total word count and how often each letter appears.
- Python 3.9 or newer (no third-party dependencies)
python3 main.py <path_to_book>For example:
python3 main.py books/frankenstein.txtIf no path is given, the program prints usage instructions and exits with status 1.
============ BOOKBOT ============
Analyzing book found at books/frankenstein.txt...
----------- Word Count ----------
Found 75767 total words
--------- Character Count -------
e: 44538
t: 29493
a: 25894
...
============= END ===============
python3 -m unittest.
├── books/ # plain-text books to analyze
├── main.py # CLI entry point and report formatting
├── stats.py # word counting, character counting, and sorting
├── test_stats.py # unit tests for stats.py
├── LICENSE
└── README.md
get_book_textreads the file at the given path.get_num_wordscounts whitespace-separated words.get_chars_dictcounts every character, lowercased.chars_dict_to_sorted_listconverts that dict into(character, count)pairs sorted from most to least frequent.print_reportprints the report, skipping non-alphabetic characters withstr.isalpha().
The books in books/ are public-domain texts from Project Gutenberg.
Released under the MIT License.