fastrag.retrieval.sections#

Database-independent exact source context for structural retrieval hits.

Classes

SectionContext(document_id, section_id, ...)

Original retained section syntax, with document-scoped provenance.

SectionIndex([documents])

Keep source parents outside vector chunks and resolve merged sections.

class fastrag.retrieval.sections.SectionContext(document_id, section_id, content, source_spans, heading_path)[source]#

Bases: object

Original retained section syntax, with document-scoped provenance.

Parameters:
class fastrag.retrieval.sections.SectionIndex(documents=())[source]#

Bases: object

Keep source parents outside vector chunks and resolve merged sections.

Parameters:

documents (Iterable[NormalizedDocument])

add(document)[source]#

Register a validated parent; conflicting document IDs are rejected.

Parameters:

document (NormalizedDocument)

Return type:

None

resolve(chunk, *, ancestors=False, missing='raise')[source]#

Return all source sections in source order, optionally with ancestors.

Parameters:
Return type:

tuple[SectionContext, …]