# -*- coding: utf-8 -*-
import io, sys, os, re, html
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
def clean(fn):
    raw=open(fn,"rb").read().decode("utf-8","ignore")
    raw=html.unescape(re.sub(r"<script.*?</script>","",raw,flags=re.S)); raw=html.unescape(re.sub(r"<style.*?</style>","",raw,flags=re.S))
    t=re.sub(r"<[^>]+>"," ",raw); return html.unescape(re.sub(r"\s+"," ",t))
files={"ECE":"_19_JHU-ECE-MSE.txt","CBE":"_19_JHU-CBE-MSE.txt","Civil":"_19_JHU-Civil-MSE.txt","EngMgmt":"_19_JHU-EngMgmt-MS.txt","HSI":"_19_JHU-HSI-MS.txt"}
for k,fn in files.items():
    if not os.path.exists(fn):
        print(k,"MISSING",fn); continue
    t=clean(fn)
    print("="*22,k,"len",len(t))
    for kw in ["Master of Science","M.S.E","M.S.","credits","credit","two semesters","full-time","part-time","online","thesis","capstone","concentration","focus","prerequisite","admission","research","curriculum"]:
        m=re.search(re.escape(kw),t)
        if m:
            s=max(0,m.start()-50); e=min(len(t),m.end()+170); print(f"[{kw}] …{t[s:e]}\n")
