forked from gregdurrett/fp-dataset-artifacts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_errors.py
More file actions
22 lines (17 loc) · 690 Bytes
/
Copy pathview_errors.py
File metadata and controls
22 lines (17 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import json
# Path to the input JSON file
input_file = "output-snli-lit-dev-perturbed-baseline/eval_predictions.jsonl"
# Path to save filtered mismatches
output_file = "output-snli-lit-dev-perturbed-baseline/wrong_predictions.json"
# Read the JSON file line by line and filter mismatches
mismatches = []
with open(input_file, "r") as f:
for line in f:
data = json.loads(line.strip())
if data["label"] != data["predicted_label"]:
mismatches.append(data)
# Save mismatches to a new JSON file
with open(output_file, "w") as f:
for mismatch in mismatches:
f.write(json.dumps(mismatch) + "\n")
print(f"Filtered mismatches saved to {output_file}")