Upload eval_baseline.py with huggingface_hub
Browse files47 unmodified lines484950515253545556575859606162636465666768697071727374757677787980818247 unmodified linesreturn Nonedef walk_scenarios():"""Yield (scenario_id, turn_idx, atc_text, expected_intent, expected_params) for every ATC-to-ownship turn."""for path in sorted(SCENARIO_DIR.glob("*.json")):try:scn = json.loads(path.read_text())except Exception:continuescn_id = scn.get("id", path.stem)# Walk turns — schema varies slightly across scenario types# Most have "phases" with "atc_instructions" or top-level "turns" with "expected_*"phases = scn.get("phases") or scn.get("dialog") or []if not phases and "turns" in scn:phases = [{"atc_instructions": scn.get("turns", [])}]turn_idx = 0for phase in phases:for turn in phase.get("atc_instructions", []) + phase.get("turns", []):text = turn.get("atc_text") or turn.get("text") or turn.get("transmission")if not text:continue# Filter to ATC-to-ownship (skip pilot replies and broadcasts to others)addr = turn.get("addressed_to") or turn.get("speaker") or ""if "ownship" not in str(addr).lower() and "all aircraft" not in str(addr).lower() and addr:continueexp_intent = turn.get("expected_intent") or turn.get("intent")exp_params = turn.get("expected_parameters") or turn.get("parameters") or {}if not exp_intent:continueyield scn_id, turn_idx, text, exp_intent, exp_paramsturn_idx += 1def main():47 unmodified lines4849505152535455565758596061626364656667686970717273747576777847 unmodified linesreturn Nonedef walk_scenarios(only_ownship: bool = True):"""Yield (scenario_id, turn_idx, atc_text, expected_intent, expected_params) per turn.Schema: top-level `turns[]` with {speaker, target, expected_transcript, expected_intent, expected_parameters}.ATC-to-ownship subset matches `just baseline`'s 253 scored turns when only_ownship=True."""for path in sorted(SCENARIO_DIR.glob("*.json")):try:scn = json.loads(path.read_text())except Exception:continuescn_id = scn.get("scenario_id", scn.get("id", path.stem))for turn in scn.get("turns", []):speaker = turn.get("speaker", "").lower()target = turn.get("target", "").lower()if speaker != "atc":continueif only_ownship and target != "ownship":continuetext = turn.get("expected_transcript", "").strip()exp_intent = turn.get("expected_intent")exp_params = turn.get("expected_parameters") or {}if not text or not exp_intent:continueyield scn_id, turn.get("turn_index", 0), text, exp_intent, exp_paramsdef main():
eval_baseline.py+20-24