API Reference

Public API

pdf_jsonl_smith.extract_pdf_to_jsonl(input_path, output_path, *, source_uri=None, schema_version='0.1')[source]

Extract PDF text blocks to BigQuery-ready JSONL.

Returns the number of records written.

Parameters:
  • input_path (str | Path)

  • output_path (str | Path)

  • source_uri (str | None)

  • schema_version (str)

Return type:

int

Modules

pdf_jsonl_smith.extractor.extract_pdf_to_jsonl(input_path, output_path, *, source_uri=None, schema_version='0.1')[source]

Extract PDF text blocks to BigQuery-ready JSONL.

Returns the number of records written.

Parameters:
  • input_path (str | Path)

  • output_path (str | Path)

  • source_uri (str | None)

  • schema_version (str)

Return type:

int

pdf_jsonl_smith.extractor.iter_text_unit_records(*, input_path, source_uri=None, schema_version='0.1')[source]

Yield one flat record for each merged text unit.

Parameters:
  • input_path (str | Path)

  • source_uri (str | None)

  • schema_version (str)

Return type:

Iterator[dict[str, Any]]

pdf_jsonl_smith.records.is_text_unit_record(record)[source]

Return whether a mapping has the v0.1 flat record shape.

Parameters:

record (Mapping[str, Any])

Return type:

bool

pdf_jsonl_smith.records.make_text_unit_record(*, schema_version, doc_id, source_uri, filename, page_number, unit_index, text, bbox, extracted_at, unit_type='block', warning=None)[source]

Create one flat BigQuery-ready text unit record.

Parameters:
  • schema_version (str)

  • doc_id (str)

  • source_uri (str | None)

  • filename (str)

  • page_number (int)

  • unit_index (int)

  • text (str)

  • bbox (tuple[float, float, float, float])

  • extracted_at (str)

  • unit_type (str)

  • warning (str | None)

Return type:

dict[str, Any]

pdf_jsonl_smith.writer.write_jsonl(records, output_path)[source]

Write records as UTF-8 JSONL and return the number of lines written.

Parameters:
  • records (Iterable[Mapping[str, Any]])

  • output_path (str | Path)

Return type:

int