24 lines
2.1 KiB
Python
24 lines
2.1 KiB
Python
"""Bind existing authored result copy to repaired exact question identities."""
|
|
import copy,json
|
|
from pathlib import Path
|
|
r=Path(__file__).resolve().parents[2];base=r/'PlotLine/Content/WritingSolver'
|
|
old=json.loads((base/'Candidates/curated-v2-stage1/writing-solver-curated-v2-stage1.json').read_text());oldids={n['id'] for n in old['nodes']}
|
|
g=json.loads((base/'Candidates/curated-v2-stage1-repair/writing-solver-curated-v2-stage1-repair.json').read_text());path=base/'Presentation/results-v1.json';catalog=json.loads(path.read_text())
|
|
catalog['evidence']=[e for e in catalog['evidence'] if e['node'] in oldids];source=copy.deepcopy(catalog['evidence'])
|
|
dominance={'even':'You want the other threads to carry more of the book than they currently do.','disappears':'The supporting threads disappear while the main storyline is prominent, and you want those gaps addressed.','connect':'The other threads are present but do not clearly affect the main plot, and you want that connection clearer.','lost':'You want a central main plot, but keep losing track of the supporting threads.'}
|
|
for node in g['nodes']:
|
|
if node['id'] in oldids:continue
|
|
for choice in node['choices']:
|
|
obs={k for k,v in choice['weights'].items() if k.startswith('observed-') and v>0}
|
|
matched=[s['id'] for s in g['solutions'] if obs.intersection(s['requiredSignals'])]
|
|
if not matched:continue
|
|
if node['id']=='final-dominance':text=dominance[choice['id']]
|
|
else:
|
|
family=node['id'].split('-')[1]
|
|
candidates=[e for e in source if e['node'].startswith('check-'+family) and e['choice']==choice['id'] and e['priority']==100 and set(e['solutions'])==set(matched)]
|
|
assert candidates,(node['id'],choice['id'],matched)
|
|
text=candidates[0]['text']
|
|
catalog['evidence'].append(dict(node=node['id'],choice=choice['id'],solutions=matched,text=text,priority=100))
|
|
if node['id'].startswith('final-') and node['id']!='final-dominance':catalog['evidence'].append(dict(node=node['id'],choice=choice['id'],solutions=matched,text='You identified this as a difficulty you want help with.',priority=80))
|
|
path.write_text(json.dumps(catalog,ensure_ascii=False,indent=2)+'\n')
|