(
input_dir: Path,
output_dir: Path,
*,
roles_file: Path,
top_k: int = DEFAULT_TOP_K,
background_negatives_per_day: int = DEFAULT_BACKGROUND_NEGATIVES_PER_DAY,
)
| 837 | |
| 838 | |
| 839 | def run_baseline( |
| 840 | input_dir: Path, |
| 841 | output_dir: Path, |
| 842 | *, |
| 843 | roles_file: Path, |
| 844 | top_k: int = DEFAULT_TOP_K, |
| 845 | background_negatives_per_day: int = DEFAULT_BACKGROUND_NEGATIVES_PER_DAY, |
| 846 | ) -> Dict[str, Any]: |
| 847 | input_dir = input_dir.resolve() |
| 848 | output_dir = output_dir.resolve() |
| 849 | episodes_path = input_dir / "episodes.jsonl" |
| 850 | if not episodes_path.exists(): |
| 851 | raise FileNotFoundError(f"Missing benchmark episodes: {episodes_path}") |
| 852 | |
| 853 | output_dir.mkdir(parents=True, exist_ok=True) |
| 854 | rows, label_rows = load_clean_benchmark_inputs(input_dir) |
| 855 | episode_rows = load_jsonl(episodes_path) |
| 856 | reranked_rows, method_stats = rerank_episodes( |
| 857 | rows, |
| 858 | label_rows, |
| 859 | top_k=top_k, |
| 860 | roles_file=roles_file, |
| 861 | input_dir=input_dir, |
| 862 | background_negatives_per_day=background_negatives_per_day, |
| 863 | ) |
| 864 | |
| 865 | write_jsonl(output_dir / "episode_papers.jsonl", reranked_rows) |
| 866 | shutil.copy2(episodes_path, output_dir / "episodes.jsonl") |
| 867 | if (input_dir / "users.json").exists(): |
| 868 | shutil.copy2(input_dir / "users.json", output_dir / "users.json") |
| 869 | |
| 870 | evaluation = write_evaluation(output_dir, reranked_rows, episode_rows) |
| 871 | method_stats["input_dir"] = str(input_dir) |
| 872 | method_stats["output_dir"] = str(output_dir) |
| 873 | method_stats["roles_file"] = str(roles_file) |
| 874 | method_stats["using_clean_input"] = True |
| 875 | (output_dir / "scholar_inbox_summary.json").write_text( |
| 876 | json.dumps(method_stats, ensure_ascii=False, indent=2), |
| 877 | encoding="utf-8", |
| 878 | ) |
| 879 | return {"method_stats": method_stats, "evaluation": evaluation} |
| 880 | |
| 881 | |
| 882 | def parse_args() -> argparse.Namespace: |
no test coverage detected