File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 11[flake8]
22per-file-ignores = __init__.py:F401
3- max-line-length = 88
3+ max-line-length = 120
44exclude = test/*
55max-complexity = 25
66docstring-convention = google
Original file line number Diff line number Diff line change @@ -472,8 +472,27 @@ class SegmentedPage(BaseModel):
472472 word_cells : List [TextCell ] = []
473473 textline_cells : List [TextCell ] = []
474474
475+ # These flags are set to differentiate if above lists of this SegmentedPage
476+ # are empty (page had no content) or if they have not been computed (i.e. textline_cells may be present
477+ # but word_cells are not)
478+ has_chars : bool = False
479+ has_words : bool = False
480+ has_lines : bool = False
481+
475482 image : Optional [ImageRef ] = None
476483
484+ @model_validator (mode = "after" )
485+ def validate_page (self ) -> "SegmentedPage" :
486+ """Validate page."""
487+ if len (self .textline_cells ) > 0 :
488+ self .has_lines = True
489+ if len (self .word_cells ) > 0 :
490+ self .has_words = True
491+ if len (self .char_cells ) > 0 :
492+ self .has_chars = True
493+
494+ return self
495+
477496 def iterate_cells (self , unit_type : TextCellUnit ) -> Iterator [TextCell ]:
478497 """Iterate through text cells of the specified unit type.
479498
You can’t perform that action at this time.
0 commit comments