Upload eval_baseline.py with huggingface_hub
Browse files- 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 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():
|