"""Anchor an open recorded major attempt at its observed battle introduction.""" import json,re,time,pathlib,sys ROOT=pathlib.Path(__file__).resolve().parents[1];cfg=json.loads(pathlib.Path(sys.argv[1]).read_text());number=int(sys.argv[2]) p=ROOT/'recordings/major-fights'/f'session-{number:03}-attempts.json';rows=json.loads(p.read_text());row=rows[-1] assert row['id']==cfg['id'] and 'end'not in row norm=lambda s:re.sub('[^a-z]','',s.lower()).replace('amerthyst','amethyst').replace('meutuo','mewtwo').replace('meutwo','mewtwo') name=norm(cfg.get('intro_name',cfg['opponent']));hits=[] for line in(ROOT/'recordings/screens.jsonl').read_text().splitlines(): s=json.loads(line);text=' '.join(s['text']);c=norm(text) if s['epoch']