File size: 1,199 Bytes
0eb2e78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
"""Random sample of coded threads for manual review (local only; prints titles/excerpts).
Usage: python3 -I scripts/sample_for_review.py coded_kw.jsonl N [seed] [--exclude judgement.csv ...]
Prints one block per thread plus a CSV header to fill in manual/judgement_full.csv (keyed by url)."""
import json, random, sys, csv
args = sys.argv[1:]
excl = set()
if "--exclude" in args:
    i = args.index("--exclude")
    for p in args[i + 1:]:
        excl |= {r.get("url") for r in csv.DictReader(open(p)) if r.get("url")}
    args = args[:i]
coded = [json.loads(l) for l in open(args[0])]
n, seed = int(args[1]), int(args[2]) if len(args) > 2 else 20261028
pool = [c for c in coded if c["url"] not in excl]
random.Random(seed).shuffle(pool)
for c in pool[:n]:
    print(f'{c["url"]} [{c["state"]}/{c["state_reason"]}] T: {c["title"]}')
    print(f'   E: {c["excerpt_private"]}')
    print(f'   KW rel={c["kw_relevant"]} host={c["kw_target_host"]} app={c["kw_app_type"]} fw={c["kw_framework"]} '
          f'prov={c["kw_model_provider"]} cat={c["kw_topic"]} err={c["kw_error_type"]} '
          f'res={c["kw_resolution_type"]} aigen={c["kw_ai_generated_app"]}/{c["kw_ai_tool"]}')