-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_cq_generalize.py
More file actions
70 lines (56 loc) · 1.92 KB
/
Copy pathmain_cq_generalize.py
File metadata and controls
70 lines (56 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Entry point for Step 2 of the CQ narrowing pipeline:
cross-paper generalisation.
Reads all Step 1 dedup outputs, groups CQs by archetype, and makes one
LLM call per archetype to produce domain-level generalised CQs.
Usage
─────
# Run on all dedup files in v2/dedup/
python main_cq_generalize.py
# Re-run and overwrite existing output
python main_cq_generalize.py --overwrite
Prerequisites
─────────────
Step 1 must have been run first:
python main_cq_dedup.py (single paper test)
python main_cq_dedup.py (all papers)
Output
──────
data/papers/v2/generalized/cross_paper_gen_v2.json ← combined
data/papers/v2/generalized/by_archetype/GEN_{ARCH}.json ← per archetype
"""
import argparse
import sys
from workflows.cq_generalize_flow import run_generalize_pipeline
def main() -> None:
parser = argparse.ArgumentParser(
description="CQ Cross-paper Generalisation — Step 2 of the CQ narrowing pipeline",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=__doc__,
)
parser.add_argument(
"--overwrite",
action="store_true",
default=False,
help="Overwrite existing generalisation output. Default: skip if output exists.",
)
args = parser.parse_args()
print("=" * 60)
print(" CQ Narrowing Pipeline — Step 2: Cross-paper Generalisation")
print("=" * 60)
print(f" Overwrite: {args.overwrite}")
print()
try:
out_path = run_generalize_pipeline(overwrite=args.overwrite)
except FileNotFoundError as exc:
print(f"\nERROR: {exc}", file=sys.stderr)
sys.exit(1)
except Exception as exc:
print(f"\nUnexpected error: {exc}", file=sys.stderr)
raise
print(f"\n{'=' * 60}")
print(f" Done — output written to:")
print(f" {out_path}")
print("=" * 60)
if __name__ == "__main__":
main()