ontocast.tool.chunk.sections¶
Document section span detection and overlap-based labeling for chunk prepare.
SectionSpan
¶
build_section_spans_from_labels(text, labeled_headings)
¶
Build section spans from explicit (offset, label) pairs.
detect_section_spans(text, schema=None)
¶
Detect section headings via regex and return character spans.
Source code in ontocast/tool/chunk/sections.py
document_text_for_section_tagging(doc)
¶
inject_front_matter_spans(spans, text, schema, *, min_gap_chars=80, max_gap_chars=ABSTRACT_FRONT_MATTER_MAX_CHARS)
¶
Insert an abstract span for unheaded front matter before the first IMRaD section.
Source code in ontocast/tool/chunk/sections.py
label_from_headings(headings, schema)
¶
Return the first schema label matched from the heading breadcrumb (most-specific first).
This uses docling's structural metadata directly — no substring search required — so it is reliable even when the markdown export differs from the hybrid-chunker text.
Source code in ontocast/tool/chunk/sections.py
label_text_from_spans(text, document_text, spans, search_from)
¶
Assign section label via span overlap; return label and next search offset.
Source code in ontocast/tool/chunk/sections.py
resolve_section_label(chunk_text, document_text, spans, search_from=0)
¶
Return section label with max overlap; second value is next search offset.
When the chunk text cannot be located in document_text the cursor is
preserved at search_from (not reset to 0) so that subsequent segments
are not mis-anchored to the start of the document.