# -*- coding: utf-8 -*-
"""r378：从 program-requirements 全文抽关键字行（课程/单元/考试/学制）。"""
import io, re, sys

KEY = ('units', 'course', 'Course', 'examination', 'Examination', 'quarters',
       'degree', 'thesis', 'dissertation', 'GPA', 'grade', 'Teaching', 'required')

for f in sys.argv[1:]:
    t = io.open('_r375_txt/' + f, encoding='utf-8').read()
    lines = [l.strip() for l in t.splitlines() if len(l.strip()) > 40]
    print('=====', f, len(t), 'lines', len(lines))
    seen = set()
    out = []
    for l in lines:
        if any(k in l for k in KEY) and l not in seen:
            seen.add(l)
            out.append(l)
    print('\n'.join(out[:34]))
