
    iR                     Z   d dl Z d dlmZ d dlmZ d dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZ d dlmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZm Z  d dl!m"Z" dd	l#m$Z$ dd
l%m&Z& ddl'm(Z( ddl)m*Z* erddl+m,Z, ddl-m.Z. ddl/m0Z0  ed      Z1eee
e1   ge
ee1      f   e"f   Z2eede3ge
d   f   e"f   Z4eedgeee	e3ef   gdf   ef   f   e"f   Z5dee   de	e3ef   dee3   fdZ6 edd      Z7 edd      Z8 e9       ddddede
e3   de3de:de;e   f
d Z<dd!d"d#ded$e	e3ef   d%ee3   de3de
e3   de	e3ef   fd&Z=de>dee3   fd'Z? G d( d)e      Z@ G d* d+e      ZA G d, d-e3e      ZB ed./      ZCeeBeCf   ZDee@ef   ZEeeAeef   ZFee@eAe3eGeHe>e:f   ZIe&d0   ZJ G d1 d2e      ZK G d3 d4e      ZL G d5 d6e      ZM G d7 d8e      ZN G d9 d:e      ZO G d; d<e      ZP G d= d>e      ZQ G d? d@e      ZR G dA dBe      ZSeOeNeQeRdCZT G dD dEe      ZU G dF dGe      ZV G dH dIe      ZW G dJ dKe      ZXy)L    N)defaultdict)Enum)TYPE_CHECKINGAnyCallableDictIterableListOptionalTupleTypeTypeVarUnion)	BaseModel
ConfigDictField
StrictBoolStrictFloat	StrictInt	StrictStrValidationErrorconstrcreate_modelfield_validator)ConfigValidationErrorModel	Optimizer)Promise   )NAMES)Literal)Lookups)is_cython_func)Language)Example)VocabItemTr$   r%   schemaobjreturnc                    	  | di | g S # t         $ r}|j                         }t        t              }|D ]c  }dj	                  |j                  dg       D cg c]  }t        |       nc c}w c}      }||   j                  |j                  d             e |j                         D 	cg c]  \  }}	d| ddj	                  |	        nc c}	}w c}	}cY d}~S d}~ww xY w)	zValidate data against a given pydantic schema.

    obj (Dict[str, Any]): JSON-serializable data to validate.
    schema (pydantic.BaseModel): The schema to validate against.
    RETURNS (List[str]): A list of error messages, if available.
    z -> locmsg[z] z, N )	r   errorsr   listjoingetstrappenditems)
r(   r)   er0   dataerrorperr_locr,   r-   s
             ^/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/spacy/schemas.pyvalidater=   6   s    	J	 J4  	3Ekk599UB3G"Ha3q6"H"HIGM  5!12	3 =AJJLIS!C5499S>*+IIIJs4   	 	C%AC A+*AC /!C
C C% C%forbidTextraarbitrary_types_allowedArgModel)excludenamestrictfuncrC   rD   rE   c                6   i }	 t        j                  |       }d}|j
                  j                         D ]  }|j                  |v r|j                  |j                  k(  rd}.|j                  |j                  k7  r|j                  nt        }t        |       rdnd}	|j                  |j                  k7  r|j                  n|	}
||
f||j                  <    |xr | }|rt        nt        |d<   t        |fi |S # t        $ r t        |t              cY S w xY w)a  Generate a pydantic model for function arguments.

    func (Callable): The function to generate the schema for.
    exclude (Iterable[str]): Parameter names to ignore.
    name (str): Name of created model class.
    strict (bool): Don't allow extra arguments if no variable keyword arguments
        are allowed on the function.
    RETURNS (type[BaseModel]): A pydantic model.
    )
__config__FTN.rH   )inspect	signature
ValueErrorr   ArgSchemaConfigExtra
parametersvaluesrD   kindVAR_KEYWORD
annotationemptyr   r#   defaultArgSchemaConfig)rF   rC   rD   rE   sig_argssighas_variableparamrQ   default_emptyrS   	is_stricts               r<   get_arg_modelr[   Q   s     HC%
 L&&( 5:: ::***  L).)9)9U[[)HU%%c
 !/t 4##(==EKK#?%--] *G4!5" +|+I09_?SH\)))1  C D-ABBCs   C; ;DD )get_examplesnlp)sectionrD   rC   settingsr_   c                    t        | |d      }	 |j                  |      j                         S # t        $ r2}|sdnd| }d| d}t	        ||j                         ||      dd}~ww xY w)	a  Validate initialization settings against the expected arguments in
    the method signature. Will parse values if possible (e.g. int to string)
    and return the updated settings dict. Will raise a ConfigValidationError
    if types don't match or required values are missing.

    func (Callable): The initialize method of a given component etc.
    settings (Dict[str, Any]): The settings from the respective [initialize] block.
    section (str): Initialize section, for error message.
    name (str): Name of the block in the section.
    exclude (Iterable[str]): Parameter names to exclude from schema.
    RETURNS (Dict[str, Any]): The validated settings.
    InitArgModel)rC   rD   
initializezinitialize.z-Error validating initialization settings in [])titler0   configparentN)r[   model_validate
model_dumpr   r   r0   )	rF   r`   r_   rD   rC   r(   r7   blockre   s	            r<   validate_init_settingsrk      s~    ( 4~FF$$X.99;; $+;wi1H?waH#
8D
	s   / 	A*-A%%A*c                    d }t        | t              rUg }| D ]L  }t        |t              r)|j                         D ci c]  \  }} ||      | }}}|j	                  |       N |} t        t        d| i      S c c}}w )Nc                 \    t        | t              r| t        t              k  r	t        |    S | S N)
isinstanceintlenr    )ks    r<   <lambda>z(validate_token_pattern.<locals>.<lambda>   s!    Jq#$61s5z>a q     pattern)ro   r1   dictr6   r5   r=   TokenPatternSchema)r)   get_key	convertedru   rr   vs         r<   validate_token_patternr{      s    PG#t	 	&G'4(5<]]_ETQ71:q=EEW%	& &C(899 Fs   A;c                      e Zd ZU  edd      Zeeed f      ed<    edd      Z	ee
e      ed<    edd      Zee
e      ed<    edd	      Zee
e      ed
<    edd      Zee
e      ed<    edd      Zee
e      ed<    edd      Zeeed f      ed<    edd      Zeeed f      ed<    edd      Zeeed f      ed<    edd      Zeeed f      ed<    edd      Zeeed f      ed<    edd      Zeeed f      ed<    edd      Zeeed f      ed<    edd      Zeeed f      ed<    edd      Zeeed f      ed <    edd!      Zeeed f      ed"<    ed#d$%      Z ed&d'(      ed)               Zy)*TokenPatternStringNregexaliasREGEXinINnot_inNOT_IN	is_subset	IS_SUBSETis_supersetIS_SUPERSET
intersects
INTERSECTSfuzzyFUZZYfuzzy1FUZZY1fuzzy2FUZZY2fuzzy3FUZZY3fuzzy4FUZZY4fuzzy5FUZZY5fuzzy6FUZZY6fuzzy7FUZZY7fuzzy8FUZZY8fuzzy9FUZZY9r>   Tr@   populate_by_name*beforemodec                      |t        d      |S NzNone / null is not allowedrK   clsrz   s     r<   raise_for_nonez!TokenPatternString.raise_for_none        99::rt   )__name__
__module____qualname__r   r   r   r   r   __annotations__r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   model_configr   classmethodr   r/   rt   r<   r}   r}      sv   >CDPW>XE8E)%99:;X$)$d$;Bi!;(-d((CFHT)_%C+0[+IIxY(I-24}-MK$y/*M,1$l,KJi)K>CDPW>XE8E)%99:;X?DH@FHU9&::;<  @EH@FHU9&::;<  @EH@FHU9&::;<  @EH@FHU9&::;<  @EH@FHU9&::;<  @EH@FHU9&::;<  @EH@FHU9&::;<  @EH@FHU9&::;<  @EH@FHU9&::;<  HtDLSx(  )rt   r}   c                   V   e Zd ZU  edd      Zee   ed<    edd      Zee	e
      ed<    edd      Zee	e
      ed<    edd	      Zee	e
      ed
<    edd      Zee	e
      ed<    edd      Zee	e
      ed<    edd      Zeee
ef      ed<    edd      Zeee
ef      ed<    edd      Zeee
ef      ed<    edd      Zeee
ef      ed<    edd      Zeee
ef      ed<    edd      Zeee
ef      ed<    edd      Z edd       ed!               Zy)"TokenPatternNumberNr~   r   r   r   r   r   r   r   r   r   r   r   r   z==EQz!=NEQz>=GEQz<=LEQ>GT<LTr>   Tr   r   r   r   c                      |t        d      |S r   r   r   s     r<   r   z!TokenPatternNumber.raise_for_none   r   rt   )r   r   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r/   rt   r<   r   r      s   !&t7!;E8I;$)$d$;Bi!;(-d((CFHT)_%C+0[+IIxY(I-24}-MK$y/*M,1$l,KJi)K27D2IBy+-./I38T3JC%	;./	0J38T3JC%	;./	0J38T3JC%	;./	0J27C2HBy+-./H27C2HBy+-./HHtDLSx(  )rt   r   c                   v    e Zd ZU  ed      Zeed<    ed      Zeed<    ed      Zeed<    ed      Zeed<   y	)
TokenPatternOperatorSimple+plusr   star?question!exclamationN)	r   r   r   r   r   r   r   r   r   r/   rt   r<   r   r      s:    nD)$nD)$#C.Hi(&s^K+rt   r   z#^(\{\d+\}|\{\d+,\d*\}|\{\d*,\d+\})$)ru   )r\   IOBr   r         c                   N   e Zd ZU dZee   ed<   dZee   ed<   dZee   ed<   dZ	ee   ed<   dZ
ee   ed<   dZee   ed<   dZee   ed<   dZee   ed	<   dZee   ed
<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZ ee   ed<   dZ!ee   ed<   dZ"ee   ed<   dZ#ee   ed<   dZ$ee   ed<   dZ%ee   ed<   dZ&ee   ed<   dZ'ee   ed <   dZ(ee   ed!<   dZ)ee   ed"<   dZ*ee   ed#<   dZ+ee   ed$<   dZ,ee-   ed%<    e.dd&'      Z/ee0e1e2f      ed(<    e3d)d*d+ ,      Z4 e5d-d./      e6d0               Z7y)1TokenPatternNorthtextlowerpostagmorphdeplemmashapeent_typeent_iobent_id	ent_kb_idnormlengthspacyis_alphais_asciiis_digitis_loweris_upperis_titleis_punctis_space
is_bracketis_quoteis_left_punctis_right_punctis_currencyis_stopis_sent_start
sent_startlike_numlike_url
like_emailop_r   
underscorer>   Tc                 "    | j                         S rn   )upper)values    r<   rs   zTokenPattern.<lambda>1  s    ekkm rt   )r@   r   alias_generatorr   r   r   c                      |t        d      |S r   r   r   s     r<   r   zTokenPattern.raise_for_none4  r   rt   )8r   r   r   r   r   StringValuer   r   r   r   r   r   r   r   r   r   r   IobValuer   r   r   r   NumberValuer   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   TokenPatternOperatorr   r   r   r   UnderscoreValuer   r   r   r   r   r/   rt   r<   r   r     su   "&D(;
&"&D(;
&#'E8K '!%C+	%!%C+	%#'E8K '!%C+	%#'E8K '#'E8K '&*Hh{#*"&GXh&$(FH[!('+Ix$+"&D(;
&$(FH[!("&E8J&%)Hhz")%)Hhz")%)Hhz")%)Hhz")%)Hhz")%)Hhz")%)Hhz")%)Hhz")'+J$+%)Hhz")*.M8J'.+/NHZ(/(,K*%,$(GXj!(*.M8J'.'+J$+%)Hhz")%)Hhz")'+J$+)-B%&-=B4s=SJi89:S3L Sx(  )rt   r   c                   D    e Zd ZU  edd      Zee   ed<    ed      Z	y)rw   .r   )
min_lengthru   r>   r@   N)
r   r   r   r   ru   r
   r   r   r   r   r/   rt   r<   rw   rw   <  s"    "'":GT,:H-Lrt   rw   c                   b   e Zd ZU  edd      Zeed<    edd      Zeed<    edd      Zeed<    ed	d
      Z	eed<    edd      Z
eed<    eg d      Zee   ed<    eg d      Zee   ed<    ed	d      Zeed<    ed	d      Zeed<    ed	d      Zeed<    ed	d      Zeed<    ed	d      Zeed<    edd      Zeeee   eeeef      f      ed<    ei d       Zeeef   ed!<    ei d"      Zeeee   f   ed#<    ei d$      Zeeef   ed%<    ed	d&      Zeed'<   y)(ModelMetaSchema.z#Two-letter language code, e.g. 'en're   langz
Model namerD   zModel versionversionr\   z#Compatible spaCy version identifierspacy_versionr   z9Name of parent spaCy package, e.g. spacy or spacy-nightlyparent_packagezIAdditional Python package dependencies, used for the Python package setuprequirementszNames of pipeline componentspipelinezModel descriptiondescriptionzModel licenselicensezModel author nameauthorzModel author emailemailzModel author URLurlNzTraining data sourcessourceszIncluded word vectorsvectorsz)Component labels, keyed by component namelabelszAccuracy and speed numbersperformancezCommit of spaCy version usedspacy_git_version)r   r   r   r   r  r   r   rD   r  r  r  r  r
   r	  r
  r  r  r  r  r  r   r   r   r4   r  r   r  r  r  r/   rt   r<   r  r  E  s}   C'LMD)MC|4D)4s/:GY:$R/TUM9U %g5p qNIq$)"4  %AL$y/  A %b0N OHd9oO"2-@AKAr9GY9b(;<FI<R';<E9<2%78C8FKDXoFpGXeDOT$sCx.-AABCp#B.EFGT#s(^F#(3^#_FDd3i _"'2N"OKc3hO#(3Q#RyRrt   r  c                      e Zd ZU  edd      Zeed<    edd      Zeed<    edd      Ze	ed<    edd	      Z
eed
<    edd      Zeed<    edd      Zeed<    edd      Zeed<    edd      Zeed<    edd      Zee   ed<    edd      Zee   ed<    edd      Zeed<    edd      Zeeeeeef      f   ed<    edd      Zeed<    edd      Zeed<    edd      Zee   ed <    edd!      Zee   ed"<    edd#      Z ee!d$gd$f      ed%<    edd&      Z"ee!d$eee#f   gd'f      ed(<    e$d)d*+      Z%y'),ConfigSchemaTraining.z"Path in the config to the dev datar  
dev_corpus'Path in the config to the training datatrain_corpusBatcher for the training databatcherDropout ratedropoutzBHow many steps to continue without improvement in evaluation scorepatience%Maximum number of epochs to train for
max_epochsz+Maximum number of update steps to train for	max_stepsz-How often to evaluate during training (steps)eval_frequencyzRandom seedseedz$Memory allocator when running on GPUgpu_allocatorz,Whether to divide the batch up into substepsaccumulate_gradientz<Scores to report and their weights for selecting final modelscore_weightsThe optimizer to use	optimizerz%The logger to track training progressloggerz=Pipeline components that shouldn't be updated during trainingfrozen_componentsz?Pipeline components that should set annotations during trainingannotating_componentszPOptional callback to modify nlp object after training, before it's saved to diskr$   before_to_diskzDOptional callback that is invoked at the start of each training stepNbefore_updater>   Tr?   )&r   r   r   r   r  r   r   r  r  Batcherr  r   r  r   r  r   r!  r"  r   r#  r$  r%  r   r   r'  r   r(  Loggerr)  r
   r4   r*  r+  r   r,  r   r   r   r/   rt   r<   r  r  c  s   !#-QRJ	R#C/XYL)YS(GHGWH N;G[;+opHip!#-TUJ	U ,YZIyZ %c1` aNIa %c ?D(9
?).s:`)aM8I&a%*36d%eeNSTW  `^  O_M4	8E+y2H,I#JJK  _ ,BCIyC3&MNFFN#(4s#ttCyt',S8y'z49zCH  Ug  DhNHXzlJ&>?@  hLQRU  ^d  MeM8Hj$sCx.%A4%GHI  e HdKLrt   r  c                      e Zd ZU  edd      Zeed<    edd      Zee   ed<    edd      Z	ee   ed<    edd	      Z
eed
<    edd      Zeeed   ged   f      ed<    edd      Zeedgdf      ed<    edd      Zeedgdf      ed<    edd      Zee   ed<    edd      Zeed<    edd      Zy)ConfigSchemaNlp.zThe base language to user  r  z%The pipeline component names in orderr	  z)Pipeline components to disable by defaultdisabledzThe tokenizer to use	tokenizerz@Optional callback to modify Language class before initializationr$   before_creationz\Optional callback to modify nlp object after creation and before the pipeline is constructedafter_creationzHOptional callback to modify nlp object after the pipeline is constructedafter_pipeline_creationzDefault batch size
batch_sizezVectors implementationr  r>   Tr?   N)r   r   r   r   r  r   r   r	  r
   r1  r2  r   r3  r   r   r4  r5  r6  rp   r  r   r   r/   rt   r<   r0  r0  |  s    C'ABD)B %c1X YHd9oY %c1\ ]Hd9o]+ABIxBPUVY  bd  QeOXhZ(8'94
;K'KLM  eCH  Us  DtNHXzlJ&>?@  tLQRU  ^h  MiXh
|Z/G&HI  i %c1E FJFc)ABGXB HdKLrt   r0  c                       e Zd Z ed      Zy)ConfigSchemaPretrainEmptyr>   r   N)r   r   r   r   r   r/   rt   r<   r8  r8    s    H-Lrt   r8  c                   h   e Zd ZU  edd      Zeed<    edd      Zeed<    edd      Z	e
e   ed<    edd	      Ze
e   ed
<    edd      Zeed<    edd      Zeed<    edd      Zeed<    edd      Zeed<    edd      Zeed<    edd      Zedegef   ed<    edd      Zy)ConfigSchemaPretrain.r  r  r  r  r  zASaving additional temporary model after n batches within an epochn_save_everyz Saving model after every n epochn_save_epochr&  r'  r  corpusr  r  z'Component to find the layer to pretrain	componentz(Layer to pretrain. Whole model if empty.layerz2A function that creates the pretraining objective.r&   	objectiver>   Tr?   N)r   r   r   r   r  r   r   r  r   r;  r   r<  r'  r   r=  r   r  r-  r>  r4   r?  r@  r   r   r   r   r/   rt   r<   r:  r:    s    !#-TUJ	U N;G[;(-c9|(}L(9%}(-c9[(\L(9%\ ,BCIyCc)RSFISS(GHGWH3&OPIsPs"LME3M38Dx3yIx%(%/0y HdKLrt   r:  c                   l   e Zd ZU  edd      Zee   ed<    edd      Zee	   ed<    edd      Z
ee   ed<    edd	      Zee   ed
<    edd      Zeeef   ed<    edd      Zeeeeef   f   ed<    edd      Zeedgdf      ed<    edd      Zeedgdf      ed<    edd      Zy)ConfigSchemaInit.z&Path to JSON-formatted vocabulary filer  
vocab_dataz-Vocabulary lookups, e.g. lexeme normalizationlookupszPath to vectorsr  z"Path to pretrained tok2vec weightsinit_tok2vecz0Arguments to be passed into Tokenizer.initializer2  zYArguments for TrainablePipe.initialize methods of pipeline components, keyed by component
componentsz<Optional callback to modify nlp object before initializationr$   before_initz;Optional callback to modify nlp object after initialization
after_initr>   Tr?   N)r   r   r   r   rC  r   r   r   rD  r"   r  rE  r2  r   r   rF  rG  r   rH  r   r   r/   rt   r<   rB  rB    s   &+C7_&`J#`!&s2a!bGXgb#(4E#FGXi F(-c9](^L(9%^&+C7i&jItIsN#j8=c  Je  9fJYY^ 445  f@Ec  RP  AQK(J<#;<=  Q?DS  QN  @OJ:,
":;<  O HdKLrt   rB  c                       e Zd ZU eed<   eed<   i Zeee	f   ed<   e
ee
eef   f   ed<   e
eef   ed<   eed<    edd	      Zy
)ConfigSchematrainingr^   pretrainingrF  corporarc   allowTr?   N)r   r   r   r  r   r0  rL  r   r:  r8  r   r4   r   ReaderrB  r   r   r/   rt   r<   rJ  rJ    s]    ""	JLK+-FFGLS$sCx.())#v+  GTJLrt   rJ  )r^   rK  rL  rc   c                   "    e Zd ZU eed<   eed<   y)RecommendationTrfItemrD   size_factorN)r   r   r   r4   r   rp   r/   rt   r<   rQ  rQ    s    
Irt   rQ  c                   "    e Zd ZU eed<   eed<   y)RecommendationTrf
efficiencyaccuracyN)r   r   r   rQ  r   r/   rt   r<   rT  rT    s    %%##rt   rT  c                   D    e Zd ZU dZee   ed<   dZee   ed<   dZ	e
ed<   y)RecommendationSchemaNword_vectorstransformerThas_letters)r   r   r   rY  r   r4   r   rZ  rT  r[  boolr/   rt   r<   rX  rX    s*    "&L(3-&/3K+,3Krt   rX  c            	          e Zd ZU dZ edd      Zeeee	f      e
d<    edd      Zeeeeeeef   f         e
d<    edd      Zeeeeef         e
d	<    ed
d      Zee
d<    edd      Zeeeeeeeeef   f      f      e
d<    ed
d      Zeeeeeef   f      e
d<    eddd      Zeeeef      e
d<    edd      Zeeeeeeef      f      e
d<    edd      Zeeeeeeef      f      e
d<   y)DocJSONSchemazB
    JSON/dict format for JSON representation of Doc objects.
    Nz+Categories with corresponding probabilitiesr  catszInformation on entitiesentsz+Indices of sentences' start and end indicessents.zDocument textr   z2Span information - end/start indices, label, KB IDspansz*Token information - ID, start, annotationstokensz4Any custom data stored in the document's _ attributer   )re   r   underscore_docz1Any custom data stored in the token's _ attributeunderscore_tokenz0Any custom data stored in the span's _ attributeunderscore_span)r   r   r   __doc__r   r_  r   r   r   r   r   r`  r
   r   r   ra  r   rb  rc  rd  r   re  rf  r/   rt   r<   r^  r^    s    49A4D(4	;./
0  JO-JD(4Yi.B(CCDE
F  9>A9E8Di2345  C7D)7 	dNO 
8YT)U9i3G-H"HIJJK P BG?BFDiy)';!<<=>  6;D6NHT)S.12 
 OTGOhtItDC4H/I$IJK  NSFNOXd9d4	33G.H#HIJ rt   r^  )YrI   collectionsr   enumr   typingr   r   r   r   r	   r
   r   r   r   r   r   pydanticr   r   r   r   r   r   r   r   r   r   r   	thinc.apir   r   r   thinc.configr   attrsr    compatr!   rD  r"   utilr#   languager$   rK  r%   vocabr&   r'   r-  r4   rO  r.  r=   rT   rL   tupler\  typer[   rk   r1   r{   r}   r   r   TokenPatternOperatorMinMaxr   r   r   rp   floatr   r   r   rw   r  r  r0  r8  r:  rB  rJ  CONFIG_SCHEMASrQ  rT  rX  r^  r/   rt   r<   <module>rx     sK    #        > =       "! 	
(5/*HT%[,AABGK
L	xS)8I+>>?H	I	xeHd38n5Et5K,Lh,V&WWXZaa	bJT)_ J4S> Jd3i J, 8TJ!$O  #W+*
+* c]+* 	+*
 +* 
)_+*d "4
38n c]	
  c] 
#s(^D
: 
:c 
:+ +\ 0,d , $,RS  79SST &	12&	;>?*CeT4G 0129 2j. .Si S<L9 L2Li L .	 .L9 L"Ly LK9 K $'"	I 
$	 $
9 I rt   