ontocast.tool.chunk.segment¶
Mutable text segments during chunk preparation (before sizing).
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
PrepareSegment
dataclass
¶
One logical segment prior to min/max sizing.
section_label_source records how the label was decided. It is load
bearing, not bookkeeping: forward-fill refuses to overwrite a segment whose
section is explicitly unresolved, which is what stops a neighbouring label
from being smeared across an unrecognised section.
Source code in ontocast/tool/chunk/segment.py
Attributes¶
doc_item_refs = ()
class-attribute
instance-attribute
¶
headings = None
class-attribute
instance-attribute
¶
section_label = None
class-attribute
instance-attribute
¶
section_label_confidence = 0.0
class-attribute
instance-attribute
¶
section_label_source = None
class-attribute
instance-attribute
¶
text
instance-attribute
¶
Methods:¶
__init__(text, headings=None, doc_item_refs=(), section_label=None, section_label_source=None, section_label_confidence=0.0)
¶
Functions:¶
coalesce_small_segments_right(segments, min_chars, schema)
¶
Merge undersized segments into the right neighbor; otherwise into the left.
Source code in ontocast/tool/chunk/segment.py
is_abstract_exempt(segment, schema)
¶
Preserve short abstract segments instead of merging them into neighbors.
Source code in ontocast/tool/chunk/segment.py
merge_doc_item_refs(left, right)
¶
Source code in ontocast/tool/chunk/segment.py
merge_into_left(left, right)
¶
Source code in ontocast/tool/chunk/segment.py
merge_into_right(left, right)
¶
Source code in ontocast/tool/chunk/segment.py
segments_differ_in_structure(left, right, schema)
¶
True when merging would join distinct document sections.
Source code in ontocast/tool/chunk/segment.py
starts_with_section_heading(segment, schema)
¶
True when the segment opens with a recognised section heading line.