aws-samples / aws-samples/aws-textract-comprehend-lex-chatbot

Lambda extract_text_from_textract_async_job_output.py where is only writing Page 1 in the output.

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
22
Forks
23
PR merge metrics
No merged PRs in 30d

Description

There's an issue within the Lambda function extract_text_from_textract_async_job_output.py where it's only writing Page 1 in the output.

Even though it fetches all pages from Textract and iterates through all the nextToken, when it saves the Python object 'pages', it only saves the content of the first page (line 27).

```python
content=pages[1]['Content']
```

https://github.com/aws-samples/aws-textract-comprehend-lex-chatbot/blob/5c8b069eae56314bc744ae85ed1ef5598296d811/src/lambda/extract_text_from_textract_async_job_output.py#L27C3-L27C32

For my purposes, I've made the following adjustment:

```python
content=json.dumps(pages, indent=4, separators=(", ", ": "), ensure_ascii=False)
```

However, this alteration pertains to a different use case, and it might not necessarily be the optimal solution for the example scenario.

Contributor guide

Open the contributing guide

Research direction

Open src/lambda/extract_text_from_textract_async_job_output.py and inspect the page collection around line 27, where only pages[1]['Content'] is saved. Trace how all Textract pages and nextToken results are assembled, then determine the output expected by this example. Done means the saved output represents the fetched pages rather than only Page 1.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.