How xiebingqiang/glossbook works
glossbook turns an EPUB into a language-learning edition: the CLI reads and selects chapters, generates or reuses translations and annotations, then renders them into an EPUB with ruby glosses, popup notes, and optional chapter guides. Preview, cache-only rebuild, inspection, and usage reporting are additional user workflows. The sampled excerpts show key boundaries; some CLI-to-module wiring and unsampled feature implementations are represented only where the README or module descriptions support them.
Main entry points: cli.py CLI commands · pipeline.py Generation pipeline · render.py Notes and ruby rendering · llm.py Model client
Components 20
Command interface
- CLI commands
glossbook/cli.py - Settings and models
glossbook/config.py
EPUB analysis
- EPUB loader
glossbook/epub.py - Chapter selection
glossbook/chapters.py - Language detection
glossbook/detect.py - Text segmentation
glossbook/segment.py
Annotation generation
- Generation pipeline
glossbook/pipeline.py - Annotation prompts
glossbook/prompt.py - Model client
glossbook/llm.py - Request cache
glossbook/pipeline.py - Usage and estimates
glossbook/usage.py - Gloss matching
glossbook/match.py
Preview and publishing
- Gloss placement
glossbook/placement.py - XHTML text editing
glossbook/textnodes.py - Notes and ruby rendering
glossbook/render.py - Interactive HTML preview
glossbook/preview.py - EPUB packaging
glossbook/package.py
Other components
- Reader
- OpenAI-compatible API
- Annotated EPUB
Connections 25
- Reader → CLI commands: runs commands
- CLI commands → Settings and models: loads settings
- CLI commands → EPUB loader: opens book
- CLI commands → Chapter selection: selects chapters
- CLI commands → Language detection: checks language
- EPUB loader → Chapter selection: provides book structure
- CLI commands → Generation pipeline: runs generation
- Generation pipeline → Text segmentation: splits text
- Generation pipeline → Annotation prompts: builds requests
- Generation pipeline → Request cache: reads and writes
- Generation pipeline → Model client: dispatches requests
- Model client → OpenAI-compatible API: sends completions
- Generation pipeline → Gloss matching: validates glosses
- Model client → Usage and estimates: records usage
- CLI commands → Usage and estimates: estimates and reports
- CLI commands → Gloss placement: prepares glosses
- Gloss placement → Gloss matching: matches expressions
- CLI commands → Notes and ruby rendering: renders annotations
- Notes and ruby rendering → Gloss placement: uses placements
- Notes and ruby rendering → XHTML text editing: edits XHTML
- CLI commands → Interactive HTML preview: builds preview
- Interactive HTML preview → Notes and ruby rendering: renders variants
- CLI commands → EPUB packaging: writes book
- EPUB packaging → Annotated EPUB: creates EPUB
- Reader → Annotated EPUB: reads edition