fix: [P0] IR 结构化覆盖率不足 (36.1% < 70%) - Closes #21 #24
@@ -484,10 +484,53 @@ def _quick_validate(
|
||||
):
|
||||
gaps["missing_concepts"].append("缺少 scope 概念: 海外")
|
||||
|
||||
# --- Section and table coverage ---
|
||||
# Count functional sections (those with numbered titles that contain text/tables)
|
||||
func_sections = [
|
||||
s for s in doc.get("sections", [])
|
||||
if s.get("source", "").strip()
|
||||
and any(b.get("type") in ("para", "table") for b in s.get("blocks", []))
|
||||
]
|
||||
covered_sections: set[str] = set()
|
||||
for fu in units:
|
||||
for src in fu.get("sources", []):
|
||||
sec = src.get("section", "")
|
||||
if sec:
|
||||
covered_sections.add(sec)
|
||||
|
||||
section_cov = len(covered_sections) / max(len(func_sections), 1)
|
||||
if section_cov < config.COVERAGE_TARGET:
|
||||
uncovered = [s["source"] for s in func_sections
|
||||
if s["source"] not in covered_sections]
|
||||
gaps["missing_paths"].append(
|
||||
f"章节覆盖率 {section_cov:.0%} < {config.COVERAGE_TARGET:.0%}, "
|
||||
f"未覆盖: {uncovered[:5]}"
|
||||
)
|
||||
|
||||
# Count table rows
|
||||
total_rows = sum(
|
||||
len(b.get("rows", []))
|
||||
for s in doc.get("sections", [])
|
||||
for b in s.get("blocks", [])
|
||||
if b.get("type") == "table"
|
||||
)
|
||||
covered_rows = sum(
|
||||
1 for fu in units
|
||||
for src in fu.get("sources", [])
|
||||
if src.get("type") == "table" and src.get("row")
|
||||
)
|
||||
row_cov = covered_rows / max(total_rows, 1)
|
||||
if row_cov < config.COVERAGE_TARGET:
|
||||
gaps["missing_paths"].append(
|
||||
f"表格行覆盖率 {row_cov:.0%} < {config.COVERAGE_TARGET:.0%}, "
|
||||
f"({covered_rows}/{total_rows} rows)"
|
||||
)
|
||||
|
||||
passed = (
|
||||
not gaps["missing_paths"]
|
||||
and not gaps["format_issues"]
|
||||
and not gaps["parent_issues"]
|
||||
and section_cov >= config.COVERAGE_TARGET
|
||||
)
|
||||
return passed, gaps
|
||||
|
||||
|
||||
Reference in New Issue
Block a user