Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETL Output Dataclasses #205

Merged
merged 6 commits into from
Dec 20, 2024
Merged

ETL Output Dataclasses #205

merged 6 commits into from
Dec 20, 2024

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
9 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