JL i7ddlZddlZddlmZmZmZmZmZm Z m Z m Z m Z m Z mZmZmZddlmZddlmZmZmZmZmZmZmZmZmZmZmZddlm Z ddl!m"Z"dZ#dZ$d Z%d Z&id d d dddddddddddd dddddddd d!d"d#d$d%d&d'd(d)d*d+Z'Gd,d-Z(Gd.d/Z)d0Z*e+d1k(re*d2gZ,y)3N) ENDLEFTSUNKENButtonFrameIntVarLabelMenu OptionMenu Scrollbar StringVarTextTk)Font) alpinobrowncess_catcess_espflorestaindian mac_morphomachadonps_chatsinica_treebanktreebank)FreqDist)in_idlez <>z <>dzEnglish: Brown Corpus (Humor)zCatalan: CESS-CAT Corpusc*tjSN)rwords_/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/nltk/app/collocations_app.pyr%3 (8r#zEnglish: Brown Corpusc*tjSr rr!r"r#r$r%r%4s U[[]r#zEnglish: Brown Corpus (Press)c2tjgdS)N)news editorialreviews categoriesr(r"r#r$r%r%5sU[[3.r#z English: Brown Corpus (Religion)c.tjdS)Nreligionr-r(r"r#r$r%r%8s z0Rr#zEnglish: Brown Corpus (Learned)c.tjdS)Nlearnedr-r(r"r#r$r%r%9u{{i/Pr#z'English: Brown Corpus (Science Fiction)c.tjdS)Nscience_fictionr-r(r"r#r$r%r%:su{{$8r#zEnglish: Brown Corpus (Romance)c.tjdS)Nromancer-r(r"r#r$r%r%=r3r#c.tjdS)Nhumorr-r(r"r#r$r%r%>sU[[G-Lr#zEnglish: NPS Chat Corpusc*tjSr )rr!r"r#r$r%r%?r&r#z#English: Wall Street Journal Corpusc*tjSr )rr!r"r#r$r%r%@s 8>>3Cr#zChinese: Sinica Corpusc*tjSr )rr!r"r#r$r%r%Aso&;&;&=r#zDutch: Alpino Corpusc*tjSr )rr!r"r#r$r%r%Bs FLLNr#zHindi: Indian Languages Corpusc.tjdS)Nz hindi.pos)files)rr!r"r#r$r%r%Csfll.Mr#z&Portuguese: Floresta Corpus (Portugal)c*tjSr )rr!r"r#r$r%r%Ds hnn6Fr#z&Portuguese: MAC-MORPHO Corpus (Brazil)c*tjSr )rr!r"r#r$r%r%Esj6F6F6Hr#z#Portuguese: Machado Corpus (Brazil)c*tjSr )rr!r"r#r$r%r%Fs 7==?r#zSpanish: CESS-ESP Corpusc*tjSr )rr!r"r#r$r%r%Gr&r#ceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZy)CollocationsViewz#FFFctj|_t|j|_t |_|j|j |j|j|j |j|jj|j jt|j|_ yr )qQueuequeueCollocationsModelmodelrtop _init_top _init_menubar _init_widgets load_corpusDEFAULT_CORPUSafter POLL_INTERVAL_pollselfs r$__init__zCollocationsView.__init__NsWWY &tzz2 4 txx   488$ 223XX^^M4::> r#c|jd|jd|jd|j|j d|j|j ddy)Nz 550x650+50+50zNLTK Collocations Listz WM_DELETE_WINDOWi&i)geometrytitlebinddestroyprotocolminsize)rVrLs r$rMzCollocationsView._init_topXsN _% *+  - '6 Cr#c ft|t|jddd|_|j |j|j |j|j |j|j|j|jjddy)N) backgroundpadxpadyborderbothT)fillexpand) rdict_BACKGROUND_COLOUR main_frame_init_corpus_select_init_results_box _init_paging _init_statuspackrVparents r$rOzCollocationsView._init_widgets_s DD$;$;!!TUV    1 t/ $//* $//* &6r#c t||j}t||_|jj |j j t|td|jdddjdt|j jjj|j j }t||j|j j g|j jd |j i}d|d <d|d <|jd|jd d dy)Nrbz Corpus: rar)justifytextrbrcrdreleft)sidecommand borderwidthhighlightthicknessrLxnryrganchor)rrjr varsetrKrQr rrplistCORPORAkeysremover non_default_corporacorpus_selected)rVrr innerframe other_corporaoms r$rlz$CollocationsView._init_corpus_selectis!6d.E.EF Z(  TZZ../ ..  $F$ TZZ//4467>> JJ % %   HH JJ % % ZZ + + -  ((  =#$   VUS9r#c t|tt|jddd|_|jj ddy)Nrra)rvreliefrbrercrdrLswryr)r rrrjstatusrprqs r$rozCollocationsView._init_statussB ..   eD1r#ct|j|_t|j}t|dd}|j dd|j d|j dd|t|d }t|d }|jd |jdd |j |jd |jdd|j |jd|jdd|j |jd|j dd||j dd||jj|y)Nr)tearoffr{ExitrazCtrl-q)label underlinerz acceleratorFile)rrmenu)r20)rvariablervaluerz502100rz Result CountEdit)r) rrL _result_sizer add_commandr] add_cascadeadd_radiobuttonset_result_sizeinvokeconfig)rVmenubarfilemenueditmenu rescntmenus r$rNzCollocationsView._init_menubarsW"488,txx.:At||   &AHE+(A. ""&&(( #  ""&&(( #  ""&&(( #  !>QZP&AHE W%r#c V|jj|j_yr )rgetrK result_count)rVkwargss r$rz CollocationsView.set_result_sizes"&"3"3"7"7"9 r#c t|}t|}t|}t|d}t|dd}t|tdddd|j|jd d d d |_|j j d dd|j d dd|j|j j|j d ddd|j|j jt|d|jj d d|j dddd|j ddd|j dddy)Nra)r{horiz)r{orientcourier16)familysizedisablednone40r) fontstater{yscrollcommandxscrollcommandwrapwidthheightexportselectionrxrfT)ryrgrhyer)rzr}w)ryrgrhrz )rwrbrrLr~bottoms) rr rrr results_boxrpryviewxviewr rj)rVrrri1i2 vscrollbar hscrollbars r$rmz"CollocationsView._init_results_boxsR6] :  : rq1 rqA  YT2%>>%>>   6tDV#c:$"2"2"8"89V#d3G$"2"2"8"89 bu)@)@AFF G  USA XC4U=r#c Pt||j}t|d|jddddx|_}|j dd t|d |j ddddx|_}|j d d |j d d |jy)NrtPrevious10rar)rwrzrr{r|rrxcenterrNextrightrLr)ryrg) rrjrpreviousprevrp__next__nextreset_current_page)rVrrrrrs r$rnzCollocationsView._init_pagings6d.E.EF ! MM    D vh /! MM    D wx 0U- !r#cd|_yN) current_pagerUs r$rz#CollocationsView.reset_current_pages r#c: |jjd}|tk(r|j|n|tk(r|j | |jjt|j|_ y#t j$rYEwxYw)NF)block) rIrCORPUS_LOADED_EVENThandle_corpus_loadedERROR_LOADING_CORPUS_EVENThandle_error_loading_corpusrGEmptyrLrRrSrTrVevents r$rTzCollocationsView._polls} 8JJNNN/E++))%044007XX^^M4::> ww   sBBBcd|jjz|jd<|j|j |j |j y)NzError in loading rw)rrrunfreeze_editableclear_results_boxfreeze_editablerrs r$rz,CollocationsView.handle_error_loading_corpussO1DHHLLNB F      !r#cT|jjdz|jd<|j|j |j |j j|jdz}|j||xjdz c_y)Nz is loadedrwra) rrrrrrrKrr write_results)rVr collocationss r$rz%CollocationsView.handle_corpus_loaded s"hhlln|; F     !zzt'8'81'<=  <( Qr#cZ|jj}|j|yr )rrrP)rVargs new_selections r$rz CollocationsView.corpus_selecteds   'r#c|j|jj|jdz }|jdz |_|j |j ||j yNra)rrKrrrrrrVrs r$rzCollocationsView.previoussd zzt'8'81'<=  --1   <(  r#c|j|jj|jdz}|j |j ||xjdz c_|j yr)rrKrrrrrrs r$rzCollocationsView.__next__ sb zzt'8'81'<=    <( Q  r#c|jj|k7rAd|zdz|jd<|j|jj |yy)NzLoading z...rw)rKselected_corpusrrrP)rV selections r$rPzCollocationsView.load_corpus(sO :: % % 2",y"85"@DKK   " JJ " "9 - 3r#c@d|jd<d|jd<y)Nrr)rrrUs r$rz CollocationsView.freeze_editable.s' '' 'r#cd|jd<|jjdtd|jd<y)Nnormalrz1.0r)rdeleterrUs r$rz"CollocationsView.clear_results_box2s8$,! s+$.!r#c>|jj|dy)Ntail)when)rLevent_generaters r$ fire_eventzCollocationsView.fire_event7s F3r#c|jy|jj|j|jjd|_yr )rL after_cancelrRr])rVrs r$r]zCollocationsView.destroy;s< 88   djj) r#cRtry|jj|i|yr )rrLmainloop)rVrrs r$rzCollocationsView.mainloopBs# 9 4*6*r#c$|jyr )set_paging_button_statesrUs r$rz"CollocationsView.unfreeze_editableGs %%'r#c|jdk(s|jdk(rd|jd<nd|jd<|jj|jrd|jd<yd|jd<y)Nrrrrr)rrrK is_last_pagerrUs r$rz)CollocationsView.set_paging_button_statesJsm    "d&7&71&}|jjt|dz|ddz|dzdz|dz }@d|jd<y) Nrrraz.0r  r)rinsertstr)rVresultsroweachs r$rzCollocationsView.write_resultsTsu$,! D    # #CHtOT!Ws]T!W5Lt5S T 1HC %/!r#N)__name__ __module__ __qualname__rjrWrMrOrlrorNrrmrnrrTrrrrrrPrrrr]rrrrr"r#r$rErEKs?7:: 2%&N:>>"2 ?"(!!. (/ 4+ (*/r#rEc`eZdZdZdZdZdZdZdZdZ Gdd e jZ y ) rJcd|_d|_d|_t|_t |_||_|jyr ) rrr_CORPORAr_DEFAULTrQrI reset_results)rVrIs r$rWzCollocationsModel.__init__^s< #  &  r#c g|_d|_y)Nr) result_pagesresults_returnedrUs r$rzCollocationsModel.reset_resultsgs !r#c||_d|_|j||}|j|j yr )rr LoadCorpusstartr)rVname runner_threads r$rPzCollocationsModel.load_corpusks:# d3  r#cg}|jt|jj|j |j |j |Sr )extendrrrrrQsort)rVcopys r$rz%CollocationsModel.non_default_corporarsE D**,-. D''(  r#c|t|jkry|j|t|jz |jzzt|jk\S)NF)lenrrrr)rVnumbers r$rzCollocationsModel.is_last_pageys_ C))* *$$ S**+ +   (!$T%6%6!78 8r#cxt|jdz |krt|t|jdz z D]j}|jj|j|j |j |j z|xj |j z c_l|j|Sr)r%rrangeappendrrr)rVpageis r$rzCollocationsModel.nexts !! "Q &$ .43t'8'8#9A#=>? ;!!((%%--0E0E++1, %%):)::% ;  &&r#c.|dk(rgS|j|Sr)r)rVr*s r$rzCollocationsModel.prevs 2:I  &&r#ceZdZdZdZy)CollocationsModel.LoadCorpusc`tjj|||c|_|_yr ) threadingThreadrWrKr)rVrrKs r$rWz%CollocationsModel.LoadCorpus.__init__s&    % %d +$)4 !DJ r#c  |jj|j}ddlm}|Dcgc]}t |dkDs|c} t fdtt dz D}t }|Dcgc]\}}||f|||fdz||||zz f!}}}|j|ddtt|d||j_ |jjjtycc}wcc}}w#t$r>} t!| |jjjt"Yd} ~ yd} ~ wwxYw) Nr) itemgetterruc3@K|]}t||dzyw)ruN)tuple).0r+rws r$ z3CollocationsModel.LoadCorpus.run..s SeDQUO4SsraT)keyreverse)rKrroperatorr3r%rr(r"rmaprrIputr Exceptionprintr) rVr!r3rfdvocabw1w2scoredrrws @r$runz CollocationsModel.LoadCorpus.runsA A5 **49957/#(7aCFQJ7SeCIPQM>RSS #%B"Xr2r(|q0E"Ib 4IJK 1 t <*.s:a=&/I*J '   $$%898 Aa   $$%?@@ As;2D(D D rPss    &$, *  8 2 $&  '(R  &'P .0 &'P $%L  8 *+C =  2! "%&M# $-.F% &-.H' (*+B) * 8+ 2O/O/dJAJAb  zE 'r#