
    is                     2   d dl Z d dlmZ d dlmZmZmZmZ d dlm	Z	 e j                  d        Ze j                  d        Ze j                  d        Ze j                  d        Ze j                  d	        Ze j                  d
        Zd Zd Zd Zd Zd Zy)    N)nonproj)	ancestorscontains_cycleis_nonproj_arcis_nonproj_tree)Docc                  
    g dS )N)      r         r   r    r       p/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/spacy/tests/parser/test_nonproj.pytreer            r   c                  
    g dS )Nr
   r   r   r   r      r   r   r   r   r   cyclic_treer      r   r   c                  
    g dS )N)	r
   r   r   r   r   N   r   r   r   r   r   r   partial_treer      s    ))r   c                  
    g dS )N	r
   r   r   r   r   r   r   r   r   r   r   r   r   nonproj_treer          &&r   c                  
    g dS )N	r
   r   r   r   r   r   r   r   r   r   r   r   r   	proj_treer    !   r   r   c                  
    g dS )N)r   r   r   r   r   r   r   r   r   
   r   r"               r%      r$   r   r   r   r   r   multirooted_treer(   &   s    PPr   c                 0   t        d|       D cg c]  }| c}g dk(  sJ t        d|      D cg c]  }| c}g dk(  sJ t        d|      D cg c]  }| c}g dk(  sJ t        d|      D cg c]  }| c}g k(  sJ y c c}w c c}w c c}w c c}w )Nr   )r   r   r   )r   r   r   r   r   r   r   )r   r   Nr'   )r   )r   r   r   r(   as        r   test_parser_ancestorsr+   +   s     D)*!A*i777 K01!A15JJJJ L12!A2lBBB %567!A72=== +127s   	B	B		B2	Bc                 v    t        |       J t        |      h dk(  sJ t        |      J t        |      J y )N>   r   r   r   )r   )r   r   r   r(   s       r   test_parser_contains_cycler-   2   sI    $'''+&)333,'///*+333r   c                    t        d|      du sJ t        d|      du sJ t        d|      du sJ t        d|      du sJ t        d|      du sJ t        d|      du sJ t        d|      du sJ t        d	|      d
u sJ t        d|      du sJ t        d	|      du sJ t        d|      du sJ t        d|      d
u sJ t        j                  t        d      5  t        d|        d d d        y # 1 sw Y   y xY w)Nr   Fr
   r   r   r   r      r   T   r'   r&   8Found cycle in dependency graph: \[1, 2, 2, 4, 5, 3, 2\]match)r   pytestraises
ValueError)r   r   r   r(   s       r   test_parser_is_nonproj_arcr7   9   s5    !\*e333!\*e333!\*e333!\*e333!\*e333!\*e333!\*e333!\*d222!\*e333!\*e333"./5888"./4777	U
 ' 	q+&' ' 's   C22C;c                     t        |       du sJ t        |      du sJ t        |      du sJ t        |      du sJ t        j                  t        d      5  t        |       d d d        y # 1 sw Y   y xY w)NFTr1   r2   )r   r4   r5   r6   )r    r   r   r   r(   s        r   test_parser_is_nonproj_treer9   N   s     9%...<(D000<(E111+,444	U
 % 	$% % %s   A--A6c                      fd}g d}g d}g d}g d}g d}g d}g d}t        j                  d	      d
k(  sJ t        j                  d      dk(  sJ t        j                  d	      du sJ t        j                  d      du sJ t        j                  d|       |g dk(  sJ t        j                  |      dk(  sJ t        j                  |      dk(  sJ t        j
                  ||      \  }	}
t        j                  t        d      5  t        j
                  ||       d d d        |	g dk(  sJ |
g dk(  sJ  ||	|
      \  }}||k(  sJ ||k(  sJ t        j
                  ||      \  }	}
|	g dk(  sJ |
g dk(  sJ  ||	|
      \  }}||k(  sJ ||k(  sJ g d}	g d}
 ||	|
      \  }}||	k(  sJ |g dk(  sJ g d}	g d}
 ||	|
      \  }}|g dk(  sJ |g dk(  sJ y # 1 sw Y   xY w)Nc                     dgt        |       z  }t        |||       }t        j                  |       |D cg c]  }|j                  j
                   c}|D cg c]  }|j                   c}fS c c}w c c}w )Nz	whatever )wordsdepsheads)lenr   r   deprojectivizeheadidep_)
proj_headsdeco_labelsr<   docttokenen_vocabs         r   r@   z6test_parser_pseudoprojectivity.<locals>.deprojectivize\   sd    J/(%kLs#"%&Q&(E(EEE&(Es   A3A8)r
   r   r   r   )	   r
   r   r
   r   r/   rJ   r0   r/   r
   r/   r$      r"   r
   r   )	detnsubjrootrL   dobjauxrM   aclpunct)advmodrN   rL   rM   rS   rL   rO   rL   nmodrP   rT   rS   rL   amodrR   )rL   rM   rN   rL   rO   rP   rR   zX||Y)XYrV   )rV    TFr   )r   r   r   r   r"   r1   r2   r   )	rL   rM   rN   rL   rO   rP   rM   z	acl||dobjrR   )r
   r
   r   r
   r   r/   rJ   r0   r/   r
   rJ   r$   rK   r"   r
   )advmod||auxrN   rL   rM   rS   rL   rO   rL   rT   rP   
nmod||dobjrS   rL   rU   rR   )	rL   rM   rN   rL   rO   rP   rM   z	acl||iobjrR   )rY   rN   rL   rP   rS   rL   rO   rL   rT   rP   rZ   rS   rL   rU   rR   )r   r
   r   r
   r   r/   rJ   r0   r/   r
   r/   r$   rK   r"   r
   )rS   rN   rL   rP   rS   rL   rO   rL   rT   rP   rT   rS   rL   rU   rR   )	r   	decomposeis_decorated_liftget_smallest_nonproj_arc_slowprojectivizer4   r5   r6   )rI   r@   r   r   nonproj_tree2r   labelslabels2cyclic_labelsrD   rE   deproj_headsundeco_labelss   `            r   test_parser_pseudoprojectivityrf   [   sz   F D.LDM'KTF JGKMV$
222S!Y...'4///$---MM!T900>!CCC00?2EEE%22<HJ	z)d	e 9[-894444 : : : :"0["IL-<'''F"""%22='JJIIII = = = = #1["IL-=(((G### -J)K"0["IL-:%%% 6 6 6 6 BJ+K #1["IL-KKKK 5 5 5 5E9 9s   G++G4)r4    spacy.pipeline._parser_internalsr   (spacy.pipeline._parser_internals.nonprojr   r   r   r   spacy.tokensr   fixturer   r   r   r   r    r(   r+   r-   r7   r9   rf   r   r   r   <module>rk      s     4   ! ! ! ! * * ' ' ' ' Q Q>4'*
%>5r   