
    gP                     :    d dl Z d dlZd dlZdZ G d d      Zd Zy)    NFc                   .    e Zd ZdZd Zd Zd Zd Zd Zy)LazyCorpusLoadera  
    To see the API documentation for this lazily loaded corpus, first
    run corpus.ensure_loaded(), and then run help(this_corpus).

    LazyCorpusLoader is a proxy object which is used to stand in for a
    corpus object before the corpus is loaded.  This allows NLTK to
    create an object for each corpus, but defer the costs associated
    with loading those corpora until the first time that they're
    actually accessed.

    The first time this object is accessed in any way, it will load
    the corresponding corpus, and transform itself into that corpus
    (by modifying its own ``__class__`` and ``__dict__`` attributes).

    If the corpus can not be found, then accessing this object will
    raise an exception, displaying installation instructions for the
    NLTK data package.  Once they've properly installed the data
    package (or modified ``nltk.data.path`` to point to its location),
    they can then use the corpus object without restarting python.

    :param name: The name of the corpus
    :type name: str
    :param reader_cls: The specific CorpusReader class, e.g. PlaintextCorpusReader, WordListCorpusReader
    :type reader: nltk.corpus.reader.api.CorpusReader
    :param nltk_data_subdir: The subdirectory where the corpus is stored.
    :type nltk_data_subdir: str
    :param `*args`: Any other non-keywords arguments that `reader_cls` might need.
    :param `**kwargs`: Any other keywords arguments that `reader_cls` might need.
    c                     ddl m} t        ||      sJ |x| _        | _        || _        d|v r|d   | _        |j                  dd        nd| _        || _        || _	        y )Nr   )CorpusReadernltk_data_subdircorpora)
nltk.corpus.reader.apir   
issubclass_LazyCorpusLoader__name__name___LazyCorpusLoader__reader_clssubdirpop_LazyCorpusLoader__args_LazyCorpusLoader__kwargs)selfname
reader_clsargskwargsr   s         E/var/www/openai/venv/lib/python3.12/site-packages/nltk/corpus/util.py__init__zLazyCorpusLoader.__init__3   sd    7*l333&**dm&' !34DKJJ)40#DK    c                   	 t        j                  dd| j                        }t        r0	 t        j
                  j                  | j                   d|       }n9	 t        j
                  j                  | j                   d| j                         } | j                  |g| j                  i | j                  }| j                  | j                  c| j                  | j                  c	|j                  | _        |j                  | _        	fd}t        ||       | _        y # t        $ rS}	 t        j
                  j                  | j                   d| j                         }n# t        $ r |w xY wY d }~d }~ww xY w# t        $ rJ}	 t        j
                  j                  | j                   d|       }n# t        $ r |w xY wY d }~Ed }~ww xY w)Nz(([^/]+)(/.*)?)z
\2.zip/\1//c                     t        gi }|j                  | _        |j                  | _        t        j                          y N)r   __dict__	__class__gccollect)r   lazy_readerr   r   r   r   s     r   _unloadz(LazyCorpusLoader.__load.<locals>._unloadh   s<    *4MdMfMK'00DM(22DNJJLr   )resubr   TRY_ZIPFILE_FIRSTnltkdatafindr   LookupErrorr   r   r   r   r   _make_bound_methodr#   )
r   zip_namerootecorpusr#   r   r   r   r   s
         @@@@r   __loadzLazyCorpusLoader.__loadD   s   66,mT[[Iyy~~Qxj&AByy~~Qt{{m&DE #""4G$++GG {{DMMf;;(9(9j))
	 *'48I  99>>T[[M4;;-*HID" G   99>>T[[M8**EFD" G sS   .D- 8F -	F	78E0/F0E<<FF		G.GGGGGc                 Z    |dk(  rt        d      | j                          t        | |      S )N	__bases__z4LazyCorpusLoader object has no attribute '__bases__')AttributeError_LazyCorpusLoader__loadgetattr)r   attrs     r   __getattr__zLazyCorpusLoader.__getattr__p   s0    
 ; !WXX tT""r   c                 h    dj                  | j                  j                  d| j                  z         S )Nz<{} in {!r} (not loaded yet)>z.../corpora/)formatr   r   r   r   s    r   __repr__zLazyCorpusLoader.__repr__}   s0    .55&&T[[(
 	
r   c                      y r    r:   s    r   r#   zLazyCorpusLoader._unload   s     	r   N)	r   
__module____qualname____doc__r   r4   r7   r;   r#   r=   r   r   r   r      s!    <"*9X#
r   r   c                      G d d      } |       }t        |j                        }	  || ||j                        S # t        $ r  || |      cY S w xY w)z>
    Magic for creating bound methods (used for _unload).
    c                       e Zd Zd Zy)_make_bound_method.<locals>.Fooc                      y r   r=   r:   s    r   methz$_make_bound_method.<locals>.Foo.meth   s    r   N)r   r>   r?   rE   r=   r   r   FoorC      s    	r   rF   )typerE   r   	TypeError)funcr   rF   fbound_methods        r   r+   r+      sV    
  	A<L(D$77 (D$''(s   < AA)r    r$   r'   r&   r   r+   r=   r   r   <module>rL      s(    
 	  s sl(r   