#!/usr/bin/env python3
"""McNemar worked example (LAT-2246 topic 2 / LAT-2253 tool spec).

Two reviewers decide approve/deny on the SAME 200 cases. Constructed so the
pedagogy is sharp:
  - raw agreement is HIGH (85%) and kappa is respectable (~0.66) -- the surfaces
    a naive check looks at say "fine";
  - but the 30 disagreements are lopsided: 24 go one way, 6 the other. McNemar
    is the test that sees THAT, because it only looks at the discordant pairs.

Cell counts (fixed by design, then shuffled with seed 42 into case order):
  both approve = 120, both deny = 50, A-only approve = 6, B-only approve = 24.
"""
import csv
import random

BOTH_YES, BOTH_NO, A_ONLY, B_ONLY = 120, 50, 6, 24

rows = ([("approve", "approve")] * BOTH_YES + [("deny", "deny")] * BOTH_NO +
        [("approve", "deny")] * A_ONLY + [("deny", "approve")] * B_ONLY)
random.Random(42).shuffle(rows)

with open("cases.csv", "w", newline="") as f:
    w = csv.writer(f)
    w.writerow(["case_id", "reviewer_a", "reviewer_b"])
    for i, (a, b) in enumerate(rows, 1):
        w.writerow([f"case_{i:03d}", a, b])
print(f"wrote cases.csv: n={len(rows)}")
