File size: 1,786 Bytes
c202fc8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Shared resolution of per-rater synthetic-ratings tables.

Every analysis that consumes synthetic ratings takes a `--model <slug>` and
routes through here, so adding a rater never means editing a hardcoded path.

    data/main_study/synth_long_{audio,text}_table_<slug>.csv

`gpt4o` falls back to the unsuffixed tables the paper was written against, so
running any of these scripts with no arguments reproduces the published
numbers exactly.
"""

from __future__ import annotations

from pathlib import Path

import pandas as pd

STUDY = Path("data/main_study")
DEFAULT_MODEL = "gpt4o"


def synth_path(model: str, modality: str) -> Path:
    """Path to one rater's long table. modality in {'audio', 'text'}."""
    path = STUDY / f"synth_long_{modality}_table_{model}.csv"
    if path.exists():
        return path

    fallback = STUDY / f"synth_long_{modality}_table.csv"
    if model == DEFAULT_MODEL and fallback.exists():
        return fallback

    raise FileNotFoundError(
        f"{path} not found. Generate it with:\n"
        f"  python analysis/01_data_prep/03_synth_to_long_csv_multi.py "
        f"--model {model}"
    )


def load_synth(model: str, modality: str) -> pd.DataFrame:
    return pd.read_csv(synth_path(model, modality))


def add_model_arg(parser) -> None:
    parser.add_argument(
        "--model", default=DEFAULT_MODEL,
        help=f"synthetic rater slug (default: {DEFAULT_MODEL}, the published run)",
    )


def tag(model: str) -> str:
    """
    Filename suffix for outputs.

    Empty for the default rater so the published artifacts keep their names and
    are overwritten in place; '_<slug>' for anything else so a new rater cannot
    silently clobber the paper's figures.
    """
    return "" if model == DEFAULT_MODEL else f"_{model}"