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.
evidence holds every tier's vote; the label, its source and its
strength are decided from it (:func:ontocast.tool.chunk.assignment.assign).
With no evidence, a source of OUTLINE_UNRESOLVED marks a section the
outline saw but could not name.
Source code in ontocast/tool/chunk/segment.py
Attributes¶
evidence = field(default_factory=list)
class-attribute
instance-attribute
¶
headings = None
class-attribute
instance-attribute
¶
region = None
class-attribute
instance-attribute
¶
section_label = None
class-attribute
instance-attribute
¶
section_label_source = None
class-attribute
instance-attribute
¶
section_label_strength = None
class-attribute
instance-attribute
¶
text
instance-attribute
¶
Methods:¶
__init__(text, headings=None, section_label=None, section_label_source=None, section_label_strength=None, evidence=list(), region=None)
¶
SectionRegion
dataclass
¶
The headed section a segment belongs to, as the model is shown it.
Every segment of one headed section shares one region and so one model vote. Unheaded text has no region: each such segment is shown on its own.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
Position of the section in the document's section blocks. |
excerpt |
str
|
The heading line and the opening of the section's text. |
Source code in ontocast/tool/chunk/segment.py
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_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.