import json, re
todo=json.load(open('todo_upgrade.json',encoding='utf-8'))
html=open('index_main.html',encoding='utf-8').read()
items=re.findall(r'\{id:"([^"]+)",s:"([^"]+)",n:"([^"]*)",en:"([^"]*)",deg:"([^"]*)"',html)
existing_en={(i[1],i[3].lower().strip()) for i in items}
existing_ids={i[0] for i in items}

# 找 todo 里 deg 含 PhD 的未核验项
phd_todo=[t for t in todo if 'PhD' in t.get('deg','') or 'doctor' in t.get('deg','').lower()]
print('todo PhD count:',len(phd_todo))

# 排除已落库（按 s+en 匹配）
remaining=[]
for t in phd_todo:
    key=(t['s'], t['en'].lower().strip())
    # 宽松匹配：检查 en 是否在已有 en 列表中
    hit=False
    for es in [e for (s,e) in existing_en if s==t['s']]:
        if t['en'].lower().strip() in es or es in t['en'].lower().strip():
            hit=True; break
    if not hit:
        remaining.append(t)

print('remaining PhD:',len(remaining))
for t in remaining[:40]:
    print(f"  {t['s']:10s} | {t['deg']:8s} | {t['en'][:90]}")
