feat(regulatory): 对齐附件4目录核查规则
This commit is contained in:
@@ -5,7 +5,27 @@ from review_agent.regulatory_review.schemas import Finding
|
||||
|
||||
def run_structure_check(document_texts: dict[str, str], rule_set: dict) -> list[Finding]:
|
||||
findings: list[Finding] = []
|
||||
combined_all_text = "\n".join(document_texts.values())
|
||||
for requirement in rule_set.get("requirements", []):
|
||||
if requirement.get("structure_required") and not _contains_any(
|
||||
combined_all_text,
|
||||
[requirement.get("title", ""), *requirement.get("aliases", [])],
|
||||
):
|
||||
findings.append(
|
||||
Finding(
|
||||
rule_code=requirement["code"],
|
||||
category="structure",
|
||||
severity=requirement.get("severity", "medium"),
|
||||
title=f"申报资料目录缺少{requirement['title']}章节",
|
||||
detail=f"未在申报资料目录或章节标题候选中发现{requirement['title']}。",
|
||||
suggestion=requirement.get("suggestion", ""),
|
||||
evidence={
|
||||
"attachment4_code": requirement.get("attachment4_code"),
|
||||
"expected_title": requirement["title"],
|
||||
"aliases": requirement.get("aliases", []),
|
||||
},
|
||||
)
|
||||
)
|
||||
required_sections = requirement.get("required_sections") or []
|
||||
if not required_sections:
|
||||
continue
|
||||
@@ -14,7 +34,7 @@ def run_structure_check(document_texts: dict[str, str], rule_set: dict) -> list[
|
||||
continue
|
||||
combined_text = "\n".join(matching_docs.values())
|
||||
for section in required_sections:
|
||||
if section in combined_text:
|
||||
if _contains_any(combined_text, [section]):
|
||||
continue
|
||||
findings.append(
|
||||
Finding(
|
||||
@@ -39,3 +59,12 @@ def _matching_documents(document_texts: dict[str, str], keywords: list[str]) ->
|
||||
if any(str(keyword).lower() in haystack for keyword in keywords):
|
||||
result[name] = text
|
||||
return result
|
||||
|
||||
|
||||
def _contains_any(text: str, needles: list[str]) -> bool:
|
||||
normalized = _normalize_title(text)
|
||||
return any(_normalize_title(needle) in normalized for needle in needles if needle)
|
||||
|
||||
|
||||
def _normalize_title(value: str) -> str:
|
||||
return "".join(str(value).lower().replace("/", "").replace("/", "").split())
|
||||
|
||||
Reference in New Issue
Block a user