
    /h                     T    S SK Jr  S SKJr   " S S\5      rS r\S:X  a  \" 5         gg)    )chain)Counterc                       \ rS rSrS rS rS rS rS rSS jr	S	 r
\S
 5       r\SS j5       r\S 5       rS rS rSS jrSrg)
FStructure   c                 <    X;  a  / X'   X   R                  U5        g)zW
Append 'item' to the list at 'key'.  If no list exists for 'key', then
construct one.
N)append)selfkeyitems      D/var/www/auris/envauris/lib/python3.13/site-packages/nltk/sem/lfg.py
safeappendFStructure.safeappend   s     
 ?DI	    c                 L    [         R                  XR                  5       U5        g N)dict__setitem__lower)r
   r   values      r   r   FStructure.__setitem__   s    yy{E2r   c                 H    [         R                  XR                  5       5      $ r   )r   __getitem__r   r
   r   s     r   r   FStructure.__getitem__   s    iik22r   c                 H    [         R                  XR                  5       5      $ r   )r   __contains__r   r   s     r   r   FStructure.__contains__   s      yy{33r   c                 D    U R                  5       nUR                  U5      $ r   )to_depgraphto_glueformula_list)r
   	glue_dictdepgraphs      r   r!   FStructure.to_glueformula_list!   s!    ##%,,X66r   Nc                 ^   SSK Jn  U" 5       nUR                  nU R                  USS5        UR	                  5        Hb  u  pVS UR                  5        5        HB  nUS   U:X  d  M  US   nUS   R                  U/ 5        US   U   R                  US   5        MD     Md     US	   Ul        U$ )
Nr   DependencyGraphROOTc              3   :   #    U  H  oS    S:w  d  M  Uv   M     g7f)relTOPN ).0ns     r   	<genexpr>)FStructure.to_depgraph.<locals>.<genexpr>/   s     F.QeH4Eqq.s   	headr*   depsaddress   )	nltk.parse.dependencygraphr'   nodes_to_depgraphitemsvalues
setdefaultr	   root)	r
   r*   r'   r#   r6   r3   noden2relations	            r   r    FStructure.to_depgraph%   s    >"$%F+ #[[]MGF%,,.Ff:(!%yHL++Hb9L*11"Y-@	 G + ar   c           
         [        U5      nX   R                  UU R                  S   U R                  S   UUS.5        [        U 5       H  n[        X   5       H  n[	        U[
        5      (       a  UR                  XU5        M,  [	        U[        5      (       a,  [        U5      nX   R                  UUS   US   UUS.5        Mm  [	        U[        5      (       a  U H  nUR                  XU5        M     M  [        SU-  5      e   M     g )Nr   r4   )r3   wordtagr1   r*   0feature %s is not an FStruct, a list, or a tuple)
lenupdatepredsorted
isinstancer   r7   tuplelist	Exception)	r
   r6   r1   r*   indexfeaturer   	new_indexr.   s	            r   r7   FStructure._to_depgraph9   s    E
 		!yy|	
 d|Gt}-dJ//%%eG<e,, #E
I$++'0$(G#'7$)#*  d++!uW= " $JWT % . $r   c                 B    [         R                  U R                  U 5      $ r   )r   _read_depgraphr;   )r#   s    r   read_depgraphFStructure.read_depgraph]   s    ((AAr   c           
         U(       d
  [        5       nU S   R                  5       S;   a
  U S   U S   4$ [        5       nS Ul        [        R	                  UR                  5       5      Ul        X4l        U S   U S   peUS S S:X  a&  USS S:X  a  UR                  S	S
5        XVS S 4Ul        UR                  (       d  XV4Ul        [        R                  " U S   R                  5       5       Vs/ s H  nUR                  U   PM     nnU H,  n	UR                  U	S   [        R                  XX$5      5        M.     U$ s  snf )Nr*   )specpunctrA   rB      VB   Dtense)PASTr[   r2   )r   r   r   rF   _make_labelgetlabelparentr   r   from_iterabler9   r6   rQ   )
r<   r#   label_counterr`   fstructrA   rB   idxchildrenchilds
             r   rQ   FStructure._read_depgrapha   s>   #IM;"33L$u+.. !lGGL&22=3D3D3FGGM#NVd5k#2Aw$q8s?&&w0AB $"1g<< ${ !..tF|/B/B/DEEC s#E   """%L--e}V " Ns   ,D;c                 ^    / SQU S-
     n[        U 5      S-  nUS:  a  U[        U5      -   $ U$ )z
Pick an alphabetic character as identifier for an entity in the model.

:param value: where to index into the list of characters
:type value: int
)fghijklmr.   opqrstuvwxyzabcder4      r   )intstr)r   letternums      r   r]   FStructure._make_label   sB    
6 !)78 %jB7CH$$Mr   c                 B    U R                  5       R                  SS5      $ )N
 )__str__replacer
   s    r   __repr__FStructure.__repr__   s    ||~%%dB//r   c                 "    U R                  5       $ r   )pretty_formatr   s    r   r   FStructure.__str__   s    !!##r   c                     SU R                   -  n USU R                  S   -  -  n[        U 5       GH  nX    H  n[	        U[
        5      (       aQ  U[        U5      -   S-   [        U R                   5      -   nUSR                  SU-  UUR                  U5      5      -  nMi  [	        U[        5      (       a  USR                  SU-  X4S   5      -  nM  [	        U[        5      (       a?  US	R                  SU-  US
SU[        U5      -   S-   -  -  R                  U5      5      -  nM  [        SU-  5      e   GM
     US-   $ ! [         a    Sn GNAf = f! [         a     GN<f = f)Nz%s:[[z	pred '%s'r   rY   z
{}{} {} z

{}{} '{}'z
{}{} {{{}}}z
%srW   rC   ])r_   	NameErrorrF   rG   rH   r   rD   formatr   rI   rJ   joinrK   )r
   indentaccumrM   r   next_indents         r   r   FStructure.pretty_format   sx   	TZZ'E	[DIIaL11E d|GdJ//"(3w<"7!";c$**o"MK[//v**;7 E
  e,,]11#.'PQ7SSEd++_33v3&3w<*?!*C#DEKKDQ E $JWT # & $* s{9  	E	  		s"   E E EE
E$#E$r,   r   )NN)rY   )__name__
__module____qualname____firstlineno__r   r   r   r   r!   r    r7   staticmethodrR   rQ   r]   r   r   r   __static_attributes__r,   r   r   r   r      su    3347("H B B " "H ' 'R0$r   r   c                      SSK Jn   U " S5      nU " S5      nU " S5      nU " S5      nXX4/nU H!  n[        [        R	                  U5      5        M#     g )Nr   r&   zEsso       NNP     2       SUB
said       VBD     0       ROOT
the        DT      5       NMOD
Whiting    NNP     5       NMOD
field      NN      6       SUB
started    VBD     2       VMOD
production NN      6       OBJ
Tuesday    NNP     6       VMOD
zUJohn    NNP     2       SUB
sees    VBP     0       ROOT
Mary    NNP     2       OBJ
zWa       DT      2       SPEC
man     NN      3       SUBJ
walks   VB      0       ROOT
zevery   DT      2       SPEC
girl    NN      3       SUBJ
chases  VB      0       ROOT
a       DT      5       SPEC
dog     NN      3       OBJ
)r5   r'   printr   rR   )r'   dg1dg2dg3dg4	depgraphsdgs          r   demo_read_depgraphr      sp    :
		C 	C 	C 	C 3$Ij&&r*+ r   __main__N)	itertoolsr   nltk.internalsr   r   r   r   r   r,   r   r   <module>r      s7     "G GT),X z r   