Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

fix: Add handling for documents missing all layout elements. - #161

Merged
holtskinner merged 4 commits into
mainfrom
hocr-index-fix
Sep 5, 2023
Merged

fix: Add handling for documents missing all layout elements.#161
holtskinner merged 4 commits into
mainfrom
hocr-index-fix

Conversation

@holtskinner

Copy link
Copy Markdown
Contributor
  • Bounding boxes for empty elements will show up in output as 0,0,0,0

Fixes #160 🦕

- Bounding boxes will show up as 0,0,0,0
- Fixes #160
@holtskinner
holtskinner requested review from a team September 1, 2023 17:06
@product-auto-label product-auto-label Bot added the size: s Pull request size is small. label Sep 1, 2023
Comment thread google/cloud/documentai_toolbox/utilities/docai_utilities.py Outdated
return 0, 0, 0, 0

top, left = vertices[0]
bottom, right = vertices[2]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR, this vertices[0] could result in an IndexError, also it is still unclear what happens to vertices[1]. I would suggest eventually restructure and improve the code here (not blocking this PR). We also seem to be assuming that bounding_poly is always a bounding box (as opposed to more general polygons) - do we know that the service always returns boxes?

Additionally, if the utility function needs only bounding_poly.normalized_vertices, it should receive just a list of normalized vertices and not the whole bounding_poly.

@holtskinner
holtskinner merged commit 1ac6f5e into main Sep 5, 2023
@holtskinner
holtskinner deleted the hocr-index-fix branch September 5, 2023 17:54
holtskinner added a commit that referenced this pull request Oct 3, 2023
- Should resolve customer reported issue in support case #47169701 relating to duplicate/inaccurate elements in hOCR output
- Followup to:
  - #161
  - #169
holtskinner added a commit that referenced this pull request Oct 3, 2023
- Should resolve customer reported issue in support case #47169701 relating to duplicate/inaccurate elements in hOCR output
- Followup to:
  - #161
  - #169
holtskinner added a commit that referenced this pull request Oct 6, 2023
* fix: `docai_utilities.py` to return `Optional`

- Should resolve customer reported issue in support case #47169701 relating to duplicate/inaccurate elements in hOCR output
- Followup to:
  - #161
  - #169

* Increase test coverage

* Addressed review comments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blank Documents cause hOCR export to fail

3 participants