Skip to main content

Processing Pipelines

Importing a script runs a four-stage pipeline that turns raw PDF bytes into a structured show.

PDF bytes
│
▼
[1] Ingest (crates/ocr) extract_text() ── native text layer, else OCR
│ plain text, one line per source line
▼
[2] Classify (crates/classify) classify_line() ── Heading / StageDirection / Dialog / Noise
│ Vec<ClassifiedLine>
▼
[3] Construct (crates/show) construct_show() ── build Section/Cue tree
│ Show (raw)
▼
[4] Filter (crates/show) filter_show() ── drop noise & empty sections
│
▼
Show

show::pipeline::build_show_from_text runs stages 2–4; import_pdf_show runs stage 1 and then calls it.

Stage responsibilities​

StageCrate / fileDoes
Ingestocr/src/pipeline.rsPDF → text. Detects native text; else renders + OCRs.
Classifyclassify/src/rules.rsEach line → a LineKind (and headings → HeadingKind).
Constructshow/src/pipeline.rsAssembles classified lines into acts/scenes/cues.
Filtershow/src/filter.rsRemoves noise cues and (optionally) empty sections.

Why the stages are separate​

Each stage has a single responsibility and is independently testable:

  • Ingest only gets text out of the document. It never interprets structure.
  • Classify is a pure function from line to label, so the rules can be refined and unit-tested without touching tree-building.
  • Construct follows structural rules and can be tested with synthetic classified input.
  • Filter is a cleanup pass that can be relaxed or extended without disturbing construction.

Continue with OCR ingest, Classify, and Construct & filter.