(
input_dir: Path,
output_dir: Path,
*,
roles_file: Path,
top_k: int = DEFAULT_TOP_K,
)
| 618 | |
| 619 | |
| 620 | def run_baseline( |
| 621 | input_dir: Path, |
| 622 | output_dir: Path, |
| 623 | *, |
| 624 | roles_file: Path, |
| 625 | top_k: int = DEFAULT_TOP_K, |
| 626 | ) -> Dict[str, Any]: |
| 627 | input_dir = input_dir.resolve() |
| 628 | output_dir = output_dir.resolve() |
| 629 | episodes_path = input_dir / "episodes.jsonl" |
| 630 | if not episodes_path.exists(): |
| 631 | raise FileNotFoundError(f"Missing benchmark episodes: {episodes_path}") |
| 632 | |
| 633 | output_dir.mkdir(parents=True, exist_ok=True) |
| 634 | rows, label_rows = load_clean_benchmark_inputs(input_dir) |
| 635 | episode_rows = load_jsonl(episodes_path) |
| 636 | reranked_rows, method_stats = rerank_episodes( |
| 637 | rows, |
| 638 | label_rows, |
| 639 | top_k=top_k, |
| 640 | roles_file=roles_file, |
| 641 | input_dir=input_dir, |
| 642 | ) |
| 643 | |
| 644 | write_jsonl(output_dir / "episode_papers.jsonl", reranked_rows) |
| 645 | shutil.copy2(episodes_path, output_dir / "episodes.jsonl") |
| 646 | if (input_dir / "users.json").exists(): |
| 647 | shutil.copy2(input_dir / "users.json", output_dir / "users.json") |
| 648 | |
| 649 | evaluation = write_evaluation(output_dir, reranked_rows, episode_rows) |
| 650 | method_stats["input_dir"] = str(input_dir) |
| 651 | method_stats["output_dir"] = str(output_dir) |
| 652 | method_stats["roles_file"] = str(roles_file) |
| 653 | method_stats["using_clean_input"] = True |
| 654 | (output_dir / "nl_profile_summary.json").write_text( |
| 655 | json.dumps(method_stats, ensure_ascii=False, indent=2), |
| 656 | encoding="utf-8", |
| 657 | ) |
| 658 | return {"method_stats": method_stats, "evaluation": evaluation} |
| 659 | |
| 660 | |
| 661 | def parse_args() -> argparse.Namespace: |
no test coverage detected