# -*- coding: utf-8 -*-
import io, sys, os, json, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
b = r"D:\work buddy\2026-11-05-14-15-52"
raw = json.load(open(os.path.join(b, "raw_uchicago.json"), encoding="utf-8"))

# 剔除：MD / MD-PhD；Law 职业法学位（JD/JSD/D.Comp.L）
def remove_reason(x):
    p = str(x.get("phd") or "")
    u = str(x.get("unit") or "")
    if re.search(r"M\.D\.|MD/PhD", p): return "MD/MD-PhD"
    if u.startswith("Law"): return "Law 职业法学位"
    return None

keep, rem = [], []
for x in raw:
    if not x.get("phd"): continue
    reason = remove_reason(x)
    if reason: rem.append((reason, x["title"], x["phd"]))
    else: keep.append(x)

print("=== 剔除博士:", len(rem))
for r,t,p in rem: print(f"  [{r}] {t} | {p}")

print("\n=== 保留博士:", len(keep))
for x in keep:
    print(f"{x['unit'][:12]:12}|{str(x['phd'])[:12]:12}|{x['title']}")
