i d.d/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6Z?i d/d/6d1d16d3d36d5d56d7d76d9d96d;d;6d=d=6d?d?6dCdD6dCdC6Z@dEe4eAe0e0e0dFZBdGdHZCdIZDdJZEdKe6fdLYZFdMe jGfdNYZHdOe6fdPYZIdQdRdSdTdUdUdVdWdXdYdZd[d\d]d^dUd_gZJdS(`u Functions to find and load NLTK resource files, such as corpora, grammars, and saved processing objects. Resource files are identified using URLs, such as ``nltk:corpora/abc/rural.txt`` or ``http://nltk.org/sample/toy.cfg``. The following URL protocols are supported: - ``file:path``: Specifies the file whose path is *path*. Both relative and absolute paths may be used. - ``http://host/path``: Specifies the file stored on the web server *host* at path *path*. - ``nltk:path``: Specifies the file stored in the NLTK data package at *path*. NLTK will search for these files in the directories specified by ``nltk.data.path``. If no protocol is specified, then the default protocol ``nltk:`` will be used. This module provides to functions that can be used to access a resource file, given its URL: ``load()`` loads a given resource, and adds it to a resource cache; and ``retrieve()`` copies a given resource to a local file. i(tprint_functiontunicode_literals(tdivisionN(tGzipFiletREADtWRITE(t Z_SYNC_FLUSH(tZ_FINISH(tpy3_datat add_py3_data(t text_typet string_typestBytesIOturlopent url2pathnameu NLTK_DATAuuAPPENGINE_RUNTIMEu~/u ~/nltk_datauwinu C:\nltk_datau D:\nltk_datau E:\nltk_datau nltk_dataulibuAPPDATAuC:\u/usr/share/nltk_datau/usr/local/share/nltk_datau/usr/lib/nltk_datau/usr/local/lib/nltk_dataurbi uutf-8cC s:|dkr$t||||}ntj||||S(N(tNoneRtiot TextIOWrapper(tfilenametmodet compressleveltencodingtfileobjterrorstnewline((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pytgzip_open_unicodegs cC sz|jdd\}}|dkr'nI|dkr[|jdrpd|jd}qpntjdd|}||fS(u Splits a resource url into ":". >>> windows = sys.platform.startswith('win') >>> split_resource_url('nltk:home/nltk') ('nltk', 'home/nltk') >>> split_resource_url('nltk:/home/nltk') ('nltk', '/home/nltk') >>> split_resource_url('file:/home/nltk') ('file', '/home/nltk') >>> split_resource_url('file:///home/nltk') ('file', '/home/nltk') >>> split_resource_url('file:///C:/home/nltk') ('file', '/C:/home/nltk') u:iunltkufileu/u^/{0,2}u(tsplitt startswithtlstriptretsub(t resource_urltprotocoltpath_((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pytsplit_resource_urlns  cC syt|\}}Wntk r5d}|}nX|dkrotjj|rod}t|td}nU|dkrd}t|td}n.|dkrd}t|t}n |d7}dj ||gS(u Normalizes a resource url >>> windows = sys.platform.startswith('win') >>> os.path.normpath(split_resource_url(normalize_resource_url('file:grammar.fcfg'))[1]) == \ ... ('\\' if windows else '') + os.path.abspath(os.path.join(os.curdir, 'grammar.fcfg')) True >>> not windows or normalize_resource_url('file:C:/dir/file') == 'file:///C:/dir/file' True >>> not windows or normalize_resource_url('file:C:\\dir\\file') == 'file:///C:/dir/file' True >>> not windows or normalize_resource_url('file:C:\\dir/file') == 'file:///C:/dir/file' True >>> not windows or normalize_resource_url('file://C:/dir/file') == 'file:///C:/dir/file' True >>> not windows or normalize_resource_url('file:////C:/dir/file') == 'file:///C:/dir/file' True >>> not windows or normalize_resource_url('nltk:C:/dir/file') == 'file:///C:/dir/file' True >>> not windows or normalize_resource_url('nltk:C:\\dir\\file') == 'file:///C:/dir/file' True >>> windows or normalize_resource_url('file:/dir/file/toy.cfg') == 'file:///dir/file/toy.cfg' True >>> normalize_resource_url('nltk:home/nltk') 'nltk:home/nltk' >>> windows or normalize_resource_url('nltk:/home/nltk') == 'file:///home/nltk' True >>> normalize_resource_url('http://example.com/dir/file') 'http://example.com/dir/file' >>> normalize_resource_url('dir/file') 'nltk:dir/file' unltkufile://ufileunltk:u://uN( R"t ValueErrortostpathtisabstnormalize_resource_nametFalseRtTruetjoin(RR tname((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pytnormalize_resource_urls !     cC s6ttjd|p*|jtjj}tjj drQ|j d}ntj dd|}|rtjj |}n9|dkrtj}ntjjtjj||}|jddjtjjd}tjj drtjj|rd|}n|r2|jd r2|d7}n|S(u( :type resource_name: str or unicode :param resource_name: The name of the resource to search for. Resource names are posix-style relative path names, such as ``corpora/brown``. Directory names will automatically be converted to a platform-appropriate path separator. Directory trailing slashes are preserved >>> windows = sys.platform.startswith('win') >>> normalize_resource_name('.', True) './' >>> normalize_resource_name('./', True) './' >>> windows or normalize_resource_name('dir/file', False, '/') == '/dir/file' True >>> not windows or normalize_resource_name('C:/file', False, '/') == '/C:/file' True >>> windows or normalize_resource_name('/dir/file', False, '/') == '/dir/file' True >>> windows or normalize_resource_name('../dir/file', False, '/') == '/dir/file' True >>> not windows or normalize_resource_name('/dir/file', True, '/') == 'dir/file' True >>> windows or normalize_resource_name('/dir/file', True, '/') == '/dir/file' True u[\\/.]$uwinu/u^/+u\N(tboolRtsearchtendswithR$R%tseptsystplatformRRRtnormpathRtcurdirtabspathR*treplaceR&(t resource_nametallow_relativet relative_pathtis_dir((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR's -   $$  t PathPointercB s,eZdZddZdZdZRS(uq An abstract base class for 'path pointers,' used by NLTK's data package to identify specific paths. Two subclasses exist: ``FileSystemPathPointer`` identifies a file that can be accessed directly via a given absolute path. ``ZipFilePathPointer`` identifies a file contained within a zipfile, that can be accessed by reading that zipfile. cC stddS(u Return a seekable read-only stream that can be used to read the contents of the file identified by this path pointer. :raise IOError: If the path specified by this pointer does not contain a readable file. uabstract base classN(tNotImplementedError(tselfR((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pytopenscC stddS(u Return the size of the file pointed to by this path pointer, in bytes. :raise IOError: If the path specified by this pointer does not contain a readable file. uabstract base classN(R<(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt file_sizescC stddS(uP Return a new path pointer formed by starting at the path identified by this pointer, and then following the relative path given by ``fileid``. The path components of ``fileid`` should be separated by forward slashes, regardless of the underlying file system's path seperator character. uabstract base classN(R<(R=tfileid((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR*sN(t__name__t __module__t__doc__RR>R?R*(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR;s tFileSystemPathPointercB s\eZdZedZedZddZdZ dZ dZ dZ RS( um A path pointer that identifies a file which can be accessed directly via a given absolute path. cC sDtjj|}tjj|s7td|n||_dS(u Create a new path pointer for the given absolute path. :raise IOError: If the given path does not exist. uNo such file or directory: %rN(R$R%R5texiststIOErrort_path(R=RG((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt__init__"scC s|jS(u2The absolute path identified by this path pointer.(RG(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR%2scC s4t|jd}|dk r0t||}n|S(Nurb(R>RGRtSeekableUnicodeStreamReader(R=Rtstream((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR>7s cC stj|jjS(N(R$tstatRGtst_size(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR?=scC s"tjj|j|}t|S(N(R$R%R*RGRD(R=R@RG((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR*@scC std|jS(NuFileSystemPathPointer(%r)(tstrRG(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt__repr__DscC s|jS(N(RG(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt__str__JsN( RARBRCRRHtpropertyR%RR>R?R*RNRO(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRDs    tBufferedGzipFilecB seZdZd ZdeZedddddZdZdZ dZ dZ e d Z dd Zd d ZRS(u A ``GzipFile`` subclass that buffers calls to ``read()`` and ``write()``. This allows faster reads and writes of data to and from gzip-compressed files at the cost of using more memory. The default buffer size is 2MB. ``BufferedGzipFile`` is useful for loading large gzipped pickle objects as well as writing large encoded feature files for classifier training. iii cK sJtj||||||jd|j|_t|_d|_dS(u! Return a buffered gzip file object. :param filename: a filesystem path :type filename: str :param mode: a file mode which can be any of 'r', 'rb', 'a', 'ab', 'w', or 'wb' :type mode: str :param compresslevel: The compresslevel argument is an integer from 1 to 9 controlling the level of compression; 1 is fastest and produces the least compression, and 9 is slowest and produces the most compression. The default is 9. :type compresslevel: int :param fileobj: a BytesIO stream to read from instead of a file. :type fileobj: BytesIO :param size: number of bytes to buffer during calls to read() and write() :type size: int :rtype: BufferedGzipFile usizeiN(RRHtgettSIZEt_sizeR t_buffert_len(R=RRRRtkwargs((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRH\s cC st|_d|_dS(Ni(R RURV(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt _reset_bufferxs cC s8|dk r4|jj||jt|7_ndS(N(RRUtwriteRVtlen(R=tdata((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt _write_buffer~s cC s4tj||jj|j|j|dS(N(RRYRUtgetvalueRXR\(R=R[((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt _write_gzips cC s6|jtkr)|jd|jntj|S(N(RtGZ_WRITER^RRXRtclose(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR`s  cC s!|jjtj||dS(N(RUtflushR(R=tlib_mode((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRas cC sv|sb|j}t}x=trWtj||}|sG|jPn|j|qW|jStj||SdS(N(RTR R)RtreadRaRYR](R=tsizetcontentstblocks((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRcs     icC sL|s|j}n|jt||kr;|j|n |j|dS(u :param data: bytes to write to file or buffer :type data: bytes :param size: buffer at least size bytes before writing to file :type size: int N(RTRVRZR\R^(R=R[Rd((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRYs  iN(RARBRCtMBRSRRRHRXR\R^R`tFLUSHRaRcRY(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRQNs         tGzipFileSystemPathPointercB seZdZddZRS(u A subclass of ``FileSystemPathPointer`` that identifies a gzip-compressed file located at a given absolute path. ``GzipFileSystemPathPointer`` is appropriate for loading large gzip-compressed pickle objects efficiently. cC s.t|jd}|r*t||}n|S(Nurb(RQRGRI(R=RRJ((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR>sN(RARBRCRR>(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRistZipFilePathPointercB sneZdZeddZedZedZd dZ dZ dZ dZ d Z RS( u~ A path pointer that identifies a file contained within a zipfile, which can be accessed by reading that zipfile. ucC st|tr*ttjj|}nt|tdjd}|ry|j |Wqt k r|j drg|j D]}|j |r|^qrqtd|j|fqXn||_||_dS(u Create a new path pointer pointing at the specified entry in the given zipfile. :raise IOError: If the given zipfile does not exist, or if it does not contain the specified entry. u/uZipfile %r does not contain %rN(t isinstanceR tOpenOnDemandZipFileR$R%R5R'R)Rtgetinfot ExceptionR/tnamelistRRFRt_zipfilet_entry(R=tzipfiletentrytn((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRHs  . cC s|jS(u The zipfile.ZipFile object used to access the zip file containing the entry identified by this path pointer. (Rp(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRrscC s|jS(u_ The name of the file within zipfile that this path pointer points to. (Rq(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRsscC sm|jj|j}t|}|jjdrKt|jd|}n|dk rit||}n|S(Nu.gzR(RpRcRqR R/RQRRI(R=RR[RJ((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR>s  cC s|jj|jjS(N(RpRmRqR?(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR?scC s#d|j|f}t|j|S(Nu%s/%s(RqRjRp(R=R@Rs((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR*scC std|jj|jfS(NuZipFilePathPointer(%r, %r)(RMRpRRq(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRNs cC s(tjjtjj|jj|jS(N(R$R%R3R*RpRRq(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRO sN(RARBRCRRHRPRrRsRR>R?R*RNRO(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRjs!   c C st|t}|dkr$t}ntjd|}|j\}}x6|D].}|rtjj|r|j dryt ||SWq}t k rqOq}XqO| stjj |rO|dkr"tjj |t|}tjj|rz|j drt|St|Sqzq}tjj |t|}tjj|r}yt ||SWqzt k rvqOqzXq}qOqOW|dkr |jd}xltt|D]U}dj || ||dg||} yt| |SWqtk rqXqWntjd|fddddd d } | d d j d |D7} dd} d| | | f} t| dS(u Find the given resource by searching through the directories and zip files in paths, where a None or empty string specifies an absolute path. Returns a corresponding path name. If the given resource is not found, raise a ``LookupError``, whose message gives a pointer to the installation instructions for the NLTK downloader. Zip File Handling: - If ``resource_name`` contains a component with a ``.zip`` extension, then it is assumed to be a zipfile; and the remaining path components are used to look inside the zipfile. - If any element of ``nltk.data.path`` has a ``.zip`` extension, then it is assumed to be a zipfile. - If a given resource name that does not contain any zipfile component is not found initially, then ``find()`` will make a second attempt to find that resource, by replacing each component *p* in the path with *p.zip/p*. For example, this allows ``find()`` to map the resource name ``corpora/chat80/cities.pl`` to a zip file path pointer to ``corpora/chat80.zip/chat80/cities.pl``. - When using ``find()`` to locate a directory contained in a zipfile, the resource name must end with the forward slash character. Otherwise, ``find()`` will not locate the directory. :type resource_name: str or unicode :param resource_name: The name of the resource to search for. Resource names are posix-style relative path names, such as ``corpora/brown``. Directory names will be automatically converted to a platform-appropriate path separator. :rtype: str u(.*\.zip)/?(.*)$|u.zipu.gzu/ucResource %r not found. Please use the NLTK Downloader to obtain the resource: >>> nltk.download()tinitial_indentu tsubsequent_indenttwidthiBu Searched in:ucs s|]}d|VqdS(u - %rN((t.0td((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pys ysu*iFu %s %s %sN(R'R)RR%RtmatchtgroupsR$tisfileR/RjRFtisdirR*RRERiRDRtrangeRZtfindt LookupErrorttextwraptfill( R7tpathstmRrtzipentryR!tptpiecestit modified_nametmsgR0tresource_not_found((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRsR%   '      $   ! cC st|}|d krX|jdr@tjj|d}qXtjdd|}ntjj|rtjj |}t d|n|rt d||fnt |}t |d:}x0tr|jd }|j||sPqqWWd QX|jd S( u Copy the given resource to a local file. If no filename is specified, then use the URL's filename. If there is already a file named ``filename``, then raise a ``ValueError``. :type resource_url: str :param resource_url: A URL specifying where the resource should be loaded from. The default protocol is "nltk:", which searches for the file in the the NLTK data package. ufile:iu (^\w+:)?.*/uuFile %r already exists!uRetrieving %r, saving to %ruwbii@Ni(R,RRR$R%RRRRER5R#tprintt_openR>R)RcRYR`(RRtverbosetinfiletoutfilets((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pytretrieves$     u;A serialized python object, stored using the pickle module.upickleu9A serialized python object, stored using the json module.ujsonu9A serialized python object, stored using the yaml module.uyamluA context free grammar.ucfguA probabilistic CFG.upcfguA feature CFG.ufcfguZA list of first order logic expressions, parsed with nltk.sem.logic.Expression.fromstring.ufoluA list of first order logic expressions, parsed with nltk.sem.logic.LogicParser. Requires an additional logic_parser parameterulogicu>A semantic valuation, parsed by nltk.sem.Valuation.fromstring.uvalu)The raw (byte string) contents of a file.urawu-The raw (unicode string) contents of a file. utextutxtuautocC st|}t|}|dkr|jd}|d}|dkrV|d}ntj|}|d krtd|qn|tkrtd|fn|rtj||f} | d k r|rt d|fn| Sn|r t d |fnt |} |d kr2| j } ni|d krPt j | } nK|d krdd l} ddlm} | j | } d } t| dkrt| j} n| | krtdqn|dkrdd l}|j | } n| j }|d k r&|j|}n6y|jd}Wn tk r[|jd}nX|dkrq|} n*|dkrtjjj|d|} n|dkrtjjj|d|} n|dkrtjjj|d|d|d|} n|dkr4tjj|dtjjj d|} ng|dkratjj|d|d|} n:|dkrtjj!|d|} nt"d|f| j#|ry| t||f>u<>urawupickleujsonN(t json_tagsiuUnknown json tag.uyamluutf-8ulatin-1utextucfgRupcfgufcfgt logic_parsertfstruct_readerufolulogicuvalu@Internal NLTK error: Format %s isn't handled by nltk.data.load()(%R,R Rt AUTO_FORMATSRRRR#tFORMATSt_resource_cacheRRRctpickletloadtjsont nltk.jsontagsRRZtnexttkeystyamltdecodetUnicodeDecodeErrortnltktgrammartCFGt fromstringtPCFGtFeatureGrammartsemt read_logictlogict LogicParsertread_valuationtAssertionErrorR`t TypeError(RtformattcacheRRRRtresource_url_partstextt resource_valtopened_resourceRRttagRt binary_datat string_data((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRs2                                       u##cC s|t|}t|dddt}|j}xE|D]=}|j|rRq7ntjd|rjq7nt|q7WdS(u} Write out a grammar file, ignoring escaped and empty lines. :type resource_url: str :param resource_url: A URL specifying where the resource should be loaded from. The default protocol is "nltk:", which searches for the file in the the NLTK data package. :type escape: str :param escape: Prepended string that signals lines to be ignored RutextRu^$N(R,RR(t splitlinesRRRzR(RtescapeRtlinestl((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pytshow_cfgbs   cC stjdS(uF Remove all objects from the resource cache. :see: load() N(Rtclear(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt clear_cachexscC st|}t|\}}|dks<|jdkrVt|tdgjS|jdkr~t|dgjSt|SdS(uo Helper function that returns an open file object for a resource, given its resource URL. If the given resource URL uses the "nltk:" protocol, or uses no protocol, then use ``nltk.data.find`` to find its path, and open it with the given mode; if the resource URL uses the 'file' protocol, then open the file with the given mode; otherwise, delegate to ``urllib2.urlopen``. :type resource_url: str :param resource_url: A URL specifying where the resource should be loaded from. The default protocol is "nltk:", which searches for the file in the the NLTK data package. unltkuufileN(R,R"RtlowerRR%R>R (RR R!((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRs t LazyLoadercB s2eZedZdZdZdZRS(cC s ||_dS(N(RG(R=RG((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRHscC s+t|j}|j|_|j|_dS(N(RRGt__dict__t __class__(R=tresource((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt__loads cC s|jt||S(N(t_LazyLoader__loadtgetattr(R=tattr((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt __getattr__s cC s|jt|S(N(Rtrepr(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRNs (RARBRRHRRRN(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRs  RlcB sAeZdZedZdZdZdZdZRS(u A subclass of ``zipfile.ZipFile`` that closes its file pointer whenever it is not using it; and re-opens it when it needs to read data from the zipfile. This is useful for reducing the number of open file handles when many zip files are being accessed at once. ``OpenOnDemandZipFile`` must be constructed from a filename, not a file-like object (to allow re-opening). ``OpenOnDemandZipFile`` is read-only (i.e. ``write()`` and ``writestr()`` are disabled. cC sTt|tstdntjj|||j|ksFt|jdS(Nu+ReopenableZipFile filename must be a string( RkR RRrtZipFileRHRRR`(R=R((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRHs cC sM|jdkstt|jd|_tjj||}|j|S(Nurb( tfpRRR>RRrRRcR`(R=R+tvalue((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRcs  cO stddS(u<:raise NotImplementedError: OpenOnDemandZipfile is read-onlyu OpenOnDemandZipfile is read-onlyN(R<(R=targsRW((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRYscO stddS(u<:raise NotImplementedError: OpenOnDemandZipfile is read-onlyu OpenOnDemandZipfile is read-onlyN(R<(R=RRW((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pytwritestrscC sttd|jS(NuOpenOnDemandZipFile(%r)(RRMR(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRNs( RARBRCRRHRcRYRRN(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRls     RIcB seZdZeZeddZd!dZd!dZ d!edZ dZ dZ dZ d Zed Zed Zed Zd ZddZdZd!dZdZd!dZdZiejd!fgd6ejdfejdfgd6ejd!fgd6ejd!fgd6ejdfejdfgd6ejd!fgd6ejd!fgd6Z d Z!RS("u A stream reader that automatically encodes the source byte stream into unicode (like ``codecs.StreamReader``); but still supports the ``seek()`` and ``tell()`` operations correctly. This is in contrast to ``codecs.StreamReader``, which provide *broken* ``seek()`` and ``tell()`` methods. This class was motivated by ``StreamBackedCorpusView``, which makes extensive use of ``seek()`` and ``tell()``, and needs to be able to handle unicode-encoded files. Note: this class requires stateless decoders. To my knowledge, this shouldn't cause a problem with any of python's builtin unicode encodings. ustrictcC sq|jd||_||_||_tj||_d|_d|_ d|_ d|_ |j |_ dS(Nit(tseekRJRRtcodecst getdecoderRt bytebufferRt linebuffert_rewind_checkpointt_rewind_numcharst _check_bomt_bom(R=RJRR((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRHs       cC sG|j|}|jrCdj|j|}d|_d|_n|S(u6 Read up to ``size`` bytes, decode them using this reader's encoding, and return the resulting unicode string. :param size: The maximum number of bytes to read. If not specified, then read as many bytes as possible. :type size: int :rtype: unicode uN(t_readRR*RR(R=Rdtchars((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRc4s    c C s|jrIt|jdkrI|jjd}|jt|7_|S|pRd}d}|jr||jj7}d|_nxTtr|jjt|j}|j |}|r|j dr||j d7}n||7}|j t}t|dkrT|d}|d|_t|t|t||_||_ PnLt|dkr|d}|dj t d} || kr|}Pqn| s|dk r|}Pn|dkr|d9}qqW|S( uj Read a line of text, decode it using this reader's encoding, and return the resulting unicode string. :param size: The maximum number of bytes to read. If no newline is encountered before ``size`` bytes have been read, then the returned value may not be a complete line of text. :type size: int iiiHuu i@iN(RRZtpopRRR)RJttellRRR/RRR(( R=RdtlinetreadsizeRtstartpost new_charsRt line0withendtline0withoutend((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pytreadlineHsF             cC s|jj|S(u Read this file's contents, decode them using this reader's encoding, and return it as a list of unicode lines. :rtype: list(unicode) :param sizehint: Ignored. :param keepends: If false, then strip newlines. (RcR(R=tsizehinttkeepends((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt readliness cC s |j}|r|StdS(u8Return the next decoded line from the underlying stream.N(Rt StopIteration(R=R((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRs cC s |jS(N(R(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt__next__scC s|S(u Return self((R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt__iter__scC s|S(u Return self((R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt xreadlinesscC s |jjS(u(True if the underlying stream is closed.(RJtclosed(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRscC s |jjS(u"The name of the underlying stream.(RJR+(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR+scC s |jjS(u"The mode of the underlying stream.(RJR(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRscC s|jjdS(u. Close the underlying stream. N(RJR`(R=((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR`sicC s_|dkrtdn|jj||d|_d|_d|_|jj|_dS(u Move the stream to a new file position. If the reader is maintaining any buffers, then they will be cleared. :param offset: A byte count offset. :param whence: If 0, then the offset is from the start of the file (offset should be positive), if 1, then the offset is from the current position (offset may be positive or negative); and if 2, then the offset is from the end of the file (offset should typically be negative). iumRelative seek is not supported for SeekableUnicodeStreamReader -- consider using char_seek_forward() instead.RN( R#RJRRRRRRR(R=toffsettwhence((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRs    cC s?|dkrtdn|j|j|j|dS(uI Move the read pointer forward by ``offset`` characters. iu"Negative offsets are not supportedN(R#RRt_char_seek_forward(R=R((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pytchar_seek_forwards cC s)|dkr|}nd}xtr$|jj|t|}||7}|j|\}}t||kr|jjt| |ddSt||kr xCt||kr||t|7}|j|| \}}qW|jjt| |ddS||t|7}qWdS(u Move the file position forward by ``offset`` characters, ignoring all buffers. :param est_bytes: A hint, giving an estimate of the number of bytes that will be neded to move forward by ``offset`` chars. Defaults to ``offset``. RiN(RR)RJRcRZt _incr_decodeR(R=Rt est_bytestbytestnewbytesRt bytes_decoded((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRs"    cC sC|jdkr)|jjt|jS|jj}|t|j|j}td|jD}t||j |j |}|jj |j|j |j ||jj}|j r/|jj ||j |jjdd}dj|j}|j|s/|j|s/tn|jj ||S(u Return the current file position on the underlying byte stream. If this reader is maintaining any buffers, then the returned file position will be the position of the beginning of those buffers. cs s|]}t|VqdS(N(RZ(RxR((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pys si2iuN(RRRJRRZRRtsumtintRRRtDEBUGRRcR*RR(R=t orig_filepost bytes_readtbuf_sizeRtfilepostcheck1tcheck2((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR s$   'cC s|dkrdS|jrD|jjdkrD|jj|jn|dkrb|jj}n|jj|}|j|}|j|\}}|dk r| rt|dkrxH|s|jjd}|sPn||7}|j|\}}qWn|||_|S(u Read up to ``size`` bytes from the underlying stream, decode them using this reader's encoding, and return the resulting unicode string. ``linebuffer`` is not included in the result. iuiN(RRJRRcRRRRZ(R=Rdt new_bytesRRR((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR7s$   %   cC sxtry|j|dSWqtk r}|jt|kr^|j||j |jS|jdkrsq|j||jSqXqWdS(u Decode the given byte string into a unicode string, using this reader's encoding. If an exception is encountered that appears to be caused by a truncation error, then just decode the byte string without the bytes that cause the trunctaion error. Return a tuple ``(chars, num_consumed)``, where ``chars`` is the decoded unicode string, and ``num_consumed`` is the number of bytes that were consumed. ustrictN(R)RRtendRZtstartR(R=Rtexc((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyR]s uutf8uutf16-leuutf16-beuutf16uutf16leuutf16beuutf32-leuutf32-beuutf32uutf32leuutf32becC stjdd|jj}|jj|}|r|jjd}|jjdxB|D]7\}}|j |r_|r||_nt |Sq_WndS(Nu[ -]uii( RRRRt _BOM_TABLERRRJRcRRRZR(R=tenctbom_infoRtbomt new_encoding((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRs N("RARBRCR)RRRHRRcRRRRRRRPRR+RR`RRRRRRRtBOM_UTF8t BOM_UTF16_LEt BOM_UTF16_BEt BOM_UTF32_LEt BOM_UTF32_BERR(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyRIs@8  =      ( . &   upathu PathPointeruFileSystemPathPointeruBufferedGzipFileuGzipFileSystemPathPointerufinduretrieveuFORMATSu AUTO_FORMATSuloadushow_cfgu clear_cacheu LazyLoaderuOpenOnDemandZipFileuSeekableUnicodeStreamReader(KRCt __future__RRRR1RR$RRRrRtgzipRRtGZ_READRR_tzlibRRht ImportErrorRtcPickleRRt nltk.compatRR R R R R RR%tenvironRRRMRtpathsept_paths_from_envRyt expandusertappendR2RR*tprefixRRR"R,R)R'tobjectR;RDRQRiRjRRRRRR(RRRRRRRlRIt__all__(((s[/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/data.pyt s          ('#'"$ 4     83)1eT e(      !)