aws-samples / aws-samples/amazon-textract-textractor
issue with ordering in extractions, markdown and gettext methods
- Dominant language
- Jupyter Notebook
- Stars
- 493
- Forks
- 163
- PR merge metrics
- No merged PRs in 30d
Description
the attached input document contains text then a table followed by some text, we want the text file to be the same as the input pdf file.

I tried extraction using different methods:
for 1.) and 2.) this is the code I am using:
`
textract_json = extractor.start_document_analysis(
file_source="s3://s3sagemakerbucket/textract_analysis/12382593_bnp_credit_facility_20m.pdf",
features=[TextractFeatures.LAYOUT, TextractFeatures.TABLES],
save_image=False,
)`
`response_textract_async = extractor.get_result(job_id=textract_json.job_id, api=Textract_API.ANALYZE)`
`markdown_text = response_textract_async.to_markdown()
`
1.) .to_markdown() method

the issue here is the two table are at the bottom.
2.) .get_text() method

in this case as well we can see the two tables are at the bottom and like we know without config parameter we wont get markdown output.
now the third is interesting
the code used for this is:
`from textractcaller.t_call import call_textract, Textract_Features`
`from textractprettyprinter.t_pretty_print import get_text_from_layout_json`
`textract_json = call_textract(input_document="s3://s3sagemakerbucket/textract_analysis/12382593_bnp_credit_facility_20m.pdf",
features=[Textract_Features.LAYOUT,Textract_Features.TABLES],)
`
3.) get_text_from_layout_json(textract_json=textract_json)
also tried with get_text_from_layout_json(textract_json=textract_json, generate_markdown = True) in both of these cases getting the same output.


the issue in using this method is like you can see, the data is getting repeated twice, also there is no markdown format present.
@Belval or anyone can you please suggest if there is anything we can do to prevent this and get the text in correct like we have in the pdf file.
Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.