JL idZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z m Z mZmZddlmZmZddlmZddlmZmZddlmZddlmZmZdd lmZdd lm Z dd l!m"Z"Gd d Z#dZ$e%dk(re$dgZ&y)zl A graphical tool for exploring the regular expression based chunk parser ``nltk.chunk.RegexpChunkParser``. N) ButtonCanvas CheckbuttonFrameIntVarLabelMenu ScrollbarTextTk)askopenfilenameasksaveasfilename)Font) ChunkScoreRegexpChunkParser)RegexpChunkRule) conll2000treebank_chunk)ShowText)Tree)in_idlec eZdZdZidddddddd d d d d ddddddddddddddddddd d!d"d#id$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQ ZgdRZdSedTUfdVedWUfdXedYZfd[ed\]fd^ed\]fd_ed`d`afdbedcddafdeedfUfdgedhUfdiedjUfg ZdkZ dlZ dmZ dnZ doZ edpdqdrdrdkdsdtduvZ edldldrdrdwdkdsdtdux Zedydzd{d{dkdsdtdud|} Zed~dsdtZeddZeddtdtdZed{d{dkdsdtddZedddZdZdrZedrZZedZZdZdZ ddZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0ddZ1dZ2dZ3dZ4dZ5ddZ6dZ7dZ8dZ9dZ:ddZ;ddZddZ?ddZ@dZAy)RegexpChunkAppz A graphical tool for exploring the regular expression based chunk parser ``nltk.chunk.RegexpChunkParser``. See ``HELP`` for instructional text. CCzCoordinating conjunctionzPRP$zPossessive pronounCDzCardinal numberRBAdverbDT DeterminerRBRzAdverb, comparativeEXzExistential thereRBSzAdverb, superlativeFWz Foreign wordRPParticleJJ AdjectiveTOtoJJRzAdjective, comparativeUH InterjectionJJSzAdjective, superlativeVBzVerb, base formLSzList item markerVBDzVerb, past tenseMDModalNNSz Noun, pluralNNzNoun, singular or massVBNzVerb, past participleVBZzVerb,3rd ps. sing. presentNNPzProper noun, singularNNPSzProper noun pluralWDTz wh-determinerPDT PredeterminerWPz wh-pronounPOSzPossessive endingzWP$zPossessive wh-pronounPRPzPersonal pronounWRBz wh-adverb(zopen parenthesis)zclose parenthesisz open quotecommaz close quoteperiodzpound sign (currency marker)zdollar sign (currency marker)zPreposition/subord. conjunctionz#Symbol (mathematical or scientific)zVerb, gerund/present participlezVerb, non-3rd ps. sing. presentcolon) z``,z''.#$INSYMVBGVBP:))Help20a-Welcome to the regular expression chunk-parser grammar editor. You can use this editor to develop and test chunk parser grammars based on NLTK's RegexpChunkParser class. Use this box ('Help') to learn more about the editor; click on the tabs for help on specific topics: Rules: grammar rule types Regexps: regular expression syntax Tags: part of speech tags Use the upper-left box ('Grammar') to edit your grammar. Each line of your grammar specifies a single 'rule', which performs an action such as creating a chunk or merging two chunks. The lower-left box ('Development Set') runs your grammar on the development set, and displays the results. Your grammar's chunks are highlighted, and the correct (gold standard) chunks are underlined. If they match, they are displayed in green; otherwise, they are displayed in red. The box displays a single sentence from the development set at a time; use the scrollbar or the next/previous buttons view additional sentences. The lower-right box ('Evaluation') tracks the performance of your grammar on the development set. The 'precision' axis indicates how many of your grammar's chunks are correct; and the 'recall' axis indicates how many of the gold standard chunks your system generated. Typically, you should try to design a grammar that scores high on both metrics. The exact precision and recall of the current grammar, as well as their harmonic mean (the 'f-score'), are displayed in the status bar at the bottom of the window.)Rules10a

{...regexp...}

Chunk rule: creates new chunks from words matching regexp.

}...regexp...{

Strip rule: removes words matching regexp from existing chunks.

...regexp1...}{...regexp2...

Split rule: splits chunks that match regexp1 followed by regexp2 in two.

...regexp...{}...regexp...

Merge rule: joins consecutive chunks that match regexp1 and regexp2 )Regexps10 60aZ

Pattern Matches...

<T> a word with tag T (where T may be a regexp). x? an optional x x+ a sequence of 1 or more x's x* a sequence of 0 or more x's x|y x or y . matches any character (x) Treats x as a group # x... Treats x... (to the end of the line) as a comment \C matches character C (useful when C is a special character like + or #)

Examples:

Matches "cow/NN" Matches "green/NN" Matches "eating/VBG" Matches "ate/VBD"
Matches "on/IN the/DT car/NN" ? Matches "ran/VBD" Matches "slowly/RB ate/VBD" \t<\#> # This is a comment...\n Matches "#/# 100/CD" )TagsrSzB

Part of Speech Tags:

<> redz#a00 foregroundgreenz#080 highlightz#ddd background underlineT)r\h1indentlmargin1lmargin2 hangindentr<varz#88fregexpz#ba7matchz#6a6g?g{Gz?g{Gz?( z#efegrooveword)widthheightr[highlightbackgroundhighlightthicknessreliefborderwrapz#555) rorpr[rqrWrrrsrtruF z#eef)) rorpr[rqrrrsrtrutabsz#9bb)r[rsrt helveticaifamilysizez#777)r[padxpadyrti,i)r[rqrrrsrtrorp)r[activebackgroundrqz#abactjdd|}tjdd|}tjdd|}|j}tjdd|}|S) N((\\.|[^#])*)(#.*)?\1z + z\n\s+z\nz ([^\\])\$z\1\\$)resubstrip)selfgrammars ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/nltk/app/chunkparser_app.pynormalize_grammarz RegexpChunkApp.normalize_grammar4s[&&/@&&sG,&&5'2--/&&x9Nc&||_| |j}||_|C|dk(rtjd}n(|dk(rt j}nt d|zd|_ ||_ d|_ d|_ ||_ ||_ d|_ d|_ g|_ d|_ d|_ d|_ d|_ t)||_ t-x}|_|j1d |j3d |j5d |j6t9||_|j:j=d |j?||jA||jC||jE||jFjI|r;|jFjKd |dz|jFjMdd|jOd|jQy)a :param devset_name: The name of the development set; used for display & for save files. If either the name 'treebank' or the name 'conll2000' is used, and devset is None, then devset will be set automatically. :param devset: A list of chunked sentences :param grammar: The initial grammar to display. :param tagset: Dictionary from tags to string descriptions, used for the help page. Defaults to ``self.TAGSET``. Nrz train.txttreebankzUnknown development set %sr chunk_labelz+50+50zRegexp Chunk Parser Appz dend insert1.0)) _chunk_labelTAGSETtagsetr chunked_sentsr ValueErrorchunkerrnormalized_grammargrammar_changeddevset devset_name devset_index_last_keypress_history_history_index _eval_grammar_eval_normalized_grammar _eval_indexr _eval_scorer topgeometrytitlebinddestroyr _devset_sizeset _init_fonts _init_widgets_init_bindings _init_menubar grammarboxfocusrmark_set show_devsetupdate)rrrrrrrs r__init__zRegexpChunkApp.__init__?s $( >[[F  >k)"00=:%'557 != !KLL 7 )"&7 ; A&? - =  8  I" )-%5 5&+> :dh X +,  -#3K c"  3 C  3   OO " "5'D. 9 OO $ $Xu 5  rcj|jdj|jdj|jdj|jdj|jdfd|jdfdj jdjj jdjj jdjj jd jy) Nz z z z z c$jSN) save_grammarers rz/RegexpChunkApp._init_bindings..$*;*;*=rz c$jSr) load_grammarrs rrz/RegexpChunkApp._init_bindings..rrz )r _devset_next _devset_prevtoggle_show_tracerrevalbox _eval_plotrrs` rrzRegexpChunkApp._init_bindingss  1 12  1 12  6 67 t{{+  =>  => ]D,B,BC ]D,=,=> ]D,=,=> -9rc$t||_|jjdtd|jj |_tdt |jj dzdz |_y)Nr_rzr{)r_sizerrget_fontint _smallfontrs rrzRegexpChunkApp._init_fontssgC[  rDJJNN4D3DE s4::>>+;b+@B+F'G%H rct|}t|d}|jdd|j|jddd|j|jddd |j|jd d |j |jd d |j d|jdd|t|d}|jd|jdd|j|jd|jdd|j|jd|jdd|j|jd|jdd|j|jd|jdd|j|jdd|t|d}|jd|jd|j |jd!|jd"|j |jd#|jd$|j |jd%|jd&|j |jd'd|t|d}|jd(d|j|jd)d||j|*y)+Nr)tearoffzReset Application)labelr\commandzSave Current GrammarzCtrl-s)rr\ acceleratorrz Load GrammarzCtrl-ozSave Grammar History ExitrhzCtrl-q)rr\rrFile)rr\menuTinyrw)rvariabler\valuerSmallMediumr_LargeHuge"Viewz 50 sentences2)rrrrz 100 sentencesrz 200 sentencesz 500 sentencesizDevelopment-SetAboutrN)r)r add_commandresetrr save_historyr add_cascadeadd_radiobuttonrresizerset_devset_sizeaboutconfig)rparentmenubarfilemenuviewmenu devsetmenuhelpmenus rrzRegexpChunkApp._init_menubarsv,+#6!TZZX( %%    %%   (B@Q@Q   At||   &AHE+  ZZKK !    ZZKK !    ZZKK !    ZZKK !    ZZKK !  &AHE'1- "" &&(( # ""!&&(( # ""!&&(( # ""!&&(( # "3qzR+7aL&AHE 7 #rc^|jr|jy|jy)Nbreak)_showing_tracer show_tracerrs rrz RegexpChunkApp.toggle_show_trace#s+        OO rFc  |jd|jj}|jd|jj}|jj d|jj d|dzdz ddd }|jj |dd z|dz }}|jj |||z dzz|dz d d d }d|jj |ddz } }|jd} |jj|jjdd|dz d| | |jj|jjd| dzdd| | |jjrt|jdkDrdx} } dx} }tdtt|j|jdzD]G}|j| \}}}}t|| } t||}t!|| } t!|| } It!| dz d} t!|dz d}t| dzd} t| dzd} ndx} }dx} } tdD]}|||z |dz |z | |z z zz}| | |z |dz | z | | z z zz }||cxkr|kr#nn |jj#|||| d||cxkr| ksknn|jj#||||d|jj#|||| |jj#|| || |jj |dz | dddd| zz |jj |dz |dddd| zz |jj || dzd ddd|zz |jj || dzd ddd| zz dx}}t%|jD]6\}\}}}}|||z ||z | |z z zz}| | |z || z | | z z zz }||j&k(rU|jj)|dz |dz |dz|dzd d!d"|dzzd#|dzzzd$|dzzz|j*d%<nF|jj|jj)|dz |dz |dz|dzd&d'|S|j,jr9|jj|jj#||||d'||}}9y)(Nrorpallrwrmleftw Precision)justifyanchortextrsRecallcenter)rrrrhr[ri)filloutlineg{Gz? g$@z#888)r r~rightsez%d%%rnenwz#0f0z#000zPrecision: %.2f%% zRecall: %.2f%% zF-score: %.2f%%r#afaz#8c8)rr winfo_width winfo_heightdelete create_textbbox_EVALBOX_PARAMSlowercreate_rectangle _autoscalelenrrangemin_SCALE_Nmax create_line enumerater create_ovalstatus _eval_lines)rrrrorptagrr rbotbg max_precision max_recall min_precision min_recallir precisionrecallfmeasurexyprev_xprev_y_fscores rrzRegexpChunkApp._eval_plot-s 7DLL$<$<$>?Hdll&?&?&AB E"ll&& ! b &;' ll'',Q/!3URZell&& EDLQ& & RK ' t||((-a025S ! !, /  LL ) )!Qq$RQS ) T   LL ) )!S1WdDrSU ) V ??   S%7!%;)* *MJ)* *MJ1c#dmm"4dmma6GHI 57;}}aR7H4FH #I} =  4 #I} =  4  5$  4a8MZ$.2J  4a8MZ$.2J)* *MJ)* *MJr IA TJ&: +BCAsSyTM)mm.KLAa% ((CCf(EQ}} ((q%(H I   sD#6   sE37   1H 3./ !    1H 3./ !     !G3+, !     !G3+, ! 1:4==1I " -A-9ff *$j)@AAsSy]*}}/LMAD''' ((E1q5!a%QVV)*Y_=(FSL9:'6C<89 F#  ""LL,,Aq1ua!eQU- !d&6&6&:&:&< ""LL,,VVQ,OFF5 "rc|jy|jd|_ytj}tj|jz |j kr\|j |jk7rCd|_|jjt|jdz|jS|j |jk7r|jD]\}}}}|j |j|k(s'|jj||||ft|jdz |_|j#d|_d|_yd|_t'|j(|_|j,|_|j |_|j j1dk(rd|_y|j2|j$t5|j$|j6z|j8j;D]=}|j=|j?}|j*jA||?|xj$|j6z c_|j$|j8j;k\r|jj|j.|j*jC|j*jE|j*jGft|jdz |_|j#d|_d|_yd|j$z|j8j;z }d |z|jHd <d|_|jKtj|z |jjt|jdz|jy) NFTirhrrrz$Evaluating on Development Set (%d%%)r)&rr_eval_demon_runningtimer _EVAL_DELAYrrafterr _EVAL_FREQ _eval_demonrrappendrrrrrrrrrrrr _EVAL_CHUNKrr _chunkparseleavesscorer-r. f_measurer#_adaptively_modify_eval_chunk) rt0gprfgoldguessprogresss rr=zRegexpChunkApp._eval_demonsF 88   << ',D $ YY[ IIK$-- -0@0@ @''4+H+HH'+D $88>>#doo&<"=t?O?OP P  " "d&C&C C#mm  1a**d.D.DQ.GGMM((!Q16*-dmm*ij"j%d(t|fdj ijl_7jnjdd?d@dddAd4j,dB<d4jBdB<jd }t|dCd|jddt|ddC|jddt|dDd|jddE|j%d%d"FjBj;dGdHdIJjBj;dKdIdLMjBj;dNdOjBj;dPdQdRSjBj;dTdUdRVjBj;dWdLXjj;dWdYjj;dZd[Xjj;d\d]Xjj;d^d_Xjj;d`ddaby)cNr)weightr~rmrhrfontGrammar:blackr[)rTrhighlightcolorr[SW)columnrowstickyNEWS)rNWS)yscrollcommandrZEWz Prev Grammar)rrr)sidez Next Grammar)rrTSz c&j|Sr) show_help)rtabrs rrz.RegexpChunkApp._init_widgets..Ns4>>#;Nr)rpror[)rYrZ)rTelideT)retag-%sboth)expandr zDevelopment Set:r )rTrrr[horiz)rorientxscrollcommandbottomr0)r`r zPrev Example (Ctrl-p)zNext Example (Ctrl-n)z Show exampledisabled)rrstatez Show tracez Evaluation:)rYrZr[ columnspanFZoom)rrrLinesrHistory NEW)rYrZr[rrrprorwr)r rhtrue-posrTrue)r[r\ false-negz#800)r\rW false-posz#faatracez#666none)rWru wrapindentrx)rbruerrorrVz#feccommentz#840anglez#00fbracez#0a0rcrjr`)8r _FRAME_PARAMSgrid_columnconfiguregrid_rowconfigurer r_GRAMMARBOX_PARAMSrr grammarlabelgridr yviewrrr _history_prev_BUTTON_PARAMSpack _history_nextr_HELPBOX_PARAMShelpboxhelptabsr!HELPr_HELPTAB_SPACER configure tag_config HELP_AUTOTAGrc_DEVSETBOX_PARAMS devsetbox devsetlabel_devset_scroll devset_scrollxviewdevset_xscrollrrr devset_buttonr trace_buttonrrrrrrrrr$_STATUS_PARAMSr#)rrframe0grammar_scrollbarr'frame3 helptab_framer,rdtabstopsrrr%paramshelp_scrollbarframe4frame1frame2s` rrzRegexpChunkApp._init_widgetss s1d001##Aa#0##Aa#0  1 -  1 -vRDJJR$:Q:QR! "..|<   aQt< A1V<&fdoo6K6KLaQu= .?.C.CD   -v"- 1!D 1  && !!  $F$   && !!  $F$ FQQDKC #DLL # #HsN =f = > tyy|A'#64<<3E3EF >+=+=>1!E:v$*<*<\*JKfP4::P9O9OP 4f5 #--l;   QAd; 1!F 3'vt7J7JK qa>' DNN00 ,0+>+>+B+B'(   hS 9   -v"- 1!D 1  (%% !!  $F$   (%% !!  $F$ #  $$  !!   W-"  %t BFBUBU  G,f=(<(<=  ++L9    !4 0 &QG   -v"- 1!D 1 * E"  __OO  !!  $F$ !$((+ U#  %%OO  !!  $F$ v=I=)<)<=BBBPFKKt7J7JK  qQQSTU!+ W",w   - fRqR8==QA=N fQbR8==QA=N fQaB7< ""9"@ ""7v"> ""7v"> ""rrcharnumlinenumrr@_chunks intersection _color_chunkrr;rr)rr gold_treertagseqrwordnumrnposr,jr test_tree gold_chunks test_chunkschunks rrzRegexpChunkApp.show_traces"%/'"&.7#"*w eU+#<    "D$5$5$9$9$; <$   <<  NN ! !%)N O NN " "7E5 9 KK 1 12  ""$#$-i.>.>.@$A ( G[dC eck !F NN3v; ' ( 3u:>* 3w<( FGAJ    /4CJN.CD1q519 D s5zA~& 9AAv%%eZ8&&w0CYO%%e]U1q5\-IJ&&w0CYO NN ! !%$ 7 NN " "<1Di P'bq 2G(()9)9); 8!!!UJ7 8${2 9!!!UK8 9${2 9!!!UK8 9) 9, e]3 w(;YG sD//33Q>rc3&K|] }d|z yw)z %s %sN).0items r z+RegexpChunkApp.show_help..s #T)cXtjd|dxrd|dfxsd|dfS)Nz\w+rrh)rrg)t_ws rrz*RegexpChunkApp.show_help.."s8BHHVSV,D-,!"CF -+ !3q6{r)key)ryz z1.0 + %d charsz(?s)()(.*?)()rerhrfrmr~rnr)rrrreplacejoinsortedlistritemsrr_HELPTAB_FG_PARAMSrrrfinditerrstartr_HELPTAB_BG_PARAMS) rrdnamerrCr%rpatternms rrczRegexpChunkApp.show_helps ( W E5)$(II F D(Ds{|| II$* !2!2!45!+% + d#**ET-D-DE ###2 ##E4)+;<$#'#4#4TKC &se:cU"=G[[$7T ,,Wa!''!*na!%%PQ(lS ,,$sNA NAaL ,,Wa!''!*na!%%PQ(lS TT+ d#**ET-D-DE9 F:!+ Wrc@|j|jdz yNrhr _view_historyrrs rrzRegexpChunkApp._history_prev9 4..23rc@|j|jdzyrrrs rrzRegexpChunkApp._history_next=rrc6tdtt|jdz |}|jsy||jk(ryd|j d<|j j dd|j jd|j|d|j jdd||_|j|j|d|j|j|d|_ |jr<|jjdDcgc]}tj|}}ng}t||_|j#|j%|j&r|j)|jt|jdz kr@d j+|jdzt|j|j,d <yd |j,d <ycc}w) NrrhrrorrrrzGrammar {}/{}:rrU)rrrrrrrrr_syntax_highlight_grammarrrsplitr fromstringrrr_highlight_devsetrrformatr)rindexliners rrzRegexpChunkApp._view_historyAsAs3t}}-159:}}  D'' ' $,  ue, udmmE&:1&=>   51# &&t}}U';A'>?"&"8"8u9Ma9P"Q  " "!3399$? **40E E(/       OO    T]]!3a!7 7(8(?(?##a'DMM")D  f % )3D  f %)s4Hc*|jdddy)Nscrollrhpagerrrs rrzRegexpChunkApp._devset_nextjs Ha0rc*|jdddy)Nrrrrrrs rrzRegexpChunkApp._devset_prevns Hb&1rc`|jy|jjd|_yr)rrrs rrzRegexpChunkApp.destroyrs& 88   rcd}|j}|dk(r?|djdr+|j|jt |dzn|dk(rB|djdr.|j|j|t |dzznT|dk(rB|jt t |d|j jzn Jd|d||r|jyy) Nrhrunitrrmovetozbad scroll command r) r startswithrrrfloatrrr)rrargsN showing_traces rrzRegexpChunkApp._devset_scrollxs ++ h 47#5#5f#=   T..T!W= >  T!W%7%7%?   T..Sa\1AA B    StAw$2C2C2G2G2I!IJ K <+G9AdV< <1  OO  rc| |j}ttd||jj dz }||jk(r |j sy||_d|_d|j d<d|jd<d|jd<d|jd<|jjd d d |jdz|jj fz|jd <|j|j|jdz}i|_ ddi|_ t|D]\}}d }t|jD]J\}\}}t!||j||f<||d|dz }t!||j||dzf<L|jj#d |dddz|j$|j'd|jd<|j|jj z } |jdz|jj z } |j(j+| | y)NrrhFrrornrnrurrrrr7/rrz rm)rrrrrrrrrrrrrrr!rArrrrrr) rrsamplesentnumsentlinestrrrnrfirstlasts rrzRegexpChunkApp.show_devsetsP =%%EC5M4#4#4#8#8#:Q#>? D%% %d.A.A !#%-'"&07##+w!'v eU+#<    "D$5$5$9$9$; <$  T..1B1BQ1FG 1v &v. @MGTG(1$++-(@ B$$14W Wg-.dV1SE++58\ Wgk12 B NN ! !%")> ?  @ << #  " " $",w!!D$5$5$9$9$;;!!A%):):)>)>)@@ ud+rct}d}|D]b}t|trK|j|jk(r|j ||t |zf|t |z }^|dz }d|S)Nrrh)r isinstancerrraddr)rtreechunksrchilds rrzRegexpChunkApp._chunksss E%&;;=D$5$55JJ3u:)=>?3u:%1    rc|jy|jjddd|jjddd|jjddd|jjdddt |j dD]O\}}|j stjd|}d}|jd r`|jd }d |d z|jd fz}d |d z|jd fz}|jjd||tjd |D]}||j|k\rd |d z|jfz}d |d z|jfz}|jd vr|jjd||z|jjd||Ry)Nrrrrrrcrz(\\.|[^#])*(#.*)?rmz%d.%drhz[<>{}]z<>) rr tag_removerr!rrrrggrouprrr)rrlinenorr comment_startrrs rrz(RegexpChunkApp._syntax_highlight_grammars 88   ""9eU; ""7E59 ""7E59  eU;%gmmD&9: ;LFD::<-t4A Mwwqz ! vz1771:66vz155844'' 1a8[[40 ; ,m1Kvz177955vz155733779$OO++GQ:OO++GQ: ; ;rc |jy|jjdddg|_t |j dD]E\}}t jdd|}|j}|s0 tj|Gd |jd <y#t$r3}|jjdd|dzzd |dzzYd}~d}~wwxYw) Nr~rrrrrz%s.0rhz %s.0 lineendr7r)rrr_grammarcheck_errsr!rrrrrrrrr#)rrrrrs r _grammarcheckzRegexpChunkApp._grammarchecks 88   ""7E59"$%gmmD&9: LFD660%>D::$..t4 )/  ""7E59#yy{    OO   " " $''    (+     w 'DL   s*-E9E4E94E99 F$FF$cp|&|j|j|jdz}|jjddd|jjddd|jjdddt |D]\}}|j |j }|j|}|j|}|j|D]}|j||d||z D]}|j||d||z D]}|j||dy)Nrhrwrrryrz) rrrrr!r@rArrr)rrrrrrrrs rrz RegexpChunkApp._highlight_devsets2 >[[!2!2T5F5F5JKF !!*eU; !!+ue< !!+ue<#,F"3 ? GY(()9)9); >!!'5*= >${2 ?!!'5+> ?${2 ?!!'5+> ? ?rc |jj|S#ttf$r)}|jj ddd|cYd}~Sd}~wwxYw)Nr~rr)rparser IndexErrorrr)rwordsrs rr@zRegexpChunkApp._chunkparse5sN <<%%e, ,J'  OO # #GUE :L  sAA AAc |\}}|jj||j|d|j||f|j|d|j||fdz y)NrFrh)rrrr)rrrr%rrs rrzRegexpChunkApp._color_chunk@sq s  ||G$%Qt||GUN'C&D E||G$%Qt||GSL'AA'E&F G rcd|_d|_d|_d|_g|_d|_|j jdd|jd|jy)Nrrr) rrrrrrrrrr)rs rrzRegexpChunkApp.resetHsZ  "&   ue,  rz# Regexp Chunk Parsing Grammar # Saved %(date)s # # Development set: %(devset)s # Precision: %(precision)s # Recall: %(recall)s # F-score: %(fscore)s %(grammar)s c |sddg}t|d}|sy|jrL|j|j|jddk(rd|jdddD\}}}n|jd x}x}}nd x}x}}t |d 5}|j |jttj|j||||jj zdddy#1swYyxYw) Nz Chunk Gramamr.chunkz All files*r filetypesdefaultextensionrrc3,K|] }dd|zzyw)z%.2f%%rNr)rvs rrz.RegexpChunkApp.save_grammar..js))*C!G$)srhzGrammar not well formedzNot finished evaluation yetr)daterr-r.r5r)rrrrropenwriteSAVE_GRAMMAR_TEMPLATEdictr9ctimerrr)rfilenameftypesr-r.r5outfiles rrzRegexpChunkApp.save_grammaras13EFF(6HUH ==T448N8N MM" a 9  ).2mmB.?.C) %Ivv\\ !*C CI C*G GI G (C G MM**++'!! LL..0     s A"C??Dc|sddg}t|d}|sy|jjdd|jt |5}|j }dddt jddj}|jjd||jy#1swY[xYw) Nrrrrrrz2^\# Regexp Chunk Parsing Grammar[\s\S]*F-score:.* r7) r rrrrreadrrlstripr)rrr infilers rrzRegexpChunkApp.load_grammars13EFF&(SH ue, (^ $vkkmG $&& Er7 &(  ug.  $ $s B99Cc |sddg}t|d}|syt|d5}|jd|jdtjz|jd|j zt |jD]\}\}}}}d |d zt|j|d z|d z|d zfz} |jd | z|jd jd|jjD|jr.|j|j|jddk(s||j|jdn|jd|jd jd|jjjDdddy#1swYyxYw)N)zChunk Gramamr History.txtrr'rrz'# Regexp Chunk Parsing Grammar History z # Saved %s z# Development set: %s z>Grammar %d/%d (precision=%.2f%%, recall=%.2f%%, fscore=%.2f%%)rhrz %s r7c3&K|] }d|z ywz %s Nrrrs rrz.RegexpChunkApp.save_history..s%T$ho%Trrrz# Current Grammar (not well-formed) z! Current Grammar (not evaluated) c3&K|] }d|z ywr)rr*s rrz.RegexpChunkApp.save_history..sUHtOUr)rrrr9rrr!rrrrrrrrr) rrr r!r,rFrGrHrIhdrs rrzRegexpChunkApp.save_historys79KLF(6FSH (C  G MMD E MM.4::<7 8 MM3d6F6FF G#,T]]#; V?@<<'MM"IJMM"GH GGU 8J8J8L8R8R8TUU-   s F.GG#cd}d} ddlm}|||jy#t|j||YyxYw)NzTD - 2 E / 4 4 6 - TXXue ,s %Ac"||jj||jjtt|j|jj |j d|j dy)Nrhr)rrrrrrrrr}s rrzRegexpChunkApp.set_devset_sizesk      ! !$ ' c#dkk"2D4E4E4I4I4KLM  rc*||jj||jj}|jj t | |j j tdt | dzdzy)N)r}irr_)rrrrrabsrrr5s rrzRegexpChunkApp.resizeso   JJNN4 zz~~ CI,/ !!s3#d) r0AR0G'H!IrcRtry|jj|i|y)z Enter the Tkinter mainloop. This function must be called if this demo is created from a non-interactive program (e.g. from a secript); otherwise, the demo will close as soon as the script completes. N)rrmainloop)rrkwargss rr9zRegexpChunkApp.mainloops% 9 4*6*r)rNr7NPNr)B__name__ __module__ __qualname____doc__rrrrr:r?r<rOrNrrrr _FONT_PARAMSrrr_HELPTAB_BG_COLOR_HELPTAB_FG_COLORrrrrrrrrrr _DRAW_LINESrr8r=rDrrrrcrrrrrrrrrrrrrr@rrrrrrrrrr9rrrrr-s. (.$. . h . l . $ . !. $. n. j. k. d. '. n. '. !."  #.$ !%.& g'.( ~).* &+., &-.. +/.0 &1.2 $3.4 5.6 7.8 l9.: ";.< &=.> !?.@ {A.B C.D E.F   + ,/400 [.Fne DP '( $&)* df-. dT*+ td#$ 4b12 tQ45 '( 46*+ $&)* L"K+K#JCOO"  "  O"   VHQGN{5LF1EM"OFN00O   iV : `$DHKE"N IJV0{JzN==~ +D'3R +,Z ;6!"1f?.    < B-J +rrc4tjyr)rr9rrrapprEsr__main__rE)'r?randomrtextwrapr9tkinterrrrrrrr r r r tkinter.filedialogr r tkinter.fontr nltk.chunkrrnltk.chunk.regexpr nltk.corpusrrnltk.draw.utilr nltk.treer nltk.utilrrrEr<__all__rrrrSsj     B4-1#e+e+P-  zE 'r