pycognaize.document.tag.table_tag.TableTag
- class TableTag(left, right, top, bottom, page, cell_data)[source]
Bases:
BoxTag
Base class for all pycognaize table fields
- Parameters:
page (
Page
)cell_data (
dict
)
Methods
Build Field from pycognaize raw data
Return the Euclidean distance of two tag centers
get_top_left
get_width_height
Shifts rectangle horizontally
Checks id there is an intersection between this and other rectangle
Calculate Intersection over Union for given rectangles
Check if the rectangle is in the other rectangle
Convert excel style coordinates into zero index coordinate
set_class_confidence
Shifts rectangle by 2 axes simultaneously
Return the letters and numbers of the Excel coordinate as a tuple.
Converts table tag to dict
Returns a string representation of the table
Shifts rectangle vertically
Attributes
Area of the rectangle
bottom
cell_data
cells
Center point of the rectangle
confidence
df
Height of the rectangle
left
page
raw_df
right
top
Width of the rectangle
Center of horizontal line of the rectangle
Center of vertical line of the rectangle
- __add__(other)
Merge two rectangles into one
- property area: float
Area of the rectangle
- property center: Tuple[float, float]
Center point of the rectangle
- distance(other)
Return the Euclidean distance of two tag centers
- Parameters:
other (
BoxTag
)- Return type:
Union
[int
,float
]
- property height: int | float
Height of the rectangle
- hshift(by)
Shifts rectangle horizontally
- Parameters:
by – the amount by which the tag should be horizontally shifted
- Return type:
- Returns:
shifted rectangle
- intersects(other)
Checks id there is an intersection between this and other rectangle
- iou(other)
Calculate Intersection over Union for given rectangles
- Return type:
Union
[int
,float
]
- is_in_rectangle(other, thresh)
Check if the rectangle is in the other rectangle
- Parameters:
other (
BoxTag
) – Another rectangle objectthresh (
float
) – If the fraction area of the rectangle is in the other rectangle is larger or equal to thresh, it is in the other rectangle
- Return type:
bool
- Returns:
True if rectangle is in other rectangle, False otherwise
- letter_2_num(letters)[source]
Convert excel style coordinates into zero index coordinate
- Return type:
int
- shift(horizontal, vertical)
Shifts rectangle by 2 axes simultaneously
- Parameters:
horizontal
vertical
- Return type:
- Returns:
shifted rectangle
- static split_excel_letters_numbers(str_coord)[source]
Return the letters and numbers of the Excel coordinate as a tuple. If the string is not a valid Excel coordinate, return None
- Parameters:
str_coord (
str
)- Return type:
Optional
[Tuple
[str
,int
]]
- vshift(by)
Shifts rectangle vertically
- Parameters:
by – the amount by which the tag should be vertically shifted
- Return type:
- Returns:
shifted rectangle
- property width: int | float
Width of the rectangle
- property xcenter: float
Center of horizontal line of the rectangle
- property ycenter: float
Center of vertical line of the rectangle