tetrak_ocr.outputs¶
Output formats for a finished transcript.
One transcript can be written several ways at once — Markdown for a human, plain text for a downstream tool, a searchable PDF for a catalogue — so the pipeline asks for a set of formats rather than a single one.
Every writer exposes the same callable:
write(source, transcript, destination, **options) -> None
source is the file that was transcribed, which the text formats ignore and
the PDF writer needs (it embeds the scan). options carries format-specific
settings; a writer must tolerate options meant for a different format, because
the caller passes one dict to all of them. The pipeline and the ocr
subcommand pass the same set to every writer:
page_transcripts one string per page of a multi-page document, or None
spans the backend's positioned spans for the document --
``layout.TextSpan``, pixels, top-left origin, in the
engine's own order -- or None when the backend has none
(see ``layout.Transcript`` and ``layout.spans_of``)
page_spans one such list, or None, per page, when the document was
read page by page; ``spans`` is then None
pdf_full_size the searchable PDF's own settings
pdf_font
The text writers ignore the spans. They exist for the positioned formats – ALTO, hOCR – where the coordinates are the output.
Adding a format means adding one entry to _FORMATS and nothing else: the
CLI takes its choices, its help text and its validation from this table, the
same way backends are resolved through registry.py.
Functions
|
Resolve a format name or alias, raising for anything unrecognised. |
|
Format list for --help, one per line. |
|
The file extension a format writes, including the leading dot. |
|
Turn CLI |
|
Write transcript in format name, returning the path written. |
|
Write transcript in format name to exactly destination. |