diff --git a/审计报告/0856_统考名额与推免占比_20261101.csv b/审计报告/0856_统考名额与推免占比_20261101.csv new file mode 100644 index 000000000..a152751ad --- /dev/null +++ b/审计报告/0856_统考名额与推免占比_20261101.csv @@ -0,0 +1,18 @@ +院校,专业代码,专业名称,统考名额_不含推免,推免已接收,总规模,推免占比 +东北大学,085601,材料工程,255,126,381,33% +东北大学,085602,化学工程,35,6,41,15% +东北大学,085603,冶金工程,184,60,244,25% +东华大学,085600,材料与化工,182,56,238,24% +东南大学,085601,材料工程,33,3,36,8% +东南大学,085602,化学工程,34,11,45,24% +中山大学,085600,材料与化工,32,25,57,44% +中山大学,085601,材料工程,30,59,89,66% +北京航空航天大学,085601,材料工程,58,36,94,38% +南京理工大学,085602,化学工程,96,25,121,21% +合肥工业大学,085601,材料工程,56,48,104,46% +合肥工业大学,085602,化学工程,28,19,47,40% +山东大学,085600,材料与化工,52,78,130,60% +山东大学,085601,材料工程,14,3,17,18% +西北工业大学,085601,材料工程,136,189,325,58% +西北工业大学,085602,化学工程,22,20,42,48% +重庆大学,085600,材料与化工,91,59,150,39% diff --git a/脚本/公告正文挖掘/merge_accommodation.py b/脚本/公告正文挖掘/merge_accommodation.py new file mode 100644 index 000000000..2ca68d697 --- /dev/null +++ b/脚本/公告正文挖掘/merge_accommodation.py @@ -0,0 +1,131 @@ +# -*- coding: utf-8 -*- +"""给 agent 抽的 507 行住宿值补上「学习方式归属」,再与自抽的 135 行合流。 + +agent 那批只有「提供 / 不安排」两值且不带 learn_scope,直接并进主表会出现 +同一校同一年既有「提供」又有「不提供」的假冲突——真实原因往往是 +「全日制提供、非全日制不安排」。合流前必须回到公告正文按句重新判归属。 +""" +import csv +import re +import sqlite3 +import sys +import time + +sys.path.insert(0, r'D:/择校/运行暂存/agent_ingest_20261101') +SRC = r'D:/择校/运行暂存/agent_ingest_20261101/tuition/stage_a_rows.csv' +ZX = r'D:/择校/数据库/zexiao_2027.db' + +NEG = re.compile(r'不提供|不解决|不安排|无法提供|不予安排|自行解决|需自行|无宿舍') +PART = re.compile(r'仅基本学制内|原则上不|部分|校区以当年') +IRRELEVANT = re.compile(r'往返交通|复试期间|复试的考生|本科.{0,12}宿舍|离校|收件|录取通知书' + r'|复试费|收费编码|缴费方式') + + +def scope_of(s): + if re.search(r'非全日制|在职|MBA|MPA|定向', s): + return '非全日制/定向' + if re.search(r'全日制', s): + return '全日制' + if re.search(r'其他类型|其余|其他研究生', s): + return '非全日制/定向' + return '未限定' + + +def value_of(s): + sc = scope_of(s) + m = re.search(r'非全日制|在职|MBA|MPA|定向|全日制', s) if sc != '未限定' else None + body = s[m.end():] if m else s + if sc == '全日制': + nxt = re.search(r'其他类型|其余|其他研究生', body) + if nxt: + body = body[:nxt.start()] + if re.search(r'第一学年.{0,20}(安排|租用)|后续.{0,10}自行|视情给予.{0,6}补贴', body): + return sc, '部分提供(仅第一学年安排)' + if re.search(r'[一二三四五\d]年级.{0,16}不安排', body) or re.search(r'[一二三四五\d]年级.{0,12}安排', body): + return sc, '部分提供(按年级安排)' + b2 = re.sub(r'(住宿)?费用?自理', '', body) + if re.search(r'统一安排|由学校统一安排', body) and '自理' in body: + return sc, '提供(费用自理)' + if NEG.search(b2): + return sc, '不提供' + if PART.search(b2): + return sc, '仅学制内提供' + if re.search(r'安排住宿|提供住宿|由学校.{0,4}住宿', b2): + return sc, '提供' + return sc, '' + + +def main(): + rows = [r for r in csv.DictReader(open(SRC, encoding='utf-8-sig')) + if (r.get('accommodation') or '').strip()] + print('待补归属的住宿行=%d 校=%d' % (len(rows), len({r['school'] for r in rows}))) + z = sqlite3.connect(ZX, timeout=600) + z.execute('PRAGMA busy_timeout=600000') + now = time.strftime('%Y-%m-%dT%H:%M:%S') + got = skip = nohit = 0 + conflicts = [] + have = {(r[0], r[1], r[2]): r[3] for r in z.execute( + 'select school,learn_scope,value,notice_key from web_accommodation_policy')} + for r in rows: + nk = r.get('local_evidence', '') + m = re.search(r'notice_key=([^ |]+)', nk) + body = None + if m: + for key in m.group(1).split(','): + b = z.execute('select body from notices_all where notice_key=?', + (key.strip(),)).fetchone() + if b and b[0]: + body = b[0] + break + if not body: + nohit += 1 + continue + b = re.sub(r'\s+', ' ', body) + best = None + for s in re.split(r'[。;;]', b): + s = s.strip() + if not re.search(r'住宿|宿舍', s): + continue + if IRRELEVANT.search(s) and not NEG.search(s): + continue + sc, val = value_of(s) + if val: + best = (sc, val, s[:190]) + break + if not best: + nohit += 1 + continue + sc, val, ev = best + k = (r['school'], sc, val) + if k in have: + skip += 1 + continue + # agent 原值与重判结果不一致时留证不覆盖:可能它取的是另一条公告 + raw = r['accommodation'] + agree = (raw in val) or (raw == '不安排' and val == '不提供') or (raw == '提供' and val.startswith('提供')) + z.execute('INSERT OR IGNORE INTO web_accommodation_policy ' + '("school","learn_scope","value","notice_key","title","source_url","pub_date",' + '"evidence","rule","confidence","_ingested_at","data_flag") ' + 'VALUES (?,?,?,?,?,?,?,?,?,?,?,?)', + (r['school'], sc, val, nk[:60], (r.get('major_name') or '')[:80], + r.get('source_url', ''), r.get('year', ''), ev, + 'agent行按公告正文重判归属', 'high' if sc != '未限定' else 'low', now, + '' if agree else 'source_values_disagree')) + have[k] = nk + got += 1 + if not agree: + conflicts.append((r['school'], raw, val)) + z.execute('INSERT INTO changelog VALUES (?,?,?,?,?,?)', + (now, 'accom_merge_20261101', 'web_accommodation_policy', 'insert', got, + 'agent 507行住宿按公告正文补 learn_scope 后合流;已在表内跳过%d,正文取不到%d,原值与重判不一致%d' % + (skip, nohit, len(conflicts)))) + z.commit() + print('新增=%d 已存在跳过=%d 正文取不到=%d 原值不一致=%d' % (got, skip, nohit, len(conflicts))) + print('表内=%d 校=%d' % (z.execute('select count(*),count(distinct school) from web_accommodation_policy').fetchone())) + print('不一致例:', conflicts[:5]) + print('quick_check=', z.execute('PRAGMA quick_check').fetchone()[0]) + z.close() + + +if __name__ == '__main__': + main()