aws-samples / aws-samples/amazon-textract-textractor

page number is overwritten in function find_phrase_in_lines

Open
#94 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
493
Forks
163
PR merge metrics
No merged PRs in 30d

Description

The page number is overwritten if you pass it to the function within the for loop.
Plus the page number is not considered as search criteria.

[Source Code Snipped from line 1091ff](https://github.com/aws-samples/amazon-textract-textractor/blob/master/tpipelinegeofinder/textractgeofinder/tgeofinder.py)

```
def find_phrase_in_lines(
self, phrase: str, min_textdistance=0.6, page_number: int = 1
) -> List[TWord]:
"""
phrase = words seperated by space char
"""
# first check if we already did find this phrase and stored it in the DB
# TODO: Problem: it will not find Current: when the phrase has current and there are other current values in the document without :
if not phrase:
raise ValueError(f"no valid phrase: '{phrase}")
phrase_words = phrase.split(" ")
if len(phrase_words) < 1:
raise ValueError(f"no valid phrase: '{phrase}")
# TODO: check for page_number impl
found_phrases: "list[TWord]" = self.ocrdb.select_text(
textract_doc_uuid=self.textract_doc_uuid,
text=make_alphanum_and_lower_for_non_numbers(phrase),
)
print("after ocrdb.select_text")
if found_phrases:
print("phrases found")
return found_phrases

alphanum_regex = re.compile(r"[\W_]+")
# find phrase (words that follow each other) in trp lines
for page in self.doc.pages:
page_number = 1
for line in page.lines:
......
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.