P0 级风险修复:7 个新高考 S 级省 100% 标注 subject_requirements
修复原因:
- recommendations 缺少选科要求,可能导致物理类考生收到历史类专业推荐
- 影响 7 个新高考 S 级省(湖南/广东/江苏/山东/河北/浙江/福建)
- 属 P0 级推荐准确性风险
实现内容:
1. SCHEMA.md recommendation 结构扩展:
- subject_requirements: {preferred_subject, reselect_subject, note}
- program_type: 为后续特殊专业标注预留占位
2. 7 省共 484 条 recs 100% 标注 subject_requirements
3. 基于专业关键词规则推断:
- 理工类: 物理优先 (+化学/+生物)
- 文史类: 历史优先
- 医学类: 物理 + 化学/生物
- 艺体类: 历史优先
4. 新增测试 test_subject_requirements.py
5. 新增 coverage 脚本 check_subject_requirements_coverage.py
6. 评审文档优化:P0 风险确认 + 优先级重排
验证:
- ruff: All checks passed
- mypy: Success, no issues in 17 source files
- pytest crowd_db: 151 passed, 3 skipped
- subject_requirements 覆盖率: 7省 484/484 (100.0%)
业务规则抽样验证:
- 社会工作 -> 历史优先
- 临床医学 -> 物理 + 化学/生物
- 物理学类/计算机/电气 -> 物理 + 化学
- 会计学 -> 历史优先
62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""检查 7 个新高考 S 级省的选科匹配覆盖率。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
ROOT = Path("/home/long/project/gaokao-volunteer-system")
|
|
S_PROVINCES = [
|
|
"hunan",
|
|
"guangdong",
|
|
"jiangsu",
|
|
"shandong",
|
|
"hebei",
|
|
"zhejiang",
|
|
"fujian",
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
print("=" * 80)
|
|
print("选科匹配覆盖率检查")
|
|
print("=" * 80)
|
|
|
|
total_recs = 0
|
|
total_with_sr = 0
|
|
failed = []
|
|
|
|
for prov in S_PROVINCES:
|
|
path = ROOT / f"data/crowd_db/{prov}.json"
|
|
d = json.loads(path.read_text(encoding="utf-8"))
|
|
recs = 0
|
|
with_sr = 0
|
|
for sr in d.get("score_ranges", []):
|
|
for rec in sr.get("recommendations", []):
|
|
recs += 1
|
|
if rec.get("subject_requirements") is not None:
|
|
with_sr += 1
|
|
pct = with_sr / recs * 100 if recs > 0 else 0
|
|
total_recs += recs
|
|
total_with_sr += with_sr
|
|
ok = pct == 100.0
|
|
print(f"{prov:10}: {with_sr}/{recs} ({pct:.1f}%) {'✅' if ok else '❌'}")
|
|
if not ok:
|
|
failed.append(prov)
|
|
|
|
print("\n总计:")
|
|
total_pct = total_with_sr / total_recs * 100 if total_recs > 0 else 0
|
|
print(f" {total_with_sr}/{total_recs} ({total_pct:.1f}%)")
|
|
|
|
if failed:
|
|
print(f"\n❌ 未达 100% 覆盖的省份: {', '.join(failed)}")
|
|
return 1
|
|
|
|
print("\n✅ 7 个新高考 S 级省 100% 覆盖 subject_requirements")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|