Repository navigation
Fix get_cells_by_type returning only COLUMN_HEADER cells - #457
Merged
Merged
Conversation
TableCell._update_response_metadata compared the Textract EntityTypes against incorrect string literals for every type except COLUMN_HEADER: 'SECTION_TITLE', 'SUMMARY_CELL', 'FLOATING_TITLE' and 'FLOATING_FOOTER'. Textract actually emits 'TABLE_SECTION_TITLE', 'TABLE_SUMMARY', 'TABLE_TITLE' and 'TABLE_FOOTER' (the same strings the response parser already uses to set is_section_title / is_summary / is_title / is_footer on the cell). As a result the isSectionTitleCell / isSummaryCell / isTitleCell / isFooterCell metadata flags were always False and Table.get_cells_by_type() returned an empty result for those four types. Use the shared constants (TABLE_SECTION_TITLE, TABLE_SUMMARY, TABLE_TITLE, TABLE_FOOTER, TABLE_COLUMN_HEADER, MERGED_CELL) instead of raw literals so the comparison stays consistent with the parser and cannot drift again. Also update the now-inaccurate get_cells_by_type docstring which claimed only COLUMN_HEADER was supported. NOTE: this changes observable output - get_cells_by_type() now returns cells for SECTION_TITLE / SUMMARY_CELL / FLOATING_TITLE / FLOATING_FOOTER where it previously returned nothing. Closes #206
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TableCell._update_response_metadata compared the Textract EntityTypes against incorrect string literals for every type except COLUMN_HEADER: 'SECTION_TITLE', 'SUMMARY_CELL', 'FLOATING_TITLE' and 'FLOATING_FOOTER'. Textract actually emits 'TABLE_SECTION_TITLE', 'TABLE_SUMMARY', 'TABLE_TITLE' and 'TABLE_FOOTER' (the same strings the response parser already uses to set is_section_title / is_summary / is_title / is_footer on the cell). As a result the isSectionTitleCell / isSummaryCell / isTitleCell / isFooterCell metadata flags were always False and Table.get_cells_by_type() returned an empty result for those four types.
Use the shared constants (TABLE_SECTION_TITLE, TABLE_SUMMARY, TABLE_TITLE, TABLE_FOOTER, TABLE_COLUMN_HEADER, MERGED_CELL) instead of raw literals so the comparison stays consistent with the parser and cannot drift again. Also update the now-inaccurate get_cells_by_type docstring which claimed only COLUMN_HEADER was supported.
NOTE: this changes observable output - get_cells_by_type() now returns cells for SECTION_TITLE / SUMMARY_CELL / FLOATING_TITLE / FLOATING_FOOTER where it previously returned nothing.
Closes #206