Turn a public digital archive URL into a structured, browsable CSV — no manual transcription, no custom code per collection type.
Give it a URL from the Library of Congress, Internet Archive, or any institution that publishes a public IIIF manifest (CONTENTdm repositories included). It downloads the scans, OCRs them, and extracts entries into a structured CSV. Every row links back to its page in the original scan and, with the enrichment steps, to the exact line.
Built for digitized historical directories — city directories, gazetteers, trade directories — but works on just about any historical document with regular entry-like structure.

The auto-generated data explorer. Categorical facets generated from the data, full-text search, IIIF page thumbnails, and a “View in source document” deep link for every row.
Requires Python 3.11+ and uv.
uv sync # creates .venv/ and installs the `pipeline` command
source .venv/bin/activate # puts `pipeline` on your PATH (or prefix each command with `uv run`)
# One-time calibration for a new collection type — generates OCR and NER
# prompts that will work for any item with the same entry structure
pipeline ingest https://archive.org/details/ldpd_11290437_000/
pipeline calibrate https://archive.org/details/ldpd_11290437_000/
# Automated run — produces the entries CSV + browsable HTML explorer
pipeline run https://archive.org/details/ldpd_11290437_000/
# Or the human-in-the-loop version of the same run: adds page scoping,
# #xywh= bounding boxes, and interactive alignment review (needs GPU or Apple Silicon)
pipeline guided https://archive.org/details/ldpd_11290437_000/
Calibrate once, run many. pipeline calibrate is a one-time step per collection type: it opens a browser UI where you pick 4–10 representative pages, then has Gemini analyze them and write tailored OCR and extraction prompts. For any additional volume in the same series, point to the first volume’s NER prompt and skip calibration entirely:
pipeline run https://archive.org/details/ldpd_11290437_001/ \
--ner-prompt output/ldpd_11290437_000/ner_prompt.md
Requires GEMINI_API_KEY. Can run on the free tier — no billing required for collections up to ~150 pages. Flex inference (~50% cheaper API calls, 1–15 min latency per request, best-effort availability) is on by default; pass --no-flex for time-sensitive runs.
A CSV where every row is one extracted entry. Field names are driven entirely by your NER prompt — no code changes necessary for a new document or volume of the same type. An example entry from a travel guide:
| name | address | city | state | category | canvas_fragment |
|---|---|---|---|---|---|
| Mrs. Simmons Tourist Home | 418 Johnson St | Augusta | GA | Tourist Home | https://...#xywh=142,890,1240,68 |
The canvas_fragment column is a IIIF URI pointing back to the source scan. With the precision upgrade, it includes a #xywh= bounding box pinpointing the exact line. The data explorer and map use this to link directly to the highlighted entry in the original document.
Alongside the extracted data CSV, pipeline run also generates a self-contained HTML data explorer (shown above). With geocoding enabled on materials with address fields, you also get:

Markers clustered and color-coded by category. Popups include a IIIF thumbnail fetched directly from the source institution’s image server.
Two published collections built with this pipeline:
Entry detail views from the published explorers. Left: each Tulsa entry renders the exact line from the source scan via its canvas_fragment URI. Right: a Green Book establishment with its listing history across volumes.
Both explorers received additional front-end design work beyond what the pipeline generates. The pipeline produces the entry CSVs, IIIF manifests, and a baseline HTML explorer; these published sites build on that output.
uv sync # core: Gemini OCR + entry extraction
uv sync --extra gpu # add Surya OCR (GPU or Apple Silicon recommended)
uv sync --extra geo # add geocoding + map generation
uv sync --all-extras # everything
uv sync creates and manages the project’s virtual environment in .venv/ and installs the pipeline command into it — there is no environment to create yourself, and no conda. Either activate it once (source .venv/bin/activate) or prefix each command with uv run. Everything below is written in the bare form, and the same applies to the underlying python main.py … interface.
Set your API keys (or copy .env.template to .env):
export GEMINI_API_KEY=your_key_here
export GOOGLE_MAPS_API_KEY=your_key_here # optional; enables address-level geocoding
Run pipeline --help for all subcommands, and pipeline <subcommand> --help for each one’s options:
pipeline run <URL> # automated: download → OCR → extract → explore
pipeline guided <URL> # human-in-loop: page selection + alignment review
pipeline ingest <URL> # download only
pipeline calibrate <URL|DIR> # select sample pages + generate prompts (once per collection type)
pipeline ocr <DIR> # Surya OCR + Gemini OCR + align bboxes
pipeline review <DIR> # interactive alignment review (browser UI)
pipeline extract <DIR> # NER extraction + explorer
pipeline geo <DIR> # geocode entries + build map (needs address fields)
pipeline postprocess <DIR> # fix + combine volumes + rebuild explorer
Each subcommand wraps the underlying python main.py <URL> [flags] stage interface — see docs/pipeline-stages.md for the flag-level reference and every artifact each stage produces.
Beyond the subcommands:
| Goal | Command |
|---|---|
| Improve accuracy on complex layout-dependent materials | pipeline extract output/<vol>/ --mode multimodal → details |
| Review entries that could not be placed on a line | python tools/collate_review_queue.py output/<vol>/ |
| See what a run actually cost | python tools/report_cost.py output/<vol>/ |
| Export ALTO XML (Solr, IIIF Content Search) | python main.py output/<vol>/ --export-alto |
| Export W3C/IIIF annotations | python -m pipeline.iiif.export_annotations output/<vol>/ |
| Extract one section of a huge volume without downloading it all | python tools/slice_manifest.py <MANIFEST> --from-id … --to-id … --slug <slug> → details |
| Use pipeline pieces from a notebook or script | from pipeline.api import iter_canvases, … → details |
The core pipeline run path gives you a canvas URI per row. Adding Surya OCR and alignment upgrades each entry’s canvas_fragment to a #xywh= bounding box on its exact line, usable by any IIIF viewer. An entry the pipeline cannot place confidently keeps its page link and goes on the review list rather than getting a guessed box.
pipeline ocr output/<vol>/ # Surya bboxes + alignment (requires GPU or Apple Silicon)
pipeline review output/<vol>/ # optional: fix unmatched lines interactively

By default extraction sends the OCR text to Gemini. --mode multimodal also sends the page image, so the model can see section headings, column boundaries and layout cues that OCR text loses. It helps most where headings fall mid-page or reading order is ambiguous — on Green Book volumes it eliminated mid-page geographic attribution errors — and adds about $0.00006 per page (costs).
pipeline extract output/<vol>/ --mode multimodal
A single ~80-page volume costs roughly $0.30–$0.40 in Gemini API charges with --flex, about twice that at standard rates, and fits within the free tier’s daily quota (the 15 RPM limit stretches the API stages to 15–20 minutes). python tools/report_cost.py output/<vol>/ reports what a run actually spent, from the token usage each stage records. See docs/costs.md for the full breakdown, including platform costs for Surya OCR (Mac, Colab, and GPU).
extract_entries.py hard-codes nothing. The NER prompt defines all field names; CSV columns are inferred dynamically — no code changes for a new collection type.canvas_fragment URI, and placed entries a #xywh= box in natural image pixel coordinates, directly consumable by IIIF viewers and annotation tools.--iiif-csv and --download accept any public IIIF Presentation v2 or v3 manifest URL, not just LoC and IA, and IIIF Collection manifests are enumerated one child manifest per CSV row. CONTENTdm repositories work via sources/build_contentdm_manifest.py.See docs/key-design-decisions.md for full technical notes.
See docs/prior-work.md for these and other annotated citations, including the Green Books digitization the category taxonomy comes from.