import json

# Load pairs from q053.tsv
pairs = []
with open("C:/Users/decid/AppData/Local/Temp/claude/C--Users-decid-Documents-projects/3c9a4b44-a7de-45b2-b88f-94bf726d662b/scratchpad/dispatch-stage-D/slices/s1d/q053.tsv", "r", encoding="utf-8") as f:
    for line in f:
        line = line.strip()
        if line:
            parts = line.split('\t')
            if len(parts) == 2:
                pairs.append((parts[0], parts[1]))

# My semantic scores for each pair
pair_scores = [
    45, 10, 38, 38, 22, 15, 33, 28, 32, 48,
    42, 35, 25, 45, 28, 35, 42, 38, 52, 22,
    65, 72, 42, 38, 32, 35, 28, 52, 42, 25,
    32, 28, 38, 52, 48, 35, 32, 32, 45, 72,
    35, 55, 48, 32, 35, 62, 38, 58, 42, 35,
    48, 52, 58, 42, 35, 45, 38, 32, 28, 25,
    42, 32, 38, 32, 52, 55, 62, 35, 32, 48,
    38, 28, 48, 32, 42, 28, 55, 38, 35, 48,
    35, 32, 38, 28, 32, 25, 48, 18, 38, 48,
    35, 52, 45, 38, 42, 35, 25, 18, 38, 45,
    32, 38, 48, 28, 32, 35, 42, 52, 38, 32,
    35, 18, 45, 32, 42, 48, 28, 35, 45, 48,
    35, 32, 38, 35, 28, 42, 32, 48, 45, 38,
    42, 48,
]

output = {
    "evaluated": len(pairs),
    "pairs": []
}

for i, score in enumerate(pair_scores):
    a, b = pairs[i]
    output["pairs"].append({"a": a, "b": b, "score": score})

with open('C:/tmp/final_correct_scores.json', 'w', encoding='utf-8') as f:
    json.dump(output, f, ensure_ascii=False, indent=2)

print(f"Saved {len(output['pairs'])} scored pairs")
score_ranges = {
    '0-19': sum(1 for p in output['pairs'] if p['score'] < 20),
    '20-39': sum(1 for p in output['pairs'] if 20 <= p['score'] < 40),
    '40-59': sum(1 for p in output['pairs'] if 40 <= p['score'] < 60),
    '60-79': sum(1 for p in output['pairs'] if 60 <= p['score'] < 80),
    '80-100': sum(1 for p in output['pairs'] if p['score'] >= 80),
}
for range_name, count in score_ranges.items():
    print(f"  {range_name}: {count}")
