Files
old-nlp/venv/lib/python3.7/site-packages/nltk/__pycache__/downloader.cpython-37.pyc

659 lines
61 KiB
Plaintext
Raw Normal View History

2019-10-20 13:16:49 +02:00
B
D(<28>] k<00>@sdZddlmZmZmZddlZddlZddlZddlZddl Z ddl
Z
ddl Z ddl Z ddl Z ddlZddlmZddlmZyXdZddlmZmZmZmZmZmZmZmZmZddlmZdd l m!Z!dd
l"m#Z#Wne$k
r<EFBFBD>d Ze%ZYnXdd l&m'Z'm(Z(dd l)m*Z*ddl+m,Z,ddl-m.Z.m/Z/ddl0Z0ddl1m2Z2e2Gdd<12>de3<65><03>Z4e2Gdd<14>de3<65><03>Z5Gdd<16>de3<65>Z6Gdd<18>de6<65>Z7Gdd<1A>de6<65>Z8Gdd<1C>de6<65>Z9Gdd<1E>de6<65>Z:Gdd <20>d e6<65>Z;Gd!d"<22>d"e6<65>Z<Gd#d$<24>d$e6<65>Z=Gd%d&<26>d&e6<65>Z>Gd'd(<28>d(e6<65>Z?Gd)d*<2A>d*e6<65>Z@Gd+d,<2C>d,e6<65>ZAGd-d.<2E>d.e6<65>ZBGd/d0<64>d0e6<65>ZCGd1d2<64>d2e3<65>ZDGd3d4<64>d4e3<65>ZEGd5d6<64>d6e3<65>ZFd7d8<64>ZGd9d:<3A>ZHdqd;d<<3C>ZIdrd=d><3E>ZJd?d@<40>ZKdsdBdC<64>ZLdDdE<64>ZMdFdG<64>ZNdHdI<64>ZOdJdK<64>ZPeD<65>ZQeQjRZRdLdM<64>ZSdNdO<64>ZTdPdQ<64>ZUeVdRk<02>r<>ddSlWmXZXeX<65>ZYeYjZdTdUdVdWdXdY<64>eYjZdZd[d\d]d d^d_<64>eYjZd`dadbd]d dcd_<64>eYjZdddedfd]d dgd_<64>eYjZdhdidjej[<5B>\dk<64>dldm<64>eY<65>]<5D>\Z^Z_eDe^j`dn<64>Zae_<65>r<>xZe_D]6ZbeajRebe^jce^jde^jee^jfdo<64>Zgegd k<02>r<>e^jf<6A>r<>P<00>q<>WneajRe^jce^jde^jee^jfdp<64>dS)taH
The NLTK corpus and module downloader. This module defines several
interfaces which can be used to download corpora, models, and other
data packages that can be used with NLTK.
Downloading Packages
====================
If called with no arguments, ``download()`` will display an interactive
interface which can be used to download and install new packages.
If Tkinter is available, then a graphical interface will be shown,
otherwise a simple text interface will be provided.
Individual packages can be downloaded by calling the ``download()``
function with a single argument, giving the package identifier for the
package that should be downloaded:
>>> download('treebank') # doctest: +SKIP
[nltk_data] Downloading package 'treebank'...
[nltk_data] Unzipping corpora/treebank.zip.
NLTK also provides a number of "package collections", consisting of
a group of related packages. To download all packages in a
colleciton, simply call ``download()`` with the collection's
identifier:
>>> download('all-corpora') # doctest: +SKIP
[nltk_data] Downloading package 'abc'...
[nltk_data] Unzipping corpora/abc.zip.
[nltk_data] Downloading package 'alpino'...
[nltk_data] Unzipping corpora/alpino.zip.
...
[nltk_data] Downloading package 'words'...
[nltk_data] Unzipping corpora/words.zip.
Download Directory
==================
By default, packages are installed in either a system-wide directory
(if Python has sufficient access to write to it); or in the current
user's home directory. However, the ``download_dir`` argument may be
used to specify a different installation target, if desired.
See ``Downloader.default_download_dir()`` for more a detailed
description of how the default download directory is chosen.
NLTK Download Server
====================
Before downloading any packages, the corpus and module downloader
contacts the NLTK download server, to retrieve an index file
describing the available packages. By default, this index file is
loaded from ``https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml``.
If necessary, it is possible to create a new ``Downloader`` object,
specifying a different URL for the package index file.
Usage::
python nltk/downloader.py [-d DATADIR] [-q] [-f] [-k] PACKAGE_IDS
or::
python -m nltk.downloader [-d DATADIR] [-q] [-f] [-k] PACKAGE_IDS
<EFBFBD>)<03>print_function<6F>division<6F>unicode_literalsN)<01>md5)<01> ElementTreeT) <09>Tk<54>Frame<6D>Label<65>Entry<72>Button<6F>Canvas<61>Menu<6E>IntVar<61>TclError)<01> showerror)<01>Table)<01>ShowTextF)<02> string_types<65> text_type)<01>input)<01>urlopen)<02> HTTPError<6F>URLError)<01>python_2_unicode_compatiblec @s6eZdZdZddd<07>Zedd <09><00>Zd
d <0B>Zd d <0A>ZdS)<0F>Packagea4
A directory entry for a downloadable package. These entries are
extracted from the XML index file that is downloaded by
``Downloader``. Each package consists of a single file; but if
that file is a zip file, then it can be automatically decompressed
when the package is installed.
N<><00>UnknownTcKs<>||_|p ||_||_||_t|<05>|_t|<06>|_||_||_| |_ |
|_
| |_ | |_ t j<0E>|<02>d<01>d<00>d}t j<0E>|||<00>|_tt| <0A><01>|_|j<15>|<0E>dS)N<>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<17>id<69>name<6D>subdir<69>url<72>int<6E>size<7A> unzipped_size<7A>checksum<75> svn_revision<6F> copyright<68>contact<63>license<73>author<6F>os<6F>path<74>splitext<78>split<69>join<69>filename<6D>bool<6F>unzip<69>__dict__<5F>update)<10>selfr r#r!r"r%r&r'r(r)r*r+r,r4<00>kw<6B>ext<78>r:<00>1/tmp/pip-install-4m6m_5d_/nltk/nltk/downloader.py<70>__init__<5F>s 


zPackage.__init__cCsDt|t<01>rt<02>|<00>}x"|jD]}t|j|<00>|j|<qWtf|j<04>S)N)<07>
isinstancerr<00>parse<73>attribrr)<02>xml<6D>keyr:r:r;<00>fromxmls


 zPackage.fromxmlcCs |j|jkS)N)r )r7<00>otherr:r:r;<00>__lt__"szPackage.__lt__cCs
d|jS)Nz <Package %s>)r )r7r:r:r;<00>__repr__%szPackage.__repr__) NrNNNNrrrrT) <09>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r<<00> staticmethodrBrDrEr:r:r:r;r<00>s
7 rc@s6eZdZdZd dd<04>Zedd<06><00>Zdd<08>Zd d
<EFBFBD>ZdS) <0C>
Collectionz<EFBFBD>
A directory entry for a collection of downloadable packages.
These entries are extracted from the XML index file that is
downloaded by ``Downloader``.
NcKs,||_|p ||_||_d|_|j<04>|<04>dS)N)r r!<00>children<65>packagesr5r6)r7r rLr!r8r:r:r;r<1s

zCollection.__init__cCs`t|t<01>rt<02>|<00>}x"|jD]}t|j|<00>|j|<qWdd<02>|<00>d<03>D<00>}tfd|i|j<04><02>S)NcSsg|]}|<01>d<00><01>qS)<01>ref)<01>get)<02>.0<EFBFBD>childr:r:r;<00>
<listcomp>Isz&Collection.fromxml.<locals>.<listcomp><3E>itemrL)r=rrr>r?r<00>findallrK)r@rArLr:r:r;rBCs 

 zCollection.fromxmlcCs |j|jkS)N)r )r7rCr:r:r;rDLszCollection.__lt__cCs
d|jS)Nz<Collection %s>)r )r7r:r:r;rEOszCollection.__repr__)N) rFrGrHrIr<rJrBrDrEr:r:r:r;rK)s

 rKc@seZdZdZdS)<03>DownloaderMessagezVA status message object, used by ``incr_download`` to
communicate its progress.N)rFrGrHrIr:r:r:r;rUXsrUc@seZdZdZdd<03>ZdS)<05>StartCollectionMessagez<Data server has started working on a collection of packages.cCs
||_dS)N)<01>
collection)r7rWr:r:r;r<`szStartCollectionMessage.__init__N)rFrGrHrIr<r:r:r:r;rV]srVc@seZdZdZdd<03>ZdS)<05>FinishCollectionMessagez=Data server has finished working on a collection of packages.cCs
||_dS)N)rW)r7rWr:r:r;r<gsz FinishCollectionMessage.__init__N)rFrGrHrIr<r:r:r:r;rXdsrXc@seZdZdZdd<03>ZdS)<05>StartPackageMessagez-Data server has started working on a package.cCs
||_dS)N)<01>package)r7rZr:r:r;r<nszStartPackageMessage.__init__N)rFrGrHrIr<r:r:r:r;rYksrYc@seZdZdZdd<03>ZdS)<05>FinishPackageMessagez.Data server has finished working on a package.cCs
||_dS)N)rZ)r7rZr:r:r;r<uszFinishPackageMessage.__init__N)rFrGrHrIr<r:r:r:r;r[rsr[c@seZdZdZdd<03>ZdS)<05>StartDownloadMessagez.Data server has started downloading a package.cCs
||_dS)N)rZ)r7rZr:r:r;r<|szStartDownloadMessage.__init__N)rFrGrHrIr<r:r:r:r;r\ysr\c@seZdZdZdd<03>ZdS)<05>FinishDownloadMessagez/Data server has finished downloading a package.cCs
||_dS)N)rZ)r7rZr:r:r;r<<00>szFinishDownloadMessage.__init__N)rFrGrHrIr<r:r:r:r;r]<00>sr]c@seZdZdZdd<03>ZdS)<05>StartUnzipMessagez,Data server has started unzipping a package.cCs
||_dS)N)rZ)r7rZr:r:r;r<<00>szStartUnzipMessage.__init__N)rFrGrHrIr<r:r:r:r;r^<00>sr^c@seZdZdZdd<03>ZdS)<05>FinishUnzipMessagez-Data server has finished unzipping a package.cCs
||_dS)N)rZ)r7rZr:r:r;r<<00>szFinishUnzipMessage.__init__N)rFrGrHrIr<r:r:r:r;r_<00>sr_c@seZdZdZdd<03>ZdS)<05>UpToDateMessagez/The package download file is already up-to-datecCs
||_dS)N)rZ)r7rZr:r:r;r<<00>szUpToDateMessage.__init__N)rFrGrHrIr<r:r:r:r;r`<00>sr`c@seZdZdZdd<03>ZdS)<05> StaleMessagez3The package download file is out-of-date or corruptcCs
||_dS)N)rZ)r7rZr:r:r;r<<00>szStaleMessage.__init__N)rFrGrHrIr<r:r:r:r;ra<00>srac@seZdZdZdd<03>ZdS)<05> ErrorMessagez Data server encountered an errorcCs&||_t|t<02>rt|<02>|_n||_dS)N)rZr=<00> Exception<6F>str<74>message)r7rZrer:r:r;r<<00>s
 zErrorMessage.__init__N)rFrGrHrIr<r:r:r:r;rb<00>srbc@seZdZdZdd<03>ZdS)<05>ProgressMessagez4Indicates how much progress the data server has madecCs
||_dS)N)<01>progress)r7rgr:r:r;r<<00>szProgressMessage.__init__N)rFrGrHrIr<r:r:r:r;rf<00>srfc@seZdZdZdd<03>ZdS)<05>SelectDownloadDirMessagez:Indicates what download directory the data server is usingcCs
||_dS)N)<01> download_dir)r7rir:r:r;r<<00>sz!SelectDownloadDirMessage.__init__N)rFrGrHrIr<r:r:r:r;rh<00>srhc@sBeZdZdZdZdZdZdZdZdZ dDd d
<EFBFBD>Z
dEd d<0E>Z dd<10>Z dd<12>Z dd<14>Zdd<16>Zdd<18>ZdFdd<1A>Zdd<1C>Zdd<1E>Zdd <20>Zddd d d!d d ejfd"d#<23>ZdGd$d%<25>ZdHd&d'<27>ZdId(d)<29>ZdJd*d+<2B>Zd,d-<2D>ZdKd.d/<2F>ZdLd0d1<64>Zd2d3<64>Zd4d5<64>Z d6d7<64>Z!d8d9<64>Z"d:d;<3B>Z#e$e"e#<23>Z%d<d=<3D>Z&d>d?<3F>Z'd@dA<64>Z(e$e'e(<28>Z)dBdC<64>Z*dS)M<>
Downloaderzy
A class used to access the NLTK data server, which can be used to
download corpora and other data packages.
izChttps://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml<6D> installedz not installedz out of date<74>partialNcCsN|p|j|_i|_i|_||_d|_d|_i|_d|_|jdkrJ|<00> <09>|_dS)N)
<EFBFBD> DEFAULT_URL<52>_url<72> _collections<6E> _packages<65> _download_dir<69>_index<65>_index_timestamp<6D> _status_cache<68>_errors<72>default_download_dir)r7<00>server_index_urlrir:r:r;r<<00>s 
zDownloader.__init__TFc
Cs<>d}|dkr|j}td|<00>|rdtddt|j<03><00>td|j<00>tddt|j<03><00>|d7}d}} g}
|r~|
<EFBFBD>d<08>|r<>|
<EFBFBD>d <09><00>x"|
D<00>]} td
| <0B><05><00>|d 7}x<>tt|| <0B><02>td <0C>D]<5D>} |<00> | |<01>} | |j
kr<>|r<>q<EFBFBD>| |j kr<>d }| |j k<02>rd } |j
d|j d|j d|j di| }tjd| j<10>p8| jddd<15>dd<00>}td|| j<11>dd<19>|f<00>|t|<0F>d<1A><01>7}|r<>|dkr<>td<1B>}|<10><15>dk<06>r<>dSd}q<>Wt<01>q<>Wd}|<08>r<>|d7}| <09>r<>|d7}ttj|d dd!d"<22><03>dS)#Nrz!Using default data directory (%s)<29>=<3D>z Data server index for <%s><3E>FrM<00> collectionsz%s:r)rAT<>*<2A>-<2D>P<> z---------------------------<2D>Kz )<01>subsequent_indent<6E>z [%s] %s %s<><00>.<2E>
zHit Enter to continue: )<02>x<>qz([*] marks installed packagesz+; [-] marks out-of-date or corrupt packagesz+; [P] marks partially installed collections<6E>)<29>L)r<><00>width)rq<00>print<6E>lenrn<00>append<6E>
capitalize<EFBFBD>sorted<65>getattrrd<00>status<75> INSTALLED<45>STALE<4C>PARTIAL<41> NOT_INSTALLED<45>textwrap<61>fillr!r <00>ljustr0r<00>lower)r7riZ show_packagesZshow_collections<6E>header<65> more_prompt<70>skip_installed<65>lines<65>stalerl<00>
categories<EFBFBD>category<72>infor<6F><00>prefixr!<00>
user_input<EFBFBD>msgr:r:r;<00>lists`  

 
 
 
zDownloader.listcCs|<00><00>|j<01><02>S)N)<03> _update_indexrp<00>values)r7r:r:r;rMKszDownloader.packagescCs|<00><00>dd<02>|j<01><02>D<00>S)NcSsg|]\}}|jdkr|<02>qS)<01>corpora)r")rPr <00>pkgr:r:r;rRQsz&Downloader.corpora.<locals>.<listcomp>)r<>rp<00>items)r7r:r:r;r<>OszDownloader.corporacCs|<00><00>dd<02>|j<01><02>D<00>S)NcSsg|]\}}|jdkr|<02>qS)r<>)r")rPr r<>r:r:r;rRUsz%Downloader.models.<locals>.<listcomp>)r<>rpr<>)r7r:r:r;<00>modelsSszDownloader.modelscCs|<00><00>|j<01><02>S)N)r<>ror<>)r7r:r:r;r{WszDownloader.collectionscCst|t<01>r|<00>|<01>S|SdS)N)r=rr<>)r7<00>
info_or_idr:r:r;<00> _info_or_id_s

zDownloader._info_or_idc
cs<>|dkr|j}t|<02>Vt|ttf<02>rHx|<00>|||<03>D]
}|Vq6WdSy|<00>|<01>}Wn:ttfk
r<EFBFBD>}zt dd||f<00>VdSd}~XYnXt|t
<EFBFBD>r<>t |<05>Vx|<00> |j ||<03>D]
}|Vq<>Wt|<05>Vnx|<00>|||<03>D]
}|Vq<>WdS)NzError loading %s: %s)rqrhr=r<><00>tuple<6C>_download_listr<74><00>IOError<6F>
ValueErrorrbrKrV<00> incr_downloadrLrX<00>_download_package)r7r<>ri<00>forcer<65>r<><00>er:r:r;r<>ns&




 zDownloader.incr_downloadcCst|t<01>rdSt|j<03>SdS)Nr)r=rr<>rM)r7rSr:r:r;<00> _num_packages<65>s
zDownloader._num_packagesc #sxbtt|<01><01>D]R}y<16><00>||<00>||<Wqttfk
r^}zt|||<05>VdSd}~XYqXqWt<06>fdd<02>|D<00><01>}d}x<>t|<01>D]t\}}t|t <09>r<>d|} nt|j
<EFBFBD>|} x<<3C><00> |||<03>D]*}
t|
t <0C>r<>t ||
j | <00>Vq<>|
Vq<>W|d| 7}q<>WdS)Nc3s|]}<01><00>|<01>VqdS)N)r<>)rPrS)r7r:r;<00> <genexpr><3E>sz,Downloader._download_list.<locals>.<genexpr>rg<00>?<3F>d)<0E>ranger<65>r<>r<>r<>rb<00>sum<75> enumerater=rrMr<>rfrg) r7r<>rir<><00>ir<69>Z num_packagesrgrS<00>deltar<61>r:)r7r;r<><00>s"



zDownloader._download_listc
csdt|<01>Vtd<01>V|<00>||<02>}|sP||jkrPt|<01>Vtd<02>Vt|<01>VdS|j<06>|jd<00>t j
<EFBFBD> ||j <0C>}t j
<EFBFBD> |<05>r<>||jkr<>t|<01>Vt <09>|<05>t j
<EFBFBD> |<02>s<>t <09>|<02>t j
<EFBFBD> t j
<EFBFBD> ||j<12><02>s<>t <09>t j
<EFBFBD> ||j<12><02>t|<01>Vtd<03>Vy<>t|j<15>}t|d<04><02>p}td|jd<00>}xXt<19><1A>D]L} |<06>d<06>}
|<07>|
<EFBFBD>|
<EFBFBD>sDP| ddk<02>r$ttddd | |<00><02>V<00>q$WWdQRX|<06><1E>Wn>tk
<EFBFBD>r<>} zt |d
|j|j| f<00>VdSd} ~ XYnXt!|<01>Vtd<08>V|j <0C>"d <0B><01>rVt j
<EFBFBD> ||j<12>} |j#<23>st j
<EFBFBD> t j
<EFBFBD> | |j<08><02><01>rVt$|<01>Vx$t%|| d d <0A>D]} || _&| V<00>q6Wt'|<01>Vt|<01>VdS)Nrr<><00><00>wbri@<00><00>Pr<>z$Error downloading %r from <%s>:
%sz.zipF)<01>verbose)(rYrfr<>r<>r`r[rt<00>popr r-r.r1r2<00>existsr<73>ra<00>remove<76>mkdirr"r\rr#<00>open<65>maxr%<00> itertools<6C>count<6E>read<61>write<74>min<69>closer<65>rbr]<00>endswithr4r^<00> _unzip_iterrZr_)r7r<>rir<>r<><00>filepath<74>infile<6C>outfileZ
num_blocks<EFBFBD>block<63>sr<73><00>zipdirr<72>r:r:r;r<><00>s`

 


 


 



 

, 

"
 
zDownloader._download_package<67> [nltk_data] c
s<>tjt|d<01><02>|dkr0|dk r$||_|<00><04>dSd<13><00>fdd<05> } <09>x<>|<00>|||<04>D<00>]n}
t|
t<07>r<>| |
j<08>|rzt |
j<08><01>|r<>dSd|_
|d<07>t <0B><00> <0C>} | dkr<>|<00> |
jj|||<04>||<07>s<>dSn | d kr<>dS|sRt|
t<10><02>r| d
|
jj<00><00>d 7<00><00><01><00>qRt|
t<12><02>rP<72><01><00><00>dd <0C><00>|j
<EFBFBD>r>| d |
jj<00>n| d|
jj<00>qRt|
t<13><02>rr| d|
jj|f<00>qRt|
t<14><02>r<>| d|
jjd<11>qRt|
t<15><02>r<>| d|
jjd<11>qRt|
t<17>rR|
j}qRWdS)N)<01>fileTrcs$<00>tj|<00>|<00>|dd<02><03>dS)Nz )<02>initial_indentr<74>)r<>r<>)r<>Zprefix2)r<><00>print_tor:r;<00>show
s
z!Downloader.download.<locals>.showFz(Error installing package. Retry? [n/y/e])<02>y<>Y)r<><00>EzDownloading collection %rz | <20><><EFBFBD><EFBFBD><EFBFBD>z$Downloaded collection %r with errorszDone downloading collection %szDownloading package %s to %s...z!Package %s is already up-to-date!z z Unzipping %s.)r)<19> functoolsrlr<>rq<00>_interactive_downloadr<64>r=rbrer<>rur<00>strip<69>downloadrZr rVrWrXrYr`r^r2rhri) r7r<>ri<00>quietr<74>r<><00> halt_on_errorZraise_on_errorZprint_error_tor<6F>r<><00>choicer:)r<>r<>r;r<><00>sl  



 
     

zDownloader.downloadcCs|<00>||<02>|jkS)N)r<>r<>)r7r<>rir:r:r;<00>is_staleRszDownloader.is_stalecCs|<00>||<02>|jkS)N)r<>r<>)r7r<>rir:r:r;<00> is_installedUszDownloader.is_installedcCs&|dkr|j<00><01>n|j<00>|d<00>dS)N)rt<00>clearr<72>)r7r r:r:r;<00>clear_status_cacheXs zDownloader.clear_status_cachecs<>|dkr<0E>j}<02><00>|<01>}t|t<03>r<><72>fdd<03>|jD<00>}<04>j|krF<72>jS<00>j|krV<72>jS<00>j|krp<72>j|krp<72>jS<00>j|kr<><72>jS<00>jSnRt j
<EFBFBD> ||j <0C>}|<02>jkr<><72><00> ||<05>S|j<0E>jk<00> ||<05><02>j|j<<00>j|jSdS)z<>
Return a constant describing the status of the given package
or collection. Status can be one of ``INSTALLED``,
``NOT_INSTALLED``, ``STALE``, or ``PARTIAL``.
Ncsg|]}<01><00>|j<01><01>qSr:)r<>r )rPr<>)r7r:r;rRjsz%Downloader.status.<locals>.<listcomp>)rqr<>r=rKrMr<>r<>r<>r<>r-r.r1r2<00> _pkg_statusr rt)r7r<>rir<>Z
pkg_statusr<EFBFBD>r:)r7r;r<>^s(





  zDownloader.statuscCs<>tj<01>|<02>s|jSyt<00>|<02>}Wntk
r6|jSX|jt|j<08>krN|j St
|<02>|j krb|j S|<02> d<01>r<>|dd<02>}tj<01>|<04>s<>|j Stj<01>|<04>s<>|j Stdd<04>t<00>|<04>D<00><01>}||jkr<>|j S|j S)Nz.zipr<70>css4|],\}}}|D]}t<00>tj<02>||<04><02>jVqqdS)N)r-<00>statr.r1<00>st_size)rP<00>d<>_<>files<65>fr:r:r;r<><00>sz)Downloader._pkg_status.<locals>.<genexpr>)r-r.r<>r<>r<><00>OSErrorr<72>r$r%r<><00> md5_hexdigestr'r<>r<><00>isdirr<72><00>walkr&)r7r<>r<>ZfilestatZunzipdirr&r:r:r;r<><00>s, 
   
zDownloader._pkg_statuscCs>|<00><00>x0|<00><01>D]$}|<00>|<03>|jkr|j|||d<01>qWdS)zA
Re-download any packages whose status is STALE.
)r<>r<>N)r<>rMr<>r<>r<>)r7r<>r<>r<>r:r:r;r6<00>szDownloader.updatec Cs<>|jdks*|dk s*t<01><01>|j|jks*dS|p2|j|_tj<06>t<08> t
|j<04><01><01> <0B><00>|_t<01><01>|_dd<03>|j<00> d<04>D<00>}t dd<06>|D<00><01>|_dd<03>|j<00> d<08>D<00>}t d d<06>|D<00><01>|_xz|j<0F><10>D]l}xft|j<12>D]X\}}||jkr<>|j||j|<q<>||jk<06>r|j||j|<q<>td
<EFBFBD>|<06><01>|j|=q<>Wq<>Wxj|j<0F><10>D]\}i}|g}x@|D]8}t|t<16><02>rl|<07>|j<12>nt|t<18><02>rN|||j<n<00>qNW|<02><10>|_<1A>q:W|j<1B><1C>dS) z<>A helper function that ensures that self._index is
up-to-date. If the index is older than self.INDEX_TIMEOUT,
then download it again.NcSsg|]}t<00>|<01><01>qSr:)rrB)rP<00>pr:r:r;rR<00>sz,Downloader._update_index.<locals>.<listcomp>zpackages/packagecss|]}|j|fVqdS)N)r )rPr<>r:r:r;r<><00>sz+Downloader._update_index.<locals>.<genexpr>cSsg|]}t<00>|<01><01>qSr:)rKrB)rP<00>cr:r:r;rR<00>szcollections/collectioncss|]}|j|fVqdS)N)r )rPr<>r:r:r;r<><00>sz.removing collection member with no package: {})rr<00>timers<00> INDEX_TIMEOUTrn<00>nltk<74> internalsZElementWrapperrr>r<00>getrootrT<00>dictrpror<>r<>rLr<><00>formatr=rK<00>extendrr rMrtr<>) r7r#rMr{rWr<>Zchild_id<69>queuerQr:r:r;r<><00>sB
 

 
   zDownloader._update_indexcCs|<00><00>|jS)z<>
Return the XML index describing the packages available from
the data server. If necessary, this index will be downloaded
from the data server.
)r<>rr)r7r:r:r;<00>index<65>szDownloader.indexcCs@|<00><00>||jkr|j|S||jkr0|j|Std|<00><01>dS)zNReturn the ``Package`` or ``Collection`` record for the
given item.zPackage %r not found in indexN)r<>rpror<>)r7r r:r:r;r<><00>s 



zDownloader.infocCsh|<00><00>x&|j<01>d<01>D]}|<02>d<02>|kr|SqWx&|j<01>d<03>D]}|<03>d<02>|kr>|Sq>Wtd|<00><01>dS)z-Return the XML info record for the given itemzpackages/packager zcollections/collectionzPackage %r not found in indexN)r<>rrrTrOr<>)r7r rZrWr:r:r;<00>xmlinfoszDownloader.xmlinfocCs|jS)z)The URL for the data server's index file.)rn)r7r:r:r;<00>_get_urlszDownloader._get_urlcCs.|j}y|<00>|<01>Wn||_<00>YnXdS)z<>
Set a new URL for the data server. If we're unable to contact
the given url, then the original url is kept.
N)rnr<>)r7r#<00> original_urlr:r:r;<00>_set_urls zDownloader._set_urlcCs<>dtjkrdSx,tjjD] }tj<04>|<01>rtj<06>|<01>r|SqWtj dkr\dtjkr\tjd}ntj<04>
d<05>}|dkrxt d<06><01>tj<04> |d<07>S)a<>
Return the directory to which packages will be downloaded by
default. This value can be overridden using the constructor,
or on a case-by-case basis using the ``download_dir`` argument when
calling ``download()``.
On Windows, the default download directory is
``PYTHONHOME/lib/nltk``, where *PYTHONHOME* is the
directory containing Python, e.g. ``C:\Python25``.
On all other platforms, the default directory is the first of
the following which exists or which can be created with write
permission: ``/usr/share/nltk_data``, ``/usr/local/share/nltk_data``,
``/usr/lib/nltk_data``, ``/usr/local/lib/nltk_data``, ``~/nltk_data``.
<20>APPENGINE_RUNTIMEN<45>win32<33>APPDATAz~/z+Could not find a default download directory<72> nltk_data) r-<00>environr<6E><00>datar.r<>r<><00> is_writable<6C>sys<79>platform<72>
expanduserr<EFBFBD>r1)r7Znltkdir<69>homedirr:r:r;rv#s
  zDownloader.default_download_dircCs|jS)a
The default directory to which packages will be downloaded.
This defaults to the value returned by ``default_download_dir()``.
To override this default on a case-by-case basis, use the
``download_dir`` argument when calling ``download()``.
)rq)r7r:r:r;<00>_get_download_dirJszDownloader._get_download_dircCs||_|j<01><02>dS)N)rqrtr<>)r7rir:r:r;<00>_set_download_dirSszDownloader._set_download_dircCsHtr8yt|<00><01><02>WqDtk
r4t|<00><01><05>YqDXn t|<00><01><05>dS)N)<06>TKINTER<45> DownloaderGUI<55>mainloopr<00>DownloaderShell<6C>run)r7r:r:r;r<>^s z Downloader._interactive_download)NN)NTTTFF)NF)N)N)N)N)Fr<46>)N)+rFrGrHrIr<>rmr<>r<>r<>r<>r<r<>rMr<>r<>r{r<>r<>r<>r<>r<>r <00>stderrr<72>r<>r<>r<>r<>r<>r6r<>rr<>rrr<00>propertyr#rvrrrir<>r:r:r:r;rj<00>sb 
'
5
GX



"$
> 

' 
rjc@sLeZdZdd<02>Zdd<04>Zdd<06>Zdd<08>Zd d
<EFBFBD>Zd d <0C>Zd d<0E>Z dd<10>Z
dS)rcCs
||_dS)N)<01>_ds)r7<00>
dataserverr:r:r;r<kszDownloaderShell.__init__cGsLtd<01>dtdd<04>|D<00><01>t|<01>dd}td|<02>|<01><00>td<01>dS)NzK---------------------------------------------------------------------------<2D>Dcss|]}t|<01>VqdS)N)r<>)rP<00>or:r:r;r<>psz;DownloaderShell._simple_interactive_menu.<locals>.<genexpr>rrz )r<>r<>r<>r1)r7<00>optionsZspcr:r:r;<00>_simple_interactive_menuns&z(DownloaderShell._simple_interactive_menuc
CsTtd<01><00>xD|<00>dddddd<07>td<08><01><03>}|s8t<00>q |<01><04><00><05>d }|<01><05>d
d<00>}y<>|d kr<>t<00>|jj|jjd d d<0E>nb|dkr<>|<00> <09>nP|dkr<>|<00>
<EFBFBD>n>|dkr<>dS|dkr<>|<00> |<03>n|dkr<>|<00> <0C>n td|<00>Wn`t k
<EFBFBD>r}ztd|<00>Wdd}~XYn2tk
<EFBFBD>rD}ztd|j<00>Wdd}~XYnXt<00>q WdS)NzNLTK Downloaderz d) Downloadzl) Listz
u) Updatez c) Configzh) Helpzq) Quitz Downloader> rr<00>lFT)r<>r<><00>hr<68>)r<>r<>r<><00>uzCommand %r unrecognizedzError reading from server: %szError connecting to server: %s)r<>rrr<>r<>r0rr<>ri<00>_simple_interactive_help<6C>_simple_interactive_config<69>_simple_interactive_download<61>_simple_interactive_updaterr<00>reason)r7r<><00>command<6E>argsr<73>r:r:r;rwsF 

 
 zDownloaderShell.runc Cs|rXxP|D]H}y|jj|dd<02>Wq
ttfk
rP}z t|<03>Wdd}~XYq
Xq
Wn<>x<EFBFBD>t<04>td<03>td<04>}|<04><06>dkr<>|jj|jjdddd<08>qZqZ|<04><06>d kr<>dS|rZxV|<04> <09>D]J}y|jj|dd<02>Wq<>ttfk
<EFBFBD>r<>}z t|<03>Wdd}~XYq<>Xq<>WPqZWdS)
Nz )r<>z*Download which package (l=list; x=cancel)?z Identifier> r FT)r<>r<>r<>)r<>r<>r)
rr<>r<>r<>r<>rr<>r<>rir0)r7r)<00>argr<67>r<>r r:r:r;r%<00>s4
   z,DownloaderShell._simple_interactive_downloadc
CsP<00>xHg}d}}xDtt|jd<02><02>td<03>D]*}|j<02>|<04>|jjkr(|<01>|j|jf<02>q(Wt <09>|<01>r<t d<04>xD|D]<\}}t
j d|ddd<08>d d<00>}t d
|<05> d d <0C>|f<00>qpWt <09>t d <0A>}|<08><0E>dk<02>r(xV|D]N\}}y|jj|dd<10>Wq<>ttfk
<EFBFBD>r} z t | <09>Wdd} ~ XYq<>Xq<>WPn|<08><0E>dk<06>rHdSqt d<12>dSqWdS)NFrM)rAz/Will update following packages (o=ok; x=cancel)z---------------------------r<>z )r<>r<>z [ ] %s %sr<73>r<>z Identifier> rz )r<>)r<>r<>rzNothing to update.)r<>r<>rrdr<>r<>r<>r r!r<>r<>r<>r<>rr<>r<>r<>r<>)
r7Zstale_packagesr<73>rlr<><00>pidZpnamer!r<>r<>r:r:r;r&<00>s6
z*DownloaderShell._simple_interactive_updatecCs*t<00>td<01>td<02>td<03>td<04>dS)Nz Commands:zH d) Download a package or collection u) Update out of date packagesz1 l) List packages & collections h) Helpz1 c) View & Modify Configuration q) Quit)r<>)r7r:r:r;r#<00>s z(DownloaderShell._simple_interactive_helpcCslt<00>td<01>td|jj<00>tdt|j<01><04><00><00>tdt|j<01><05><00><00>t<00>td<05>td|jj<00>dS)Nz Data Server:z - URL: <%s>z$ - %d Package Collections Availablez$ - %d Individual Packages AvailablezLocal Machine:z - Data directory: %s)r<>rr#r<>r{rMri)r7r:r:r;<00> _show_config<69>szDownloaderShell._show_configc
Cs|<00><00><00>xt<01>|<00>dddd<04>td<05><01><04><00><05>}|dkrD|<00><00>q |dkr<>td<08><01><04>}|d krjtd
<EFBFBD>n"tj<07>|<02>r<>||j _
n td |<00>q |d k<02>r td <0A><01><04>}|d kr<>td
<EFBFBD>nT|<03> d<0E>s<>d|}y ||j _ Wn4t k
<EFBFBD>r}ztd||f<00>Wdd}~XYnXq |dkr Pq WdS)Nzs) Show Configzu) Set Server URLzd) Set Data Dirz m) Main MenuzConfig> r<>r<>z New Directory> )rr<>r<><00>X<>Qz Cancelled!z)Directory %r not found! Create it first.r"z New URL> )zhttp://zhttps://zhttp://zError reading <%r>:
%s<>m)r,r<>rrr<>r<>r-r.r<>rri<00>
startswithr#rc)r7r<>Z
new_dl_dir<EFBFBD>new_urlr<6C>r:r:r;r$<00>s6 
 
 

 

 $z*DownloaderShell._simple_interactive_configN) rFrGrHr<rrr%r&r#r,r$r:r:r:r;rjs )  
rc @s<eZdZdZdddddddd d
d d d g Zddddd<10>Zddddddd<16>ZdZdddddgZxeD]Z e eks`t
<EFBFBD>q`WxeD]Z e ekszt
<EFBFBD>qzWxeD]Z e eks<>t
<EFBFBD>q<>WdZ e j de jde jde jdiZdZdZdZdZd Zdrd"d#<23>Zd$d%<25>Zd&d'<27>Zd(d)<29>Zd*d+<2B>Zd,d-<2D>Zd.d/<2F>Zdsd1d2<64>Zd3d4<64>Zd5d6<64>Z d7d8<64>Z!d9d:<3A>Z"d;d<<3C>Z#d=d><3E>Z$d?d@<40>Z%dAZ&d0Z'dBdC<64>Z(dDdE<64>Z)dFdG<64>Z*dZ+dHdI<64>Z,dJdK<64>Z-dLdM<64>Z.dNdO<64>Z/dPdQ<64>Z0dRdS<64>Z1dTdU<64>Z2dVdW<64>Z3dXdY<64>Z4dZd[<5B>Z5d\d]<5D>Z6e7<65>8d^<5E>Z9d_d`<60>Z:dadb<64>Z;dZ<dcdd<64>Z=dedf<64>Z>dgdh<64>Z?didj<64>Z@dkdl<64>ZAGdmdn<64>dneBjC<6A>ZDdoZEdpdq<64>ZFd0S)trzU
Graphical interface for downloading packages from the NLTK data
server.
r<00>
Identifier<EFBFBD>Name<6D>Size<7A>Statusz Unzipped SizeZ CopyrightZContactZLicenseZAuthorZSubdirZChecksumrr<>)rr3r4r5rr<><00>-<00>
<00> )rr2r3r4z Unzipped Sizer5<00>)z#000z#ccc)z#afaz#080)z#ffaz#880)z#faaz#800)z#fffz#888)z#fffz#45c)z#aaaz#67a)z#f00z#aaazhelvetica -16 boldTc
CsF||_||_t<02><03>|_g|_g|_d|_i|_g|_ d|_
|<00> d<03>t <0C>}|_ |<03>d<04>|<03>d<05>|j|jdd<07>|<03>d|j<13>|<03>d |j<13>d|_i|_|<00><16>|<00><17>y |<00><18>WnZtk
r<EFBFBD>}ztd
|<04>Wdd}~XYn0tk
<EFBFBD>r}ztd |j<1C>Wdd}~XYnX|<00><1D>|<00><1E>|j<1F> d<02>|j<1F>d |j!<21>dS) NFrzNLTK Downloader Started!z+50+50zNLTK Downloaderr)<01>
backgroundz <Control-q>z <Control-x>zError reading from serverzError connecting to serverz <Destroy>)"r<00> _use_threads<64> threading<6E>Lock<63>_download_lock<63>_download_msg_queue<75>_download_abort_queue<75> _downloading<6E>_afterid<69> _log_messages<65> _log_indent<6E>_logr<00>topZgeometry<72>title<6C> configure<72>_BACKDROP_COLOR<4F>bind<6E>destroy<6F>
_destroyed<EFBFBD> _column_vars<72> _init_widgets<74>
_init_menu<EFBFBD> _fill_tablerrrr'<00>
_show_info<EFBFBD>_select_columns<6E>_table<6C>select<63>_destroy)r7rZ use_threadsrFr<>r:r:r;r<ls<

 

  zDownloaderGUI.__init__cCs$|j<00>dt<02><03>d|j|f<00>dS)Nz%s %s%sz | )rCr<>r<><00>ctimerD)r7r<>r:r:r;rE<00>szDownloaderGUI._logcs<>t<00>jddddd<05>}|jdddd <09>|jdd
d <0B>|jdd
d <0B>t|dd <0C>jddd <0A>t|<01>}|jdd
dd<0F>t|<01>}|jdddd<0F>t|<01>}|jdddd<0F>t|dd <0C>jddd <0A>t|<01>}|jdddd<0F>t|dd <0C>jddd <0A>t<00>jdd<10>jd
d<14>}|jddd<17>d<04>jd<d<04>jd<ddddg<04>_i<00>_x^t <09>j<07>D]P\}}t
||<08>j d<1E>} | jd|d
dd d!<21>| <09> d"<22>j <0A>| <09>j|<08><0E><<00>q<W<00>fd#d$<24><08>jD<00>}
t|<03>j|
dd%<25>jd&<26><06>_<12>jjd<04>jdd'<27>x8t <09>j<0F>D]*\}} <0B>j<15>| <0B>j<17>} <0C>jj|| d(<28><00>q<>W<00>jjddd)<29><00>j<12><18><00>j<12>d*<2A>j<1A><00>j<12> d+<2B>j<1B><00>j<12> d,<2C>j<1A><00>j<12> d-<2D>j<1C><00>j<12> d.<2E>j<1D><00>j<12> d/<2F>j<1E>|jd
d
d <0B>d0d1<64>jfd2d3<64>j fg} i<00>_!x<>t | <0A>D]|\}\}} }t
|| d4<64>jd|d5d<0F>t"|d6d7d8d9<64>}||f<02>j!|<|<10> d,<2C>j#<23>|<10> d"|f<01>fd:d;<3B> <09>|jd
|d<d<0F><00>q<>W<00>j<01> d"<22>j#<23>t$|d=<3D>jdd><3E><04>_%<25>j%jdd?<3F>t$|d@<40>j&dd><3E><04>_'<27>j'jdAd?<3F>t
|dB<64>jd<00>jd
dC<64><04>_(t)|dDd%<25>j*d
dEd
dF<EFBFBD><06>_+<2B><00>,<2C><00>j+jdAd?<3F><00>j(jdd?<3F>dS)GNZraisedr<64><00>r)<04>relief<65>border<65>padx<64>padyrFTZboth)Zsid<69>expandr<64>r)Zweight)<01>height)<02>column<6D>row<6F>news)r^r_Zstickyrz<00>r<><00>)rZr[r:Zbottomr<6D>)<02>sider<65>rY<00>highlightthicknessZ CollectionsZCorporaZModelsz All Packages)<02>text<78>font<6E>leftr7)rcrZz
<Button-1>csg|]}<01>j<00>|d<00><02>qS)r)<02>COLUMN_WEIGHTSrO)rPr^)r7r:r;rR<00>sz/DownloaderGUI._init_widgets.<locals>.<listcomp><3E>)<04>column_weightsrdZlistbox_heightZreprfunc)<01>
foreground)r<>)r\r<>z<Double-Button-1>z<space>z<Return>z<Left>z<Right>z <Control-a>r#z Server Index:rizDownload Directory:)rer<>Zcourier<65>groove<76>black)rfrXZdisabledforegroundcs
<00><00>|<01>S)N)<01>
_info_edit)r<>rA)r7r:r;<00><lambda><3E><00>z-DownloaderGUI._init_widgets.<locals>.<lambda><3E>ew<65>Download)rer(r<>)rcZRefresh<73>rightr)rerkr:<00><><00>sunken)r<>r]r:rXrY)-rrF<00>packZgrid_rowconfigureZgrid_columnconfigureZgridrI<00>
_tab_names<EFBFBD>_tabsr<73>r <00> _TAB_FONTrJ<00> _select_tabr<62><00>COLUMNSr<00>_table_reprfuncrSZ columnconfig<69> _MARK_COLOR<4F> COLUMN_WIDTHSrO<00>DEFAULT_COLUMN_WIDTH<54>focusZbind_to_listboxes<65> _download<61> _table_mark<72> _prev_tab<61> _next_tab<61> _mark_allrr<00>_infor
<00>
_info_saver <00>_download_button<6F>_refreshZ_refresh_button<6F>_progresslabelr <00>_PROGRESS_COLOR<4F> _progressbar<61>_init_progressbar)r7<00>f1ZtabframeZ
tableframeZ buttonframeZ infoframeZ progressframer<65><00>tab<61>labelrjr^r<>r<>rA<00>callback<63>entryr:)r7r;rN<00>s<>

 


zDownloaderGUI._init_widgetscs&t<00>j<01>}t|dd<02>}|jdd<01>jdd<05>|<02><04>|jdd<07>fdd <09>d
<EFBFBD>|jd d<01>fd d <09>d
<EFBFBD>|<02><04>|jd d<0E>jd
<EFBFBD>|<02><04>|jdd<10>jdd<05>|jdd|d<13>t|dd<02>}xd<78>jj dd<00>D]P}t
<EFBFBD>j<01>}|<04>j ks<>t <0C>|<05>j |<|<04>j k<06>r|<05>d<10>|j|d|<05>jd<15>q<>W|jdd|d<13>t|dd<02>}x8<78>jj dd<00>D]$}|jd||f<01>fdd <09> d<19><00>qHW|<06><04>x8<78>jj dd<00>D]$}|jd||f<01>fdd <09> d<19><00>q<>W|jdd|d<13>t|dd<02>}|jdd<01>jd
<EFBFBD>|jdd<01>jdd<05>|jd d|d<13><00>j<01>d!<21>j<12><00>jj|d"<22>dS)#Nr)Ztearoffrr<00>Return)r<><00> underliner(Z acceleratorzChange Server Index<65>cs
<00><00>d<01>S)Nr#)rnr:)r7r:r;rorpz*DownloaderGUI._init_menu.<locals>.<lambda>)r<>r<>r(zChange Download Directorycs
<00><00>d<01>S)Nri)rnr:)r7r:r;ro!rpzShow Logr<67>ZExitrzCtrl-xZFile)r<>r<><00>menur<75>)r<>r<><00>variabler(ZViewz
Sort by %scs<00>j<00>|d<01>S)N<> ascending)rS<00>sort_by)r<>)r7r:r;roArp)r<>r(zReverse sort by %scs<00>j<00>|d<01>S)NZ
descending)rSr<>)r<>)r7r:r;roHrpZSortZAboutZ InstructionsZF1ZHelpz<F1>)r<>)r rFZ add_commandr<64>Z add_separator<6F> _show_logrKZ add_cascaderS<00> column_namesrrM<00>AssertionError<6F>INITIAL_COLUMNS<4E>setZadd_checkbuttonrR<00>about<75>helprJ<00>config)r7ZmenubarZfilemenuZviewmenur^<00>varZsortmenuZhelpmenur:)r7r;rOs^
  

 
  zDownloaderGUI._init_menucCs>x8|j<00><01>D]*\}}|<02><02>r*|j<03>|<01>q |j<03>|<01>q WdS)N)rMr<>rOrSZ show_columnZ hide_column)r7r^r<>r:r:r;rRVszDownloaderGUI._select_columnsc
Cs<>|j<00><01>y |<00><02>WnXtk
rB}ztd|<01>Wdd}~XYn.tk
rn}ztd|j<06>Wdd}~XYnX|j<07>d<03>dS)NzError reading from serverzError connecting to serverr) rr<>rPrrrr'rSrT)r7r<>r:r:r;r<>]s
 zDownloaderGUI._refreshcCs2|<00><00>|j|\}}d|d<d|d<|<02><02>dS)N<>normal<61>staterurX)r<>r<>r<>)r7Zinfo_keyr<79>r<>r:r:r;rngs
zDownloaderGUI._info_editNcCsv|j}xb|j<01><02>D]T\}}|ddkr(q|dk rJ|j|krJ|jdkrJ|}qd|d<d|d<||<03><05><00>qW|<02><06>dS)Nr<4E><00>disabledr<64>rlrX)rSr<>r<><00>widgetZkeysymrOr<>)r7r<>r<>r<>r<>r:r:r;r<>ns zDownloaderGUI._info_savecCst|jj|<00>d<01>rXt|t<04>r$d|S|dkr8d|dS|dkrLd|dSd |d
S|d krht|<03>Sd|SdS) Nr4z %siz %.1f KBg<00>@i@z %.1f MBg0Az %.1f GBg<00>A)rr)rSr<>r<>r=rrd)r7r_<00>col<6F>valr:r:r;r|{s
   zDownloaderGUI._table_reprfuncc
Csb||jjkrdSy||j_|<00><02>Wn0tk
rT}ztdt|<02><01>Wdd}~XYnX|<00><06>dS)NzError Setting Server Index)rr#rPr<>rrdrQ)r7r#r<>r:r:r;r<00>s   zDownloaderGUI._set_urlc
Cs<>|jj|krdS||j_y |<00><02>WnXtk
rP}ztd|<02>Wdd}~XYn.tk
r|}ztd|j<06>Wdd}~XYnX|<00><07>dS)NzError reading from serverzError connecting to server)rrirPrrrr'rQ)r7rir<>r:r:r;r<00>s  zDownloaderGUI._set_download_dircCs<>td|jj<02>x*|j<03><04>D]\}}d|d<|<01>dd<05>qW|jdd<00>d|jj<02>|jdd<00>d|jj<07>x|j<03><04>D]\}}d|d<qzWdS) Nz showing infor<6F>r<>r<00>endr#rir<>)r<>rr#r<>r<><00>delete<74>insertri)r7r<><00>cbr:r:r;rQ<00>szDownloaderGUI._show_infoc Gs<>x<>t|j<01>D]<5D>\}}|<03><02>|jkr |dkr |j|d<00><02>|_y|<00><04>Stk
rr}ztd|<01>Wdd}~XYq tk
r<EFBFBD>}ztd|j<08>Wdd}~XYq Xq WdS)NrrzError reading from serverzError connecting to server) r<>rwr<><00>_tabrPrrrr')r7r<>r<>r<>r:r:r;r<><00>szDownloaderGUI._prev_tabc Gs<>x<>t|j<01>D]<5D>\}}|<03><02>|jkr |t|j<05>dkr |j|d<00><02>|_y|<00><06>Stk
r|}ztd|<01>Wdd}~XYq t k
r<EFBFBD>}ztd|j
<EFBFBD>Wdd}~XYq Xq WdS)NrzError reading from serverzError connecting to server) r<>rwr<>r<>r<>rxrPrrrr')r7r<>r<>r<>r:r:r;r<><00>s zDownloaderGUI._next_tabc
Csz|jd<00><01>|_y |<00><03>WnXtk
rH}ztd|<02>Wdd}~XYn.tk
rt}ztd|j<07>Wdd}~XYnXdS)NrezError reading from serverzError connecting to server)r<>r<>r<>rPrrrr')r7<00>eventr<74>r:r:r;rz<00>s zDownloaderGUI._select_tabr{cs`<00>j<00><01>}<01>j<00><02><00>jdkr*<2A>j<04><05>}nT<6E>jdkr@<40>j<04><06>}n><3E>jdkrV<72>j<04><07>}n(<28>jdkrl<72>j<04><08>}nds~t d<06>j<00><01><01>fdd<08>|D<00>}<03>j<00>
|<03>xV<78>j <0B> <0C>D]H\}}|<04>jkr<>|j <0A>jd<00>jd d
<EFBFBD>q<>|j <0A>jd<00>jd d
<EFBFBD>q<>W<00>jjd d d <0A><00><00><11><00>j<00>|<01><00>jjd<0E>jjjf<02>jj<17><18><00><02><00>jjd<0F>jjjf<02>jj<17><18><00><02>dS)Nz all packagesr<73>r<>r{rzbad tab value %rcsg|]}<01><00>|<01><01>qSr:)<01>_package_to_columns)rPrS)r7r:r;rR<00>sz-DownloaderGUI._fill_table.<locals>.<listcomp>r)rkr:r2r<>)<01>order<65><72>i,)rS<00> selected_rowr<77>r<>rrMr<>r<>r{r<>r<>rxr<>rH<00>_FRONT_TAB_COLOR<4F>_BACK_TAB_COLORr<52><00> _color_tablerTrF<00>afterZ
_scrollbarr<EFBFBD>Z_mlbZyview)r7r<>r<>Zrowsr<73>r<>r:)r7r;rP<00>s4


 
 
 
  
 "zDownloaderGUI._fill_tablecCsHx:tt|j<02><01>D](}|j<03>|j|df<00>}||j|df<qW|<00><05>dS)Nr2r5)r<>r<>rSrr<>r<>)r7Zrow_numr<6D>r:r:r;<00>_update_table_status<75>sz"DownloaderGUI._update_table_statuscsz<00>jr<10>j|<01>S<00>fdd<02>tt<03>j<04><01>D<00>}<02>j<04><05>}|sR|dk rR<72>j|dfg}<02>j<06>|<02>jj<08>}d<04>_ <09><00>
||<02>dS)Ncs,g|]$}<01>j|dfdkr<04>j|df<00>qS)rrr2)rS)rPr_)r7r:r;rRsz+DownloaderGUI._download.<locals>.<listcomp>r2r) r;<00>_download_threadedr<64>r<>rSr<>rr<>rirD<00> _download_cb)r7r<><00>marked<65> selection<6F> download_iterr:)r7r;r<>s


 zDownloaderGUI._downloadcs<>y t|<01>}Wn8tk
rD<00><00><02><00>j<03>d<01>jd<02>}|<04>jd<dSX<00>fdd<05>}t|t<08>rl<72><00>|j <09><00>n.t|t
<EFBFBD>r<>||j <0B>|j dk r<><72><00> |j j<0E><00><00>d<00>dSt|t<0F>r<>|d|jj<00><00>jd7_n<>t|t<12>r<>|d|j j<00>n<>t|t<13><02>r
|d |j j<00>n<>t|t<14><02>r(|d
|j j<00>nrt|t<15><02>rF|d |j j<00>nTt|t<17><02>r<><72>jd8_|d |jj<00><00><00>|jj<0E>nt|t<19><02>r<><72><00>|j j<0E><00>j<03><04>j<1A>j||<02>}|<04>jd<dS) Nr7rr<>cs|<00>jd<<00><00>|<00>dS)Nre)r<>rE)r<>)r7r:r;r<>s
z(DownloaderGUI._download_cb.<locals>.showzDownloading collection %srzDownloading package %szPackage %s is up-to-date!zFinished downloading %r.z Unzipping %sz#Finished downloading collection %r.)<1C>next<78> StopIterationr<6E>rFr<><00>_show_progressrBr=rfrgrbrerZ<00>_selectr rVrWrDrYr`r]r^r2rX<00> _clear_markr[<00> _DL_DELAYr<59>)r7r<><00>idsr<73><00>afteridr<64>r:)r7r;r<>sF 
 






     zDownloaderGUI._download_cbcCs>x8tt|j<02><01>D]&}|j|df|kr|j<02>|<02>dSqWdS)Nr2)r<>r<>rSrT)r7r r_r:r:r;r<>As zDownloaderGUI._selectcCsrxltt|j<02><01>D]Z}|j|j|df\}}d\}}|jj|||||d<03>|jj|d|jd|jdd<06>qWdS)Nr5)rmZwhite)rkZselectforegroundr:Zselectbackgroundrr)rkr:)r<>r<>rS<00>
_ROW_COLORZ rowconfigZ itemconfigurer})r7r_<00>bgZsbgZfgZsfgr:r:r;r<>GszDownloaderGUI._color_tablecCs<x6tt|j<02><01>D]$}|j|df|krd|j|df<qWdS)Nr2rr)r<>r<>rS)r7r r_r:r:r;r<>XszDownloaderGUI._clear_markcGs*x$tt|j<02><01>D]}d|j|df<qWdS)Nr-r)r<>r<>rS)r7r<>r_r:r:r;r<>]szDownloaderGUI._mark_allcGsT|j<00><01>}|dkrB|j|ddkr4d|j|df<nd|j|df<|jjdd<05>dS)Nrrr-r)r<>)rSr<>rT)r7r<>r<>r:r:r;r<>as 
zDownloaderGUI._table_markcCsd<01>|j<01>}t|jd|<01>dS)Nr<4E>zNLTK Downloader Log)r1rCrrF)r7rer:r:r;r<>js zDownloaderGUI._show_logcCs<>g}x~t|j<01>D]p\}}|dkr,|<02>d<02>q|dkrB|<02>|j<03>q|dkr^|<02>|j<04>|<01><01>q|<04><06><00>dd<06>}|<02>t||d<07><03>qW|S)z<>
Given a package, return a list of values describing that
package, one for each column in ``self.COLUMNS``.
rrr2r5rr<>zn/a) r<>r{r<>r rr<>r<><00>replacer<65>)r7r<>r_Z column_indexZ column_name<6D>attrr:r:r;r<>ns z!DownloaderGUI._package_to_columnscGs|jr
dS|j<01><02>d|_dS)NT)rLrFrK)r7r<>r:r:r;rK<00>s
zDownloaderGUI.destroycGsL|jdk r*x|j<01><02>D]}|j<00>|<02>qW|jr>|jr>|<00><06>|j<07><08>dS)N) rFrBr<>Z after_cancelrAr;<00>_abort_downloadrMr<>)r7r<>r<>r:r:r;rU<00>s 
 zDownloaderGUI._destroycOs|jj||<02>dS)N)rFr)r7r)<00>kwargsr:r:r;r<00>szDownloaderGUI.mainloopan This tool can be used to download a variety of corpora and models
that can be used with NLTK. Each corpus or model is distributed
in a single zip file, known as a "package file." You can
download packages individually, or you can download pre-defined
collections of packages.
When you download a package, it will be saved to the "download
directory." A default download directory is chosen when you run
the downloader; but you may also select a different download
directory. On Windows, the default download directory is
"package."
The NLTK downloader can be used to download a variety of corpora,
models, and other data packages.
Keyboard shortcuts::
[return] Download
[up] Select previous package
[down] Select next package
[left] Select previous tab
[right] Select next tab
c GsHyt|jd|j<02><03>ddd<04>Wn$t|jd|j<02><03>dd<06>YnXdS)NzHelp: NLTK Dowloaderr<72>Zfixed)r<>rfzHelp: NLTK Downloader)r<>)rrF<00>HELPr<50>)r7r<>r:r:r;r<><00>s zDownloaderGUI.helpcGsPd}d}y ddlm}|||d<05><02><02>Wn"tk
rJt|j||<02>YnXdS)Nz'NLTK Downloader
Written by Edward LoperzAbout: NLTK Downloaderr)<01>Message)rerG)<06>six.moves.tkinter_messageboxr<78>r<><00> ImportErrorrrF)r7r<>ZABOUTZTITLEr<45>r:r:r;r<><00>s zDownloaderGUI.aboutc Cs<>|j}t|d<00>t|d<00>}}xptdt|d<00>d|j<00>D]P}|j||jdd||j|d|d|jddt|d d
<00>d d <0C>q>W|<01>d <0A>|jd dd<0F>|<01>d|j dddd|j
dd<11><05>dS)Nr<4E>r]rr<>r<>i<><69><EFBFBD><EFBFBD>z #%02x0000r<30>rbrzr8)r<>r<><00>gradient<6E>hidden)r<><00>redbox)r<>) r<>r$r<><00>_gradient_widthZ create_line<6E>absZ
addtag_all<EFBFBD>
itemconfigZaddtag_withtagZcreate_rectangler<65>)r7r<>r<>r]r<>r:r:r;r<><00>s" $
zDownloaderGUI._init_progressbarcCsx|j}|dkr0|<02>ddddd<02>|jddd<05>nDt|d<00>t|d<00>}}|t|<03>dd }|<02>ddd||d <00>dS)
Nr<EFBFBD>rr<>r<>)r<>r<>r]r<>r)r<>Zcoordsr<73>r$)r7<00>percentr<74>r<>r]r<>r:r:r;r<><00>szDownloaderGUI._show_progresscCs<>|j}|js|jddd<03>nj|jddd<03>|<01>d<01>\}}}}|dkr^|<01>d|jddd<08>n|<01>dd d<08>|j<06>d
|j<08>}||j d <dS) Nr<4E>r<>)r<>r<>i<><69><EFBFBD><EFBFBD>rbrarr<>rt<00>_progress_alive)
r<EFBFBD>rAr<>Zbbox<6F>mover<65>rFr<>r<>rB)r7r<><00>x1<78>y1Zx2<78>y2r<32>r:r:r;r<><00>szDownloaderGUI._progress_alivecs<><00>jr<12><00><01>dSd<01>jd<<00>fdd<04>tt<04>j<05><01>D<00>}<02>j<05><06>}|s^|dk r^<5E>j|dfg}t<07>jj <09>jj
<EFBFBD>}<04>j gks~t <0C><01>j gks<>t <0C><01><00>||<02>j<0F>j <0B>j <0A><05><10>d<06>_d<07>_<00><00><12><00><00><13>dS)NZCancelrecs,g|]$}<01>j|dfdkr<04>j|df<00>qS)rrr2)rS)rPr_)r7r:r;rRsz4DownloaderGUI._download_threaded.<locals>.<listcomp>r2rT)rAr<>r<>r<>r<>rSr<>rjrr#rir?r<>r@<00>_DownloadThreadr><00>startrD<00>_monitor_message_queuer<65>)r7r<>r<>r<>Zdsr:)r7r;r<> s,


  z DownloaderGUI._download_threadedcCs*|jr&|j<01><02>|j<03>d<01>|j<01><05>dS)N<>abort)rAr><00>acquirer@r<><00>release)r7r:r:r;r<>5s
 zDownloaderGUI._abort_downloadc@seZdZdd<02>Zdd<04>ZdS)zDownloaderGUI._DownloadThreadcCs.||_||_||_||_||_tj<06>|<00>dS)N)<08> data_serverr<72><00>lock<63> message_queuer<65>r<<00>Threadr<)r7r<>r<>r<>r<>r<>r:r:r;r<<s z&DownloaderGUI._DownloadThread.__init__cCs|xV|j<00>|j<02>D]D}|j<03><04>|j<05>|<01>|jrJ|j<05>d<01>|j<03><08>dS|j<03><08>qW|j<03><04>|j<05>d<02>|j<03><08>dS)N<>aborted<65>finished) r<>r<>r<>r<>r<>r<>r<>r<>r<>)r7r<>r:r:r;rDs
  

 z!DownloaderGUI._DownloadThread.runN)rFrGrHr<rr:r:r:r;r<>;sr<>r<>cs<><00>fdd<02>}<01>j<00><01>sdS<00>x<1C>jD<00>]}|dks:|dkr<><72><00><03>d<05>_d<06>jd<<00>jdd<00>=<00>jdd<00>=<00>j<00><07>|dkr<>|d<08><00><00>d<00>n<1C>j <09>
d <09>jd<00>}|<03>j d
<dSt |t <0A><00>|j<0E>q$t |t<0F><02>r
||j<10>|jdk r<><72><00>|jj<13><00><00>d<00>d<05>_dSt |t<14><02>r6|d |jj<00><00>jd 7_q$t |t<17><02>rd<72>j<18>|jj<13>|d |jj<00>q$t |t<1A><02>r<>|d|jj<00>q$t |t<1B><02>r<>|d|jj<00>q$t |t<1C><02>r<>|d|jj<00>q$t |t<1E><02>r<>|d|jj<00>q$t |t<1F><02>r<16>jd 8_|d|jj<00><00><00> |jj<13>q$t |t!<21>r$<24><00><03><00><00> |jj<13>q$W<00>j<06>rLd<13>j"d<<00>jdd<00>=<00>j<00><07><00>j <09>
<EFBFBD>j#<23>j$<24>}|<03>j d
<dS)Ncs|<00>jd<<00><00>|<00>dS)Nre)r<>rE)r<>)r7r:r;r<>Us
z2DownloaderGUI._monitor_message_queue.<locals>.showr<77>r<>FrrrezDownload aborted!r<>r<>zDownloading collection %rrzDownloading package %rzPackage %s is up-to-date!zFinished downloading %r.z Unzipping %szFinished installing %sz#Finished downloading collection %r.zAborting download...)%r>r<>r?r<>rAr<>r@r<>r<>rFr<>rBr=rfrgrbrerZr<>r rVrWrDrYrr<>r`r]r^r2r_rXr<>r[r<><00>_MONITOR_QUEUE_DELAYr<59>)r7r<>r<>r<>r:)r7r;r<>Tsj 

  
 

 


       

 
z$DownloaderGUI._monitor_message_queue)T)N)GrFrGrHrIr{rhr~rr<>r<>r<>rIrjr<>r<>r<>r<>r<>r}r<>r<>r<>ryr<rErNrOrRr<>rnr<>r|rrrQr<>r<>rzr<>Z_rowsrPr<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>rKrUrr<><00>dedentr<74>r<>r<>r<>r<>r<>r<>r<>r<>r<r<>r<>r<>r<>r:r:r:r;rs<>




1 kE



   ),  
,rc Cs,t|t<01>r$t|d<01><02>
}t|<01>SQRXt|<00>S)zz
Calculate and return the MD5 checksum for a given file.
``file`` may either be a filename or an open stream.
<20>rbN)r=rr<><00>_md5_hexdigest)r<>r<>r:r:r;r<><00>s
 r<>cCs.t<00>}x|<00>d<01>}|sP|<01>|<02>qW|<01><03>S)Ni@)rr<>r6<00> hexdigest)<03>fpZ
md5_digestr<EFBFBD>r:r:r;r<><00>s
r<>cCs,x&t|||<02>D]}t|t<02>rt|<03><01>qWdS)z\
Extract the contents of the zip file ``filename`` into the
directory ``root``.
N)r<>r=rbrc)r2<00>rootr<74>rer:r:r;r4<00>s
r4c
cs<>|r*tj<01>dtj<04>|<00>d<00>tj<01><06>yt<07>|<00>}Wn\tj k
rh}zt
|d<03>VdSd}~XYn.t k
r<EFBFBD>}zt
||<04>VdSd}~XYnX|<03> |<01>|r<>t <0A>dS)Nz Unzipping %srzError with downloaded zip file)r <00>stdoutr<74>r-r.r0<00>flush<73>zipfile<6C>ZipFile<6C>errorrbrc<00>
extractallr<EFBFBD>)r2r<>r<><00>zfr<66>r:r:r;r<><00>s
  
r<>cCs<>g}x<>ttj<02>|d<01><02>D]<5D>\}}}t<01>|j<05>}d||tj<02>|j<05>df}tdd<05>|<04><08>D<00><01>}|<03> dd|<00>|<03> dd|j
<00>|<03> d dt |j<05><00>|<03> d
|<05>|<03> d <0B>s<>|<03> d |<07>|<02> |<03>qWtttj<02>|d <0C><02><01>} t <09>}
xB|| D]6} | <0B> d <0A>|
k<06>rtd| <0B> d <0A><00><01>|
<EFBFBD>| <0B> d <0A><01>q<>Wt<12>d<0F>} | <0C> t<12>d<01><01>x|D]} | d<00> | <0A><00>qHW| <0C> t<12>d <0C><01>x| D]}| d<00> |<0E><00>qvWt| <0C>| S)a}
Create a new data.xml index file, by combining the xml description
files for various packages and collections. ``root`` should be the
path to a directory containing the package xml and zip files; and
the collection xml files. The ``root`` directory is expected to
have the following subdirectories::
root/
packages/ .................. subdirectory for packages
corpora/ ................. zip & xml files for corpora
grammars/ ................ zip & xml files for grammars
taggers/ ................. zip & xml files for taggers
tokenizers/ .............. zip & xml files for tokenizers
etc.
collections/ ............... xml files for collections
For each package, there should be two files: ``package.zip``
(where *package* is the package name)
which contains the package itself as a compressed zip file; and
``package.xml``, which is an xml description of the package. The
zipfile ``package.zip`` should expand to a single subdirectory
named ``package/``. The base filename ``package`` must match
the identifier given in the package's xml file.
For each collection, there should be a single file ``collection.zip``
describing the collection, where *collection* is the name of the collection.
All identifiers (for both packages and collections) must be unique.
rMz%s/%s/%srcss|] }|jVqdS)N)<01> file_size)rPZzf_infor:r:r;r<> szbuild_index.<locals>.<genexpr>r&z%sr%r'r"r#r{r zDuplicate UID: %sr r)<15>_find_packagesr-r.r1r<>r2r0r<><00>infolistr<74>r<>r<>rOr<>r<><00>_find_collectionsr<73><00>addr<00>Element<6E> _indent_xml)r<><00>base_urlrM<00>pkg_xmlr<6C>r"Zzipstatr#r&r{ZuidsrSZtop_eltrZrWr:r:r;<00> build_index<65>s6  
 


r<>rcCs<>t|<00>dkr<>|jpd<02><02>d|d|_x|D]}t||d<00>q.Wx0|dd<06>D] }|jp^d<02><02>d|d|_qRW|djp<>d<02><02>d||d_dS)z<>
Helper for ``build_index()``: Given an XML ``ElementTree``, modify it
(and its descendents) ``text`` and ``tail`` attributes to generate
an indented tree, where each nested element is indented by 2
spaces with respect to its parent.
rrr<>z Nr)r<>rer<>r<><00>tail)r@r<>rQr:r:r;r<>+ s 
 r<>csntj<01>tj<01>|<01>d<00>d<00>|<00>d<03><01>kr@td|<00>d<03><01>f<00><01>t<06>fdd<06>|<02><07>D<00><01>rjtd<07><00>f<00><01>dS) zr
Helper for ``build_index()``: Perform some checks to make sure that
the given package is consistent.
rrr z&package identifier mismatch (%s vs %s)c3s&|]}|<01>ko|<01><00>d<00> VqdS)rN)r0)rPr!)<01>uidr:r;r<>H sz!_check_package.<locals>.<genexpr>z;Zipfile %s.zip does not expand to a single subdirectory %s/N)r-r.r/r0rOr<>r<><00>namelist)r<><00> zipfilenamer<65>r:)rr;<00>_check_package; srcCshtjddd|gtjtjd<04>}|<01><03>\}}|jdks:|s:|s\tdtj<07>|<00>dt <09>
|<03>f<00><01>|<02><08>dS) z<>
Helper for ``build_index()``: Calculate the subversion revision
number for a given file (by using ``subprocess`` to run ``svn``).
<20>svnr<6E>z-v)r<>rrz)Error determining svn_revision for %s: %srr<>) <0B>
subprocess<EFBFBD>Popen<65>PIPE<50> communicate<74>
returncoder<EFBFBD>r-r.r0r<>r<>)r2r<>r<>rr:r:r;<00> _svn_revisionP s

 r
ccsXg}xNt<00>|<00>D]@\}}}x4|D],}|<05>d<01>r tj<03>||<05>}t<05>|<06><01><07>Vq WqWdS)z<>
Helper for ``build_index()``: Yield a list of ElementTree.Element
objects, each holding the xml for a single package collection.
z.xmlN)r-r<>r<>r.r1rr>r<>)r<>rM<00>dirname<6D>subdirsr<73>r2Zxmlfiler:r:r;r<>c s 

r<>c #s<>ddlm}g}<02>x<>t<02>|<00>D<00>]x\}}}d<03>|||<03><02>}<06>x4|D<00>]*}|<07>d<04>rBtj<06>||<07>}|dd<06>d} yt<07>| <09>}
Wn2t k
r<EFBFBD>} zt
d| | f<00><01>Wdd} ~ XYnXyt <0B> |<08><01> <0A>} Wn2t k
r<EFBFBD>} zt
d|| f<00><01>Wdd} ~ XYnXtj<06>|dd<06><00>d <00>| <0C>d
<EFBFBD><01>k<03>r6t
d | <0C>d
<EFBFBD><01>f<00><01>t<10>fd d <0A>|
<EFBFBD><11>D<00><01><01>rbt
d<0E><00>f<00><01>| |
|fVqBWy|<04>d<0F>Wqt
k
<EFBFBD>r<>YqXqWdS)a<>
Helper for ``build_index()``: Yield a list of tuples
``(pkg_xml, zf, subdir)``, where:
- ``pkg_xml`` is an ``ElementTree.Element`` holding the xml for a
package
- ``zf`` is a ``zipfile.ZipFile`` for the package's contents.
- ``subdir`` is the subdirectory (relative to ``root``) where
the package was found (e.g. 'corpora' or 'grammars').
r)<01>
_path_fromrz.xmlNr<4E>z.zipzError reading file %r!
%srr z&package identifier mismatch (%s vs %s)c3s&|]}|<01>ko|<01><00>d<00> VqdS)rN)r0)rPr!)rr:r;r<><00> sz!_find_packages.<locals>.<genexpr>z;Zipfile %s.zip does not expand to a single subdirectory %s/z.svn)Znltk.corpus.reader.utilr r-r<>r1r<>r.r<>r<>rcr<>rr>r<>r0rOr<>rr<>) r<>r rMr r r<><00>relpathr2Z xmlfilenamerr<>r<>r<>r:)rr;r<>p s@

""
 r<>cCstt<01><01><02>dS)N)r<00> _downloaderrr:r:r:r;<00>download_shell<6C> srcCstt<01><01><02>dS)N)rrrr:r:r:r;<00> download_gui<75> srcCs t<00><01>dS)N)rr6r:r:r:r;r6<00> sr6<00>__main__)<01> OptionParserz-dz--dir<69>dirz!download package to directory DIRZDIR)<03>destr<74><00>metavarz-qz--quietr<74><00>
store_truez work quietly)r<00>action<6F>defaultr<74>z-fz--forcer<65>z"download even if already installedz-ez--exit-on-errorr<72>zexit if an error occursz-uz--urlrwZNLTK_DOWNLOAD_URLzdownload server index url)rrr<>)rw)r<>rir<>r<>r<>)rir<>r<>r<>)T)T)r)hrI<00>
__future__rrrr<>r-r<>r r<>r<r<><00>shutilr<6C>r<00>hashlibrZ xml.etreerrZsix.moves.tkinterrrr r
r r r rrr<>rZnltk.draw.tablerZnltk.draw.utilrr<>r<><00>sixrrZ six.movesrZsix.moves.urllib.requestrZsix.moves.urllib.errorrrr<>Z nltk.compatr<00>objectrrKrUrVrXrYr[r\r]r^r_r`rarbrfrhrjrrr<>r<>r4r<>r<>r<>rr
r<>r<>rr<>rrr6rF<00>optparser<00>parser<65>
add_optionr
rO<00>
parse_argsrr)rwZ
downloaderZpkg_idrr<>r<>r<><00>rvr:r:r:r;<00><module>Ds<>\H  ,  
  
] .  .) 
H
 ?