This class constructs content-related information of a layout element in addition to its coordinate definitions (i.e. Interval, Rectangle or Quadrilateral). Args: block (:obj:`BaseCoordElement`): The shape-specific coordinate systems that the text block belongs to.
| 1171 | |
| 1172 | @inherit_docstrings(base_class=BaseCoordElement) |
| 1173 | class TextBlock(BaseLayoutElement): |
| 1174 | """ |
| 1175 | This class constructs content-related information of a layout element in addition to its coordinate definitions |
| 1176 | (i.e. Interval, Rectangle or Quadrilateral). |
| 1177 | |
| 1178 | Args: |
| 1179 | block (:obj:`BaseCoordElement`): |
| 1180 | The shape-specific coordinate systems that the text block belongs to. |
| 1181 | text (:obj:`str`, `optional`, defaults to None): |
| 1182 | The ocr'ed text results within the boundaries of the text block. |
| 1183 | id (:obj:`int`, `optional`, defaults to `None`): |
| 1184 | The id of the text block. |
| 1185 | type (:obj:`int`, `optional`, defaults to `None`): |
| 1186 | The type of the text block. |
| 1187 | parent (:obj:`int`, `optional`, defaults to `None`): |
| 1188 | The id of the parent object. |
| 1189 | next (:obj:`int`, `optional`, defaults to `None`): |
| 1190 | The id of the next block. |
| 1191 | score (:obj:`numeric`, defaults to `None`): |
| 1192 | The prediction confidence of the block |
| 1193 | """ |
| 1194 | |
| 1195 | _name = "textblock" |
| 1196 | _features = ["text", "id", "type", "parent", "next", "score"] |
| 1197 | |
| 1198 | def __init__( |
| 1199 | self, block, text=None, id=None, type=None, parent=None, next=None, score=None |
| 1200 | ): |
| 1201 | |
| 1202 | assert isinstance(block, BaseCoordElement) |
| 1203 | self.block = block |
| 1204 | |
| 1205 | self.text = text |
| 1206 | self.id = id |
| 1207 | self.type = type |
| 1208 | self.parent = parent |
| 1209 | self.next = next |
| 1210 | self.score = score |
| 1211 | |
| 1212 | @property |
| 1213 | def height(self): |
| 1214 | """ |
| 1215 | Return the height of the shape-specific block. |
| 1216 | |
| 1217 | Returns: |
| 1218 | :obj:`numeric`: Output the numeric value of the height. |
| 1219 | """ |
| 1220 | |
| 1221 | return self.block.height |
| 1222 | |
| 1223 | @property |
| 1224 | def width(self): |
| 1225 | """ |
| 1226 | Return the width of the shape-specific block. |
| 1227 | |
| 1228 | Returns: |
| 1229 | :obj:`numeric`: Output the numeric value of the width. |
| 1230 | """ |
no outgoing calls