File size: 1,198 Bytes
87ab2b9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | """Deterministic candidate screening, without deleting original rows."""
from common import *
def exclusions(audits, originals):
test_ids={r['id'] for split,r in originals if split=='test'}
test_families={norm(r['scenario_family']) for split,r in originals if split=='test'}
# Exclude both sides of candidate pairs, rather than claiming one is correct.
neighbors=set()
for filename in ['v3_lexical_pairs.json','v3_semantic_pairs.json']:
for p in load(ROOT/'reports'/filename):
if {p['id_a'],p['id_b']}&test_ids:neighbors.update([p['id_a'],p['id_b']])
result={}
for a in audits:
r=next(r for _,r in originals if r['id']==a['id']);why=[]
if a['original_split']=='test':why.append('historical_test_reserved')
if a['decision']=='review':why+=a['reasons']
if norm(r['scenario_family']) in test_families:why.append('historical_test_family_reserved')
if r['id'] in neighbors:why.append('historical_test_neighbor_reserved')
if why:result[a['id']]=sorted(set(why))
return result
if __name__=='__main__':
print('Deduplication is a build stage; see reports/v4_disposition.parquet. No originals deleted.')
|