-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathanal.py
49 lines (37 loc) · 1.16 KB
/
anal.py
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
from functools import lru_cache
from glob import glob
import json
import re
import sys
data_list = glob(f"{sys.argv[1]}/jsons/*")
pattern = re.compile(r'\-?\d+\.\d+|\-?\d+')
right = 0
all_fail = 0
truncate = 8
print(len(data_list))
from run_with_earlystopping import check
retry_times = []
retry_times_no_one = []
def checklist(gt,anss):
for ans in anss:
if check(gt,ans):
return True
return False
for file in data_list:
with open(file, 'r') as f:
data = json.load(f)
retry_time = len(data['answers_list'])
retry_times.append(retry_time)
answers = []
for i in data['answers_list']:
if i in ["I Don't Know","I can't understand this question.","I can't help with this question.","I don't know how to solve this question.","I don't know the answer to this question.","I don't know the answer to this question, sorry."]:
pass
else:
answers.append(i)
if checklist(data['ground_truth'],answers):
right += 1
else:
all_fail += 1
import numpy as np
all_len = len(data_list)
print('Acc rate',right,all_len,right/all_len)