§
    'ê[ft  ã                   ó(   — d dl Z  G d„ d¦  «        ZdS )é    Nc                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )Ú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                 ó"   — || _         || _        dS )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      úG/var/www/piapp/venv/lib/python3.11/site-packages/nltk/parse/evaluate.pyÚ__init__zDependencyEvaluator.__init__G   s   € ð
 *ˆÔØ%ˆÔÐÐó    c                 óN   ‡— h d£Šd                      ˆ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   óH   •K  — | ]}t          j        |¦  «        ‰v¯|V — Œd S )N)ÚunicodedataÚcategory)Ú.0ÚxÚpunc_cats     €r   ú	<genexpr>z4DependencyEvaluator._remove_punct.<locals>.<genexpr>V   s8   øè è € ÐSÐS˜Q­;Ô+?ÀÑ+BÔ+BÈ(Ð+RÐ+R�qÐ+RÐ+RÐ+RÐ+RÐSÐSr   )Újoin)r   ÚinStrr   s     @r   Ú_remove_punctz!DependencyEvaluator._remove_punctO   s7   ø€ ð >Ð=Ð=ˆØ�wŠwÐSÐSÐSÐS %ÐSÑSÔSÑSÔSÐSr   c                 óÀ  — t          | j        ¦  «        t          | j        ¦  «        k    rt          d¦  «        ‚d}d}d}t	          t          | j        ¦  «        ¦  «        D ]ô}| j        |         j        }| j        |         j        }t          |¦  «        t          |¦  «        k    rt          d¦  «        ‚|                     ¦   «         D ]Š\  }}||         }	|d         €Œ|d         |	d         k    rt          d¦  «        ‚|                      |d         ¦  «        dk    rŒW|dz  }|d	         |	d	         k    r|dz  }|d
         |	d
         k    r|dz  }Œ‹Œõ||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.ÚwordNz!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   sš  € õ ˆtÔ!Ñ"Ô"¥c¨$Ô*:Ñ&;Ô&;Ò;Ð;ÝØWñô ð ð ˆØˆØˆå•s˜4Ô-Ñ.Ô.Ñ/Ô/ð 	#ð 	#ˆAØ $Ô 2°1Ô 5Ô ;ÐØ"Ô.¨qÔ1Ô7ˆOåÐ$Ñ%Ô%­¨_Ñ)=Ô)=Ò=Ð=Ý Ð!DÑEÔEÐEà4E×4KÒ4KÑ4MÔ4Mð #ð #Ñ0Ð# [Ø+Ð,?Ô@�	à˜vÔ&Ð.ØØ˜vÔ&¨)°FÔ*;Ò;Ð;Ý$Ð%HÑIÔIÐIð ×%Ò% k°&Ô&9Ñ:Ô:¸bÒ@Ð@Øà˜‘
�Ø˜vÔ&¨)°FÔ*;Ò;Ð;Ø˜A‘I�DØ" 5Ô)¨Y°uÔ-=Ò=Ð=Ø ™
˜øð##ð& �u‰}˜d U™lÐ*Ð*r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r    r4   © r   r   r   r      sO   € € € € € ð8ð 8ðt&ð &ð &ðTð Tð Tð)+ð )+ð )+ð )+ð )+r   r   )r   r   r9   r   r   ú<module>r:      sO   ðð Ð Ð Ð ðu+ð u+ð u+ð u+ð u+ñ u+ô u+ð u+ð u+ð u+r   