()
| 125 | |
| 126 | |
| 127 | def main() -> None: |
| 128 | parser = argparse.ArgumentParser(description="Export a balanced human-audit subset from simulation outputs.") |
| 129 | parser.add_argument("--input-dir", required=True, help="Simulation output directory") |
| 130 | parser.add_argument("--output-file", default=None, help="Output CSV path. Defaults to <input-dir>/human_audit_subset.csv") |
| 131 | parser.add_argument("--sample-size", type=int, default=200, help="Maximum audit rows to export") |
| 132 | parser.add_argument("--seed", type=int, default=42, help="Sampling seed") |
| 133 | parser.add_argument("--start-date", default=None, help="Optional YYYY-MM-DD start date") |
| 134 | parser.add_argument("--end-date", default=None, help="Optional YYYY-MM-DD end date") |
| 135 | parser.add_argument("--shown-only", action="store_true", help="Sample only Top-20 shown papers") |
| 136 | parser.add_argument("--abstract-chars", type=int, default=1200, help="Maximum abstract characters in the CSV") |
| 137 | args = parser.parse_args() |
| 138 | |
| 139 | input_dir = Path(args.input_dir) |
| 140 | rows = load_jsonl(input_dir / "episode_papers.jsonl") |
| 141 | if args.start_date: |
| 142 | rows = [row for row in rows if str(row.get("date") or "") >= args.start_date] |
| 143 | if args.end_date: |
| 144 | rows = [row for row in rows if str(row.get("date") or "") <= args.end_date] |
| 145 | if args.shown_only: |
| 146 | rows = [row for row in rows if row.get("shown")] |
| 147 | |
| 148 | sampled = balanced_sample(rows, args.sample_size, args.seed) |
| 149 | output_file = Path(args.output_file) if args.output_file else input_dir / "human_audit_subset.csv" |
| 150 | output_file.parent.mkdir(parents=True, exist_ok=True) |
| 151 | |
| 152 | with output_file.open("w", encoding="utf-8-sig", newline="") as f: |
| 153 | writer = csv.DictWriter(f, fieldnames=AUDIT_FIELDS) |
| 154 | writer.writeheader() |
| 155 | for row in sampled: |
| 156 | writer.writerow(normalize_for_audit(row, args.abstract_chars)) |
| 157 | |
| 158 | print(f"Human audit subset written to: {output_file}") |
| 159 | print(f"Rows exported: {len(sampled)}") |
| 160 | |
| 161 | |
| 162 | if __name__ == "__main__": |
no test coverage detected