File size: 1,121 Bytes
6eed659
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Combine EXACT des hybrides par langue sur devhard (oracle lang), + verif LID."""
import json, jiwer, itertools
ROWS=[json.loads(l) for l in open("/root/devhard/devhard_linsna.jsonl")]
H=json.load(open("/root/devhard_allhyps.json",encoding="utf-8"))
def comb(R,Hy):
    pr=[(r,h) for r,h in zip(R,Hy) if r.strip()]
    r=[x for x,_ in pr]; h=[x for _,x in pr]
    w=jiwer.wer(r,h); c=jiwer.cer(r,h); return w,c,0.5*w+0.5*c
LIN=["lin_s4_best","joint_cont2_best","joint_cont_best","mms1b_lin_best"]
SNA=["sna_ps_best","joint_cont2_best","joint_cont_best"]
print("=== hybrides (oracle langue) ===")
res=[]
for a,b in itertools.product(LIN,SNA):
    hy=[H[a][r["id"]] if r["lang"]=="lin" else H[b][r["id"]] for r in ROWS]
    w,c,m=comb([r["text"] for r in ROWS],hy)
    res.append((m,a,b,w,c))
for m,a,b,w,c in sorted(res):
    print(f"  {m:.4f}  lin<-{a:18s} sna<-{b:18s} (WER {w:.4f} CER {c:.4f})")
print()
print("=== references simples ===")
for n in ["joint_cont_best","joint_cont2_best"]:
    w,c,m=comb([r["text"] for r in ROWS],[H[n][r["id"]] for r in ROWS])
    print(f"  {m:.4f}  {n}  (WER {w:.4f} CER {c:.4f})")