Wire the guarded conversational RAG answer layer end-to-end

This commit is contained in:
2026-08-05 14:33:13 +07:00
parent 834d9e51b0
commit ef08b4929e
127 changed files with 37921 additions and 169 deletions
+14 -1
View File
@@ -1,5 +1,9 @@
from ingestion.extract.models import Span
from ingestion.segment.detector import detect_monograph_titles, detect_section_headings
from ingestion.segment.detector import (
detect_monograph_titles,
detect_section_headings,
in_monograph_range,
)
def _span(text, physical_page, printed_page, y0=100.0, bold=True, size=10.0):
@@ -86,3 +90,12 @@ def test_unknown_bold_text_not_matched_as_section():
def test_section_heading_outside_monograph_range_excluded():
spans = [_span("Chỉ định", 5, 6, bold=True, size=9.5)]
assert list(detect_section_headings(spans)) == []
def test_back_index_cannot_reenter_range_via_bad_inferred_printed_page():
# Confirmed real failure: physical page 1655 of the back index was mapped
# to printed page 1496, making its "Tương tác thuốc" entry extend
# ZOLPIDEM's source range from page 1494 through page 1655.
index_span = _span("Tương tác thuốc", 1655, 1496)
assert in_monograph_range(index_span) is False
assert list(detect_section_headings([index_span])) == []