# -*- coding: utf-8 -*-
import os, io, sys, re, glob
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
BASE=os.path.dirname(os.path.abspath(__file__))
KW=['Master','degree','credit','credits','semester','term','full-time','part-time','online','on-campus','in person','residential','STEM','GRE','GMAT','TOEFL','IELTS','Duolingo','deadline','application','tuition','fee','thesis','capstone','co-op','Co-op','honours','GPA','bachelor','admission','required','optional','minimum','Fall','Spring','international']
for fn in sorted(glob.glob(os.path.join(BASE,'_28_*.html'))):
    t=open(fn,encoding='utf-8').read()
    print('\n==========',os.path.basename(fn),'len',len(t))
    # 标题段
    print('HEAD:',t[:300])
    low=t.lower()
    for k in ['online','part-time','part time','hybrid','distance','executive']:
        c=low.count(k)
        if c: print('  KW',k,c)
    # 句子级命中关键词
    sents=re.split(r'(?<=[.])\s+',t)
    seen=set()
    for s in sents:
        sl=s.lower()
        if any(k.lower() in sl for k in ['credit','semester','full-time','part-time','online','stem','gre','gmat','toefl','ielts','tuition','deadline','thesis','capstone','co-op','minimum','bachelor','honours']):
            s2=s.strip()
            if 20<len(s2)<320 and s2 not in seen:
                seen.add(s2); print('  -',s2[:300])
