Skip to content

Conversation

@mawelborn
Copy link
Contributor

@mawelborn mawelborn commented Nov 22, 2024

An initial implementation of ETL Output Dataclasses for working with OCR text, tokens, and tables that fits nicely with Result File Dataclasses. Supports loading both result file v1 and v3 and ReadAPI v2 and v3 submission ETL Output via sync and async reader functions.

def read_url(url: str) -> object:
   return client.call(RetrieveStorageObject(url))

result = results.load(submission.result_file, reader=read_url)
etl_outputs = {
   document: etloutput.load(document.etl_output_url, reader=read_url, tables=True)
   for document in result.documents
}

extraction = result.predictions.document_extractions[0]
etl_output = etl_outputs[extraction.document]
token = etl_output.token_for(extraction)
table, cell = etl_output.table_cell_for(token)

@mawelborn mawelborn merged commit befb3d8 into main Dec 20, 2024
5 checks passed
@mawelborn mawelborn deleted the mawelborn/etloutput-dataclasses branch December 20, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant