|
|
@@ -41,6 +41,19 @@ REQUIRED_INTERACTIVE = {
|
|
|
13: ["id=\"debugTree\""],
|
|
|
}
|
|
|
|
|
|
+RIGID_STRUCTURE_MARKERS = [
|
|
|
+ 'class="causal-grid"',
|
|
|
+ "前因 Why",
|
|
|
+ "机制 How",
|
|
|
+ "后果 So what",
|
|
|
+]
|
|
|
+
|
|
|
+MECHANICAL_JOIN_MARKERS = [
|
|
|
+ "。;",
|
|
|
+ ";;",
|
|
|
+ "。。这个问题链",
|
|
|
+]
|
|
|
+
|
|
|
|
|
|
@dataclass
|
|
|
class Finding:
|
|
|
@@ -96,9 +109,20 @@ def validate_file(path: Path, chapter: dict[str, Any], glossary: dict[str, Any])
|
|
|
block_plain = strip_tags(block)
|
|
|
if han_count(block_plain) < 900:
|
|
|
findings.append(Finding("error", name, f"section {index} is too shallow: {han_count(block_plain)} Han chars"))
|
|
|
- for heading in ["现象", "前因", "机制", "后果", "验证", "Runbook"]:
|
|
|
- if heading not in block_plain:
|
|
|
- findings.append(Finding("error", name, f"section {index} missing segment {heading}"))
|
|
|
+ if 'class="explanation-flow"' not in block:
|
|
|
+ findings.append(Finding("error", name, f"section {index} missing natural explanation flow"))
|
|
|
+ if 'class="evidence-panel"' not in block:
|
|
|
+ findings.append(Finding("error", name, f"section {index} missing evidence panel"))
|
|
|
+ for required_text in ["工程讲解", "证据与操作", "验证", "Runbook"]:
|
|
|
+ if required_text not in block_plain:
|
|
|
+ findings.append(Finding("error", name, f"section {index} missing required text {required_text}"))
|
|
|
+
|
|
|
+ for marker in RIGID_STRUCTURE_MARKERS:
|
|
|
+ if marker in html:
|
|
|
+ findings.append(Finding("error", name, f"rigid causal grid marker found: {marker}"))
|
|
|
+ for marker in MECHANICAL_JOIN_MARKERS:
|
|
|
+ if marker in html:
|
|
|
+ findings.append(Finding("error", name, f"mechanical join marker found: {marker}"))
|
|
|
|
|
|
for phrase in OLD_TEMPLATE_PHRASES:
|
|
|
if phrase in plain:
|
|
|
@@ -166,6 +190,8 @@ def validate(directory: Path, content: Path) -> dict[str, Any]:
|
|
|
required_anchor_errors = [f for f in errors if f.message.startswith("missing anchor")]
|
|
|
forbidden_template_errors = [f for f in errors if "forbidden template" in f.message]
|
|
|
interactive_errors = [f for f in errors if "interactive component" in f.message]
|
|
|
+ rigid_structure_errors = [f for f in errors if "rigid causal grid marker" in f.message]
|
|
|
+ mechanical_join_errors = [f for f in errors if "mechanical join marker" in f.message]
|
|
|
|
|
|
return {
|
|
|
"summary": {
|
|
|
@@ -178,6 +204,8 @@ def validate(directory: Path, content: Path) -> dict[str, Any]:
|
|
|
"required_anchors": {"passed": not required_anchor_errors, "errors": len(required_anchor_errors)},
|
|
|
"forbidden_template": {"passed": not forbidden_template_errors, "errors": len(forbidden_template_errors)},
|
|
|
"interactive_components": {"passed": not interactive_errors, "errors": len(interactive_errors)},
|
|
|
+ "rigid_causal_grid": {"passed": not rigid_structure_errors, "errors": len(rigid_structure_errors)},
|
|
|
+ "mechanical_join": {"passed": not mechanical_join_errors, "errors": len(mechanical_join_errors)},
|
|
|
},
|
|
|
"findings": [f.__dict__ for f in all_findings],
|
|
|
}
|