- Refactor codebase into src/ (preprocessing, translation, assembly) - Add pipeline/ scripts for individual stages - Externalize configuration to config/config.yaml - Fix Cover Image preservation - Update documentation and manuals
3.6 KiB
3.6 KiB
Operation Manual & Change Log
Core Principles
- Modularity: The system is divided into three distinct phases (Preprocessing, Translation, Assembly) with clear boundaries.
- Immutability:
book_structure.jsonis generated once during preprocessing and should not be modified by subsequent steps. - Source of Truth:
manifest.jsonis the single source of truth for translations. - Idempotency: Translation steps can be retried without side effects (existing translations are preserved).
Directory Structure
pipeline/: Executable scripts for each stage.01_preprocess.py: Clean EPUB, generate structure, extract text.02_translate.py: Translate text in manifest.03_assemble.py: Apply translations and build final EPUB.
src/: Core logic modules.preprocessing/: Cleaning, extraction, profiling.translation/: LLM integration, manifest management.assembly/: Backfilling, EPUB building.common/: Shared data models and utils.
work/: Working directory for intermediate files (ignored by git).
Pipeline Usage
Step 1: Preprocessing
python pipeline/01_preprocess.py inputs/my_book.epub
Generates work/my_book/book_structure.json and manifest.json.
Step 2: Translation
python pipeline/02_translate.py --input-epub inputs/my_book.epub
Translates entries in manifest.json. ensuring .env has OPENAI_API_KEY.
Step 3: Assembly
python pipeline/03_assemble.py inputs/my_book.epub --mode bilingual
Generates output/my_book_bilingual.epub.
Configuration
System settings are managed via config/config.yaml and environment variables.
config/config.yaml
Control LLM parameters and translation behavior:
llm:
model: "gpt-3.5-turbo" # LLM Model Name
base_url: "https://api.openai.com/v1"
timeout: 60
requests_per_minute: 60 # Rate limiting
concurrent_requests: 5 # Parallel chunks
translation:
chunk_size: 4000 # Characters per chunk
Environment Variables (.env)
Security-sensitive credentials must be set here:
OPENAI_API_KEY=sk-... # Required
OPENAI_BASE_URL=... # Optional override for config
Known Issues & Troubleshooting
Missing Placeholders Warning
During assembly, you may see logs like:
WARNING - Restoration warning: missing placeholders {'1'}
This indicates that the LLM translation missed a placeholder tag (e.g. φ1φ). The system attempts to recover, but this warning is logged for review. These are usually minor and do not prevent EPUB generation.
Change Log
[2026-01-28] Bug Fixes
- Fix Cover Image: Resolved issue where book cover execution was missing in the final EPUB. Added
cover_image_idtracking inBookStructureand restored proper OPF metadata inBilingualBuilder.
[2026-01-27] Externalized Configuration
- Config: Added
config/config.yamlfor tuning parameters (LLM model, RPM, Chunk Size). - Logic:
pipeline/02_translate.pynow loads settings fromconfig.yaml. - Dependency: Added
PyYAMLtorequirements.txt.
[2026-01-27] Architecture Refactoring
- Restructured: Moved source files into
src/preprocessing,src/translation,src/assembly,src/common. - Pipeline: Created individual pipeline scripts in
pipeline/. - Refactor: Renamed
fine_grained_extractortotext_extractor,translatortotranslator_engine, etc. - Logic: Enforced 100% text coverage check in
format_extractor.py(removed 95% threshold). - Docs: Created this Operation Manual.