# -*- 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))

cee=clean("_19_CEE.txt")
print("="*20,"CEE")
for kw in ["Master of Science Degrees","concentration","Civil Engineering","Environmental Engineering","Civil and Infrastructure Systems","credit hours","The M.S.","non-thesis","GRE","TOEFL","prerequisite"]:
    m=re.search(re.escape(kw),cee)
    if m:
        s=max(0,m.start()-50); e=min(len(cee),m.end()+220); print(f"[{kw}] …{cee[s:e]}\n")

mse=clean("_19_MSE.txt")
print("="*20,"MSE")
for kw in ["Master of Science","interdisciplinar","area","focus","coursework","GRE","deadline","Spring","Fall 2027","TOEFL"]:
    m=re.search(re.escape(kw),mse)
    if m:
        s=max(0,m.start()-50); e=min(len(mse),m.end()+200); print(f"[{kw}] …{mse[s:e]}\n")

pb=clean("_19_PEABODY.txt")
print("="*20,"PEABODY len",len(pb))
for kw in ["Master of Education","M.Ed","credit","semester","full-time","part-time","online","Online","deadline","GRE","TOEFL","track","concentration","education policy","international"]:
    m=re.search(re.escape(kw),pb)
    if m:
        s=max(0,m.start()-60); e=min(len(pb),m.end()+200); print(f"[{kw}] …{pb[s:e]}\n")
