ó
    óó�jÍ  ã                   ó  • S r SSKrSSKJr  \R                  4S jr\R                  SSSS4S jr\R                  4S	 jr\R                  4S
 jrSS\R                  4S jr	SS\R                  4S jr
\R                  4S jrg)zþWER print functions.

The functions here are used to print the computed statistics
with human-readable formatting.
They have a file argument, but you can also just use
contextlib.redirect_stdout, which may give a nicer syntax.

Authors
 * Aku Rouhe 2020
é    N)Úedit_distancec                 óÒ   • [        SR                  " S0 U D6USS9  [        U S   U S   :  a  SOSUS9  [        SR                  " S0 U D6US9  [        S	R                  " S0 U D6US9  g
)aJ  Prints out WER summary details in human-readable format.

This function essentially mirrors the Kaldi compute-wer output format.

Arguments
---------
wer_details : dict
    Dict of wer summary details,
    see ``speechbrain.utils.edit_distance.wer_summary``
    for format.
file : stream
    Where to write. (default: sys.stdout)
zl%WER {WER:.2f} [ {num_edits} / {num_scored_tokens}, {insertions} ins, {deletions} del, {substitutions} sub ]Ú )ÚfileÚendÚnum_scored_sentsÚnum_ref_sentsz
 [PARTIAL]©r   z=%SER {SER:.2f} [ {num_erroneous_sents} / {num_scored_sents} ]zKScored {num_scored_sents} sentences, {num_absent_sents} not present in hyp.N© ©ÚprintÚformat©Úwer_detailsr   s     Ú¤C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\speechbrain/dataio/wer.pyÚprint_wer_summaryr      sž   € ô 
Øv×}Ò}ñ 	
Øñ	
ð Øòô 
ð Ð-Ñ.°¸_Ñ1MÓMñ ààòô 
ØG×NÒNñ 	
Øñ	
ð ò	ô 
ØU×\Ò\ñ 	
Øñ	
ð ó	ó    z<eps>z ; Tc           
      óÂ   • U(       a
  [        XUS9  U  HH  nUS   (       d  M  U(       a	  [        XaS9  [        US   US   US   UUUS9  U(       d  M?  [        XQS9  MJ     g)aF  Print WER summary and alignments.

Arguments
---------
details_by_utterance : list
    List of wer details by utterance,
    see ``speechbrain.utils.edit_distance.wer_details_by_utterance``
    for format. Has to have alignments included.
file : stream
    Where to write. (default: sys.stdout)
empty_symbol : str
    Symbol to use when aligning to nothing.
separator : str
    String that separates each token in the output. Note the spaces in the
    default.
print_header: bool
    Whether to print headers
sample_separator: str
    A separator to put between samples (optional)
©r   Úempty_symbolÚ	separatorÚscoredr
   Ú	alignmentÚ
ref_tokensÚ
hyp_tokensN)Ú_print_alignments_global_headerÚ_print_alignment_headerÚ_print_alignmentr   )Údetails_by_utterancer   r   r   Úprint_headerÚsample_separatorÚdetss          r   Úprint_alignmentsr#   <   sn   € ö8 Ü'Ø¸Iò	
ó %ˆØ��>‰>ÞÜ'¨Ò8ÜØ�[Ñ!Ø�\Ñ"Ø�\Ñ"ØØ)Ø#ò÷  ÐÜÐ&Ô2ò %r   c                 ó(  • [        SUS9  [        SUS9  U (       a.  [        SUS9  U  H  n[        SR                  " S	0 UD6US9  M     O
[        SUS9  U(       a.  [        SUS9  U H  n[        SR                  " S	0 UD6US9  M     g [        SUS9  g )
NúP================================================================================r
   zUTTERANCES WITH HIGHEST WERzANon-empty hypotheses -- utterances for which output was produced:z{key} %WER {WER:.2f}z(No utterances which had produced output!z@Empty hypotheses -- utterances for which no output was produced:z,No utterances which had not produced output!r   r   )Útop_non_emptyÚ	top_emptyr   r"   s       r   Ú_print_top_wer_uttsr(   n   s�   € Ü	ˆ(˜ÒÜ	Ð
'¨dÒ3ÞÜØOØò	
ó "ˆDÜÐ(×/Ò/Ñ7°$Ñ7¸dÔCò "ô 	Ð8¸tÒDÞÜØNØò	
ó ˆDÜÐ(×/Ò/Ñ7°$Ñ7¸dÔCò ô 	Ð<À4ÓHr   c                 ór   • [        SUS9  [        SUS9  U  H  n[        SR                  " S0 UD6US9  M     g )Nr%   r
   zSPEAKERS WITH HIGHEST WERz{speaker} %WER {WER:.2f}r   r   )Úspks_by_werr   r"   s      r   Ú_print_top_wer_spksr+   …   s:   € Ü	ˆ(˜ÒÜ	Ð
%¨DÒ1ÛˆÜÐ(×/Ò/Ñ7°$Ñ7¸dÔCò r   c                 ó,  • / n/ n/ nU  H½  u  pšn[        U	5      nU
b  [        X   5      OUnUb  [        X+   5      OUn[        [        U5      [        U5      [        U5      5      nUR                  UR	                  U5      5        UR                  UR	                  U5      5        UR                  UR	                  U5      5        M¿     [        UR                  U5      US9  [        UR                  U5      US9  [        UR                  U5      US9  g )Nr
   )ÚstrÚmaxÚlenÚappendÚcenterr   Újoin)r   ÚaÚbr   r   r   Úa_paddedÚb_paddedÚ
ops_paddedÚopÚiÚjÚ	op_stringÚa_stringÚb_stringÚ
pad_lengths                   r   r   r   Œ   sæ   € ð €HØ€HØ€JÛ‰ˆˆqÜ˜“Gˆ	Ø !¡”3�q‘t”9°<ˆØ !¡”3�q‘t”9°<ˆô œ˜Y›¬¨X«¼¸H»ÓFˆ
Ø�‰˜Ÿ™¨
Ó3Ô4Ø�‰˜Ÿ™¨
Ó3Ô4Ø×Ñ˜)×*Ñ*¨:Ó6Ö7ñ ô 
ˆ)�.‰.˜Ó
"¨Ò.Ü	ˆ)�.‰.˜Ó
$¨4Ò0Ü	ˆ)�.‰.˜Ó
"¨Ó.r   c           	      ó”  • [        SUS9  [        SUS9  [        SUS9  [        SUS9  [        SUS9  / SQn/ SQn[        R                  S	   S S
4[        R                  S   S
S4[        R                  S   SS4[        R                  S   SS4[        R                  S   SS4[        R                  S   SS 4/n[        UUUUU US9  g )Nr%   r
   Ú
ALIGNMENTSr   zFormat:z<utterance-id>, WER DETAILS)Ú	referenceÚonÚtheÚfirstÚline)ÚandÚ
hypothesisrB   rC   ÚthirdÚinsr   Úsubé   Úeqé   é   é   Údelr   )r   r   ÚEDIT_SYMBOLSr   )r   r   r   r3   r4   r   s         r   r   r   ¤   sä   € ô 
ˆ(˜ÒÜ	ˆ,˜TÒ"Ü	ˆ"�4ÒÜ	ˆ)˜$ÒÜ	Ð
'¨dÒ3ò 	4€AÚ3€Aä	×	#Ñ	# EÑ	*¨D°!Ð4Ü	×	#Ñ	# EÑ	*¨A¨qÐ1Ü	×	#Ñ	# DÑ	)¨1¨aÐ0Ü	×	#Ñ	# DÑ	)¨1¨aÐ0Ü	×	#Ñ	# EÑ	*¨A¨qÐ1Ü	×	#Ñ	# EÑ	*¨A¨tÐ4ð€Iô ØØ	Ø	ØØ!Øór   c                 óL   • [        SUS9  [        SR                  " S0 U D6US9  g )Nr%   r
   zp{key}, %WER {WER:.2f} [ {num_edits} / {num_ref_tokens}, {insertions} ins, {deletions} del, {substitutions} sub ]r   r   r   s     r   r   r   Â   s5   € Ü	ˆ(˜ÒÜ	Øz÷  	Bò  	Bñ 	
Øñ	
ð ó	r   )Ú__doc__ÚsysÚspeechbrain.utilsr   Ústdoutr   r#   r(   r+   r   r   r   r   r   r   Ú<module>rW      sŒ   ðñ	ó å +ð ),¯
©
ô (ðZ 
�‰ØØØØô-3ðd 8;·z±zô Ið. +.¯*©*ô Dð #*°UÀÇÁô/ð2  E°·
±
ôð< /2¯j©jõ r   