File size: 1,509 Bytes
dedbd79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import csv
from collections import Counter, defaultdict
from pathlib import Path

OUTPUT_DIR = Path(__file__).resolve().parent / "survey_outputs"


def load_rows():
    rows = []
    for path in sorted(OUTPUT_DIR.glob("*.csv")):
        with path.open("r", encoding="utf-8") as f:
            reader = csv.DictReader(f)
            for row in reader:
                row["_source_file"] = path.name
                rows.append(row)
    return rows


def summarize(rows):
    total = 0
    ours = 0
    baseline = 0
    by_baseline = defaultdict(Counter)

    for row in rows:
        choice = row.get("chosen_source")
        if not choice:
            continue
        total += 1
        if choice == "ours":
            ours += 1
        else:
            baseline += 1
        by_baseline[row.get("baseline", "unknown")][choice] += 1

    return total, ours, baseline, by_baseline


def main():
    if not OUTPUT_DIR.exists():
        print(f"No outputs found. Missing {OUTPUT_DIR}.")
        return

    rows = load_rows()
    total, ours, baseline, by_baseline = summarize(rows)

    print("Overall")
    print(f"- answered: {total}")
    print(f"- ours: {ours}")
    print(f"- baseline: {baseline}")

    print("\nBy baseline")
    for baseline_name in sorted(by_baseline.keys()):
        c = by_baseline[baseline_name]
        print(
            f"- {baseline_name}: ours {c.get('ours', 0)} | "
            f"{baseline_name} {c.get(baseline_name, 0)}"
        )


if __name__ == "__main__":
    main()