import os, re, html, io, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
BASE = os.path.dirname(os.path.abspath(__file__))
tags=["mit-msms","mit-scm-res","rice-macc","rice-meecon","rice-mfin","wustl-cyber"]
KW=["full-time","part-time","online","residential","degree","master","thesis","capstone","credit","required","admission","deadline","deadline","toefl","ielts","duolingo","gre","gmat","tuition","fee","stem","track","concentration","orientation","duration","term","enroll","employment","non-thesis"]
for tag in tags:
    p=os.path.join(BASE,f"_26_{tag}.txt")
    raw=open(p,encoding="utf-8").read()
    txt=re.sub(r'<script[\s\S]*?</script>',' ',raw)
    txt=re.sub(r'<style[\s\S]*?</style>',' ',txt)
    txt=re.sub(r'<[^>]+>',' ',txt)
    txt=html.unescape(re.sub(r'\s+',' ',txt)).strip()
    print("="*30,tag,"textlen",len(txt))
    low=txt.lower()
    for kw in KW:
        idx=low.find(kw)
        if idx>=0:
            seg=txt[max(0,idx-70):idx+110]
            print(f"  [{kw}] …{seg}…")
    print()
