aws-samples / aws-samples/amazon-textract-textractor
Layout Linearization Duplicates text and Relegates Tables to the End
- Dominant language
- Jupyter Notebook
- Stars
- 493
- Forks
- 163
- PR merge metrics
- No merged PRs in 30d
Description
If you extract both LAYOUT and TABLEs, the tables for some reason are printed at the end of the output, rather than linearized correctly.
Related issue: https://github.com/aws-samples/amazon-textract-textractor/issues/274
My code:
`from textractor.data.text_linearization_config import TextLinearizationConfig
from textractor import Textractor
extractor = Textractor(profile_name="default")
document = extractor.analyze_document(
file_source=png_path,
features=[TextractFeatures.LAYOUT, TextractFeatures.TABLES, TextractFeatures.SIGNATURES],
save_image=True,
)
config = TextLinearizationConfig(
title_prefix="# ",
section_header_prefix="## ",
add_prefixes_and_suffixes_in_text=True,
table_tabulate_format="fancy_grid".lower(),
table_remove_column_headers=True,
)
extracted_text = document.get_text(config=config)
print(get_text_from_layout_json(textract_json=document.response, generate_markdown=True)[1])`
Contributor guide
Research direction
Reproduce the reported output with Textractor.analyze_document, TextLinearizationConfig, and document.get_text(), then compare it with get_text_from_layout_json(). Trace how layout and table blocks are ordered and emitted. Done means extracted text contains each table once and keeps tables in their layout position.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100