
    h                         S SK r S SKJr  S SKJr  S SKJrJr  S rS r	S r
\ R                  R                  S/ S	Q5      S
 5       rS rg)    N)Mock)Language)get_attr_infovalidate_attrsc                     [         R                  " SSS/S9S 5       n [         R                  " SSS/SS/S	9S
 5       n[         R                  " SS/S/S	9S 5       n[         R                  " S5      (       d   e[         R                  " S5      (       d   e[         R                  " S5      (       d   e[        5       nUR                  S5        UR                  S5        UR	                  5       S   nUS   S/:X  d   eUR                  S5        [        US5      S   SS/:X  d   eUR                  SSS9  UR                  S5      nUR                  S:X  d   eUR                  / SQ:X  d   e[         R                  " S5      (       a   eUR                  S   S:X  d   eUR                  S   S:X  d   e[        US5      S   / SQ:X  d   e[        US5      S   S/:X  d   eU" S5      (       d   eg )Nc1	token.tagz
doc.tensorassignsc                     U $ N docs    \/home/james-whalen/.local/lib/python3.13/site-packages/spacy/tests/pipeline/test_analysis.pytest_component19test_component_decorator_assigns.<locals>.test_component1	       
    c2	token.posztoken.lemma)requiresr   c                     U $ r   r   r   s    r   test_component29test_component_decorator_assigns.<locals>.test_component2   	     
r   c3ztoken._.custom_lemmac                     U $ r   r   r   s    r   test_component39test_component_decorator_assigns.<locals>.test_component3   r   r   problemsr   c4)name)r   r   r   r"   )r   r   r"   r   hello world)
r   	componenthas_factoryadd_pipeanalyze_pipesr   get_pipe_metafactory
pipe_namespipe_factories)r   r   r   nlpr!   test_component4_metas         r    test_component_decorator_assignsr/      s   {L&AB C [1M<;X 1G0H %%%%%%%%%%%%
*CLLLL  ":.HD>k]***LLl+I64,FFFLLDL!,,T2''4///>>5555##D))))d#t+++d#t+++l+I6:LLLLk*:64&@@@}r   c                  @  ^  " S S5      n [        5       mU " 5       Tl        SS[        4U4S jjjn[        R                  " SUS9  [        R
                  " S5      (       d   e[        5       nUR                  SSS0S9  U" S	5      (       d   eTR                  USS
9  g)zTest that class components can implement a from_nlp classmethod that
gives them access to the nlp object and config via the factory.c                       \ rS rSrS rSrg);test_component_factories_class_func.<locals>.TestComponent54   c                     U$ r   r   )selfr   s     r   __call__Dtest_component_factories_class_func.<locals>.TestComponent5.__call__5   s    Jr   r   N)__name__
__module____qualname____firstlineno__r6   __static_attributes__r   r   r   TestComponent5r2   4   s    	r   r=   barc5fooc                    > T" XS9$ )Nr@   r   )r-   r@   r#   mocks      r   test_componen5_factoryCtest_component_factories_class_func.<locals>.test_componen5_factory;   s    C!!r   )func)configr$   rB   N)r>   r?   )r   return_valuestrr   r*   r&   r'   assert_called_once_with)r=   rD   r-   rC   s      @r   #test_component_factories_class_funcrK   0   s      6D&(D" " " T 67%%%%
*CLLuenL-}  % 0r   c                      / SQn [        U 5      (       d   eU  H  n[        U/5      (       a  M   e   [        R                  " [        5         [        SS/5        S S S 5        g ! , (       d  f       g = f)N)	doc.sentszdoc.entsr	   ztoken._.xyzz
span._.xyzrM   doc.xyz)r   pytestraises
ValueError)attrsattrs     r   "test_analysis_validate_attrs_validrT   F   sZ    OE%    tf%%%% 	z	"Y/0 
#	"	"s   A$$
A2rS   )r   doc_entsrN   z	token.xyzz
token.tag_ztoken.tag.xyzztoken._.xyz.abcz
span.labelc                     [         R                  " [        5         [        U /5        S S S 5        g ! , (       d  f       g = fr   )rO   rP   rQ   r   )rS   s    r   $test_analysis_validate_attrs_invalidrW   O   s&     
z	"v 
#	"	"s   1
?c                     [         R                  " SS/S9S 5       n [         R                  " SS/S9S 5       n[        5       nUR                  S5        UR                  S5        UR                  5       S	   nUS   S/:X  d   eUR	                  S5        UR                  5       S	   n[        S
 UR                  5        5       5      (       d   eg)z7Test that attributes are validated correctly on remove.pipe_analysis_c6r	   r
   c                     U $ r   r   r   s    r   r   4test_analysis_validate_attrs_remove_pipe.<locals>.c1d   r   r   pipe_analysis_c7r   )r   c                     U $ r   r   r   s    r   r   4test_analysis_validate_attrs_remove_pipe.<locals>.c2h   r   r   r!   c              3   *   #    U  H	  o/ :H  v   M     g 7fr   r   ).0ps     r   	<genexpr>;test_analysis_validate_attrs_remove_pipe.<locals>.<genexpr>s   s     2 11Bw 1s   N)r   r%   r'   r(   remove_pipeallvalues)r   r   r-   r!   s       r   (test_analysis_validate_attrs_remove_piperg   a   s     *[MB C *k]C D *CLL#$LL#$  ":.H&'K=888OO&'  ":.H2 122222r   )rO   rC   r   spacy.languager   spacy.pipe_analysisr   r   r/   rK   rT   markparametrizerW   rg   r   r   r   <module>rl      sQ      # =%P1,1 
	
3r   