INNER CODE UNIT · Python

heading_level

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

def heading_level(el: Element, doc_type, promote_bare=True):
    """text_level primary (free from parser). DOTTED numbering (2.1) always refines depth;
    a BARE integer promotes to L1 only when the doc's numbering is a monotonic outline
    (`promote_bare`) — otherwise it is a list ordinal and we defer to text_level (review F1)."""
    txt = (el.text or "").strip()
    if _structural_nonheading(txt):
        return None
    if doc_type == "law" and LAW_SEC_RE.match(txt):
        return 1
    if not el.text_level:
        return None
    num = _leading_number(txt)
    if num:
        kind, val = num
        if kind == "dotted":
            return val
        if kind == "bare" and promote_bare:
            return 1

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…