import json, re
from collections import Counter

with open('index_main.html','r',encoding='utf-8') as f:
    html = f.read()
en_names = set(re.findall(r'en:"([^"]+)"', html))

with open('todo_upgrade.json','r',encoding='utf-8') as f:
    todo = json.load(f)

remaining = [t for t in todo if t.get('en','') not in en_names and t.get('deg','').lower().startswith('phd')]
print('Total todo PhD remaining:', len(remaining))

disc_count = Counter()
for t in remaining:
    disc = t.get('disc','') or t.get('col','') or ''
    disc_count[disc] += 1
print('\n=== By discipline/col ===')
for k,v in disc_count.most_common(25):
    print(f'  {k}: {v}')

print('\n=== Sample remaining PhD candidates (first 40) ===')
for t in remaining[:40]:
    s = t.get('s','?')
    deg = t.get('deg','?')
    en = t.get('en','?')[:90]
    print(f'  {s:10s} | {deg:5s} | {en}')
