pycognaize.document.tag.extraction_tag.ExtractionTag
- class ExtractionTag(left, right, top, bottom, page, raw_value, raw_ocr_value, confidence=None)[source]
Bases:
BoxTagRepresents field’s coordinate data on document
- Parameters:
confidence (
Confidence)
Methods
Builds Tag object from pycognaize raw data :type raw:
dict:param raw: pycognaize field's tag info :type page:Page:param page: Page to which the tag belongs :rtype:ExtractionTag:return:Return the Euclidean distance of two tag centers
get_top_leftget_width_heighthorizontal_shiftShifts 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
set_class_confidenceShifts rectangle by 2 axes simultaneously
Converts extraction tag to dict
vertical_shiftShifts rectangle vertically :type by: :param by: the amount by which the tag should be vertically shifted :rtype:
ExtractionTag:return: shifted rectangleAttributes
Area of the rectangle
bottomCenter point of the rectangle
confidenceHeight of the rectangle
leftpageraw_ocr_valueraw_valuerighttopWidth of the rectangle
Center of horizontal line of the rectangle
Center of vertical line of the rectangle
- property area: float
Area of the rectangle
- property center: Tuple[float, float]
Center point of the rectangle
- classmethod construct_from_raw(raw, page)[source]
Builds Tag object from pycognaize raw data :type raw:
dict:param raw: pycognaize field’s tag info :type page:Page:param page: Page to which the tag belongs :rtype:ExtractionTag:return:- Parameters:
raw (dict)
page (Page)
- Return type:
- 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)[source]
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
- shift(horizontal, vertical)
Shifts rectangle by 2 axes simultaneously
- Parameters:
horizontal
vertical
- Return type:
- Returns:
shifted rectangle
- vshift(by)[source]
Shifts rectangle vertically :type by: :param by: the amount by which the tag should be vertically shifted :rtype:
ExtractionTag:return: shifted rectangle- Return type:
- 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