feat: export core Hermes skills
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
output-style-check.py — 检查data-extractor输出的H/K/L列是否符合统一风格规范。
|
||||
用法:python3 output-style-check.py <campus>-row-data.json
|
||||
返回:exit 0 = 通过,exit 1 = 风格不符(列出具体问题)
|
||||
|
||||
This is Layer 3 of the output consistency defense (see references/output-consistency.md).
|
||||
Run AFTER data extraction, BEFORE xlsx generation. If it fails, fix the specific
|
||||
issues in the JSON before proceeding.
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
import re
|
||||
|
||||
def check_h_column(text):
|
||||
"""检查H列(金额/费用)格式"""
|
||||
issues = []
|
||||
|
||||
# 禁止bullet符号
|
||||
if re.search(r'[•\-\*]\s', text):
|
||||
issues.append("H列含bullet符号(•/-/*),应使用段落式叙述")
|
||||
|
||||
# 禁止"大类·条款号"合并标题
|
||||
if re.search(r'【[^】]*·第[一二三四五六七八九十\d]+条', text):
|
||||
issues.append("H列含'【大类·条款号】'合并标题,应分开写")
|
||||
|
||||
# 必须有【】大类标注
|
||||
if '【' not in text:
|
||||
issues.append("H列缺少【】大类标注(如【租金】【付款推算】等)")
|
||||
|
||||
return issues
|
||||
|
||||
def check_k_column(text):
|
||||
"""检查K列(法律风险)格式"""
|
||||
issues = []
|
||||
|
||||
# 禁止统计式开头
|
||||
if re.search(r'\d+项风险(\d+高', text):
|
||||
issues.append("K列用统计式开头(如'10项风险(3高/5中/2低)'),应以【整体评价】开头")
|
||||
|
||||
# 禁止"序号·等级·条款号"标签
|
||||
if re.search(r'\d+\.\s*【[高中低][中高]?·', text):
|
||||
issues.append("K列用'序号·等级·条款号'标签格式(如'1.【高·第十条】'),应用叙述式")
|
||||
|
||||
# 禁止markdown表格
|
||||
if '| #' in text or '|---|' in text:
|
||||
issues.append("K列含markdown表格,应用叙述式段落")
|
||||
|
||||
# 必须有【整体评价】
|
||||
if '【整体评价' not in text:
|
||||
issues.append("K列缺少【整体评价】段落")
|
||||
|
||||
return issues
|
||||
|
||||
def check_l_column(text):
|
||||
"""检查L列(模版差异)格式"""
|
||||
issues = []
|
||||
|
||||
# 禁止统计式开头
|
||||
if re.search(r'\d+处差异(\d+缺失', text):
|
||||
issues.append("L列用统计式开头(如'34处差异(16缺失/15修改/3新增)'),应叙述式说明")
|
||||
|
||||
# 禁止分类小标题
|
||||
if '【核心缺失' in text or '【核心修改' in text:
|
||||
issues.append("L列用'【核心缺失/修改】'分类小标题,应使用编号列表")
|
||||
|
||||
# 禁止"vs"分隔
|
||||
if ' vs ' in text:
|
||||
issues.append("L列用'vs'分隔模版和合同,应用中文叙述(如'模版为XX;本合同为XX')")
|
||||
|
||||
return issues
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("用法: python3 output-style-check.py <campus>-row-data.json")
|
||||
sys.exit(2)
|
||||
|
||||
filepath = sys.argv[1]
|
||||
try:
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
except Exception as e:
|
||||
print(f"❌ 无法读取文件: {e}")
|
||||
sys.exit(2)
|
||||
|
||||
all_issues = []
|
||||
|
||||
# Check H column (fees)
|
||||
if 'fees' in data and data['fees']:
|
||||
h_issues = check_h_column(data['fees'])
|
||||
all_issues.extend(h_issues)
|
||||
|
||||
# Check K column (risk_detail)
|
||||
if 'risk_detail' in data and data['risk_detail']:
|
||||
k_issues = check_k_column(data['risk_detail'])
|
||||
all_issues.extend(k_issues)
|
||||
|
||||
# Check L column (diff_detail)
|
||||
if 'diff_detail' in data and data['diff_detail']:
|
||||
l_issues = check_l_column(data['diff_detail'])
|
||||
all_issues.extend(l_issues)
|
||||
|
||||
# Check J column (status) - should be just "履行中", no extra text
|
||||
if 'status' in data and data['status']:
|
||||
status = data['status'].strip()
|
||||
if status not in ['履行中', '已到期', '已解除']:
|
||||
all_issues.append(f"J列状态值不规范: '{status}',应为'履行中'/'已到期'/'已解除'(不加括号说明)")
|
||||
|
||||
if all_issues:
|
||||
print(f"❌ 风格检查未通过({len(all_issues)}个问题):")
|
||||
for i, issue in enumerate(all_issues, 1):
|
||||
print(f" {i}. {issue}")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("✅ 风格检查通过:H/K/L/J列格式符合统一规范")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user