
    hb                     V   S SK JrJrJrJrJrJrJr  S SKJ	r	  SSK
Jr  SSKJrJrJr  SSKJr  \(       a  SSKJr  / SQrS	\\   S
\\   4S jrSSS\S
\\\\   4   4S jr\S.SSS\\   S
\\\\\\\   \4   4   4   4S jjr\S.S\\\\\\\   \4   4   4   S\\   S
S4S jjrg)    )TYPE_CHECKINGDict	ItemsViewIterableListSetUnion)msg   )Errors)DocSpanToken)dot_to_dict)Language)requiresassignsscoresretokenizesvaluesreturnc           
        ^ [        U  Vs0 s H  oS_M     sn5      n[        [        [        S.nUR	                  5        GH  u  mnTS:X  a  U  Vs/ s H  oUR                  S5      (       d  M  UPM     nnU Vs/ s H  oUR                  S5      (       a  M  UPM     nnU(       a5  [        [        R                  R                  SR                  U5      S95      eTU;  aB  SR                  U4S jU  5       5      n[        [        R                  R                  TUS	95      e[        U[        5      (       d&  [        [        R                  R                  TS
95      eUR	                  5        GHl  u  pQUS:X  a  USL a5  [        [        R                  R                  SR                  T5      S
95      eUR	                  5        HM  u  pU	SLd  M  T SU 3n
U
 SSR                  U	5       3n[        [        R                  R                  XS95      e   M  UR!                  S5      (       a)  [        [        R"                  R                  XUSS S95      eUSLaC  T SU 3n
U
 SSR                  U5       3n[        [        R                  R                  XS95      eUT   n[%        X5      (       a  GMH  [        [        R&                  R                  TUS95      e   GM     U $ s  snf s  snf s  snf )a  Validate component attributes provided to "assigns", "requires" etc.
Raises error for invalid attributes and formatting. Doesn't check if
custom extension attributes are registered, since this is something the
user might want to do themselves later in the component.

values (Iterable[str]): The string attributes to check, e.g. `["token.pos"]`.
RETURNS (Iterable[str]): The checked attributes.
T)doctokenspanr   zspan.zspan._., )attrsc              3   V   >#    U  H  oR                  T5      (       d  M  Uv   M      g 7fN)
startswith).0aobj_keys     M/home/james-whalen/.local/lib/python3.13/site-packages/spacy/pipe_analysis.py	<genexpr>!validate_attrs.<locals>.<genexpr>$   s     %QA<<;Paas   )	))objr   )attr_z{}._z._..)r(   solutionN)r'   r(   )r   r   r   r   itemsr    
ValueErrorr   E180formatjoinE181
isinstancedictE182E183endswithE184hasattrE185)r   valuedataobjsr   r(   
span_attrsinvalid_attrsext_attr	ext_valuegoodbadr'   r#   s                @r$   validate_attrsrD      s    8t89D5D**,f+1N64__W5M$6JN+5X:4__Y=W$:JX !3!3$))J:O!3!PQQ$ II%Q%QQMV[[//G=/QRR%&&V[[//W/=>> ;;=KDs{D=$V[[%7%7V]]7=S%7%TUU+0;;='H ,")#hZ8!%a(;'<=();););)TUU ,9 }}S!! !3!3Sb	!3!RSSD !!D6*a01 !3!3!3!LMMw-C3%% !3!3d!3!KLL' ) '@ ME 9
 OXs   K&K+.K+:K0K0nlpr   r(   c                     / / S.nU R                    H\  nU R                  U5      nXR                  ;   a  US   R                  U5        XR                  ;   d  MH  US   R                  U5        M^     U$ )a  Check which components in the pipeline assign or require an attribute.

nlp (Language): The current nlp object.
attr (str): The attribute, e.g. "doc.tensor".
RETURNS (Dict[str, List[str]]): A dict keyed by "assigns" and "requires",
    mapped to a list of component names.
)r   r   r   r   )
pipe_namesget_pipe_metar   appendr   )rE   r(   result	pipe_namemetas        r$   get_attr_inforM   ?   sm     02r#BF^^	  +<<9$$Y/== :%%i0 $ M    )keysrO   c          
         0 0 S.n[        5       n[        U R                  5       GH	  u  pEU R                  U5      nUR	                  UR
                  5        UR	                  UR                  5        U Vs0 s H  ow[        XgS5      _M     snUS   U'   U R                  SU nUR                   V	s0 s H  oS_M     n
n	U
(       a3  U H-  u  pU R                  U5      nUR
                   H  n	SX'   M	     M/     U
R                  5        V	Vs/ s H  u  pU(       a  M  U	PM     snn	US   U'   GM     U Vs0 s H  o[        X5      _M     snUS'   U$ s  snf s  sn	f s  snn	f s  snf )a@  Print a formatted summary for the current nlp object's pipeline. Shows
a table with the pipeline components and why they assign and require, as
well as any problems if available.

nlp (Language): The nlp object.
keys (List[str]): The meta keys to show in the table.
RETURNS (dict): A dict with "summary" and "problems".
)summaryproblemsNrQ   FTrR   r   )set	enumeraterG   rH   updater   r   getattrpipeliner-   rM   )rE   rO   rJ   	all_attrsinamerL   key
prev_pipesannotr   	prev_name	prev_pipe	prev_meta	fulfilledr(   s                   r$   analyze_pipesrb   Q   s[    <F %IS^^,  &&'LP"QDS4(@#@D"Qy$\\"1%
.2mm<mU5Lm<(2$	--i8	&..E&*HO / )3
 +3..*:$
*:&e)E*:$
z4  - CLL)$]355)LF7OM #R<$
 Ms   6E2EEE7E$analysisNc                   [         R                  " S5        SS/U Vs/ s H  o"R                  5       PM     snQnU S   R                  5       n[	        U5       VVVVs/ s H+  u  nu  pgXV/UR                  5        Vs/ s H  oPM     snQPM-     n	nnnn[         R                  " XSSS9  [        S U S   R                  5        5       5      n
[        S	 U S   R                  5        5       5      (       ak  [         R                  " S
U
 S35        U S   R                  5        H9  u  pU(       d  M  [         R                  " SU SSR                  U5       35        M;     g[         R                  " S5        gs  snf s  snf s  snnnnf )zPrint a formatted version of the pipe analysis produced by analyze_pipes.

analysis (Dict[str, Union[List[str], Dict[str, List[str]]]]): The analysis.
keys (List[str]): The meta keys to show in the table.
zPipeline Overview#	ComponentrQ   T)headerdivider	multilinec              3   8   #    U  H  n[        U5      v   M     g 7fr   )lenr!   ps     r$   r%   &print_pipe_analysis.<locals>.<genexpr>   s     C%BSVV%Bs   rR   c              3   $   #    U  H  ov   M     g 7fr    rl   s     r$   r%   rn      s     
4313s   z
Problems ()'z' requirements not met: r   zNo problems found.N)r
   rh   
capitalizer-   rT   r   tablesumanywarnr1   rB   )rc   rO   r[   rg   rQ   rY   nmvbody
n_problemsrZ   problems                r$   print_pipe_analysisr~   t   sE    KK#$;Dd!Cds.."2d!CDF!),224G>G>PQ>PFQQ,
+
1Q
+,>PDQIId44@CXj%9%@%@%BCCJ

4hz*113
444jA./%j1779MDw1TF":499W;M:NOP : 	%& "D+Qs   E8F
=E=F
=F
)typingr   r   r   r   r   r   r	   wasabir
   errorsr   tokensr   r   r   utilr   languager   DEFAULT_KEYSstrrD   rM   rb   r~   rp   rN   r$   <module>r      s   M M M   $ $ " @+8C= +Xc] +\z  c49n1E & +7 	 "3i 	#tCtCy$//0
01 L #'3S%S	4"8899:' s)' 
	'rN   