Sections
Every Chunk and Block carries a section field naming the region of the document it came from — cover page, body, an appendix, and so on. This page is the single reference for those values; the field descriptions on Chunk and Block link here rather than repeat the table.
section answers "where in the document is this?" — distinct from block.type (paragraph, heading, table…), which answers "what kind of content is this?" They also operate at different scales: a section is usually a run of many pages, while a single page holds many blocks — one heading, one paragraph, one table, and so on.
Why sections exist
Sections keep the heading hierarchy accurate. When DocSlicer builds result.hierarchy, it walks the document's headings and maintains a stack — each heading nests under the open heading above it. A section boundary resets that stack to the root.
This matters because heading numbering restarts between regions. An appendix often opens with its own "1. Definitions"; without section awareness, that heading would nest under whatever body heading happened to be open (say, "Item 7. Management Discussion"), producing a wrong outline. Clearing the stack at each boundary lets DocSlicer compute every region's outline independently, so the appendix heading parents under the appendix rather than under leftover body context.
The section value is also exposed on each chunk and block, so you can filter by section — see below.
How sections are detected
DocSlicer infers sections primarily from page-label numbering, not from headings or content. The printed page label (see page_label on Chunk) tells it which region a page belongs to, and each section takes its label from the format of its page numbers:
- Arabic (
1,2,3; also sub-numbered like347/1) → the longest such run is thebody; any other Arabic run becomesfront_matter(before the body) orback_matter(after it). - Roman (
i,ii,iv; also compound likeII-3) →front_matterbefore the body,back_matterafter. - Alpha-numeric (
A-1,F-3,S-2; also sub-numbered likeA-1-86) → an annex region, split by the leading letter:F→financialsS→schedules- any other (or mixed) letter →
annex
- Alpha-roman (
S-iv,F-ii,A-vii) → alwaysannex, whatever the letter. - The leading unnumbered page(s) →
coverpage; a sparse trailing page →last_page.
Because detection is label-driven, a document with no page labels (most HTML, DOCX, and PPTX) will classify almost everything as body.
Section values
section is one of:
| Value | Region | Detected from |
|---|---|---|
coverpage | Leading page(s) before any numbered content — title page, cover sheet. | Unnumbered, sparse leading pages. |
front_matter | Preface, foreword, introduction, and a Roman-paged TOC. | Roman page labels before the body (e.g. i, ii, iv). |
body | Main document content — the longest run of Arabic-numbered pages. | Arabic page labels (e.g. 1, 2, 3). |
annex | General lettered annex sections. | Alpha-prefixed labels (e.g. A-1, B-3). |
financials | Financial-statement annex. | Alpha-prefixed labels with prefix F (e.g. F-1). |
schedules | Schedules annex. | Alpha-prefixed labels with prefix S (e.g. S-1). |
back_matter | Signatures, certifications, closing matter. | Roman page labels after the body (e.g. i, ii, iv). |
last_page | Standalone closing page — contact info, disclaimer, colophon. | Blank label, low content density, or contact-info signals. |
annex, financials, and schedules reflect US legal and financial filing practice, where appendices use alpha-prefixed page labels (A-1, F-3). Outside the US, annexes typically continue Arabic page numbering, so their content classifies as body instead. Don't rely on these three values for non-US documents.
Filtering by section
Beyond the heading reset, section is handy for narrowing a result to the regions you care about:
# Body only — drop front/back matter, cover, TOC
body = [c for c in result.chunks if c.section == "body"]
# Body plus any appendices
main = [c for c in result.chunks if c.section in ("body", "annex", "financials", "schedules")]
# Everything except furniture pages
content = [c for c in result.chunks if c.section not in ("coverpage", "last_page")]The same values apply to blocks, so you can filter result.blocks identically. For navigating by heading or page instead of region, see the navigation methods on ParseResult.