rudeparis commited on
Commit
f77f964
·
verified ·
1 Parent(s): e475094

Upload eval_baseline.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. eval_baseline.py +20 -24
eval_baseline.py CHANGED
@@ -48,35 +48,31 @@ def parse(text: str):
48
  return None
49
 
50
 
51
- def walk_scenarios():
52
- """Yield (scenario_id, turn_idx, atc_text, expected_intent, expected_params) for every ATC-to-ownship turn."""
 
 
 
 
53
  for path in sorted(SCENARIO_DIR.glob("*.json")):
54
  try:
55
  scn = json.loads(path.read_text())
56
  except Exception:
57
  continue
58
- scn_id = scn.get("id", path.stem)
59
- # Walk turns — schema varies slightly across scenario types
60
- # Most have "phases" with "atc_instructions" or top-level "turns" with "expected_*"
61
- phases = scn.get("phases") or scn.get("dialog") or []
62
- if not phases and "turns" in scn:
63
- phases = [{"atc_instructions": scn.get("turns", [])}]
64
- turn_idx = 0
65
- for phase in phases:
66
- for turn in phase.get("atc_instructions", []) + phase.get("turns", []):
67
- text = turn.get("atc_text") or turn.get("text") or turn.get("transmission")
68
- if not text:
69
- continue
70
- # Filter to ATC-to-ownship (skip pilot replies and broadcasts to others)
71
- addr = turn.get("addressed_to") or turn.get("speaker") or ""
72
- if "ownship" not in str(addr).lower() and "all aircraft" not in str(addr).lower() and addr:
73
- continue
74
- exp_intent = turn.get("expected_intent") or turn.get("intent")
75
- exp_params = turn.get("expected_parameters") or turn.get("parameters") or {}
76
- if not exp_intent:
77
- continue
78
- yield scn_id, turn_idx, text, exp_intent, exp_params
79
- turn_idx += 1
80
 
81
 
82
  def main():
 
48
  return None
49
 
50
 
51
+ def walk_scenarios(only_ownship: bool = True):
52
+ """Yield (scenario_id, turn_idx, atc_text, expected_intent, expected_params) per turn.
53
+
54
+ Schema: top-level `turns[]` with {speaker, target, expected_transcript, expected_intent, expected_parameters}.
55
+ ATC-to-ownship subset matches `just baseline`'s 253 scored turns when only_ownship=True.
56
+ """
57
  for path in sorted(SCENARIO_DIR.glob("*.json")):
58
  try:
59
  scn = json.loads(path.read_text())
60
  except Exception:
61
  continue
62
+ scn_id = scn.get("scenario_id", scn.get("id", path.stem))
63
+ for turn in scn.get("turns", []):
64
+ speaker = turn.get("speaker", "").lower()
65
+ target = turn.get("target", "").lower()
66
+ if speaker != "atc":
67
+ continue
68
+ if only_ownship and target != "ownship":
69
+ continue
70
+ text = turn.get("expected_transcript", "").strip()
71
+ exp_intent = turn.get("expected_intent")
72
+ exp_params = turn.get("expected_parameters") or {}
73
+ if not text or not exp_intent:
74
+ continue
75
+ yield scn_id, turn.get("turn_index", 0), text, exp_intent, exp_params
 
 
 
 
 
 
 
 
76
 
77
 
78
  def main():