ó
    ´OÂf¹P  ã                   óF  • S SK r S SKJr  S SKJr  S SKJr  S SKJ	r	  S r " S S5      r
S	 r SS jr\ R                  " S5      rSS jrS r SS jrS r\ R                  " S\ R&                  5      r\ R                  " S5      rS r/ SQS
4S jrS r\S:X  a  \" 5         gg)é    N)Úaccuracy)Úmap_tag)Ú	str2tuple)ÚTreec                 ó¨   • / n/ nU H>  nU R                  UR                  5       5      nU[        U5      -  nU[        U5      -  nM@     [        X#5      $ )aX  
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         Ú1/usr/lib/python3/dist-packages/nltk/chunk/util.pyr   r      sZ   € ð €IØ€IÛˆ	Ø—M‘M )×"3Ñ"3Ó"5Ó6ˆ	Ø”^ IÓ.Ñ.ˆ	Ø”^ IÓ.Ñ.Š	ñ ô �YÓ*Ð*ó    c                   óp   • \ rS rSrSrS rS rS rS rS r	S r
SS	 jrS
 rS rS rS rS rS rS rSrg)Ú
ChunkScoreé3   ao
  
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                 ó´  • [        5       U l        [        5       U l        [        5       U l        [        5       U l        [        5       U l        UR                  SS5      U l        UR                  SS5      U l        UR                  SS5      U l	        UR                  SS5      U l
        SU l        SU l        SU l        SU l        SU l        SU l        S	U l        g )
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__Ú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                 ó†  • U R                   (       a°  U R                  U R                  -  U l        U R                  U R                  -
  U l        U R                  U R                  -
  U l        [        U R                  5      U l        [        U R
                  5      U l        [        U R                  5      U l	        SU l         g g )NF)
r.   r   r   r    r"   r!   Úlenr(   r)   r*   ©r/   s    r   Ú_updateMeasuresÚ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           	      óô  • U =R                   [        XR                  U R                  5      -  sl         U =R                  [        X R                  U R                  5      -  sl        U =R                  S-  sl        SU l         [        U5      n[        U5      nU =R                  [        U5      -  sl        U =R                  [        S [        XC5       5       5      -  sl
        g! [         a    S=p4 N\f = f)a  
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   ó8   #   • U  H  u  pX:X  d  M  S v •  M     g7f)r9   Nr:   )Ú.0ÚtÚgs      r   Ú	<genexpr>Ú#ChunkScore.score.<locals>.<genexpr>¨   s   é € ð "
Ú;‘&�1¸q¹v�A‰AÒ;ùs   ‚‘	N)r   Ú
_chunksetsr+   r'   r   r.   r
   Ú
ValueErrorr-   r4   r,   ÚsumÚzip)r/   ÚcorrectÚguessedÚcorrect_tagsÚguessed_tagss        r   ÚscoreÚChunkScore.score�   sÐ   € ð 	�Šœ G¯[©[¸$×:KÑ:KÓLÑL�Ø�Šœ G¯[©[¸$×:KÑ:KÓLÑL�Ø�Š�qÑ�Ø#'ˆÔ ð	-Ü)¨'Ó2ˆLÜ)¨'Ó2ˆLð 	×ÒœC Ó-Ñ-ÕØ×Òœcñ "
Ü Ô;ó"
ó 
ñ 	
Öøô ó 	-ð +-Ð,ˆL™<ð		-ús   ÂC' Ã'C7Ã6C7c                 óV   • U R                   S:X  a  gU R                  U R                   -  $ )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   r9   )r-   r,   r5   s    r   r   ÚChunkScore.accuracy¬   s,   € ð ×Ñ˜qÓ ØØ×!Ñ! D×$4Ñ$4Ñ4Ð4r   c                 ó€   • U R                  5         U R                  U R                  -   nUS:X  a  gU R                  U-  $ )zi
Return the overall precision for all texts that have been
scored by this ``ChunkScore``.

:rtype: float
r   )r6   r(   r)   ©r/   Údivs     r   Ú	precisionÚChunkScore.precision¸   ó;   € ð 	×ÑÔØ�l‰l˜TŸ\™\Ñ)ˆØ�!‹8Øà—<‘< #Ñ%Ð%r   c                 ó€   • U R                  5         U R                  U R                  -   nUS:X  a  gU R                  U-  $ )zf
Return the overall recall for all texts that have been
scored by this ``ChunkScore``.

:rtype: float
r   ©r6   r(   r*   rN   s     r   ÚrecallÚChunkScore.recallÆ   rR   r   c                 óœ   • U R                  5         U R                  5       nU R                  5       nUS:X  d  US:X  a  gSX-  SU-
  U-  -   -  $ )as  
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   r9   )r6   rP   rU   )r/   ÚalphaÚpÚrs       r   Ú	f_measureÚChunkScore.f_measureÔ   sQ   € ð 	×ÑÔØ�N‰NÓˆØ�K‰K‹MˆØ�‹6�Q˜!“VØØ�E‘I  U¡¨a¡Ñ/Ñ0Ð0r   c                 ó€   • U R                  5         [        U R                  5      nU Vs/ s H  o"S   PM	     sn$ s  snf )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
r9   )r6   Úlistr"   ©r/   ÚchunksÚcs      r   ÚmissedÚChunkScore.missedç   s7   € ð 	×ÑÔÜ�d—h‘h“ˆÙ$Ó%šf˜�!”™fÑ%Ð%ùÒ%ó   ª;c                 ó€   • U R                  5         [        U R                  5      nU Vs/ s H  o"S   PM	     sn$ s  snf )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
r9   )r6   r^   r!   r_   s      r   Ú	incorrectÚChunkScore.incorrectó   s7   € ð 	×ÑÔÜ�d—h‘h“ˆÙ$Ó%šf˜�!”™fÑ%Ð%ùÒ%rd   c                 ó`   • [        U R                  5      nU Vs/ s H  o"S   PM	     sn$ s  snf )zw
Return the chunks which were included in the correct
chunk structures, listed in input order.

:rtype: list of chunks
r9   )r^   r   r_   s      r   rE   ÚChunkScore.correctþ   ó,   € ô �d—m‘mÓ$ˆÙ$Ó%šf˜�!”™fÑ%Ð%ùÒ%ó   š+c                 ó`   • [        U R                  5      nU Vs/ s H  o"S   PM	     sn$ s  snf )zw
Return the chunks which were included in the guessed
chunk structures, listed in input order.

:rtype: list of chunks
r9   )r^   r   r_   s      r   rF   ÚChunkScore.guessed  rj   rk   c                 óT   • U R                  5         U R                  U R                  -   $ )NrT   r5   s    r   Ú__len__ÚChunkScore.__len__  s!   € Ø×ÑÔØ�|‰|˜dŸl™lÑ*Ð*r   c                 ó6   • S[        [        U 5      5      -   S-   $ )zH
Return a concise representation of this ``ChunkScoring``.

:rtype: str
z<ChunkScoring of z chunks>)Úreprr4   r5   s    r   Ú__repr__ÚChunkScore.__repr__  s   € ð #¤T¬#¨d«)£_Ñ4°zÑAÐAr   c                 óÎ   • SSU R                  5       S-  S S3-   SU R                  5       S-  S S3-   SU R                  5       S-  S S3-   SU R                  5       S-  S S	3-   $ )
zý
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:    z%%)r   rP   rU   r[   r5   s    r   Ú__str__ÚChunkScore.__str__  s’   € ð "Ø# D§M¡M£O°cÑ$9¸$Ð#?¸tÐDñFà# D§N¡NÓ$4°sÑ$:¸4Ð#@ÀÐEñGð $ D§K¡K£M°CÑ$7¸Ð#=¸TÐBñDð $ D§N¡NÓ$4°sÑ$:¸4Ð#@ÀÐCñ	Eð	
r   )r'   r   r+   r"   r*   r!   r)   r   r&   r%   r$   r.   r,   r-   r    r(   N)g      à?)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r1   r6   rI   r   rP   rU   r[   rb   rf   rE   rF   ro   rs   rv   Ú__static_attributes__r:   r   r   r   r   3   sO   † ñ<ò|)ò&-ò
ò:
5ò&ò&ô1ò&
&ò	&ò&ò&ò+òBõ
r   r   c                 ó8  • Sn/ nU  H†  n[        U[        5      (       ai  [        R                  " X%R	                  5       5      (       a"  UR                  X4UR                  5       45        U[        UR                  5       5      -  nM�  US-  nMˆ     [        U5      $ )Nr   r9   )
Ú
isinstancer   ÚreÚmatchÚlabelÚappendÚfreezer4   Úleavesr   )r=   Úcountr   Úposr`   Úchilds         r   rA   rA   2  s{   € Ø
€CØ€FÛˆÜ�eœT×"Ñ"Ü�xŠx˜§[¡[£]×3Ñ3Ø—‘ ˜|¨U¯\©\«^Ð<Ô=Ø”3�u—|‘|“~Ó&Ñ&ŠCà�1‰HŠCñ ô ˆv‹;Ðr   ÚSc                 óü  • [         R                  " S5      n[        U/ 5      /nUR                  U 5       GH  nUR	                  5       n	U	S   S:X  a_  [        U5      S:w  a  [        SUR                  5       S 35      e[        U/ 5      n
US   R                  U
5        UR                  U
5        M|  U	S   S:X  a>  [        U5      S	:w  a  [        S
UR                  5       S 35      eUR                  5         MÃ  Uc  US   R                  U	5        MÜ  [        X“5      u  p¼U(       a  U(       a  [        XEU5      nUS   R                  X¼45        GM     [        U5      S:w  a  [        S[        U 5      S 35      eUS   $ )a
  
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   Ú[r9   zUnexpected [ at char ÚdéÿÿÿÿÚ]é   zUnexpected ] at char zExpected ] at char )r€   Úcompiler   ÚfinditerÚgroupr4   rB   Ústartrƒ   Úpopr   r   )Úsr   Ú
root_labelÚsepÚsource_tagsetÚtarget_tagsetÚWORD_OR_BRACKETÚstackr�   ÚtextÚchunkÚwordÚtags                r   Útagstr2treer    ?  sP  € ô( —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Ó0‘	�Þ ¦]Ü! -ÀÓD�CØ�b‘	× Ñ  $ ×-ñ' -ô* ˆ5ƒz�QƒÜÐ.¬s°1«v°a¨jÐ9Ó:Ð:Ø�‰8€Or   z(\S+)\s+(\S+)\s+([IOB])-?(\S+)?c                 óf  • [        U/ 5      /n[        U R                  S5      5       GH  u  pEUR                  5       (       d  M  [        R                  U5      nUc  [        SUS 35      eUR                  5       u  pxpšUb  X¡;  a  Sn	U	S:H  =(       a    X£S   R                  5       :g  nU	S;   d  U(       a  [        U5      S:X  a  UR                  5         U	S	:X  d  U(       a1  [        U
/ 5      nUS   R                  U5        UR                  U5        US   R                  Xx45        GM     U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_REr�   rB   Úgroupsr‚   r4   r”   rƒ   )r•   Úchunk_typesr–   r›   ÚlinenoÚliner�   rž   rŸ   ÚstateÚ
chunk_typeÚ
mismatch_Ir�   s                r   Úconllstr2treer²   u  s  € ô$ �*˜bÓ!Ð"€Eä! !§'¡'¨$£-×0‰ˆØ�z‰z�|‰|Ùô —‘˜tÓ$ˆØ‰=Ü˜~¨f°Q¨ZÐ8Ó9Ð9Ø).¯©«Ñ&ˆ�Eð Ñ" zÓ'DØˆEð ˜c‘\×E j¸"±I·O±OÓ4EÑ&Eˆ
Ø�D‹=žJÜ�5‹z˜Q‹Ø—	‘	”ð �C‹<ž:Ü˜ RÓ(ˆEØ�"‰I×Ñ˜UÔ#Ø�L‰L˜Ôð 	ˆb‰	×Ñ˜$˜×%ñ9 1ð< �‰8€Or   c                 ó&  • / nU  H]  n UR                  5       nSnU HA  n[        U[        5      (       a  [        S5      eUR	                  US   US   XC-   45        SnMC     M_     U$ ! [
         a    UR	                  US   US   S45         MŠ  f = f)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   r9   úI-r£   )r‚   r   r   rB   rƒ   ÚAttributeError)r=   Útagsrˆ   ÚcategoryÚprefixÚcontentss         r   r
   r
   ª  s§   € ð €DÛˆð	3Ø—{‘{“}ˆHØˆFÛ!�Ü˜h¬×-Ñ-Ü$ØQóð ð —‘˜X a™[¨(°1©+°vÑ7HÐIÔJØ’ó "ñ	 ð €Køô ó 	3Ø�K‰K˜˜q™ 5¨¡8¨SÐ1×2ð	3ús   ‰AA(Á($BÂBc                 ó�  • [        U/ 5      nU  GH2  u  pVnUc&  U(       a  [        S5      eUR                  XV45        M0  UR                  S5      (       a"  UR                  [        USS XV4/5      5        Mh  UR                  S5      (       a�  [	        U5      S:X  d2  [        US   [         5      (       a  US   R                  5       USS :w  a4  U(       a  [        S5      eUR                  [        USS XV4/5      5        Mó  US   R                  XV45        GM  US:X  a  UR                  XV45        GM&  [        S	U< 35      e   U$ )
z)
Convert the CoNLL IOB format to a tree.
NzBad conll tag sequencer´   r�   rµ   r   r�   r£   zBad conll tag )r   rB   rƒ   Ú
startswithr4   r   r‚   )Úsentencer¬   r–   ÚstrictÚtreerž   ÚpostagÚchunktags           r   Úconlltags2treerÂ   Å  s(  € ô �
˜BÓ€DÜ"*Ñˆ�hØÑÞÜ Ð!9Ó:Ð:ð —‘˜T˜NÖ+Ø× Ñ  ×&Ñ&Ø�K‰Kœ˜X a b˜\¨T¨NÐ+;Ó<Ö=Ø× Ñ  ×&Ñ&ä�D“	˜Q“Ü! $ r¡(¬D×1Ñ1Ø˜‘8—>‘>Ó# x°° |Ó3æÜ$Ð%=Ó>Ð>ð —K‘K¤ X¨a¨b \°T°NÐ3CÓ DÖEà�R‘—‘  ×/Ø˜‹_Ø�K‰K˜˜×'ä˜~¨h©\Ð:Ó;Ð;ñ3 #+ð4 €Kr   c                 ó‚   • [        U 5       Vs/ s H  nSR                  U5      PM     nnSR                  U5      $ s  snf )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È   é  s;   € ô +9¸Ô*;Ó<Ò*; ˆS�X‰X�eŽ_Ñ*;€EÐ<Ø�9‰9�UÓÐùò =s   Ž<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                 ó   • [        U/ 5      /nU c  / $ [        R                  " SU 5       HÌ  nUR                  5       n UR	                  S5      (       af  [
        R                  U5      nUc  [        SU5        [        UR                  S5      / 5      nUS   R                  U5        UR                  U5        M�  UR	                  S5      (       a  UR                  5         M¸  US   R                  U5        MÎ     [        U5      S
:w  a  [        S5      eUS   $ ! [        [        4 a$  n[        SUR                  5       S S	35      UeS nAff = f)Nz<[^>]+>|[^\s<]+z<b_ÚXXXXÚtyper�   z<e_z$Bad IEER string (error at character rŒ   Ú)r9   zBad IEER stringr   )r   r€   r‘   r’   r¼   Ú_IEER_TYPE_REr�   Úprintrƒ   r”   Ú
IndexErrorrB   r“   r4   )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‘	× Ñ  Ö'ñ! 6ô* ˆ5ƒz�QƒÜÐ*Ó+Ð+Ø�‰8€Oøô œJÐ'ó 	ÜØ6°w·}±}³ÀqÐ6IÈÐKóàðûð	ús$   ¾A:DÂ:&DÃ"DÄEÄ)EÅE)	ÚLOCATIONÚORGANIZATIONÚPERSONÚDURATIONÚDATEÚCARDINALÚPERCENTÚMONEYÚMEASUREc           	      ó  • [         R                  U 5      nU(       ag  [        UR                  S5      U5      UR                  S5      UR                  S5      UR                  S5      [        UR                  S5      U5      S.$ [        X5      $ )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_REr�   rÔ   r’   )r•   r¬   r–   rÒ   s       r   Úieerstr2treerä   '  sy   € ô8 	×Ñ˜1Ó€AÞä# A§G¡G¨F£O°ZÓ@Ø—W‘W˜WÓ%Ø—w‘w˜yÓ)ØŸ™ Ó-ô (¨¯©°
Ó(;¸ZÓHñ
ð 	
ô ˜qÓ-Ð-r   c                  ó"  • Sn SS K nUR                  R                  U SS9nUR                  5         [	        5         Sn [        U SS9nUR                  5         [	        S5        [	        UR                  R                  U5      5        [	        5         g )	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æ   r‰   Ú/NN)©ræ   rç   ÚVPr‰   )rî   r‰   F)r€   Únltk.metricsr   r   Únltk.tag.mappingr   Únltk.tag.utilr   Ú	nltk.treer   r   rA   r    r�   rª   r²   r
   rÂ   rÈ   ÚDOTALLrã   rÍ   rÔ   rä   rë   rx   r:   r   r   Ú<module>rõ      sÇ   ðó 
å .Ý $Ý #Ý ò+÷<z
ñ z
ò~
ð UYô.ðf �:Š:Ð8Ó9€ô2òjð8 FKô!òH
ð �zŠzðð ‡I�Ió
€ð —
’
ÐAÓB€òòD
ð ô(.òV,ð^ ˆzÓÙ…Fð r   