in tpipelinegeofinder/textractgeofinder/tgeofinder.py [0:0]
def get_TWord_from_TBlock(self, block: t2.TBlock) -> TWord:
bbox_width = block.geometry.bounding_box.width
bbox_height = block.geometry.bounding_box.height
bbox_left = block.geometry.bounding_box.left
bbox_top = block.geometry.bounding_box.top
x_min = round(bbox_left * self.doc_width)
y_min = round(bbox_top * self.doc_height)
x_max = round(x_min + (bbox_width * self.doc_width))
y_max = round(y_min + (bbox_height * self.doc_height))
page_number = block.page if block.page else 1
if block.text:
text = make_alphanum_and_lower_for_non_numbers(block.text)
original_text = block.text
elif block.selection_status:
text = block.selection_status
original_text = block.selection_status
else:
text = ""
original_text = ""
return TWord(text=text,
original_text=original_text,
confidence=block.confidence,
id=block.id,
text_type=block.block_type,
ymin=y_min,
xmin=x_min,
ymax=y_max,
xmax=x_max,
page_number=page_number,
doc_width=self.doc_width,
doc_height=self.doc_height)