# -*- coding: utf-8 -*-
import io, os, re, sys
pat = sys.argv[1]
roots = ['_r375_txt']
rx = re.compile(pat, re.I)
for root in roots:
    for f in sorted(os.listdir(root)):
        if not f.endswith('.txt'):
            continue
        try:
            t = io.open(os.path.join(root, f), encoding='utf-8', errors='ignore').read()
        except Exception:
            continue
        for m in rx.finditer(t):
            s = max(0, m.start() - 60)
            print(f, '|', t[s:m.end() + 80].replace('\n', ' ')[:200])
