-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsanity_check.py
More file actions
36 lines (33 loc) · 1.13 KB
/
sanity_check.py
File metadata and controls
36 lines (33 loc) · 1.13 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
import jsonlines
turn_data = []
with jsonlines.open("./data/turn_level_data_final_w_last_workflow.jsonl") as reader:
for obj in reader:
turn_data.append(obj)
print(f"total number of turns: {len(turn_data)}")
cnt_dict = {
"SINGLE": 0,
"AND": 0,
"OR": 0,
"UNK": 0,
"stay": 0
}
for turn in turn_data:
if not isinstance(turn["messages"], list):
raise ValueError("messages is not a list")
context = "\n".join([f"{item['role']}: {item['content']}" for item in turn["messages"]])
# for message in turn["messages"]:
# if not isinstance(message, dict):
# print(message)
if turn["last_turn_workflow"] == turn["answer"] and turn["answer_type"] != "UNK":
cnt_dict["stay"] += 1
if "answer_type" not in turn:
raise ValueError("turn does not have answer_type")
elif turn["answer_type"] == "UNK":
cnt_dict["UNK"] += 1
elif turn["answer_type"] == "SINGLE":
cnt_dict["SINGLE"] += 1
elif turn["answer_type"] == "AND":
cnt_dict["AND"] += 1
elif turn["answer_type"] == "OR":
cnt_dict["OR"] += 1
print(cnt_dict)