# -*- 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); t=html.unescape(re.sub(r"\s+"," ",t))
    return t
for k in ["ece","me","cbe"]:
    t=clean("_17_"+k+".txt")
    print("\n"+"="*20,k,"len",len(t))
    for kw in ["Master of Science","Master of Engineering","PhD","credit","admission","deadline","application deadline","TOEFL","IELTS","GRE","tuition","stipend","STEM","concentration","track","thesis","course"]:
        m=re.search(re.escape(kw),t,re.I)
        if m:
            s=max(0,m.start()-70); e=min(len(t),m.end()+180)
            print(f"[{kw}] {t[s:e]}")
