An AI-powered tool that generates comprehensive chapter summaries and thematic analyses for books. Supports both fiction and nonfiction works with intelligent content extraction and rolling context awareness.
- Intelligent Summarization: Generates summaries that are 10-15% of original chapter length
- Thematic Analysis: Provides character dynamics, theme exploration, and narrative analysis
- Rolling Context: Maintains story/argument continuity across chapters
- Fiction & Nonfiction Support: Automatically detects book type and adapts prompts accordingly
- Long Chapter Handling: Automatically chunks and processes lengthy chapters
- EPUB Support: Works with extracted EPUB book folders
- Clone the repository:
git clone https://github.com/pokemon918/Book_Features.git
cd Book_Features- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements.txt- Configure API key:
cp env_example.txt .env
# Edit .env and add your OpenAI API keyEdit config.py to customize:
| Setting | Default | Description |
|---|---|---|
MODEL_NAME |
gpt-4o |
OpenAI model (use gpt-4o-mini for faster/cheaper) |
TARGET_SUMMARY_RATIO |
0.13 |
Target summary length (13% of original) |
MAX_CHUNK_TOKENS |
6000 |
Token limit before chunking long chapters |
OUTPUT_DIR |
summaries |
Output folder name within each book |
python summarizer.py <book_folder>Example:
python summarizer.py the_murder_links_epubpython run_all.pyEach book should be in a folder with the following structure:
book_name_epub/
├── book.metadata # JSON with title, authors, etc.
├── 01_Chapter_Title.txt # Chapter files (sorted alphabetically)
├── 02_Chapter_Title.txt
├── ...
└── summaries/ # Generated output (created automatically)
├── 01_Chapter_Title_summary.txt
├── 02_Chapter_Title_summary.txt
└── book_context.json
The .metadata file should contain:
{
"title": "Book Title",
"authors": ["Author Name"]
}Each summary file contains:
Chapter Title
SUMMARY
[Detailed chapter summary - 10-15% of original length]
ANALYSIS
[Thematic analysis and character dynamics]
- Load Book: Reads metadata and chapter files from the book folder
- Detect Type: Identifies fiction vs nonfiction based on author/title
- For Each Chapter:
- Extract Elements: Characters, events, themes (fiction) or arguments, concepts, evidence (nonfiction)
- Generate Summary: Creates detailed summary maintaining narrative flow
- Generate Analysis: Analyzes themes and character/narrative dynamics
- Update Context: Maintains rolling context for continuity
- Save Output: Writes summaries and final book context
Book_Features/
├── summarizer.py # Main processing logic
├── prompts.py # LLM prompt templates
├── config.py # Configuration settings
├── run_all.py # Batch processing script
├── requirements.txt # Python dependencies
├── env_example.txt # API key template
└── *_epub/ # Book folders
- Python 3.10+
- OpenAI API key
- Dependencies:
openai,tiktoken,python-dotenv
MIT License