a
     ˜ëj(  ã                e   @   sJ  d Z ddlZddlZddlT ddlmZ ddlmZ ddlT ddl	m
Z
 G dd„ deƒZG d	d
„ d
eƒZG dd„ deƒZdddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpœdZdS )qaß  
Corpus reader for the York-Toronto-Helsinki Parsed Corpus of Old
English Prose (YCOE), a 1.5 million word syntactically-annotated
corpus of Old English prose texts. The corpus is distributed by the
Oxford Text Archive: http://www.ota.ahds.ac.uk/ It is not included
with NLTK.

The YCOE corpus is divided into 100 files, each representing
an Old English prose text. Tags used within each text complies
to the YCOE standard: https://www-users.york.ac.uk/~lang22/YCOE/YcoeHome.htm
é    N)Ú*)ÚBracketParseCorpusReader)ÚTaggedCorpusReader)ÚRegexpTokenizerc                   @   s|   e Zd ZdZddd„Zddd„Zddd	„Zd
d„ Zddd„Zddd„Z	ddd„Z
d dd„Zd!dd„Zd"dd„Zd#dd„ZdS )$ÚYCOECorpusReaderz¶
    Corpus reader for the York-Toronto-Helsinki Parsed Corpus of Old
    English Prose (YCOE), a 1.5 million word syntactically-annotated
    corpus of Old English prose texts.
    Úutf8c                 C   s²   t  | |g |¡ t| j d¡dd|d�| _t| j d¡ddƒ| _dd„ | j ¡ D ƒ}d	d„ | j ¡ D ƒ|krtt	d
ƒ‚t
dd„ |D ƒdd„ |D ƒ ƒ}t  | |||¡ t
|ƒ| _d S )NÚpsdz.*ú.psd)ÚencodingÚposú.posc                 S   s   h | ]}|d d… ’qS ©Néüÿÿÿ© ©Ú.0Úfr   r   úV/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/nltk/corpus/reader/ycoe.pyÚ	<setcomp>.   ó    z,YCOECorpusReader.__init__.<locals>.<setcomp>c                 S   s   h | ]}|d d… ’qS r   r   r   r   r   r   r   /   r   z5Items in "psd" and "pos" subdirectories do not match.c                 S   s   g | ]}d | ‘qS ©z%s.psdr   ©r   Údocr   r   r   Ú
<listcomp>3   r   z-YCOECorpusReader.__init__.<locals>.<listcomp>c                 S   s   g | ]}d | ‘qS ©z%s.posr   r   r   r   r   r   4   r   )ÚCorpusReaderÚ__init__ÚYCOEParseCorpusReaderÚrootÚjoinÚ_psd_readerÚYCOETaggedCorpusReaderÚ_pos_readerÚfileidsÚ
ValueErrorÚsortedÚ
_documents)Úselfr   r
   Ú	documentsr#   r   r   r   r   %   s    ÿÿÿzYCOECorpusReader.__init__Nc                 C   sP   |du r| j S t|tƒr|g}|D ]}|| jvr"td| ƒ‚q"tdd„ |D ƒƒS )z£
        Return a list of document identifiers for all documents in
        this corpus, or for the documents with the given file(s) if
        specified.
        NzFile id %s not foundc                 S   s   h | ]}|d d… ’qS r   r   r   r   r   r   r   G   r   z-YCOECorpusReader.documents.<locals>.<setcomp>)r&   Ú
isinstanceÚstrÚ_fileidsÚKeyErrorr%   )r'   r#   r   r   r   r   r(   9   s    

zYCOECorpusReader.documentsc                 C   sB   |du r| j S t|tƒr|g}ttdd„ |D ƒdd„ |D ƒ ƒƒS )z•
        Return a list of file identifiers for the files that make up
        this corpus, or that store the given document(s) if specified.
        Nc                 S   s   g | ]}d | ‘qS r   r   r   r   r   r   r   T   r   z,YCOECorpusReader.fileids.<locals>.<listcomp>c                 S   s   g | ]}d | ‘qS r   r   r   r   r   r   r   U   r   )r+   r)   r*   r%   Úset©r'   r(   r   r   r   r#   I   s    
ÿÿÿzYCOECorpusReader.fileidsc                    sl   |du r| j }nJt|tƒr |g}|D ]4}|| j vr$|dd… dv rLtdƒ‚q$td| ƒ‚q$‡ fdd„|D ƒS )z‡
        Helper that selects the appropriate fileids for a given set of
        documents from a given subcorpus (pos or psd).
        Nr   )r   r	   zvExpected a document identifier, not a file identifier.  (Use corpus.documents() to get a list of document identifiers.z Document identifier %s not foundc                    s   g | ]}|› d ˆ › �‘qS )Ú.r   )r   Úd©Ú	subcorpusr   r   r   m   r   z0YCOECorpusReader._getfileids.<locals>.<listcomp>)r&   r)   r*   r$   )r'   r(   r2   Údocumentr   r1   r   Ú_getfileidsY   s    

ÿzYCOECorpusReader._getfileidsc                 C   s   | j  |  |d¡¡S ©Nr   )r"   Úwordsr4   r.   r   r   r   r6   p   s    zYCOECorpusReader.wordsc                 C   s   | j  |  |d¡¡S r5   )r"   Úsentsr4   r.   r   r   r   r7   s   s    zYCOECorpusReader.sentsc                 C   s   | j  |  |d¡¡S r5   )r"   Úparasr4   r.   r   r   r   r8   v   s    zYCOECorpusReader.parasc                 C   s   | j  |  |d¡¡S r5   )r"   Útagged_wordsr4   r.   r   r   r   r9   y   s    zYCOECorpusReader.tagged_wordsc                 C   s   | j  |  |d¡¡S r5   )r"   Útagged_sentsr4   r.   r   r   r   r:   |   s    zYCOECorpusReader.tagged_sentsc                 C   s   | j  |  |d¡¡S r5   )r"   Útagged_parasr4   r.   r   r   r   r;      s    zYCOECorpusReader.tagged_parasc                 C   s   | j  |  |d¡¡S )Nr   )r    Úparsed_sentsr4   r.   r   r   r   r<   ‚   s    zYCOECorpusReader.parsed_sents)r   )N)N)N)N)N)N)N)N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r(   r#   r4   r6   r7   r8   r9   r:   r;   r<   r   r   r   r   r      s   








r   c                   @   s   e Zd ZdZdd„ ZdS )r   zrSpecialized version of the standard bracket parse corpus reader
    that strips out (CODE ...) and (ID ...) nodes.c                 C   s*   t  dd|¡}t  d|¡rd S t | |¡S )Nz(?u)\((CODE|ID)[^\)]*\)Ú z\s*\(\s*\)\s*$)ÚreÚsubÚmatchr   Ú_parse)r'   Útr   r   r   rE   Š   s    zYCOEParseCorpusReader._parseN)r=   r>   r?   r@   rE   r   r   r   r   r   †   s   r   c                   @   s   e Zd Zddd„ZdS )r!   r   c                 C   s(   d}t |dd�}tj| ||d|d� d S )Nz+(?u)(?<=/\.)\s+|\s*\S*_CODE\s*|\s*\S*_ID\s*T)ZgapsÚ_)ÚsepÚsent_tokenizer)r   r   r   )r'   r   Úitemsr
   Zgaps_rerI   r   r   r   r   ’   s
    
ÿzYCOETaggedCorpusReader.__init__N)r   )r=   r>   r?   r   r   r   r   r   r!   ‘   s   r!   zAdrian and Ritheusu   Ã†lfric, Supplemental Homiliesu   Ã†lfric's Lives of SaintszAlcuin De virtutibus et vitiiszAlexander's Letter to AristotlezApollonius of TyreZ	Augustinez$Bede's History of the English ChurchzBenedictine RulezBlickling Homiliesz#Boethius' Consolation of PhilosophyzByrhtferth's ManualzCanons of Edgar (D)zCanons of Edgar (X)u   Ã†lfric's Catholic Homilies Iu   Ã†lfric's Catholic Homilies IIz
Saint ChadzChrodegang of Metz, RulezSaint ChristopherzAnglo-Saxon Chronicle AzAnglo-Saxon Chronicle CzAnglo-Saxon Chronicle DzAnglo-Saxon Chronicle EzCura PastoraliszCura Pastoralis (Cotton)zDicts of CatozDocuments 1 (O1)zDocuments 2 (O1/O2)zDocuments 2 (O2)zDocuments 3 (O2/O3)zDocuments 3 (O3)zDocuments 4 (O2/O4)z Honorius of Autun, Elucidarium 1u   Ã†lfric's Epilogue to GenesiszSaint Euphrosynez Saint Eustace and his companionsz
Exodus (P)zGenesis (C)zGregory's Dialogues (C)zGregory's Dialogues (H)zPseudo-Apuleius, Herbariumz"Wulfstan's Institute of Polity (D)z"Wulfstan's Institute of Polity (X)zSaint JamesZLacnungaZ	LeechdomszLaws, Cnut IzLaws, Cnut IIu   Laws, Ã†thelred Vu   Laws, Ã†thelred VIzLaws, AlfredzAlfred's Introduction to LawszLaws, Gerefaz	Laws, InezNorthumbra Preosta LaguzLaws, William I, LadZLeofricu   Ã†lfric's Letter to Sigefyrthu!   Ã†lfric's Letter to Sigeweard (B)u!   Ã†lfric's Letter to Sigeweard (Z)u   Ã†lfric's Letter to Wulfgeatu    Ã†lfric's Letter to Wulfsige (T)u!   Ã†lfric's Letter to Wulfsige (Xa)u   Ã†lfric's Letter to Wulfstan Iu   Ã†lfric's Letter to Wulfstan IIzSaint Margaret (C)zSaint Margaret (T)zMartyrology, IzMartyrology, IIzMartyrology, IIIzMarvels of the EastzMary of Egyptz
Saint NeotzGospel of Nicodemus (A)zGospel of Nicodemus (C)zGospel of Nicodemus (D)zGospel of Nicodemus (E)ZOrosiusZ
Heptateuchu(   Ã†lfric's Preface to Catholic Homilies Iu)   Ã†lfric's Preface to Catholic Homilies IIzPreface to the Cura Pastoralisu   Ã†lfric's Preface to Genesisu$   Ã†lfric's Preface to Lives of Saintsz"Preface to Augustine's Soliloquiesz*Pseudo-Apuleius, Medicina de quadrupedibuszHistory of the Holy Rood-TreezSeven SleeperszSt. Augustine's SoliloquieszSolomon and Saturn IzSolomon and Saturn IIu   Ã†lfric's De Temporibus AnnizVercelli HomilieszVercelli Homilies (E)zVercelli Homilies (L)zSaint Vincent (Bodley 343)zVindicta SalvatoriszWest-Saxon GospelszWulfstan's Homilies)dzcoadrian.o34zcoaelhom.o3zcoaelive.o3Zcoalcuinz
coalex.o23zcoapollo.o3Zcoaugustz	cobede.o2zcobenrul.o3zcoblick.o23z
coboeth.o2zcobyrhtf.o3Z	cocanedgDZ	cocanedgXzcocathom1.o3zcocathom2.o3z
cochad.o24ZcochdrulZcochristophzcochronA.o23ZcochronCZcochronDzcochronE.o34z	cocura.o2ZcocuraCzcodicts.o34z
codocu1.o1zcodocu2.o12z
codocu2.o2zcodocu3.o23z
codocu3.o3zcodocu4.o24Zcoeluc1Zcoeluc2zcoepigen.o3ZcoeuphrZcoeustZ	coexodusPZ	cogenesiCzcogregdC.o24zcogregdH.o23ZcoherbarzcoinspolD.o34Z	coinspolXZcojameszcolacnu.o23z
colaece.o2zcolaw1cn.o3zcolaw2cn.o3zcolaw5atr.o3zcolaw6atr.o3z
colawaf.o2zcolawafint.o2zcolawger.o34zcolawine.ox2zcolawnorthu.o3zcolawwllad.o4zcoleofri.o4zcolsigef.o3Z	colsigewBzcolsigewZ.o34ZcolwgeatZ	colwsigeTzcolwsigeXa.o34zcolwstan1.o3zcolwstan2.o3zcomargaC.o34ZcomargaTZcomart1Zcomart2zcomart3.o23zcomarvel.o23ZcomaryZconeotZconicodAZconicodCZconicodDZconicodEzcoorosiu.o2z
cootest.o3zcoprefcath1.o3zcoprefcath2.o3zcoprefcura.o2zcoprefgen.o3zcopreflives.o3Zcoprefsolilozcoquadru.o23ZcoroodZ	cosevenslZcosolilozcosolsat1.o4Z	cosolsat2z
cotempo.o3ZcoverhomZ	coverhomEZ	coverhomLZcovinceBZcovinsalzcowsgosp.o3z
cowulf.o34)r@   ÚosrB   Znltk.corpus.reader.apiZ nltk.corpus.reader.bracket_parser   Znltk.corpus.reader.taggedr   Znltk.corpus.reader.utilZnltk.tokenizer   r   r   r   r!   r(   r   r   r   r   Ú<module>   sÞ   hœ