Upload eval_baseline.py with huggingface_hub
Browse files47 unmodified lines4849505152515253545556575859606158596061626364656667686970717273747576777879626364656667686970717273747576777847 unmodified lines return None
def walk_scenarios(): """Yield (scenario_id, turn_idx, atc_text, expected_intent, expected_params) for every ATC-to-ownship turn."""def 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: continue scn_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 = 0 for 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: continue exp_intent = turn.get("expected_intent") or turn.get("intent") exp_params = turn.get("expected_parameters") or turn.get("parameters") or {} if not exp_intent: continue yield scn_id, turn_idx, text, exp_intent, exp_params turn_idx += 1 scn_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": continue if only_ownship and target != "ownship": continue text = 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: continue yield scn_id, turn.get("turn_index", 0), text, exp_intent, exp_params
def main():eval_baseline.py+20-24