JL iH ddlmZmZmZmZmZmZmZmZddl m Z ddl m Z m Z ddlmZddlmZmZddlmZddlmZddlmZdd lmZGd d ZGd d ZdZedk(reyy#e$rYRwxYw))ButtonFrameIntVarLabelListboxMenu ScrollbarTk)Font) CanvasFrameShowText) MaltParser) DrsDrawerDrtVariableExpression)DrtGlue)Variable) RegexpTagger)in_idleceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZddZdZdZdZdZdZy) DrtGlueDemoct|_|jjd|j|j |j||_|Dcgc]}dc}|_t|j|_|jjdd|_ g|_ d|_ d|_ d|_|j|j!|j|j#|j|j%|j|j'|j|j)|j|j*j-d|j.ycc}w)Nz DRT Glue Demoz )r _toptitle_init_bindings _init_fonts _examples _readingCacher _show_grammarset _curExample _readings_drs _drsWidget_error _init_glue _init_menubar _init_buttons_init_exampleListbox_init_readingListbox _init_canvas_canvasbind _configure)selfexamplesexamples \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/nltk/sem/drt_glue_demo.py__init__zDrtGlueDemo.__init__s)D  (  #!2:;wd;$DII. q!    499% 499% !!$)), !!$)), $))$ -9/s r3r'zDrtGlueDemo._init_glueEs+   f- yEJ c|ttd|_|jd|jt ||_|j j |jjdtdd|j j|_ td|j j|_ |j jd kr|j jd z }n|j jd z}tdd||_ y) NfontrCz*Fontsize helveticabold)familyweightrE)rHrEr) r r_sysfont option_addr_sizer!cgetget _boldfont_font_bigfont)r0rootbigs r3rzDrtGlueDemo._init_fontsYs&(6"23  /D\  t}}))&12[djjnnFVW4::>>3CD ::>> a **.."Q&C**.."Q&CKSI rAc t|x|_}|jjdddt|j|jd|_|j jt |jddd d |jd d |_|jjddd|jD]!}|jjdd|z#|jjtt|jddt|jdkDrvt|jd}|jj|j|j|jj |jdd|jj#d|j$y)NbothleftrJfillsidepadxExamplesrCtextsinglegroovewhite#909090#004040#c0f0c0 selectmoderelief background foregroundrCselectforegroundselectbackgroundrightrrZrYexpandend %s(heightwidthverticalorientyscrollcommandcommandyrZrY<>)r _exampleFramepackrrP_exampleList_labelrrQ _exampleListrinsertconfigminlenr r!yviewr._exampleList_select)r0parent listframer2 listscrolls r3r*z DrtGlueDemo._init_exampleListboxjs).v6Y V&qA"'   T^^*#  $$&#    &&   G&C~~ @G    $ $UVg-= ? @   C,?(DB O t~~  #"4#5#5jIJ    $ $JNN $ C   d&7&7&=&=  > OOcO 2 2D4L4LMrAc t|x|_}|jjdddt|j|jd|_|j jt |jddd d |jd d |_|jjdddt|jd}|jj|j|j|jj|jdd|jy)NrVrWrJrXReadingsr]r_r`rarbrcrdrerlrrmrvrwryr{r}r~)r _readingFramerrrP_readingList_labelrrQ _readingListr rr!r_populate_readingListbox)r0rrrs r3r+z DrtGlueDemo._init_readingListboxs).v6Y V&qA"'   T^^*#  $$&#    &&   G&Ct11*E     ?$"3"3"9"9:W3/ %%'rAc|jjddtt|jD]$}|jj dd|dzz&|jj tt|jdd|jjd|jy) Nrrorprrqrsr) rdeleterangerr#rrrr._readingList_select)r0is r3rz$DrtGlueDemo._populate_readingListboxs   E*s4>>*+ @A    $ $UVq1u-= ? @   C,?(DA N 2D4L4LMrAc|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|jy)Nz z znzpz )rr.destroynextprevr0s r3rzDrtGlueDemo._init_bindingss }dll3 }dll3 z4<<0 sDII& y$)), sDII& }dii0rAct|x|_}|jddddt|ddd|j jd t|d dd|j jd y) NnonebottomrJ)rYrZr[padyPrevz#90c0d0black)r^rhrir|rW)rZNext)r _buttonframerrrr)r0r buttonframes r3r)zDrtGlueDemo._init_buttonss|*/-7Kf8!!D  II  $F$   II  $F$ rAcd|_|jj\}}}}|jdz }d||||fz|jd<|j y)Nrz %d %d %d %d scrollregion) _autostep_cframerrtr-_redraw)r0eventx1y1x2y2s r3r/zDrtGlueDemo._configuresW<<446RR \\A '4BB7G'G ^$ rAct|dddd|_|jjdddd |jjx}|_d|_g|_d|_y) Nra rJsunken)rh closeenoughborderrgrrVtop)rnrYrZr)r rrcanvasr-_tree _textwidgets _textline)r0rrs r3r,zDrtGlueDemo._init_canvassk"     e!D $ 3 3 55 rAct|}t|d}|jdd|jd|jdd|t|d}|jd d|jd |jd d|j d |jd d|t|d}|j dd|jj|jd|jdd|t|d}|jd|jdd|j|jd|jdd|j|jd|jdd|j|jd|jdd|j|jd|jdd|j|jdd|t|d}|jdd|j|jd d||j|!y)"Nr)tearoffExitrq)label underliner| acceleratorFile)rrmenurzn, SpacePreviousz p, BackspaceActionzRemove Duplicatesr)rrvariabler|rOptionsTinyr)rrrvaluer|Small MediumLargeHugeViewAbout)rrr|Help)r)r add_commandr add_cascaderradd_checkbuttonr@r?_toggle_remove_duplicatesadd_radiobuttonrMresizeaboutr)r0rmenubarfilemenu actionmenu optionmenuviewmenuhelpmenus r3r(zDrtGlueDemo._init_menubarsMv,+At||   &AHE'1- Atyyj   499.   (ajI'1- ""%ZZ1122 #  )qzJ+  ZZKK !    ZZKK !    ZZKK !    ZZKK !    ZZKK !  &AHE+7aL&AHE 7 #rAc|j}|j|jj|jr?t |j|j|_|jj |j r@t |j|j |_|jj yyN)r-r%clearr$ DrsWidgetdrawr&)r0rs r3rzDrtGlueDemo._redraw3s ?? & OO ! ! # 99' dii@DO OO " ;;' dkkBDO OO " rAcnd|_|jy|jjd|_yNr)rrrr0es r3rzDrtGlueDemo.destroyFs- 99    rAcN|jj}|jj}|dkDr\t|dk(r9t |d}|dkr|j y|j |dz y|j |dz y|j yNrr)r curselectionrErint_select_previous_example_readingList_store_selectionr0r selectionreadingListSizeindexs r3rzDrtGlueDemo.prevMs%%224 ++002 Q 9~"IaL)A:11355eai@11/A2EF  ) ) +rAc|jdkDr|j|jdz y|jt|jdz yr)r"_exampleList_store_selectionrrrs r3rz$DrtGlueDemo._select_previous_exampledsG   a   - -d.>.>.B C  - -c$...AA.E FrAcN|jj}|jj}|dkDr\t|dk(r.>.B C  - -a 0rAcd}d} ddlm}|||jy#t|j||YyxYw)Nz\NLTK Discourse Representation Theory (DRT) Glue Semantics Demo Written by Daniel H. GarrettezAbout: NLTK DRT Glue Demor)Message)messager)tkinter.messageboxrshowr r)r0rABOUTTITLErs r3rzDrtGlueDemo.aboutsE . , . 2 E / 4 4 6 . TYYu -s %AcFd|_|jjyr)rr print_to_filers r3 postscriptzDrtGlueDemo.postscripts ""$rAcRtry|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)r0argskwargss r3r zDrtGlueDemo.mainloops% 9  D+F+rANc||jj||jj}|jj t | |j j t | |jj t | |jj t |dz |jy)N)rErJ) rMr!rOrQ configureabsrPrKrRr)r0rEs r3rzDrtGlueDemo.resizes   JJNN4 zz~~ CI,/   D l 3 s4y\2 s4!8}%56 rAcH|jj |j_|jjddg|_|j |j Dcgc]}dc}|_d|_d|_ d|_ |jycc}w)Nrror) r@r?rselection_clearr#rrrr"r&r$r)r0exs r3rz%DrtGlueDemo._toggle_remove_duplicatess+/::+G+G'G $ ))!U3 %%'-1^^Q   ))#il*;gd}t|jy)N)z John walkszDavid sees MaryzDavid eats a sandwichzevery man chases a dogzJohn chases himself)rr )r1s r3demor7sH,""$rA__main__N) tkinterrrrrrrr r tkinter.fontr nltk.draw.utilr r ImportError nltk.parser nltk.sem.drtrr nltk.sem.gluernltk.sem.logicrnltk.tagr nltk.utilrrrr7r%r(rAr3rCswERRR!4 "9!#!^^BJJ$%4 zFqEDEs"A//A76A7