| 526 | |
| 527 | |
| 528 | def clone_output_row( |
| 529 | row: Dict[str, Any], |
| 530 | label: Dict[str, Any], |
| 531 | score_payload: Dict[str, Any], |
| 532 | rank: int, |
| 533 | top_k: int, |
| 534 | ) -> Dict[str, Any]: |
| 535 | output = dict(row) |
| 536 | shown = rank <= top_k |
| 537 | output.update( |
| 538 | { |
| 539 | "baseline_method": METHOD_NAME, |
| 540 | "ranking_source": "baselines.citation_enhanced.runner", |
| 541 | "ranking_fallback": False, |
| 542 | "shown": shown, |
| 543 | "pool_rank": rank, |
| 544 | "system_rank": rank if shown else None, |
| 545 | "system_score": round(float(score_payload["system_score"]), 6), |
| 546 | "system_label": score_payload["system_label"], |
| 547 | "show_target_count": top_k, |
| 548 | "drift_bonus": 0.0, |
| 549 | "drift_topics": [], |
| 550 | "reading_signal_bonus": 0.0, |
| 551 | "reading_signal_topics": [], |
| 552 | "selected": bool(label.get("selected")), |
| 553 | "oracle_score": label.get("oracle_score", 0.0), |
| 554 | "oracle_label": label.get("oracle_label", "irrelevant"), |
| 555 | "select_probability": 0.0, |
| 556 | } |
| 557 | ) |
| 558 | for key, value in score_payload.items(): |
| 559 | if key in {"system_score", "system_label"}: |
| 560 | continue |
| 561 | if isinstance(value, float): |
| 562 | output[key] = round(value, 6) |
| 563 | else: |
| 564 | output[key] = value |
| 565 | return output |
| 566 | |
| 567 | |
| 568 | def group_by_episode(rows: Sequence[Dict[str, Any]]) -> Dict[str, List[Dict[str, Any]]]: |