Ë
    çÍ:jó  ã                   ó    — d dl Z  G d„ d«      Zy)é    Nc                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚDependencyEvaluatora5  
    Class for measuring labelled and unlabelled attachment score for
    dependency parsing. Note that the evaluation ignores punctuation.

    >>> from nltk.parse import DependencyGraph, DependencyEvaluator

    >>> gold_sent = DependencyGraph("""
    ... Pierre  NNP     2       NMOD
    ... Vinken  NNP     8       SUB
    ... ,       ,       2       P
    ... 61      CD      5       NMOD
    ... years   NNS     6       AMOD
    ... old     JJ      2       NMOD
    ... ,       ,       2       P
    ... will    MD      0       ROOT
    ... join    VB      8       VC
    ... the     DT      11      NMOD
    ... board   NN      9       OBJ
    ... as      IN      9       VMOD
    ... a       DT      15      NMOD
    ... nonexecutive    JJ      15      NMOD
    ... director        NN      12      PMOD
    ... Nov.    NNP     9       VMOD
    ... 29      CD      16      NMOD
    ... .       .       9       VMOD
    ... """)

    >>> parsed_sent = DependencyGraph("""
    ... Pierre  NNP     8       NMOD
    ... Vinken  NNP     1       SUB
    ... ,       ,       3       P
    ... 61      CD      6       NMOD
    ... years   NNS     6       AMOD
    ... old     JJ      2       NMOD
    ... ,       ,       3       AMOD
    ... will    MD      0       ROOT
    ... join    VB      8       VC
    ... the     DT      11      AMOD
    ... board   NN      9       OBJECT
    ... as      IN      9       NMOD
    ... a       DT      15      NMOD
    ... nonexecutive    JJ      15      NMOD
    ... director        NN      12      PMOD
    ... Nov.    NNP     9       VMOD
    ... 29      CD      16      NMOD
    ... .       .       9       VMOD
    ... """)

    >>> de = DependencyEvaluator([parsed_sent],[gold_sent])
    >>> las, uas = de.eval()
    >>> las
    0.6
    >>> uas
    0.8
    >>> abs(uas - 0.8) < 0.00001
    True
    c                 ó    — || _         || _        y)z‰
        :param parsed_sents: the list of parsed_sents as the output of parser
        :type parsed_sents: list(DependencyGraph)
        N)Ú_parsed_sentsÚ_gold_sents)ÚselfÚparsed_sentsÚ
gold_sentss      úh/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/nltk/parse/evaluate.pyÚ__init__zDependencyEvaluator.__init__G   s   € ð
 *ˆÔØ%ˆÕó    c                 ó@   ‡— h d£Šdj                  ˆfd„|D «       «      S )z©
        Function to remove punctuation from Unicode string.
        :param input: the input string
        :return: Unicode string after remove all punctuation
        >   ÚPcÚPdÚPeÚPfÚPiÚPoÚPsÚ c              3   óR   •K  — | ]  }t        j                  |«      ‰vsŒ|–— Œ  y ­w)N)ÚunicodedataÚcategory)Ú.0ÚxÚpunc_cats     €r   ú	<genexpr>z4DependencyEvaluator._remove_punct.<locals>.<genexpr>V   s#   øè ø€ ÒS˜Q¬;×+?Ñ+?ÀÓ+BÈ(Ò+R”qÑSùs   ƒ' ')Újoin)r   ÚinStrr   s     @r   Ú_remove_punctz!DependencyEvaluator._remove_punctO   s   ø€ ò >ˆØ�w‰wÓS %ÔSÓSÐSr   c                 ól  — t        | j                  «      t        | j                  «      k7  rt        d«      ‚d}d}d}t	        t        | j                  «      «      D ]Î  }| j                  |   j
                  }| j                  |   j
                  }t        |«      t        |«      k7  rt        d«      ‚|j                  «       D ]e  \  }}||   }	|d   €Œ|d   |	d   k7  rt        d«      ‚| j                  |d   «      dk(  rŒ?|dz  }|d   |	d   k(  sŒP|dz  }|d	   |	d	   k(  sŒa|dz  }Œg ŒÐ ||z  ||z  fS )
z†
        Return the Labeled Attachment Score (LAS) and Unlabeled Attachment Score (UAS)

        :return : tuple(float,float)
        zE Number of parsed sentence is different with number of gold sentence.r   z!Sentences must have equal length.Úwordz!Sentence sequence is not matched.r   é   ÚheadÚrel)Úlenr   r   Ú
ValueErrorÚrangeÚnodesÚitemsr    )
r   ÚcorrÚcorrLÚtotalÚiÚparsed_sent_nodesÚgold_sent_nodesÚparsed_node_addressÚparsed_nodeÚ	gold_nodes
             r   ÚevalzDependencyEvaluator.evalX   st  € ô ˆt×!Ñ!Ó"¤c¨$×*:Ñ*:Ó&;Ò;ÜØWóð ð ˆØˆØˆä”s˜4×-Ñ-Ó.Ó/ò 	#ˆAØ $× 2Ñ 2°1Ñ 5× ;Ñ ;ÐØ"×.Ñ.¨qÑ1×7Ñ7ˆOäÐ$Ó%¬¨_Ó)=Ò=Ü Ð!DÓEÐEà4E×4KÑ4KÓ4Mò #Ñ0Ð# [Ø+Ð,?Ñ@�	à˜vÑ&Ð.ØØ˜vÑ&¨)°FÑ*;Ò;Ü$Ð%HÓIÐIð ×%Ñ% k°&Ñ&9Ó:¸bÒ@Øà˜‘
�Ø˜vÑ&¨)°FÑ*;Ó;Ø˜A‘I�DØ" 5Ñ)¨Y°uÑ-=Ó=Ø ™
™ñ##ð	#ð4 �u‰}˜d U™lÐ*Ð*r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r    r4   © r   r   r   r      s   „ ñ8òt&òTó)+r   r   )r   r   r9   r   r   ú<module>r:      s   ðó ÷u+ò u+r   