"""Run beside samples.json: python reproduce.py. Standard library only; no network."""
import json, re
from pathlib import Path
from difflib import SequenceMatcher
data = json.loads(Path(__file__).with_name('samples.json').read_text(encoding='utf-8'))
def tokens(t):
    return re.findall(r"\w+(?:'\w+)*", t.replace('’', "'").casefold())
for c in data['cases']:
    a, b = tokens(c['reference']), tokens(c['draft'])
    different = any(op != 'equal' for op, *_ in SequenceMatcher(None, a, b, autojunk=False).get_opcodes())
    assert different == c['result']['wording_difference'], c['id']
    print(c['id'], 'wording difference' if different else 'no wording difference')
print('Reproduced', len(data['cases']), 'constructed comparisons. Not an ASR accuracy test.')
