File size: 842 Bytes
1915a02
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Count FOF-Bench fields that are not strings, per split.
# Usage: uv run --no-project python -I malformed_fields.py <dir with train.jsonl val.jsonl test.jsonl>
import collections, csv, json, os, sys
d = sys.argv[1]
w = csv.writer(sys.stdout)
w.writerow(["split", "rows", "nonstring_anchor", "nonstring_positive", "nonstring_negative", "objects_with_plan_key"])
for split in ("train", "val", "test"):
    rows = 0; bad = collections.Counter(); plan = 0
    for line in open(os.path.join(d, f"{split}.jsonl"), encoding="utf-8"):
        r = json.loads(line); rows += 1
        for f in ("anchor", "positive", "negative"):
            if not isinstance(r[f], str):
                bad[f] += 1
                plan += isinstance(r[f], dict) and "plan" in r[f]
    w.writerow([split, rows, bad["anchor"], bad["positive"], bad["negative"], plan])