forked from SpeechColab/Leaderboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrep_result
executable file
·33 lines (27 loc) · 905 Bytes
/
grep_result
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
#!/usr/bin/env python3
import sys, glob, os
import json
if (len(sys.argv) != 2):
print('show_result.py "result_dir_pattern"')
exit(0)
pattern = sys.argv[1]
directories = glob.glob(pattern)
buffer=[]
print('MODEL,TESTSET,ACC,TER,N:HYP:REF:MAX,DATE')
for dir in directories:
try:
date, service, test_set, max_utts = dir.split('__')
with open(os.path.join(dir, 'RESULTS.txt'), 'r', encoding = 'utf8') as f:
for l in f:
if 'token_error_rate' in l:
r = json.loads(l)
TER = r['token_error_rate']
R = r['num_ref_utts']
H = r['num_hyp_utts']
n = r['num_eval_utts']
buffer.append(F"{service},{test_set},{100-TER:.2f},{TER:.2f},{n}:{H}:{R}:{max_utts},{date}")
except:
continue
buffer.sort()
for l in buffer:
print(l)