
3Ic           @   sw  d  d k  Z  d  d k l Z l Z l Z d  d k l Z d  d k Td Z	 d Z
 d Z h  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& <Z d' d/ d(     YZ d) d0 d*     YZ d+   Z d,   Z e d- j o e   n d. g Z d S(1   iN(   t   corpust   FreqDistt   in_idle(   t   Text(   t   *s   <<CL_EVENT>>s   <<ELC_EVENT>>s   English: Brown Corpus (Humor)c           C   s   t  i i   S(    (   R    t   cess_catt   words(    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyt   <lambda>   s    s   Catalan: CESS-CAT Corpusc           C   s   t  i i   S(    (   R    t   brownR   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    s   English: Brown Corpusc           C   s   t  i i d  d d d g  S(   t
   categoriest   newst	   editorialt   reviews(   R    R   R   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    s   English: Brown Corpus (Press)c           C   s   t  i i d  d  S(   R	   t   religion(   R    R   R   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    s    English: Brown Corpus (Religion)c           C   s   t  i i d  d  S(   R	   t   learned(   R    R   R   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    s   English: Brown Corpus (Learned)c           C   s   t  i i d  d  S(   R	   t   science_fiction(   R    R   R   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    s'   English: Brown Corpus (Science Fiction)c           C   s   t  i i d  d  S(   R	   t   romance(   R    R   R   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   !   s    s   English: Brown Corpus (Romance)c           C   s   t  i i d  d  S(   R	   t   humor(   R    R   R   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   #   s    c           C   s   t  i i   S(    (   R    t   nps_chatR   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   %   s    s   English: NPS Chat Corpusc           C   s   t  i i   S(    (   R    t   treebankR   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   '   s    s#   English: Wall Street Journal Corpusc           C   s   t  i i   S(    (   R    t   sinica_treebankR   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   )   s    s   Chinese: Sinica Corpusc           C   s   t  i i   S(    (   R    t   alpinoR   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   +   s    s   Dutch: Alpino Corpusc           C   s   t  i i d  d  S(   t   filess	   hindi.pos(   R    t   indianR   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   -   s    s   Hindi: Indian Languages Corpusc           C   s   t  i i   S(    (   R    t   florestaR   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   /   s    s&   Portuguese: Floresta Corpus (Portugal)c           C   s   t  i i   S(    (   R    t
   mac_morphoR   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   1   s    s&   Portuguese: MAC-MORPHO Corpus (Brazil)c           C   s   t  i i   S(    (   R    t   cess_espR   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   3   s    s   Spanish: CESS-ESP Corpust   CollocationsViewc           B   s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s   #FFFc         C   ss   t    |  _ |  i i |   t   |  _ |  i |  i  |  i   |  i |  i  |  i   |  i	 |  i i
  d  S(   N(   t   CollocationsModelt   modelt   add_listenert   Tkt   topt	   _init_topt   _init_menubart   _init_widgetst   _bind_event_handlerst   load_corpust   DEFAULT_CORPUS(   t   self(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyt   __init__9   s    

c         C   sA   | i  d  | i d  | i d |  i  | i d d  d  S(   Ns   550x650+50+50s   NLTK Collocations Lists   <Control-q>i&  i  (   t   geometryt   titlet   bindt   destroyt   minsize(   R'   R    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR!   C   s    c         C   s   t  | t d |  i d d d d d d   |  _ |  i |  i  |  i |  i  |  i |  i  |  i |  i  |  i i d d d t	  d  S(	   Nt
   backgroundt   padxi   t   padyt   bordert   fillt   botht   expand(
   t   Framet   dictt   _BACKGROUND_COLOURt
   main_framet   _init_corpus_selectt   _init_results_boxt   _init_pagingt   _init_statust   packt   True(   R'   t   parent(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR#   I   s    0c         C   s  t  | d |  i } t |  |  _ |  i i |  i i  t | d t d d d |  i d d d d d	 d
 i	 d d  |  i i
 i   i |  i i  } t | |  i |  i i d |  i |  i i   } d
 | d <d | d <| i	 d d  | i	 d d d d d d  d  S(   NR.   t   justifyt   texts	    Corpus: R/   i   R0   i   R1   i    t   sidet   leftt   commandt   borderwidtht   highlightthicknessR    R2   t   xt   anchort   n(   R5   R7   t	   StringVart   vart   setR   R&   t   Labelt   LEFTR=   t   CORPORAt   keyst   removet
   OptionMenut   corpus_selectedt   non_default_corpora(   R'   R?   t
   innerframet   other_corporat   om(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR9   Q   s    =!0

c         C   sS   t  | d t d t d |  i d d d d d d |  _ |  i i d	 d
 d d  d  S(   NR@   t   reliefR.   R1   i    R/   i   R0   RB   R    RH   t   sw(   RM   RN   t   SUNKENR7   t   statusR=   (   R'   R?   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR<   ^   s    6c         C   s  t  |  i  |  _ t |  i  } t | d d d d } | i d d d d d |  i d	 d
  | i d d d d d |  t | d d } t | d d } | i d d d |  i d d d d d |  i  | i d d d |  i d d d d d |  i  | i d d d |  i d d d d d |  i  | i	 d  | i d d d d d |  | i d d d d d |  |  i i
 d |  d  S(   Nt   tearoffi    RE   t   labelt   Exitt	   underlinei   RD   t   accelerators   Ctrl-qt   Filet   menut   20t   variablet   valuei   t   50i2   t   100id   s   Result Countt   Edit(   t   IntVarR    t   _result_sizet   Menut   add_commandR,   t   add_cascadet   add_radiobuttont   set_result_sizet   invoket   config(   R'   t   menubart   filemenut   editmenut
   rescntmenu(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR"   b   s$    c         K   s   |  i  i   |  i _ d  S(   N(   Rj   t   getR   t   result_count(   R'   t   kwargs(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyRo   y   s    c         C   s  t  |  } t  |  } t  |  } t | d d } t | d d d d } t | d t i d d d d	  d
 d d d d | i d | i d d d d d d d d 	|  _ |  i i d d d d d t  | i d d d d d d  | i	 d |  i i
  | i d d d d d t d d  | i	 d |  i i  t | d  d! d" |  i i d d d d  | i d d# d d d t d d$  | i d d% d d d d&  | i d d# d d d t  d  S('   NRE   i   t   orientt   horizt   fontt   familyt   couriert   sizet   16t   statet   disabledt   yscrollcommandt   xscrollcommandt   wrapt   nonet   widtht   40t   heightRc   t   exportselectionRB   RC   R2   R3   R4   t   yRH   t   eRD   RG   t   wRA   s      R.   R    RI   t   bottomt   s(   R5   t	   ScrollbarR   t   tkFontt   FontRL   t   results_boxR=   R>   Rq   t   yviewt   xviewRM   R7   (   R'   R?   RU   t   i1t   i2t
   vscrollbart
   hscrollbar(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR:   |   s&    		'"+"c         C   s   t  | d |  i } t | d d d |  i d d d d d	 d d
 d |  _ } | i d d d d  t | d d d |  i d d d d d	 d d
 d |  _ } | i d d d d  | i d d d d  |  i   d  S(   NR.   RA   t   PreviousRD   R   t   10RE   i   RF   R   R   RB   RC   RH   t   centert   Nextt   rightR    R2   R   (   R5   R7   t   Buttont   previoust   prevR=   t   nextt   reset_current_page(   R'   R?   RU   R   R   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR;      s    ::c         C   s   d |  _  d  S(   Ni(   t   current_page(   R'   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    c         C   s0   |  i  i t |  i  |  i  i t |  i  d  S(   N(   R    R+   t   CORPUS_LOADED_EVENTt   handle_corpus_loadedt   ERROR_LOADING_CORPUS_EVENTt   handle_error_loading_corpus(   R'   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR$      s    c         C   sF   d |  i  i   |  i d <|  i   |  i   |  i   |  i   d  S(   Ns   Error in loading RA   (   RK   Rv   R[   t   unfreeze_editablet   clear_results_boxt   freeze_editableR   (   R'   t   event(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s
    


c         C   sq   |  i  i   d |  i d <|  i   |  i   |  i   |  i i |  i d  } |  i	 |  |  i d 7_ d  S(   Ns
    is loadedRA   i   (
   RK   Rv   R[   R   R   R   R   R   R   t   write_results(   R'   R   t   collocations(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    


c         G   s    |  i  i   } |  i |  d  S(   N(   RK   Rv   R%   (   R'   t   argst   new_selection(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyRS      s    c         C   sX   |  i    |  i i |  i d  } |  i d |  _ |  i   |  i |  |  i   d  S(   Ni   (   R   R   R   R   R   R   R   (   R'   R   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    

c         C   sW   |  i    |  i i |  i d  } |  i   |  i |  |  i d 7_ |  i   d  S(   Ni   (   R   R   R   R   R   R   R   (   R'   R   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    

c         C   sJ   |  i  i | j o3 d | d |  i d <|  i   |  i  i |  n d  S(   Ns   Loading s   ...RA   (   R   t   selected_corpusR[   R   R%   (   R'   t	   selection(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR%      s    
c         C   s   d |  i  d <d |  i d <d  S(   NR   R   (   R   R   (   R'   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    c         C   s1   d |  i  d <|  i  i d t  d |  i  d <d  S(   Nt   normalR   s   1.0R   (   R   t   deletet   END(   R'   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    c         C   s   |  i  i | d d d  S(   Nt   whent   tail(   R    t   event_generate(   R'   R   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyt
   fire_event   s    c         G   s2   |  i  d  j o d  Sn |  i  i   d  |  _  d  S(   N(   R    t   NoneR,   (   R'   R   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR,      s    c         O   s)   t    o d  Sn |  i i | |   d  S(   N(   R   R    t   mainloop(   R'   R   Rx   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    c         C   s   |  i    d  S(   N(   t   set_paging_button_states(   R'   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s    c         C   sv   |  i  d j p |  i  d j o d |  i d <n d |  i d <|  i i |  i   o d |  i d <n d |  i d <d  S(   Nii    R   R   R   (   R   R   R   t   is_last_pageR   (   R'   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s     c         C   sp   d |  i  d <d } xI | D]A } |  i  i t |  d | d d | d d  | d 7} q Wd |  i  d <d  S(	   NR   R   i   s   .0i    t    s   
R   (   R   t   insertt   str(   R'   t   resultst   rowt   each(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s     1(   t   __name__t
   __module__R7   R(   R!   R#   R9   R<   R"   Ro   R:   R;   R   R$   R   R   RS   R   R   R%   R   R   R   R,   R   R   R   R   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   6   s4   	
													
											
R   c           B   sr   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	 e i f d
     YZ RS(   c         C   sD   g  |  _  d  |  _ d  |  _ d  |  _ t |  _ t |  _ |  i	   d  S(   N(
   t	   listenersR   Rw   R   R   t   _CORPORARO   t   _DEFAULTR&   t   reset_results(   R'   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR(      s    						c         C   s   g  |  _  d |  _ d  S(   Ni    (   t   result_pagest   results_returned(   R'   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR     s    	c         C   s   |  i  i |  d  S(   N(   R   t   append(   R'   t   listener(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR     s    c         C   s%   x |  i  D] } | i |  q
 Wd  S(   N(   R   R   (   R'   R   R   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyt   notify_listeners	  s    
 c         C   s<   | |  _  d  |  _ |  i | |   } | i   |  i   d  S(   N(   R   R   R   t
   LoadCorpust   startR   (   R'   t   namet   runner_thread(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR%     s
    		
c         C   s:   g  } | i  |  i i    | i |  i  | i   | S(   N(   t   extendRO   RP   RQ   R&   t   sort(   R'   t   copy(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyRT     s
    
c         C   sL   | t  |  i  j  o t Sn |  i | t  |  i  |  i t  |  i  j S(   N(   t   lenR   t   FalseR   Rw   R   (   R'   t   number(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR     s    c         C   s   t  |  i  d | j  oe xb t | t  |  i  d  D]? } |  i i |  i |  i |  i |  i ! |  i |  i 7_ q8 Wn |  i | S(   Ni   (   R   R   t   rangeR   R   R   Rw   (   R'   t   paget   i(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s     'c         C   s    | d j o g  Sn |  i  | S(   Ni(   R   (   R'   R   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   '  s    R   c           B   s   e  Z d    Z d   Z RS(   c         C   s'   | | |  _  |  _ t i i |   d  S(   N(   R   R   t	   threadingt   ThreadR(   (   R'   R   R   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR(   -  s    c   
         sC  y|  i  i |  i   } d d k l } t d   |    t   f d   t t    d  D  } t    } g  } | D]C \ } } | | | f | | | f d t	 | | | |  f q~ ~ } | i
 d | d  d t  t | d	  |  |  i  _ |  i  i t  Wn* t j
 o }	 |	 GH|  i  i t  n Xd  S(
   Ni(   t
   itemgetterc         S   s   t  |   d  j S(   i   (   R   (   R   (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   5  s    c         3   s*   x# |  ] } t    | | d  ! Vq Wd S(   i   N(   t   tuple(   t   .0R   (   RA   (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pys	   <genexpr>6  s    i   i   t   keyt   reversei    (   R   RO   R   t   operatorR   t   filterR   R   R   t   floatR   R>   t   mapR   R   R   t	   ExceptionR   (
   R'   R   R   t   fdt   vocabt   _[1]t   w1t   w2t   scoredR   (    (   RA   s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyt   run1  s    ,W(   R   R   R(   R   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   ,  s   	(   R   R   R(   R   R   R   R%   RT   R   R   R   R   R   R   (    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR      s   										c          C   s:   g  }  t  i t  D] \ } } |  | d | q ~  } d  S(   NR   (   R'   t   _collocationst   num(   R   R   R   t   colloc_strings(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyR   @  s    c          C   s   t    }  |  i   d  S(   N(   R   R   (   t   c(    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pyt   appC  s    	t   __main__R   (    (    (   R   t   nltkR    R   R   t	   nltk.textR   t
   TextDomaint   nltk.draw.utilR   R   R   R   R   R   R   R   R   t   __all__(    (    (    s/   /p/zhu/06/nlp/nltk/nltk/app/collocations_app.pys   <module>	   s<   
H		