From 2f9c04ee1078d9d44e3875d9c987db0c2ac52d36 Mon Sep 17 00:00:00 2001 From: Sanjin <102841251+duckduckgrayduck@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:18:38 -0500 Subject: [PATCH] Add conditional to sanity check coordinate values --- main.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index fcd279a..342cdc3 100644 --- a/main.py +++ b/main.py @@ -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: