How spiral-edwin/patt-pdf works
PATT-PDF is a command-line PDF translation tool that replaces English text with Chinese while preserving page layout. The user workflow runs through CLI commands or the one-command run flow: plan PDF pages, estimate and confirm translation, translate with a selected backend, render replacements, run QA, then report or publish. Internally, text and OCR extraction feed grouping and keep rules; rendering uses font and decoration support. The README also documents offline/manual and pseudo backends, character limits, caching, and page selection. Some subsystem links rely on SOURCE INDEX references because their implementation excerpts were not provided.
Main entry points: render.py PDF rendering · jobs.py Job orchestration · ocr.py OCR planning · cli.py CLI commands
Components 24
User workflow
- CLI commands
src/patt_pdf/cli.py - Run workflow
src/patt_pdf/runcmd.py - Job orchestration
src/patt_pdf/jobs.py - Reports
src/patt_pdf/report.py - Page QA
src/patt_pdf/qa.py - Translation checks
src/patt_pdf/sanity.py
Translation services
- Translation memory
src/patt_pdf/tm.py - Translation backends
src/patt_pdf/backends.py
Page analysis
- Page planning
src/patt_pdf/analyze.py - Text extraction
src/patt_pdf/extract_text.py - OCR planning
src/patt_pdf/ocr.py - Text grouping
src/patt_pdf/grouping.py - Page classification
src/patt_pdf/classify.py - Keep rules
src/patt_pdf/keep.py - Plan data model
src/patt_pdf/model.py - Table analysis
src/patt_pdf/tables.py
PDF rendering
- PDF rendering
src/patt_pdf/render.py - Decoration handling
src/patt_pdf/decor.py - CJK fonts
src/patt_pdf/fonts.py - Typesetting
src/patt_pdf/typeset.py - OS environment
src/patt_pdf/osenv.py
Other components
- PDF operator
- DeepL API
- Tesseract
Connections 31
- PDF operator → CLI commands: invokes
README.md - CLI commands → Job orchestration: dispatches
src/patt_pdf/cli.py - CLI commands → Translation backends: selects
src/patt_pdf/cli.py - CLI commands → Reports: requests
src/patt_pdf/cli.py - CLI commands → Translation memory: uses
src/patt_pdf/cli.py - Run workflow → Job orchestration: orchestrates
src/patt_pdf/runcmd.py - Job orchestration → Page planning: plans pages
src/patt_pdf/jobs.py - Job orchestration → Translation backends: translates via
src/patt_pdf/jobs.py - Job orchestration → Translation memory: uses
src/patt_pdf/jobs.py - Job orchestration → PDF rendering: renders with
src/patt_pdf/jobs.py - Job orchestration → Page QA: checks output
src/patt_pdf/jobs.py - Translation backends → DeepL API: sends text
src/patt_pdf/backends.py - Page planning → Text extraction: extracts
src/patt_pdf/analyze.py - Page planning → OCR planning: plans scans
src/patt_pdf/analyze.py - Page planning → Page classification: classifies
src/patt_pdf/analyze.py - Text extraction → Text grouping: groups text
src/patt_pdf/extract_text.py - Text extraction → Keep rules: filters keeps
src/patt_pdf/extract_text.py - Text extraction → Table analysis: uses
src/patt_pdf/extract_text.py - Text extraction → Plan data model: builds plans
src/patt_pdf/extract_text.py - OCR planning → Tesseract: runs OCR
src/patt_pdf/ocr.py - OCR planning → Text grouping: groups OCR
src/patt_pdf/ocr.py - OCR planning → Keep rules: filters keeps
src/patt_pdf/ocr.py - OCR planning → Plan data model: builds plans
src/patt_pdf/ocr.py - PDF rendering → Text grouping: uses
src/patt_pdf/render.py - PDF rendering → Keep rules: restores keeps
src/patt_pdf/render.py - PDF rendering → OCR planning: uses OCR data
src/patt_pdf/render.py - PDF rendering → Decoration handling: handles decorations
src/patt_pdf/render.py - PDF rendering → CJK fonts: draws with
src/patt_pdf/render.py - PDF rendering → Typesetting: typesets text
src/patt_pdf/render.py - Decoration handling → CJK fonts: uses
src/patt_pdf/decor.py - CJK fonts → OS environment: finds fonts via
src/patt_pdf/fonts.py