a
     ˜ëjf  ã                   @   sP   d Z ddlZddlT dddddd	d
œZeeƒZG dd„ dƒZG dd„ deƒZdS )a)  
Corpus reader for the Information Extraction and Entity Recognition Corpus.

NIST 1999 Information Extraction: Entity Recognition Evaluation
https://www.itl.nist.gov/iad/894.01/tests/ie-er/er_99/er_99.htm

This corpus contains the NEWSWIRE development test data for the
NIST 1999 IE-ER Evaluation.  The files were taken from the
subdirectory: ``/ie_er_99/english/devtest/newswire/*.ref.nwt``
and filenames were shortened.

The corpus contains the following files: APW_19980314, APW_19980424,
APW_19980429, NYT_19980315, NYT_19980403, and NYT_19980407.
é    N)Ú*z&Associated Press Weekly, 14 March 1998z&Associated Press Weekly, 24 April 1998z&Associated Press Weekly, 29 April 1998zNew York Times, 15 March 1998zNew York Times, 3 April 1998zNew York Times, 7 April 1998)ZAPW_19980314ZAPW_19980424ZAPW_19980429ZNYT_19980315ZNYT_19980403ZNYT_19980407c                   @   s   e Zd Zddd„Zdd„ ZdS )ÚIEERDocumentNÚ c                 C   s"   || _ || _|| _|| _|| _d S ©N)ÚtextÚdocnoÚdoctypeÚ	date_timeÚheadline)Úselfr   r   r   r	   r
   © r   úV/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/nltk/corpus/reader/ieer.pyÚ__init__+   s
    zIEERDocument.__init__c                 C   sh   | j rd | j  ¡ ¡}n&d dd„ | j ¡ D ƒd d… ¡d }| jd ur\d| j› d|›d�S d	| S d S )
Nú c                 S   s    g | ]}|d d… dkr|‘qS )Né   ú<r   )Ú.0Úwr   r   r   Ú
<listcomp>7   ó    z)IEERDocument.__repr__.<locals>.<listcomp>é   z...z<IEERDocument z: ú>z<IEERDocument: %r>)r
   ÚjoinZleavesr   r   )r   r
   r   r   r   Ú__repr__2   s    $ÿ
zIEERDocument.__repr__)NNNr   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   *   s   
r   c                   @   s<   e Zd ZdZddd„Zddd„Zdd„ Zd	d
„ Zdd„ ZdS )ÚIEERCorpusReaderr   Nc                    s   t ‡ fdd„ˆ  |d¡D ƒƒS )Nc                    s    g | ]\}}t |ˆ j|d �‘qS ©)Úencoding)ÚStreamBackedCorpusViewÚ_read_block©r   ZfileidÚenc©r   r   r   r   D   s   ÿz)IEERCorpusReader.docs.<locals>.<listcomp>T©ÚconcatZabspaths©r   Zfileidsr   r$   r   ÚdocsB   s
    

þÿzIEERCorpusReader.docsc                    s   t ‡ fdd„ˆ  |d¡D ƒƒS )Nc                    s    g | ]\}}t |ˆ j|d �‘qS r   )r    Ú_read_parsed_blockr"   r$   r   r   r   L   s   ÿz0IEERCorpusReader.parsed_docs.<locals>.<listcomp>Tr%   r'   r   r$   r   Úparsed_docsJ   s
    

þÿzIEERCorpusReader.parsed_docsc                    s   ‡ fdd„ˆ   |¡D ƒS )Nc                    s&   g | ]}ˆ   |¡jd urˆ   |¡‘qS r   )Ú_parser   )r   Údocr$   r   r   r   T   s   þz7IEERCorpusReader._read_parsed_block.<locals>.<listcomp>)r!   )r   Ústreamr   r$   r   r)   R   s    
þz#IEERCorpusReader._read_parsed_blockc                 C   s4   t jj|dd�}t|tƒr(tf i |¤ŽS t|ƒS d S )NZDOCUMENT)Z
root_label)ÚnltkÚchunkZieerstr2treeÚ
isinstanceÚdictr   )r   r,   Úvalr   r   r   r+   Z   s    
zIEERCorpusReader._parsec                 C   s`   g }|  ¡ }|sq"| ¡ dkrq"q| |¡ |  ¡ }|s:qT| |¡ | ¡ dkr,qTq,d |¡gS )Nz<DOC>z</DOC>Ú
)ÚreadlineÚstripÚappendr   )r   r-   ÚoutÚliner   r   r   r!   a   s    

zIEERCorpusReader._read_block)N)N)	r   r   r   Ú__doc__r(   r*   r)   r+   r!   r   r   r   r   r   ?   s   

r   )	r9   r.   Znltk.corpus.reader.apiÚtitlesÚsortedZ	documentsr   ZCorpusReaderr   r   r   r   r   Ú<module>	   s   ú
