pycognaize.document.tag.extraction_tag.ExtractionTag

class ExtractionTag(left, right, top, bottom, page, raw_value, raw_ocr_value, confidence=None)[source]

Bases: BoxTag

Represents field’s coordinate data on document

Parameters:

confidence (Confidence)

Methods

construct_from_raw

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:

distance

Return the Euclidean distance of two tag centers

get_top_left

get_width_height

horizontal_shift

hshift

Shifts rectangle horizontally

intersects

Checks id there is an intersection between this and other rectangle

iou

Calculate Intersection over Union for given rectangles

is_in_rectangle

Check if the rectangle is in the other rectangle

set_class_confidence

shift

Shifts rectangle by 2 axes simultaneously

to_dict

Converts extraction tag to dict

vertical_shift

vshift

Shifts rectangle vertically :type by: :param by: the amount by which the tag should be vertically shifted :rtype: ExtractionTag :return: shifted rectangle

Attributes

area

Area of the rectangle

bottom

center

Center point of the rectangle

confidence

height

Height of the rectangle

left

page

raw_ocr_value

raw_value

right

top

width

Width of the rectangle

xcenter

Center of horizontal line of the rectangle

ycenter

Center of vertical line of the rectangle

__add__(other)[source]

Merge two rectangles into one

Parameters:

other (Union[BoxTag, Cell])

Return type:

ExtractionTag

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:

ExtractionTag

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:

ExtractionTag

Returns:

shifted rectangle

intersects(other)

Checks id there is an intersection between this and other rectangle

Parameters:

other (Union[BoxTag, Cell]) – Rectangle object

Return type:

bool

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 object

  • thresh (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:

BoxTag

Returns:

shifted rectangle

to_dict()[source]

Converts extraction tag to dict

Return type:

dict

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:

ExtractionTag

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