Ë
    ÿÍ:j#!  ã                   óH   — d dl Z d dlmZmZmZ d dlmZmZmZ  G d„ d«      Z	y)é    N)ÚOptionalÚTupleÚUnion)ÚTimelineÚSegmentÚ
Annotationc                   óÄ   — e Zd ZdZ	 	 ddededededef
d„Zdededefd	„Z	d
ededefd„Z
	 	 	 	 	 ddededee   dededededeeeef   eeeef   eeeeef   f   fd„Zy)ÚUEMSupportMixinu:   Provides 'uemify' method with optional (Ã  la NIST) collarÚuemÚ	referenceÚcollarÚskip_overlapÚreturnc           	      óú  — |dk(  r|s|S g g }}|dkD  r{|j                  «       D ]h  }|j                  }|j                  t        |d|z  z
  |d|z  z   «      «       |j                  }|j                  t        |d|z  z
  |d|z  z   «      «       Œj |r>|j                  |«      D ]*  \  \  }	}
\  }}|	|k(  r|
|k(  rŒ|j                  |	|z  «       Œ, ||z   }t        |¬«      j                  «       j                  |¬«      S )a…  Extrude reference boundary collars from uem

        reference     |----|     |--------------|       |-------------|
        uem       |---------------------|    |-------------------------------|
        extruded  |--| |--| |---| |-----|    |-| |-----| |-----------| |-----|

        Parameters
        ----------
        uem : Timeline
            Evaluation map.
        reference : Annotation
            Reference annotation.
        collar : float, optional
            When provided, set the duration of collars centered around
            reference segment boundaries that are extruded from both reference
            and hypothesis. Defaults to 0. (i.e. no collar).
        skip_overlap : bool, optional
            Set to True to not evaluate overlap regions.
            Defaults to False (i.e. keep overlap regions).

        Returns
        -------
        extruded_uem : Timeline
        ç        g      à?)Úsegments)Úsupport)	ÚitersegmentsÚstartÚappendr   ÚendÚco_iterr   r   Úgaps)Úselfr   r   r   r   ÚcollarsÚoverlap_regionsÚsegmentÚtÚsegment1Útrack1Úsegment2Útrack2r   s                 úk/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/pyannote/metrics/utils.pyÚextrudezUEMSupportMixin.extrude&   s  € ð< �RŠ<¡ØˆJà#% r�ˆð �BŠ;à$×1Ñ1Ó3ò J�à—M‘M�Ø—‘œw q¨2°©;¡¸¸BÀ¹K¹ÓHÔIð —K‘K�Ø—‘œw q¨2°©;¡¸¸BÀ¹K¹ÓHÕIðJñ à:C×:KÑ:KÈIÓ:Vò <Ñ6Ñ"�˜6Ñ$6 X¨vØ˜xÒ'¨F°fÒ,<Øà×&Ñ& x°(Ñ':Õ;ð	<ð ˜_Ñ,ˆä Ô*×2Ñ2Ó4×9Ñ9À#Ð9ÓFÐFó    Ú
hypothesisc                 óˆ   — |j                  d¬«      }|j                  |j                  d¬«      «       |j                  «       S )aÊ  Return timeline common to both reference and hypothesis

        reference   |--------|    |------------|     |---------|         |----|
        hypothesis     |--------------| |------|   |----------------|
        timeline    |--|-----|----|---|-|------|   |-|---------|----|    |----|

        Parameters
        ----------
        reference : Annotation
        hypothesis : Annotation

        Returns
        -------
        timeline : Timeline
        T©ÚcopyF)Úget_timelineÚupdateÚsegmentation)r   r   r&   Útimelines       r#   Úcommon_timelinezUEMSupportMixin.common_timelineb   s@   € ð" ×)Ñ)¨tÐ)Ó4ˆØ�‰˜
×/Ñ/°UÐ/Ó;Ô<Ø×$Ñ$Ó&Ð&r%   Ú
annotationr-   c                 óæ   — |j                  «       }|j                  d¬«      }|j                  |«      D ]:  \  }}|j                  |«      D ]!  }|j	                  ||¬«      }|||f   |||f<   Œ# Œ< |S )a™  Project annotation onto timeline segments

        reference     |__A__|     |__B__|
                        |____C____|

        timeline    |---|---|---|   |---|

        projection  |_A_|_A_|_C_|   |_B_|
                        |_C_|

        Parameters
        ----------
        annotation : Annotation
        timeline : Timeline

        Returns
        -------
        projection : Annotation
        Fr(   )Ú	candidate)Úemptyr*   r   Ú
get_tracksÚ	new_track)	r   r/   r-   Ú
projectionÚ	timeline_Úsegment_r   Útrack_Útracks	            r#   ÚprojectzUEMSupportMixin.projectw   s—   € ð(  ×%Ñ%Ó'ˆ
Ø×+Ñ+°Ð+Ó7ˆ	Ø!*×!2Ñ!2°8Ó!<ò 	JÑˆH�gØ$×/Ñ/°Ó9ò J�Ø"×,Ñ,¨WÀÐ,ÓG�Ø-7¸À&Ð8HÑ-I�
˜7 E˜>Ò*ñJð	Jð Ðr%   NÚreturns_uemÚreturns_timelinec                 óü  — |€r|j                  «       j                  «       }|j                  «       j                  «       }	||	z  }
t        |
r|
gng |j                  ¬«      }t	        j
                  d«       | j                  ||||¬«      }|j                  |d¬«      }|j                  |d¬«      }|r6| j                  ||«      }| j                  ||«      }| j                  ||«      }||f}|r||fz  }|r|fz  }|S )a   Crop 'reference' and 'hypothesis' to 'uem' support

        Parameters
        ----------
        reference, hypothesis : Annotation
            Reference and hypothesis annotations.
        uem : Timeline, optional
            Evaluation map.
        collar : float, optional
            When provided, set the duration of collars centered around
            reference segment boundaries that are extruded from both reference
            and hypothesis. Defaults to 0. (i.e. no collar).
        skip_overlap : bool, optional
            Set to True to not evaluate overlap regions.
            Defaults to False (i.e. keep overlap regions).
        returns_uem : bool, optional
            Set to True to return extruded uem as well.
            Defaults to False (i.e. only return reference and hypothesis)
        returns_timeline : bool, optional
            Set to True to oversegment reference and hypothesis so that they
            share the same internal timeline.

        Returns
        -------
        reference, hypothesis : Annotation
            Extruded reference and hypothesis annotations
        uem : Timeline
            Extruded uem (returned only when 'returns_uem' is True)
        timeline : Timeline:
            Common timeline (returned only when 'returns_timeline' is True)
        )r   ÚurizL'uem' was approximated by the union of 'reference' and 'hypothesis' extents.)r   r   Úintersection)Úmode)
r*   Úextentr   r>   ÚwarningsÚwarnr$   Úcropr.   r:   )r   r   r&   r   r   r   r;   r<   Úr_extentÚh_extentrA   r-   Úresults                r#   ÚuemifyzUEMSupportMixin.uemify“   s  € ð^ ˆ;Ø ×-Ñ-Ó/×6Ñ6Ó8ˆHØ!×.Ñ.Ó0×7Ñ7Ó9ˆHØ Ñ(ˆFÜ± V¡H¸BØ(Ÿ}™}ô.ˆCä�M‰Mð,ô-ð
 �l‰l˜3 	°&Ø(4ð ó 6ˆð —N‘N 3¨^�NÓ<ˆ	Ø—_‘_ S¨~�_Ó>ˆ
ñ Ø×+Ñ+¨I°zÓBˆHØŸ™ Y°Ó9ˆIØŸ™ j°(Ó;ˆJà˜ZÐ(ˆÙØ�s�fÑˆFáØ�x�kÑ!ˆFàˆr%   )r   F)Nr   FFF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚfloatÚboolr$   r.   r:   r   r   r   rH   © r%   r#   r
   r
   #   s$  „ ÙDð
 !$Ø%*ñ	:GØð:Gà%ð:Gð ð:Gð #ð	:Gð 08ó	:Gðx'¨ð 'Àð 'Øó'ð* *ð ¸ð ÀZó ð> *.Ø!Ø$)Ø#(Ø(-ñNØ$ðNà%ðNð ˜XÑ&ðNð ð	Nð
 "ðNð !ðNð "&ðNð Ø�j *Ð,Ñ-Ø�j *¨hÐ6Ñ7Ø�j *¨h¸Ð@ÑAðCñôNr%   r
   )
rB   Útypingr   r   r   Úpyannote.corer   r   r   r
   rO   r%   r#   ú<module>rR      s"   ðó: ß )Ñ )ç 7Ñ 7÷~ò ~r%   