(
input_dir: Path,
output_dir: Path,
*,
roles_file: Path,
top_k: int = DEFAULT_TOP_K,
)
| 852 | |
| 853 | |
| 854 | def run_baseline( |
| 855 | input_dir: Path, |
| 856 | output_dir: Path, |
| 857 | *, |
| 858 | roles_file: Path, |
| 859 | top_k: int = DEFAULT_TOP_K, |
| 860 | ) -> Dict[str, Any]: |
| 861 | input_dir = input_dir.resolve() |
| 862 | output_dir = output_dir.resolve() |
| 863 | episodes_path = input_dir / "episodes.jsonl" |
| 864 | if not episodes_path.exists(): |
| 865 | raise FileNotFoundError(f"Missing benchmark episodes: {episodes_path}") |
| 866 | |
| 867 | output_dir.mkdir(parents=True, exist_ok=True) |
| 868 | rows, label_rows = load_clean_benchmark_inputs(input_dir) |
| 869 | episode_rows = load_jsonl(episodes_path) |
| 870 | reranked_rows, method_stats = rerank_episodes( |
| 871 | rows, |
| 872 | label_rows, |
| 873 | top_k=top_k, |
| 874 | roles_file=roles_file, |
| 875 | input_dir=input_dir, |
| 876 | ) |
| 877 | |
| 878 | write_jsonl(output_dir / "episode_papers.jsonl", reranked_rows) |
| 879 | shutil.copy2(episodes_path, output_dir / "episodes.jsonl") |
| 880 | if (input_dir / "users.json").exists(): |
| 881 | shutil.copy2(input_dir / "users.json", output_dir / "users.json") |
| 882 | |
| 883 | evaluation = write_evaluation(output_dir, reranked_rows, episode_rows) |
| 884 | method_stats["input_dir"] = str(input_dir) |
| 885 | method_stats["output_dir"] = str(output_dir) |
| 886 | method_stats["roles_file"] = str(roles_file) |
| 887 | method_stats["using_clean_input"] = True |
| 888 | (output_dir / "knowledge_entity_summary.json").write_text( |
| 889 | json.dumps(method_stats, ensure_ascii=False, indent=2), |
| 890 | encoding="utf-8", |
| 891 | ) |
| 892 | return {"method_stats": method_stats, "evaluation": evaluation} |
| 893 | |
| 894 | |
| 895 | def parse_args() -> argparse.Namespace: |
no test coverage detected