https://github.com/zoumas/bookbot-py
Boot.dev's Build a Bookbot in Python
https://github.com/zoumas/bookbot-py
cli python3 text-processing
Last synced: about 1 month ago
JSON representation
Boot.dev's Build a Bookbot in Python
- Host: GitHub
- URL: https://github.com/zoumas/bookbot-py
- Owner: zoumas
- Created: 2026-04-17T12:33:35.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-04-17T14:26:02.000Z (3 months ago)
- Last Synced: 2026-04-17T15:42:48.254Z (3 months ago)
- Topics: cli, python3, text-processing
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BookBot
BookBot is a CLI program that reads a book (plain text file) and prints a statistical report of word and character usage.
This is a guided project from [Boot.dev](https://www.boot.dev).
## Usage
```sh
python3 main.py
```
### Example
```sh
python3 main.py books/frankenstein.txt
```
```
============ BOOKBOT ============
Analyzing book found at books/frankenstein.txt...
----------- Word Count ----------
Found 77986 total words
--------- Character Count -------
e: 46043
t: 30365
a: 26743
o: 25225
i: 24613
n: 24367
...
============= END ===============
```
Books are stored as `.txt` files in the `books/` directory (git-ignored).
## Project Structure
```
├── main.py # Entry point — reads the book, runs analysis, prints report
├── stats.py # Pure functions for word and character counting
└── books/ # Plain text book files (not committed)
```
## What I Learned
- **Reading files** — Opening and reading text files with Python's built-in `open()`.
- **String manipulation** — Splitting text into words, lowercasing, and iterating over characters.
- **Dictionaries** — Building frequency maps with `dict.get()` for default values.
- **Sorting** — Sorting dictionary items by value using `sorted()` with a `key` lambda.
- **Functions** — Breaking logic into small, reusable, well-typed functions across modules.
- **CLI arguments** — Using `sys.argv` to accept file paths from the command line.
- **Project structure** — Separating concerns across files and using `.gitignore` to keep data out of version control.