Skip to content

Commit

Permalink
Add conditional to sanity check coordinate values
Browse files Browse the repository at this point in the history
  • Loading branch information
duckduckgrayduck authored Sep 22, 2023
1 parent 5f011f2 commit 2f9c04e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,16 @@ def set_doc_text(self, document, blobs_list):

symbols_list = word["symbols"]
full_text = ''.join(symbol["text"] for symbol in symbols_list)

position_info = {
"text": full_text,
"x1": x1,
"x2": x2,
"y1": y1,
"y2": y2,
}

# Append position information to the page dictionary
page["positions"].append(position_info)
if 0 <= x1 <= 1 and 0 <= x2 <= 1 and 0 <= y1 <= 1 and 0 <= y2 <= 1:
position_info = {
"text": full_text,
"x1": x1,
"x2": x2,
"y1": y1,
"y2": y2,
}
# Append position information to the page dictionary
page["positions"].append(position_info)

pages.append(page)
except KeyError as e:
Expand Down

0 comments on commit 2f9c04e

Please sign in to comment.