Ë
    çÍ:j­P  ã                   ó<  — d dl Z d dlmZ d dlmZ d dlmZ d dlm	Z	 d„ Z G d„ d«      Z
d	„ Z	 dd„Z e j                  d«      Zdd„Zd„ Z	 dd„Zd„ Z e j                  de j&                  «      Z e j                  d«      Zd„ Zg d¢d
fd„Zd„ Zedk(  r e«        yy)é    N)Úaccuracy)Úmap_tag)Ú	str2tuple)ÚTreec                 ó¦   — g }g }|D ]=  }| j                  |j                  «       «      }|t        |«      z  }|t        |«      z  }Œ? t        ||«      S )a|  
    Score the accuracy of the chunker against the gold standard.
    Strip the chunk information from the gold standard and rechunk it using
    the chunker, then compute the accuracy score.

    :type chunker: ChunkParserI
    :param chunker: The chunker being evaluated.
    :type gold: tree
    :param gold: The chunk structures to score the chunker on.
    :rtype: float
    )ÚparseÚflattenÚtree2conlltagsÚ	_accuracy)ÚchunkerÚgoldÚ	gold_tagsÚ	test_tagsÚ	gold_treeÚ	test_trees         úd/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/nltk/chunk/util.pyr   r      sa   € ð €IØ€IØò /ˆ	Ø—M‘M )×"3Ñ"3Ó"5Ó6ˆ	Ø”^ IÓ.Ñ.ˆ	Ø”^ IÓ.Ñ.‰	ð/ô �Y 	Ó*Ð*ó    c                   óf   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	dd„Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)Ú
ChunkScorea;  
    A utility class for scoring chunk parsers.  ``ChunkScore`` can
    evaluate a chunk parser's output, based on a number of statistics
    (precision, recall, f-measure, misssed chunks, incorrect chunks).
    It can also combine the scores from the parsing of multiple texts;
    this makes it significantly easier to evaluate a chunk parser that
    operates one sentence at a time.

    Texts are evaluated with the ``score`` method.  The results of
    evaluation can be accessed via a number of accessor methods, such
    as ``precision`` and ``f_measure``.  A typical use of the
    ``ChunkScore`` class is::

        >>> chunkscore = ChunkScore()           # doctest: +SKIP
        >>> for correct in correct_sentences:   # doctest: +SKIP
        ...     guess = chunkparser.parse(correct.leaves())   # doctest: +SKIP
        ...     chunkscore.score(correct, guess)              # doctest: +SKIP
        >>> print('F Measure:', chunkscore.f_measure())       # doctest: +SKIP
        F Measure: 0.823

    :ivar kwargs: Keyword arguments:

        - max_tp_examples: The maximum number actual examples of true
          positives to record.  This affects the ``correct`` member
          function: ``correct`` will not return more than this number
          of true positive examples.  This does *not* affect any of
          the numerical metrics (precision, recall, or f-measure)

        - max_fp_examples: The maximum number actual examples of false
          positives to record.  This affects the ``incorrect`` member
          function and the ``guessed`` member function: ``incorrect``
          will not return more than this number of examples, and
          ``guessed`` will not return more than this number of true
          positive examples.  This does *not* affect any of the
          numerical metrics (precision, recall, or f-measure)

        - max_fn_examples: The maximum number actual examples of false
          negatives to record.  This affects the ``missed`` member
          function and the ``correct`` member function: ``missed``
          will not return more than this number of examples, and
          ``correct`` will not return more than this number of true
          negative examples.  This does *not* affect any of the
          numerical metrics (precision, recall, or f-measure)

        - chunk_label: A regular expression indicating which chunks
          should be compared.  Defaults to ``'.*'`` (i.e., all chunks).

    :type _tp: list(Token)
    :ivar _tp: List of true positives
    :type _fp: list(Token)
    :ivar _fp: List of false positives
    :type _fn: list(Token)
    :ivar _fn: List of false negatives

    :type _tp_num: int
    :ivar _tp_num: Number of true positives
    :type _fp_num: int
    :ivar _fp_num: Number of false positives
    :type _fn_num: int
    :ivar _fn_num: Number of false negatives.
    c                 ó´  — t        «       | _        t        «       | _        t        «       | _        t        «       | _        t        «       | _        |j                  dd«      | _        |j                  dd«      | _        |j                  dd«      | _	        |j                  dd«      | _
        d| _        d| _        d| _        d| _        d| _        d| _        d	| _        y )
NÚmax_tp_exampleséd   Úmax_fp_examplesÚmax_fn_examplesÚchunk_labelz.*r   g        F)ÚsetÚ_correctÚ_guessedÚ_tpÚ_fpÚ_fnÚgetÚ_max_tpÚ_max_fpÚ_max_fnÚ_chunk_labelÚ_tp_numÚ_fp_numÚ_fn_numÚ_countÚ_tags_correctÚ_tags_totalÚ_measuresNeedUpdate)ÚselfÚkwargss     r   Ú__init__zChunkScore.__init__r   s¯   € Ü›ˆŒÜ›ˆŒÜ“5ˆŒÜ“5ˆŒÜ“5ˆŒØ—z‘zÐ"3°SÓ9ˆŒØ—z‘zÐ"3°SÓ9ˆŒØ—z‘zÐ"3°SÓ9ˆŒØ"ŸJ™J }°dÓ;ˆÔØˆŒØˆŒØˆŒØˆŒØ ˆÔØˆÔà#(ˆÕ r   c                 ó|  — | j                   r°| j                  | j                  z  | _        | j                  | j                  z
  | _        | j                  | j                  z
  | _        t        | j                  «      | _        t        | j
                  «      | _        t        | j                  «      | _	        d| _         y y )NF)
r-   r   r   r   r!   r    Úlenr'   r(   r)   ©r.   s    r   Ú_updateMeasureszChunkScore._updateMeasures…   s�   € Ø×#Ò#Ø—}‘} t§}¡}Ñ4ˆDŒHØ—}‘} t§}¡}Ñ4ˆDŒHØ—}‘} t§}¡}Ñ4ˆDŒHÜ˜tŸx™x›=ˆDŒLÜ˜tŸx™x›=ˆDŒLÜ˜tŸx™x›=ˆDŒLØ',ˆDÕ$ð $r   c           	      óú  — | xj                   t        || j                  | j                  «      z  c_         | xj                  t        || j                  | j                  «      z  c_        | xj                  dz  c_        d| _        	 t        |«      }t        |«      }| xj                  t        |«      z  c_        | xj                  t        d„ t        ||«      D «       «      z  c_
        y# t        $ r dx}}Y Œ]w xY w)aU  
        Given a correctly chunked sentence, score another chunked
        version of the same sentence.

        :type correct: chunk structure
        :param correct: The known-correct ("gold standard") chunked
            sentence.
        :type guessed: chunk structure
        :param guessed: The chunked sentence to be scored.
        é   T© c              3   ó2   K  — | ]  \  }}||k(  sŒd –— Œ y­w)r6   Nr7   )Ú.0ÚtÚgs      r   ú	<genexpr>z#ChunkScore.score.<locals>.<genexpr>¨   s   è ø€ ò "
Ù�1�a¸qÀA»vŒAñ"
ùs   ‚�N)r   Ú
_chunksetsr*   r&   r   r-   r
   Ú
ValueErrorr,   r2   r+   ÚsumÚzip)r.   ÚcorrectÚguessedÚcorrect_tagsÚguessed_tagss        r   ÚscorezChunkScore.score�   sÖ   € ð 	�Šœ G¨T¯[©[¸$×:KÑ:KÓLÑL�Ø�Šœ G¨T¯[©[¸$×:KÑ:KÓLÑL�Ø�Š�qÑ�Ø#'ˆÔ ð	-Ü)¨'Ó2ˆLÜ)¨'Ó2ˆLð 	×ÒœC Ó-Ñ-ÕØ×Òœcñ "
Ü ¨lÓ;ô"
ó 
ñ 	
Öøô ò 	-ð +-Ð,ˆLš<ð		-ús   ÂC* Ã*C:Ã9C:c                 óT   — | j                   dk(  ry| j                  | j                   z  S )zÁ
        Return the overall tag-based accuracy for all text that have
        been scored by this ``ChunkScore``, using the IOB (conll2000)
        tag encoding.

        :rtype: float
        r   r6   )r,   r+   r3   s    r   r   zChunkScore.accuracy¬   s,   € ð ×Ñ˜qÒ ØØ×!Ñ! D×$4Ñ$4Ñ4Ð4r   c                 ó~   — | j                  «        | j                  | j                  z   }|dk(  ry| j                  |z  S )z‰
        Return the overall precision for all texts that have been
        scored by this ``ChunkScore``.

        :rtype: float
        r   )r4   r'   r(   ©r.   Údivs     r   Ú	precisionzChunkScore.precision¸   ó;   € ð 	×ÑÔØ�l‰l˜TŸ\™\Ñ)ˆØ�!Š8Øà—<‘< #Ñ%Ð%r   c                 ó~   — | j                  «        | j                  | j                  z   }|dk(  ry| j                  |z  S )z†
        Return the overall recall for all texts that have been
        scored by this ``ChunkScore``.

        :rtype: float
        r   ©r4   r'   r)   rH   s     r   ÚrecallzChunkScore.recallÆ   rK   r   c                 óš   — | j                  «        | j                  «       }| j                  «       }|dk(  s|dk(  ryd||z  d|z
  |z  z   z  S )a»  
        Return the overall F measure for all texts that have been
        scored by this ``ChunkScore``.

        :param alpha: the relative weighting of precision and recall.
            Larger alpha biases the score towards the precision value,
            while smaller alpha biases the score towards the recall
            value.  ``alpha`` should have a value in the range [0,1].
        :type alpha: float
        :rtype: float
        r   r6   )r4   rJ   rN   )r.   ÚalphaÚpÚrs       r   Ú	f_measurezChunkScore.f_measureÔ   sS   € ð 	×ÑÔØ�N‰NÓˆØ�K‰K‹MˆØ�Š6�Q˜!’VØØ�E˜A‘I  U¡¨a¡Ñ/Ñ0Ð0r   c                 ó|   — | j                  «        t        | j                  «      }|D �cg c]  }|d   ‘Œ	 c}S c c}w )zÈ
        Return the chunks which were included in the
        correct chunk structures, but not in the guessed chunk
        structures, listed in input order.

        :rtype: list of chunks
        r6   )r4   Úlistr!   ©r.   ÚchunksÚcs      r   ÚmissedzChunkScore.missedç   s5   € ð 	×ÑÔÜ�d—h‘h“ˆØ$Ö%˜��!“Ò%Ð%ùÒ%ó   ª9c                 ó|   — | j                  «        t        | j                  «      }|D �cg c]  }|d   ‘Œ	 c}S c c}w )zÀ
        Return the chunks which were included in the guessed chunk structures,
        but not in the correct chunk structures, listed in input order.

        :rtype: list of chunks
        r6   )r4   rU   r    rV   s      r   Ú	incorrectzChunkScore.incorrectó   s5   € ð 	×ÑÔÜ�d—h‘h“ˆØ$Ö%˜��!“Ò%Ð%ùÒ%rZ   c                 ó\   — t        | j                  «      }|D �cg c]  }|d   ‘Œ	 c}S c c}w )z—
        Return the chunks which were included in the correct
        chunk structures, listed in input order.

        :rtype: list of chunks
        r6   )rU   r   rV   s      r   rA   zChunkScore.correctþ   ó*   € ô �d—m‘mÓ$ˆØ$Ö%˜��!“Ò%Ð%ùÒ%ó   š)c                 ó\   — t        | j                  «      }|D �cg c]  }|d   ‘Œ	 c}S c c}w )z—
        Return the chunks which were included in the guessed
        chunk structures, listed in input order.

        :rtype: list of chunks
        r6   )rU   r   rV   s      r   rB   zChunkScore.guessed  r^   r_   c                 óT   — | j                  «        | j                  | j                  z   S )NrM   r3   s    r   Ú__len__zChunkScore.__len__  s!   € Ø×ÑÔØ�|‰|˜dŸl™lÑ*Ð*r   c                 ó6   — dt        t        | «      «      z   dz   S )z`
        Return a concise representation of this ``ChunkScoring``.

        :rtype: str
        z<ChunkScoring of z chunks>)Úreprr2   r3   s    r   Ú__repr__zChunkScore.__repr__  s   € ð #¤T¬#¨d«)£_Ñ4°zÑAÐAr   c                 óÎ   — dd| j                  «       dz  d›d�z   d| j                  «       dz  d›d�z   d| j                  «       dz  d›d�z   d| j                  «       dz  d›d	�z   S )
a-  
        Return a verbose representation of this ``ChunkScoring``.
        This representation includes the precision, recall, and
        f-measure scores.  For other information about the score,
        use the accessor methods (e.g., ``missed()`` and ``incorrect()``).

        :rtype: str
        zChunkParse score:
z    IOB Accuracy: r   z5.1fz%
z    Precision:    z    Recall:       z    F-Measure:    ú%)r   rJ   rN   rS   r3   s    r   Ú__str__zChunkScore.__str__  s’   € ð "Ø" 4§=¡=£?°SÑ#8¸Ð">¸cÐBñCà" 4§>¡>Ó#3°cÑ#9¸$Ð"?¸sÐCñDð # 4§;¡;£=°3Ñ#6°tÐ"<¸CÐ@ñAð # 4§>¡>Ó#3°cÑ#9¸$Ð"?¸qÐAñ	Bð	
r   N)g      à?)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r0   r4   rE   r   rJ   rN   rS   rY   r\   rA   rB   rb   re   rh   r7   r   r   r   r   3   sO   „ ñ<ò|)ò&-ò
ò:
5ò&ò&ó1ò&
&ò	&ò&ò&ò+òBó
r   r   c                 ó   — d}g }| D ]{  }t        |t        «      rdt        j                  ||j	                  «       «      r#|j                  ||f|j                  «       f«       |t        |j                  «       «      z  }Œw|dz  }Œ} t        |«      S )Nr   r6   )
Ú
isinstancer   ÚreÚmatchÚlabelÚappendÚfreezer2   Úleavesr   )r:   Úcountr   ÚposrW   Úchilds         r   r=   r=   2  s~   € Ø
€CØ€FØò ˆÜ�eœTÔ"Ü�x‰x˜ U§[¡[£]Ô3Ø—‘  s˜|¨U¯\©\«^Ð<Ô=Ø”3�u—|‘|“~Ó&Ñ&‰Cà�1‰H‰Cðô ˆv‹;Ðr   ÚSc                 óØ  — t        j                  d«      }t        |g «      g}|j                  | «      D �]	  }|j	                  «       }	|	d   dk(  r]t        |«      dk7  rt        d|j                  «       d›�«      ‚t        |g «      }
|d   j                  |
«       |j                  |
«       Œy|	d   dk(  r<t        |«      d	k7  rt        d
|j                  «       d›�«      ‚|j                  «        Œ½|€|d   j                  |	«       ŒÔt        |	|«      \  }}|r|rt        |||«      }|d   j                  ||f«       �Œ t        |«      dk7  rt        dt        | «      d›�«      ‚|d   S )aB  
    Divide a string of bracketted tagged text into
    chunks and unchunked tokens, and produce a Tree.
    Chunks are marked by square brackets (``[...]``).  Words are
    delimited by whitespace, and each word should have the form
    ``text/tag``.  Words that do not contain a slash are
    assigned a ``tag`` of None.

    :param s: The string to be converted
    :type s: str
    :param chunk_label: The label to use for chunk nodes
    :type chunk_label: str
    :param root_label: The label to use for the root of the tree
    :type root_label: str
    :rtype: Tree
    z\[|\]|[^\[\]\s]+r   ú[r6   zUnexpected [ at char Údéÿÿÿÿú]é   zUnexpected ] at char zExpected ] at char )ro   Úcompiler   ÚfinditerÚgroupr2   r>   Ústartrr   Úpopr   r   )Úsr   Ú
root_labelÚsepÚsource_tagsetÚtarget_tagsetÚWORD_OR_BRACKETÚstackrp   ÚtextÚchunkÚwordÚtags                r   Útagstr2treer�   ?  s]  € ô( —j‘jÐ!4Ó5€Oä�*˜bÓ!Ð"€EØ ×)Ñ)¨!Ó,ó .ˆØ�{‰{‹}ˆØ�‰7�cŠ>Ü�5‹z˜QŠÜ Ð#8¸¿¹»ÀqÐ8IÐ!JÓKÐKÜ˜ bÓ)ˆEØ�"‰I×Ñ˜UÔ#Ø�L‰L˜ÕØ�!‰W˜Š^Ü�5‹z˜QŠÜ Ð#8¸¿¹»ÀqÐ8IÐ!JÓKÐKØ�I‰I�Kàˆ{Ø�b‘	× Ñ  Õ&ä% d¨CÓ0‘	��cÙ ¡]Ü! -°ÀÓD�CØ�b‘	× Ñ  $¨ Ö-ð'.ô* ˆ5ƒz�Q‚ÜÐ.¬s°1«v°a¨jÐ9Ó:Ð:Ø�‰8€Or   z(\S+)\s+(\S+)\s+([IOB])-?(\S+)?c                 ó0  — t        |g «      g}t        | j                  d«      «      D ]è  \  }}|j                  «       sŒt        j                  |«      }|€t        d|d›�«      ‚|j                  «       \  }}}	}
|�|
|vrd}	|	dk(  xr |
|d   j                  «       k7  }|	dv s|rt        |«      dk(  r|j                  «        |	d	k(  s|r1t        |
g «      }|d   j                  |«       |j                  |«       |d   j                  ||f«       Œê |d
   S )a*  
    Return a chunk structure for a single sentence
    encoded in the given CONLL 2000 style string.
    This function converts a CoNLL IOB string into a tree.
    It uses the specified chunk types
    (defaults to NP, PP and VP), and creates a tree rooted at a node
    labeled S (by default).

    :param s: The CoNLL string to be converted.
    :type s: str
    :param chunk_types: The chunk types to be converted.
    :type chunk_types: tuple
    :param root_label: The node label to use for the root.
    :type root_label: str
    :rtype: Tree
    ú
zError on line r{   ÚOÚIr|   ÚBOr~   ÚBr   )r   Ú	enumerateÚsplitÚstripÚ_LINE_RErp   r>   Úgroupsrq   r2   rƒ   rr   )r„   Úchunk_typesr…   rŠ   ÚlinenoÚlinerp   r�   rŽ   ÚstateÚ
chunk_typeÚ
mismatch_IrŒ   s                r   Úconllstr2treer¡   u  s%  € ô$ �*˜bÓ!Ð"€Eä! !§'¡'¨$£-Ó0ò &‰ˆ�Ø�z‰zŒ|Øô —‘˜tÓ$ˆØˆ=Ü˜~¨f°Q¨ZÐ8Ó9Ð9Ø).¯©«Ñ&ˆˆs�E˜:ð Ð" z¸Ñ'DØˆEð ˜c‘\ÒE j°E¸"±I·O±OÓ4EÑ&Eˆ
Ø�D‰=™JÜ�5‹z˜QŠØ—	‘	”ð �CŠ<™:Ü˜ RÓ(ˆEØ�"‰I×Ñ˜UÔ#Ø�L‰L˜Ôð 	ˆb‰	×Ñ˜$ ˜Õ%ð9&ð< �‰8€Or   c                 ó  — g }| D ]V  }	 |j                  «       }d}|D ]<  }t        |t        «      rt        d«      ‚|j	                  |d   |d   ||z   f«       d}Œ> ŒX |S # t
        $ r |j	                  |d   |d   df«       Y Œ€w xY w)zË
    Return a list of 3-tuples containing ``(word, tag, IOB-tag)``.
    Convert a tree to the CoNLL IOB tag format.

    :param t: The tree to be converted.
    :type t: Tree
    :rtype: list(tuple)
    úB-z7Tree is too deeply nested to be printed in CoNLL formatr   r6   úI-r’   )rq   rn   r   r>   rr   ÚAttributeError)r:   Útagsrw   ÚcategoryÚprefixÚcontentss         r   r
   r
   ª  s°   € ð €DØò 3ˆð	3Ø—{‘{“}ˆHØˆFØ!ò �Ü˜h¬Ô-Ü$ØQóð ð —‘˜X a™[¨(°1©+°vÀÑ7HÐIÔJØ‘ñð	3ð €Køô ò 	3Ø�K‰K˜˜q™ 5¨¡8¨SÐ1Ö2ð	3ús   ‰AA Á #BÂBc                 óR  — t        |g «      }| D �]  \  }}}|€!|rt        d«      ‚|j                  ||f«       Œ+|j                  d«      r"|j                  t        |dd ||fg«      «       Œ^|j                  d«      r€t	        |«      dk(  s,t        |d   t         «      r|d   j                  «       |dd k7  r/|rt        d«      ‚|j                  t        |dd ||fg«      «       ŒØ|d   j                  ||f«       Œï|dk(  r|j                  ||f«       �Œ	t        d	|›�«      ‚ |S )
z1
    Convert the CoNLL IOB format to a tree.
    NzBad conll tag sequencer£   r~   r¤   r   r|   r’   zBad conll tag )r   r>   rr   Ú
startswithr2   rn   rq   )Úsentencer›   r…   ÚstrictÚtreer�   ÚpostagÚchunktags           r   Úconlltags2treer±   Å  s0  € ô �
˜BÓ€DØ"*ó <Ñˆˆf�hØÐÙÜ Ð!9Ó:Ð:ð —‘˜T 6˜NÕ+Ø× Ñ  Ô&Ø�K‰Kœ˜X a b˜\¨T°6¨NÐ+;Ó<Õ=Ø× Ñ  Ô&ä�D“	˜Q’Ü! $ r¡(¬DÔ1Ø˜‘8—>‘>Ó# x°° |Ò3áÜ$Ð%=Ó>Ð>ð —K‘K¤ X¨a¨b \°T¸6°NÐ3CÓ DÕEà�R‘—‘  v Õ/Ø˜Š_Ø�K‰K˜˜v˜Ö'ä˜~¨h¨\Ð:Ó;Ð;ð3<ð4 €Kr   c                 ó|   — t        | «      D �cg c]  }dj                  |«      ‘Œ }}dj                  |«      S c c}w )zÒ
    Return a multiline string where each line contains a word, tag and IOB tag.
    Convert a tree to the CoNLL IOB string format

    :param t: The tree to be converted.
    :type t: Tree
    :rtype: str
    ú r‘   )r
   Újoin)r:   ÚtokenÚliness      r   Útree2conllstrr·   é  s8   € ô +9¸Ó*;Ö< ˆS�X‰X�e�_Ð<€EÐ<Ø�9‰9�UÓÐùò =s   Ž9a   <DOC>\s*(<DOCNO>\s*(?P<docno>.+?)\s*</DOCNO>\s*)?(<DOCTYPE>\s*(?P<doctype>.+?)\s*</DOCTYPE>\s*)?(<DATE_TIME>\s*(?P<date_time>.+?)\s*</DATE_TIME>\s*)?<BODY>\s*(<HEADLINE>\s*(?P<headline>.+?)\s*</HEADLINE>\s*)?<TEXT>(?P<text>.*?)</TEXT>\s*</BODY>\s*</DOC>\s*z#<b_\w+\s+[^>]*?type="(?P<type>\w+)"c                 óz  — t        |g «      g}| €g S t        j                  d| «      D ]¾  }|j                  «       }	 |j	                  d«      rdt
        j                  |«      }|€t        d|«       t        |j                  d«      g «      }|d   j                  |«       |j                  |«       n6|j	                  d«      r|j                  «        n|d   j                  |«       ŒÀ t        |«      d
k7  rt        d«      ‚|d   S # t        t        f$ r$}t        d|j                  «       d›d	�«      |‚d }~ww xY w)Nz<[^>]+>|[^\s<]+z<b_ÚXXXXÚtyper|   z<e_z$Bad IEER string (error at character r{   ú)r6   zBad IEER stringr   )r   ro   r€   r�   r«   Ú_IEER_TYPE_RErp   Úprintrr   rƒ   Ú
IndexErrorr>   r‚   r2   )r„   r…   rŠ   Úpiece_mÚpieceÚmrŒ   Úes           r   Ú_ieer_read_textrÃ     s1  € Ü�*˜bÓ!Ð"€Eð 	€yØˆ	Ü—;‘;Ð1°1Ó5ò ˆØ—‘“ˆð	Ø×Ñ Ô&Ü!×'Ñ'¨Ó.�Ø�9Ü˜& %Ô(Ü˜QŸW™W V›_¨bÓ1�Ø�b‘	× Ñ  Ô'Ø—‘˜UÕ#Ø×!Ñ! %Ô(Ø—	‘	•ð
 �b‘	× Ñ  Ô'øð!ô* ˆ5ƒz�Q‚ÜÐ*Ó+Ð+Ø�‰8€Oøô œJÐ'ò 	ÜØ6°w·}±}³ÀqÐ6IÈÐKóàðûð	ús   ¼B+DÄD:ÄD5Ä5D:)	ÚLOCATIONÚORGANIZATIONÚPERSONÚDURATIONÚDATEÚCARDINALÚPERCENTÚMONEYÚMEASUREc           	      ó  — t         j                  | «      }|rgt        |j                  d«      |«      |j                  d«      |j                  d«      |j                  d«      t        |j                  d«      |«      dœS t        | |«      S )ap  
    Return a chunk structure containing the chunked tagged text that is
    encoded in the given IEER style string.
    Convert a string of chunked tagged text in the IEER named
    entity format into a chunk structure.  Chunks are of several
    types, LOCATION, ORGANIZATION, PERSON, DURATION, DATE, CARDINAL,
    PERCENT, MONEY, and MEASURE.

    :rtype: Tree
    r‹   ÚdocnoÚdoctypeÚ	date_timeÚheadline)r‹   rÎ   rÏ   rÐ   rÑ   )Ú_IEER_DOC_RErp   rÃ   r�   )r„   r›   r…   rÁ   s       r   Úieerstr2treerÓ   '  s{   € ô8 	×Ñ˜1Ó€AÙä# A§G¡G¨F£O°ZÓ@Ø—W‘W˜WÓ%Ø—w‘w˜yÓ)ØŸ™ Ó-ô (¨¯©°
Ó(;¸ZÓHñ
ð 	
ô ˜q *Ó-Ð-r   c                  ó.  — d} dd l }|j                  j                  | d¬«      }|j                  «        t	        «        d} t        | d¬«      }|j                  «        t	        d«       t	        |j                  j                  |«      «       t	        «        y )	Nzd[ Pierre/NNP Vinken/NNP ] ,/, [ 61/CD years/NNS ] old/JJ ,/, will/MD join/VB [ the/DT board/NN ] ./.r   ÚNP)r   av  
These DT B-NP
research NN I-NP
protocols NNS I-NP
offer VBP B-VP
to TO B-PP
the DT B-NP
patient NN I-NP
not RB O
only RB O
the DT B-NP
very RB I-NP
best JJS I-NP
therapy NN I-NP
which WDT B-NP
we PRP B-NP
have VBP B-VP
established VBN I-VP
today NN B-NP
but CC B-NP
also RB I-NP
the DT B-NP
hope NN I-NP
of IN B-PP
something NN B-NP
still RB B-ADJP
better JJR I-ADJP
. . O
)rÕ   ÚPP)r›   zCoNLL output:)ÚnltkrŒ   r�   Úpprintr½   r¡   r·   )r„   r×   r:   Ú
conll_trees       r   ÚdemorÚ   R  sx   € Øn€AÛà�
‰
×Ñ˜q¨dÐÓ3€AØ‡H�H„JÜ	„Gð	€Aô< ˜q¨lÔ;€JØ×ÑÔô 
ˆ/ÔÜ	ˆ$�*‰*×
"Ñ
" :Ó
.Ô/Ü	…Gr   Ú__main__)rÕ   rx   ú/NN)©rÕ   rÖ   ÚVPrx   )rÝ   rx   F)ro   Únltk.metricsr   r   Únltk.tag.mappingr   Únltk.tag.utilr   Ú	nltk.treer   r   r=   r�   r   r™   r¡   r
   r±   r·   ÚDOTALLrÒ   r¼   rÃ   rÓ   rÚ   ri   r7   r   r   ú<module>rä      sÍ   ðó 
å .Ý $Ý #Ý ò+÷<z
ñ z
ò~
ð UYó.ðf ˆ2�:‰:Ð8Ó9€ó2òjð8 FKó!òH
ð ˆr�z‰zðð ‡I�Ió
€ð �—
‘
ÐAÓB€òòD
ð ó(.òV,ð^ ˆzÒÙ…Fð r   