INNER CODE UNIT · Python

_budget

Laurent00TT/PharosRAG · src/chunker/core.py:253

    def _budget(self, doc_type):
        return self._override or self.budgets.get(doc_type, DEFAULT_BUDGET)

    def chunk(self, elements: list[Element], *, doc_id: str, doc_type: str | None = None,
              lang: str = "en", doc_meta: dict | None = None, acl: dict | None = None) -> ChunkResult:
        budget = self._budget(doc_type)
        banners = _banner_texts(elements)          # round-2: drop per-page running banners
        kept = [e for e in elements
                if e.kind not in NOISE_KINDS and _norm(e.text) not in banners]

        # reset-aware switch (review F1): bare-integer numbering only promotes to L1 when
        # the doc's bare numbers form a monotonic outline. A restart (1..9,1.. = list usage)
        # means the numbers are list ordinals, not chapters -> defer to text_level.
        bare_seq = []
        for el in kept:
            txt = (el.text or "").strip()
            if not el.text_level or _structural_nonheading(txt):
                continue

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…