择校 UI(docs/择校UI): - 搜索支持外号(东大/华科)与拼音首字母(dndx),未命中做分诊 - 目标分拖动即见三档数量,松手列出换档院校,名单按收藏/对比/本地排序 - 家乡省份接入院校库(家乡优先排序)与首页推荐(池不足时说明并可按档位判断) - 缺档改成同尺寸占位卡并可跳院校库;三档口径收敛成一份、默认收起 - 新增拼音索引.js(907 校) 设计与交接:docs/研选E决策层_20261112 36 张稿与 README v1–v34;docs/agent_handoffs 续写。 审计与脚本:审计报告新增若干核验与分流产物,脚本同步更新。 .gitignore 追加排除 /官方资料/ 与 GB 级审计中间产物(global_writer_stages、来源发现、local_ingest_*)。
62 lines
3.1 KiB
Python
62 lines
3.1 KiB
Python
"""扫「名为全量、实为切片」的表(只读)
|
||
|
||
起因:`chsi_2027_tuimian_official` 被当作"官方推免表"参与审计,实测只含 085600–085606
|
||
七个码、1,858 行、224 校,且有 truncated_page1_only 列 —— 是 0856 专项切片。
|
||
用户已明确否掉 0856 定向口径,所以要扫全库:还有哪些表带专业码列但实际只覆盖一个窄码段,
|
||
以及它们是否被当全量分母 / 覆盖证据用。
|
||
|
||
判据(全部实测,不靠表名猜):
|
||
- 码段首位分布:只看 substr(码,1,2) 的 distinct 个数
|
||
- 切片标记:distinct 码数 <= 12 且全部落在同一 4 位前缀 → 判「窄切片」
|
||
- 对照官方目录 Bc27=1,404 个码,给出覆盖占比
|
||
"""
|
||
import sqlite3
|
||
|
||
con = sqlite3.connect(r'D:\择校\数据库\zexiao_2027.db')
|
||
|
||
tables = [r[0] for r in con.execute(
|
||
"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name")]
|
||
print('库里表总数:', len(tables))
|
||
|
||
CODE_CANDS = ['zydm', 'code', 'major_code', '专业代码', 'zym', 'b_code', 'c_code', 'a_code',
|
||
'school_code', 'dwdm']
|
||
rows = []
|
||
for t in tables:
|
||
cols = [r[1] for r in con.execute('PRAGMA table_info("%s")' % t)]
|
||
hit = [c for c in cols if c in ('zydm', 'code', 'major_code', '专业代码', 'b_code', 'c_code')]
|
||
if not hit:
|
||
continue
|
||
col = hit[0]
|
||
try:
|
||
n_rows = con.execute('SELECT COUNT(*) FROM "%s"' % t).fetchone()[0]
|
||
nd = con.execute('SELECT COUNT(DISTINCT CAST("%s" AS TEXT)) FROM "%s"' % (col, t)).fetchone()[0]
|
||
if nd is None or nd == 0:
|
||
continue
|
||
pref = con.execute('SELECT DISTINCT substr(CAST("%s" AS TEXT),1,4) FROM "%s" '
|
||
'WHERE "%s" IS NOT NULL' % (col, t, col)).fetchall()
|
||
pref = sorted(x[0] for x in pref if x[0])
|
||
p2 = sorted({p[:2] for p in pref if p})
|
||
rows.append((t, col, n_rows, nd, p2, pref))
|
||
except Exception as e:
|
||
print(' !! %-40s %s' % (t, str(e)[:60]))
|
||
|
||
BC27 = con.execute('SELECT COUNT(DISTINCT CAST(zydm AS TEXT)) FROM chsi_2027_dir').fetchone()[0]
|
||
print('对照分母 Bc27(官方 2027 distinct 专业码)=%d\n' % BC27)
|
||
|
||
narrow = [r for r in rows if r[3] <= 12]
|
||
print('=== 有专业码列的表 %d 张,其中 distinct 码 <=12 的窄表 %d 张 ===' % (len(rows), len(narrow)))
|
||
for t, col, n_rows, nd, p2, pref in sorted(narrow, key=lambda x: -x[2]):
|
||
print(' %-34s 列=%-10s 行=%-8s distinct码=%-4s 码段=%s 4位前缀=%s' %
|
||
(t, col, format(n_rows, ','), nd, p2[:6], [p for p in pref if p][:12]))
|
||
|
||
print('\n=== 全部窄码段的"只覆盖 0856"表 ===')
|
||
for t, col, n_rows, nd, p2, pref in rows:
|
||
if pref and all(p.startswith('0856') for p in pref):
|
||
print(' %-34s 行=%-8s distinct码=%-4s 前缀=%s' % (t, format(n_rows, ','), nd, pref))
|
||
|
||
print('\n=== 只覆盖单个门类(首位 2 段唯一)的表 ===')
|
||
for t, col, n_rows, nd, p2, pref in rows:
|
||
if len(p2) == 1:
|
||
print(' %-34s 列=%-10s 行=%-9s distinct码=%-5s 唯一门类=%s 覆盖 Bc27 的 %.2f%%' %
|
||
(t, col, format(n_rows, ','), nd, p2[0], 100.0 * nd / BC27))
|