
    Mipa              	          S SK r S SKJr  S SKJr  S SKJrJrJrJ	r	J
r
JrJrJrJr  S SKrS SKJrJrJrJrJrJr  S SKJrJrJrJr  SSKJrJr  SS	K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*J+r+  SSK,J-r-  SSK.J/r/  Sr0Sr1Sr2\" 5       Rg                  \05      S   r4\" 5       Rg                  \15      S   r5\ " S S\5      5       r6SS.S\	\&   S\
\7   S\\   S\4S jjr8SS.S\	\&   S\9S\\   S\4S jjr:S\
\7   S\64S jr;S \7S!\7S\64S" jr<S\9S\64S# jr=S$\	\*   S\\9\4   4S% jr>S& r?\ " S' S(5      5       r@ " S) S*\/5      rAS+ rBg),    N)	dataclass)partial)	AnyCallableDictIterableListOptionalTupleUnioncast)ConfigModelOps	Optimizerget_current_opsset_dropout_rate)Floats2dInts1dInts2dRagged   )Protocolruntime_checkable)Errors)Language)Scorer)DocSpan	SpanGroup)Examplevalidate_examples)Vocab   )TrainablePipea4  
[model]
@architectures = "spacy.SpanCategorizer.v1"
scorer = {"@layers": "spacy.LinearLogistic.v1"}

[model.reducer]
@layers = spacy.mean_max_reducer.v1
hidden_size = 128

[model.tok2vec]
@architectures = "spacy.Tok2Vec.v2"

[model.tok2vec.embed]
@architectures = "spacy.MultiHashEmbed.v2"
width = 96
rows = [5000, 1000, 2500, 1000]
attrs = ["NORM", "PREFIX", "SUFFIX", "SHAPE"]
include_static_vectors = false

[model.tok2vec.encode]
@architectures = "spacy.MaxoutWindowEncoder.v2"
width = ${model.tok2vec.embed.width}
window_size = 1
maxout_pieces = 3
depth = 4
a&  
[model]
@architectures = "spacy.SpanCategorizer.v1"
scorer = {"@layers": "Softmax.v2"}

[model.reducer]
@layers = spacy.mean_max_reducer.v1
hidden_size = 128

[model.tok2vec]
@architectures = "spacy.Tok2Vec.v2"
[model.tok2vec.embed]
@architectures = "spacy.MultiHashEmbed.v1"
width = 96
rows = [5000, 1000, 2500, 1000]
attrs = ["NORM", "PREFIX", "SUFFIX", "SHAPE"]
include_static_vectors = false

[model.tok2vec.encode]
@architectures = "spacy.MaxoutWindowEncoder.v2"
width = ${model.tok2vec.embed.width}
window_size = 1
maxout_pieces = 3
depth = 4
scmodelc                   >    \ rS rSrSS.S\\   S\\   S\4S jjr	Sr
g)		SuggesterO   Nopsdocsr,   returnc                    g N )selfr-   r,   s      p/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/spacy/pipeline/spancat.py__call__Suggester.__call__Q   s    UX    r1   )__name__
__module____qualname____firstlineno__r   r   r
   r   r   r4   __static_attributes__r1   r6   r3   r)   r)   O   s"    DHXXc]XHSMXVXXr6   r)   r+   r-   sizesr,   r.   c          	         Uc
  [        5       n/ n/ nU  H  nUR                  R                  [        U5      SS9nUR	                  S5      nSnU H  nU[        U5      ::  aV  US [        U5      US-
  -
   n	UR                  UR                  R                  XU-   45      5        XsS   R                  S   -  nU(       d  Mq  US   R                  S:X  a  M   US   R                  5       e   UR                  U5        M     UR                  U5      n
[        U5      S:  a&  [        UR                  R                  U5      U
5      nO$[        UR                  R                  SSS9U
5      nUR                  R                  S:X  d   eU$ )	Nidtype)r$   r   r$   rA   r   r   r   )r   xparangelenreshapeappendhstackshapendim	asarray1ir   vstackzerosdataXd)r-   r<   r,   spanslengthsdocstartslengthsizestarts_sizelengths_arrayoutputs               r3   ngram_suggesterrX   T   s\    {EGs3xs3(Ds3x$%<s3x4!8'<=SVV]]Kt9K+LMN)//!,,uRy~~*;E"IOO;*  	v  MM'*M
5zA~e,m<V37G=="""Mr6   	spans_keyc                   Uc
  [        5       n/ n/ nU  Hl  nSnUR                  U   (       aB  UR                  U    H/  nUR                  UR                  UR                  /5        US-  nM1     UR                  U5        Mn     [        [        UR                  USS95      n[        U5      S:  a  [        UR                  USS9U5      n	U	$ [        UR                  R                  SSS9U5      n	U	$ )Nr   r$   r>   r?   rB   )r   rO   rG   startendr   r   asarrayrE   r   rC   rM   )
r-   rY   r,   rO   rP   rQ   rS   spanrV   rW   s
             r3   preset_spans_suggesterr_   q   s     {EG99Y		),djj$((34! - 	v  WC!@AM
5zA~E5}E M V37GMr6   c                     [        [        U S9$ )zSuggest all spans of the given lengths. Spans are returned as a ragged
array of integers. The array has two columns, indicating the start and end
position.r<   )r   rX   ra   s    r3   build_ngram_suggesterrb      s    
 ?%00r6   min_sizemax_sizec                 F    [        [        XS-   5      5      n[        U5      $ )zSuggest all spans of the given lengths between a given min and max value - both inclusive.
Spans are returned as a ragged array of integers. The array has two columns,
indicating the start and end position.r$   )listrangerb   )rc   rd   r<   s      r3   build_ngram_range_suggesterrh      s"     xA./E ''r6   c                     [        [        U S9$ )zSuggest all spans that are already stored in doc.spans[spans_key].
This is useful when an upstream component is used to set the spans
on the Doc such as a SpanRuler or SpanFinder.rY   )r   r_   rj   s    r3   build_preset_spans_suggesterrk      s     )Y??r6   examplesc                    ^^ [        U5      nSmUS   mUR                  ST T 35        UR                  SS5        UR                  SU4S j5        UR                  SU4S	 j5        [        R                  " U 40 UD6$ )
Nspans_rY   attrallow_overlapTgetterc                 T   > U R                   R                  U[        T5      S  / 5      $ r0   )rO   getrE   )rQ   keyattr_prefixs     r3   <lambda>spancat_score.<locals>.<lambda>   s!    399==S5E5G1H"#Mr6   has_annotationc                 "   > TU R                   ;   $ r0   )rO   )rQ   rt   s    r3   rv   rw      s    C3994Dr6   )dict
setdefaultr   score_spans)rl   kwargsru   rt   s     @@r3   spancat_scorer~      s    &\FK

C
fcU34
ot,
M &(DEh1&11r6   c                      [         $ r0   )r~   r1   r6   r3   make_spancat_scorerr      s    r6   c                   *    \ rS rSrSrS rS rS rSrg)
_Intervals   z2
Helper class to avoid storing overlapping spans.
c                 "    [        5       U l        g r0   )setrangesr2   s    r3   __init___Intervals.__init__   s    er6   c                 ^    [        X5       H  nU R                  R                  U5        M      g r0   )rg   r   add)r2   r>   jes       r3   r   _Intervals.add   s     qAKKOOA r6   c                 R    Uu  p#[        X#5       H  nX@R                  ;   d  M    g   g)NTF)rg   r   )r2   rangr>   r   r   s        r3   __contains___Intervals.__contains__   s)    qAKK  r6   )r   N)	r7   r8   r9   r:   __doc__r   r   r   r;   r1   r6   r3   r   r      s    r6   r   c                      \ rS rSrSr S>SSSSSS\S	.S
\S\\\	\
   \4   \4   S\S\S\S\S\\   S\\   S\\   S\\   S\\   SS4S jjjr\S\4S j5       rS?S jrS\S\4S jr\S\\   4S j5       r\S\	\   4S j5       r\S\\\4   4S j5       r\S\4S j5       r\S\\S4   4S j5       rS \ \
   4S! jr!S"S#.S \ \
   S$\SS4S% jjr"S \ \
   SS4S& jr#S'SSS(.S)\ \$   S*\S+\\%   S,\\\\4      S\\\4   4
S- jjr&S)\ \$   S.\\\4   S\\\4   4S/ jr'SSS0.S1\/ \ \$   4   S2\\(   S3\\	\      SS4S4 jjr)S)\ \$   4S5 jr*S6\$4S7 jr+S8\
S9\,S:\S\-4S; jr. S@S8\
S9\,S:\S\S\-4
S< jjr/S=r0g)ASpanCategorizer   zWPipeline component to label spans of text.

DOCS: https://spacy.io/api/spancategorizer
FrO         ?TNg      ?)add_negative_labelrY   negative_weightrp   max_positive	thresholdscorervocabr'   	suggesternamer   rY   r   rp   r   r   r   r.   c                    / UU
U	UUS.U l         Xl        X0l        X l        X@l        Xl        XPl        U(       d1  U	b-  U	S:  a&  [        [        R                  R                  U	S95      eggg)a}  Initialize the multi-label or multi-class span categorizer.

vocab (Vocab): The shared vocabulary.
model (thinc.api.Model): The Thinc Model powering the pipeline component.
    For multi-class classification (single label per span) we recommend
    using a Softmax classifier as a the final layer, while for multi-label
    classification (multiple possible labels per span) we recommend Logistic.
suggester (Callable[[Iterable[Doc], Optional[Ops]], Ragged]): A function that suggests spans.
    Spans are returned as a ragged array with two integer columns, for the
    start and end positions.
name (str): The component instance name, used to add entries to the
    losses during training.
spans_key (str): Key of the Doc.spans dict to save the spans under.
    During initialization and training, the component will look for
    spans on the reference document under the same key. Defaults to
    `"spans"`.
add_negative_label (bool): Learn to predict a special 'negative_label'
    when a Span is not annotated.
threshold (Optional[float]): Minimum probability to consider a prediction
    positive. Defaults to 0.5. Spans with a positive prediction will be saved
    on the Doc.
max_positive (Optional[int]): Maximum number of labels to consider
    positive per span. Defaults to None, indicating no limit.
negative_weight (float): Multiplier for the loss terms.
    Can be used to downweight the negative samples if there are too many
    when add_negative_label is True. Otherwise its unused.
allow_overlap (bool): If True the data is assumed to contain overlapping spans.
    Otherwise it produces non-overlapping spans greedily prioritizing
    higher assigned label scores. Only used when max_positive is 1.
scorer (Optional[Callable]): The scoring method. Defaults to
    Scorer.score_spans for the Doc.spans[spans_key] with overlapping
    spans allowed.

DOCS: https://spacy.io/api/spancategorizer#init
)labelsrY   r   r   r   rp   Nr$   )r   )cfgr   r   r'   r   r   r   
ValueErrorr   E1051format)r2   r   r'   r   r   r   rY   r   rp   r   r   r   s               r3   r   SpanCategorizer.__init__   sx    f ""(.*
 
"
	"4!9lQ>NV\\00l0KLL ?O!9}r6   c                 2    [        U R                  S   5      $ )zKey of the doc.spans dict to save the spans under. During
initialization and training, the component will look for spans on the
reference document under the same key.
rY   )strr   r   s    r3   rt   SpanCategorizer.key  s     488K())r6   c                 P   SnU R                   R                  S5      (       a  U R                   R                  S5      nOyU R                   R                  S5      (       aY  U R                   R	                  S5      R                  S5      (       a*  U R                   R	                  S5      R                  S5      nUbl  XR
                  :X  a\  U R                  (       dJ  [        [        R                  R                  U R                  U R                   R                  S5      S95      eggg)z<Raise an error if the component can not add any more labels.NnOoutput_layer)r   r   )r'   has_dimget_dimhas_refget_ref	_n_labelsis_resizabler   r   E922r   r   )r2   r   s     r3   _allow_extra_label"SpanCategorizer._allow_extra_label  s    ::d####D)BZZ//DJJ4F4F5

'$-5 ##N3;;DAB>bNN2$$ KK&&DII$**:L:LT:R&S  % 3>r6   labelc                 &   [        U[        5      (       d  [        [        R                  5      eXR
                  ;   a  gU R                  5         U R                  S   R                  U5        U R                  R                  R                  U5        g)zAdd a new label to the pipe.

label (str): The label to add.
RETURNS (int): 0 if label is already present, otherwise 1.

DOCS: https://spacy.io/api/spancategorizer#add_label
r   r   r$   )
isinstancer   r   r   E187r   r   r   rG   r   stringsr   )r2   r   s     r3   	add_labelSpanCategorizer.add_label%  sk     %%%V[[))KK!!!%(

u%r6   c                 2    [        U R                  S   5      $ )zvRETURNS (Tuple[str]): The labels currently added to the component.

DOCS: https://spacy.io/api/spancategorizer#labels
r   )tupler   r   s    r3   r   SpanCategorizer.labels6  s     TXXh'((r6   c                 ,    [        U R                  5      $ )zvRETURNS (List[str]): Information about the component's labels.

DOCS: https://spacy.io/api/spancategorizer#label_data
)rf   r   r   s    r3   
label_dataSpanCategorizer.label_data>  s     DKK  r6   c                 b    [        U R                  5       VVs0 s H  u  pX!_M	     snn$ s  snnf )z(RETURNS (Dict[str, int]): The label map.)	enumerater   )r2   r>   r   s      r3   
_label_mapSpanCategorizer._label_mapF  s+     *34;;)?@)?XQ)?@@@s   +c                 ~    U R                   (       a  [        U R                  5      S-   $ [        U R                  5      $ )z RETURNS (int): Number of labels.r$   )r   rE   r   r   s    r3   r   SpanCategorizer._n_labelsK  s0     ""t{{#a''t{{##r6   c                 P    U R                   (       a  [        U R                  5      $ g)z8RETURNS (Union[int, None]): Index of the negative label.N)r   rE   r   r   s    r3   _negative_label_i!SpanCategorizer._negative_label_iS  s     ""t''r6   r-   c                    U R                  XR                  R                  S9nUR                  R	                  5       S:X  a)  U R                  R                  R                  SS5      nX#4$ U R                  R                  X45      nX#4$ )zApply the pipeline's model to a batch of docs, without modifying them.

docs (Iterable[Doc]): The documents to predict.
RETURNS: The models prediction for each document.

DOCS: https://spacy.io/api/spancategorizer#predict
r+   r   )r   r'   r,   rP   sumalloc2fpredict)r2   r-   indicesscoress       r3   r   SpanCategorizer.predict[  su     ..::>>.:?? A%ZZ^^++Aq1F  ZZ''8Fr6   
candidates)candidates_keyr   c                   U R                  XR                  R                  S9n[        X15       HM  u  pE/ UR                  U'   UR
                   H)  nUR                  U   R                  XVS   US    5        M+     MO     g)aG  Use the spancat suggester to add a list of span candidates to a list of docs.
This method is intended to be used for debugging purposes.

docs (Iterable[Doc]): The documents to modify.
candidates_key (str): Key of the Doc.spans dict to save the candidate spans under.

DOCS: https://spacy.io/api/spancategorizer#set_candidates
r+   r   r$   N)r   r'   r,   ziprO   rN   rG   )r2   r-   r   suggester_outputr   rQ   indexs          r3   set_candidatesSpanCategorizer.set_candidatesj  sq      >>$JJNN>C"#3:OJ(*CIIn%#**		.)001Xa1IJ +  ;r6   c           
         Uu  p4Sn[        U5       H  u  pgX6   R                  n[        [        U R                  S   5      n	U R                  S   S:X  a=  U R                  UUXEXSR                  U   -    U	5      UR                  U R                  '   O;U R                  UUXEXSR                  U   -    5      UR                  U R                  '   XSR                  U   -  nM     g)zModify a batch of Doc objects, using pre-computed scores.

docs (Iterable[Doc]): The documents to modify.
scores: The scores to set, produced by SpanCategorizer.predict.

DOCS: https://spacy.io/api/spancategorizer#set_annotations
r   rp   r   r$   N)
r   rN   r   boolr   _make_span_group_singlelabelrP   rO   rt   _make_span_group_multilabel)
r2   r-   indices_scoresr   r   offsetr>   rQ   	indices_irp   s
             r3   set_annotationsSpanCategorizer.set_annotations|  s     )oFA
))I txx'@AMxx'1,&*&G&GF__Q-?$?@!	'		$((# '+&F&FF__Q-?$?@'		$((#
 ooa((F! &r6           )dropsgdlossesrl   r   r   r   c                p   Uc  0 nUR                  U R                  S5        [        US5        U R                  U5        [	        S U 5       5      (       d  U$ U Vs/ s H  oUR
                  PM     nnU R                  X`R                  R                  S9nUR                  R                  5       S:X  a  U$ [        U R                  U5        U R                  R                  Xg45      u  pU R                  XU45      u  pU	" U5        Ub  U R                  U5        X@R                  ==   U
-  ss'   U$ s  snf )a  Learn from a batch of documents and gold-standard information,
updating the pipe's model. Delegates to predict and get_loss.

examples (Iterable[Example]): A batch of Example objects.
drop (float): The dropout rate.
sgd (thinc.api.Optimizer): The optimizer.
losses (Dict[str, float]): Optional record of the loss during training.
    Updated using the component name as the key.
RETURNS (Dict[str, float]): The updated losses dictionary.

DOCS: https://spacy.io/api/spancategorizer#update
r   zSpanCategorizer.updatec              3   p   #    U  H,  oR                   (       a  [        UR                   5      OS v   M.     g7f)r   N)	predictedrE   ).0egs     r3   	<genexpr>)SpanCategorizer.update.<locals>.<genexpr>  s"     Oh3r||$!;hs   46r+   r   )r{   r   r"   _validate_categoriesanyr   r   r'   r,   rP   r   r   begin_updateget_lossfinish_update)r2   rl   r   r   r   r   r-   rO   r   backprop_scoreslossd_scoress               r3   updateSpanCategorizer.update  s   ( >F$))S)($<=!!(+OhOOOM'/0xx0t8==!#MT*"&**"9"94-"HxA!?s#yyT! 1s   D3spans_scoresc                    Uu  p4[        U R                  R                  R                  UR                  5      U R                  R                  R                  UR
                  5      5      n[        R                  " UR                  UR                  S9nU R                  (       a#  [        R                  " UR                  S   5      nSnU R                  n[        U5       H  u  p0 nX9   R                  n[        UR
                  U	   5       H)  n[!        XS4   5      n[!        XS4   5      nX}-   XU4'   M+     U R#                  U
5       HV  nUR$                  UR&                  4nUU;   d  M#  UU   nUUR(                     nSUUU4'   U R                  (       d  MQ  SWU'   MX     XsR
                  U	   -  nM     U R                  R                  R+                  USS9nU R                  (       a*  [        R,                  " W5      S   nSUUU R.                  4'   XE-
  nU R                  (       a0  [1        [2        U R4                  S   5      nUS:w  a  UW==   U-  ss'   [3        US-  R7                  5       5      nUU4$ )	a;  Find the loss and gradient of loss for the batch of documents and
their predicted scores.

examples (Iterable[Examples]): The batch of examples.
spans_scores: Scores representing the model's predictions.
RETURNS (Tuple[float, float]): The loss and the gradient.

DOCS: https://spacy.io/api/spancategorizer#get_loss
r?   r   r$   r   r   fr   r   )r   r'   r,   to_numpydatarP   numpyrM   rI   r@   r   onesr   r   rN   rg   int_get_aligned_spansr[   r\   label_r]   nonzeror   r   floatr   r   )r2   rl   r   rO   r   targetnegative_spansr   	label_mapr>   r   spans_indexspans_ir   r[   r\   	gold_spanrt   rowknegative_samplesr   
neg_weightr   s                           r3   r   SpanCategorizer.get_loss  s-    %JJNN##EJJ/1H1H1W
 V\\>"""ZZa:NOO	x(EA KhooG5==+,GqDM*'Q$-(,2JCL) - "44R8	 	6+%%c*C!)"2"23A%(F36N....1s+ 9 mmA&&F+ ), ''c':""$}}^<Q??BF#T%;%;;< ?""eTXX.?%@AJS )*j8*hk&&()X~r6   )nlpr   get_examplesr  r   c                   / nUb  U H  nU R                  U5        M     U" 5        Hz  nUcR  UR                  R                  R                  U R                  / 5       H  nU R                  UR
                  5        M      [        U5      S:  d  Mi  UR                  U5        M|     U R                  5         U(       a  U Vs/ s H  ofR                  PM     nn[        S/S9" U5      n	U R                  R                  R                  U	R                  R                  S   U R                   5      n
U R                  R#                  X4U
S9  gU R                  R#                  5         gs  snf )a4  Initialize the pipe for training, using a representative set
of data examples.

get_examples (Callable[[], Iterable[Example]]): Function that
    returns a representative sample of gold-standard Example objects.
nlp (Optional[Language]): The current nlp object the component is part of.
labels (Optional[List[str]]): The labels to add to the component, typically generated by the
    `init labels` command. If no labels are provided, the get_examples
    callback is used to extract the labels from the data.

DOCS: https://spacy.io/api/spancategorizer#initialize
N
   r$   ra   r   )XY)r   	referencerO   rs   rt   r  rE   rG   _require_labelsxrb   r'   r,   r   rN   rI   r   
initialize)r2   r  r  r   subbatchr   r   r^   r-   rO   r  s              r3   r  SpanCategorizer.initialize  s   & #%u%  .B~LL..22488R@DNN4;;/ A8}r!# ! 	#+,8RDD8D,)4T:E

&&u||'9'9!'<dnnMAJJ!!TMQ!7JJ!!# -s    E%c                     g r0   r1   )r2   rl   s     r3   r   $SpanCategorizer._validate_categories%  s    r6   r   c                 ~    UR                  UR                  R                  R                  U R                  / 5      SS9$ )NT)rp   )get_aligned_spans_y2xr  rO   rs   rt   )r2   r   s     r3   r  "SpanCategorizer._get_aligned_spans)  s:    ''LL""488R0 ( 
 	
r6   rQ   r   r   c                 F   [        XR                  S9nUR                  S:X  a  U$ U R                  R                  R                  U5      nU R                  R                  R                  U5      nU R                  S   nU R                  S   nX5:  nUb  [        U[        5      (       d   eU R                  (       ao  [        R                  " USS2U R                  4   5      n[        R                  * USS2U R                  4'   US-  R                  5       n	XSS2U R                  4'   OUS-  R                  5       n	U	SS2US24   n
[        U
5       H  u  pSX{U4'   M     / n[!        UR"                  S   5       H|  nX+S4   nX+S4   n[        X{   5       H\  u  nnU(       d  M  UU R                  :w  d  M!  UR%                  ['        XXR(                  U   S	95        UR%                  X;U4   5        M^     M~     [        R*                  " U5      UR,                  S
'   U$ )z5Find the top-k labels for each span (k=max_positive).r   r   r   r   NrA   Fr$   r   r   )r    rt   rT   r'   r,   r   r   r   r   r   r   copyr   infargsortr   rg   rI   rG   r   r   arrayattrs)r2   rQ   r   r   rO   r   r   keepsnegative_scoresrankedspan_filterr>   r  attrs_scoresr[   r\   r   keeps                     r3   r   +SpanCategorizer._make_span_group_multilabel.  s    #HH-;;!L((0**..))'2HH[)	xx/##lC0000&&"'**VAt7M7M4M-N"O5:YYJq$0001 2+..04Cq$0001 2+..0 LM!12K#K0 %f 1 w}}Q'(AqDMEQ$-C$UX.44D222T#cQ%PQ$++Fa4L9	 / ) !&L 9Hr6   c           
         UR                   S:X  a  [        XR                  S9$ U R                  R                  R                  U5      nU R                  R                  R                  U5      nUR                  SS9n[        R                  " U[        R                  " US5      SS9n[        R                  " UR                  [        S9nU R                  (       a#  [        R                  " XuU R                  :g  5      nU R                   S   nUb'  [        R                  " XvU:  R#                  5       5      nU(       d1  UR#                  5       S-  R%                  5       n	Xi   nXY   nX)   nXy   n['        5       n
[        XR                  S9n/ n[)        UR                  S   5       H{  nX}   (       d  M  X]   nX-S4   nX-S4   nU(       d  UU4U
;   a  M/  U
R+                  UU5        UR-                  Xm   5        UR-                  [/        XUU R0                  U   S95        M}     [        R2                  " U5      UR4                  S	'   U$ )
z$Find the argmax label for each span.r   r"  r$   )axisr?   r   rA   r#  r   )rT   r    rt   r'   r,   r   argmaxr   take_along_axisexpand_dimsr   rI   r   r   logical_andr   r   squeezer&  r   rg   r   rG   r   r   r'  r(  )r2   rQ   r   r   rp   r   argmax_scoresr)  r   sort_idxseenrO   r-  r>   r   r[   r\   s                    r3   r   ,SpanCategorizer._make_span_group_singlelabelW  s    ;;!Sxx00((0**..))'2MMqM)	--E%%i3!
 

9??$7""%%e$:P:P-PQEHH[)	 %%ey.H-Q-Q-STE%--/"4==?H)3M!+I'GOE|#HH-w}}Q'(A8LEqDMEQ$-C 3<4'HHUC( 01LLc#T[[5GHI )  !&L 9Hr6   )r   r   r'   r   r   r   r   )spancat)r.   N)T)1r7   r8   r9   r:   r   r~   r#   r   r   r	   r   r   r   r)   r   r   r
   r  r   r   r   propertyrt   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;   r1   r6   r3   r   r      s    AM $) +.(,&*%(%2AMAM U49f,-x78AM 	AM
 AM !AM AM "%AM  ~AM smAM E?AM "AM 
AMF *S * *s s " )c
 ) ) !DI ! ! ADcN A A $3 $ $ 5d#3  HSM   =IKSMK69K	K$)HSM )d )@ #'-1'7#' 	'
 i ' c5j)*' 
c5j	'R< )<9>vx?O9P<	ue|	<D #'&*$$r8G#445$$ h	$$
 c#$$ 
$$LXg-> 
W 

'' ' 	'
 
'\ #55 5 	5
 5 
5 5r6   r   c                     U S:X  a"  [         R                  " S5      nUR                  $ U S:X  a"  [         R                  " S5      nUR                  $ [	        S[
         SU  35      e)Nmake_spancatzspacy.pipeline.factoriesmake_spancat_singlelabelzmodule z has no attribute )	importlibimport_moduler>  r?  AttributeErrorr7   )r   modules     r3   __getattr__rD    sf    ~(()CD"""	+	+(()CD...
78*,>tfE
FFr6   )Cr@  dataclassesr   	functoolsr   typingr   r   r   r   r	   r
   r   r   r   r   	thinc.apir   r   r   r   r   r   thinc.typesr   r   r   r   compatr   r   errorsr   languager   r   r   tokensr   r   r    trainingr!   r"   r   r#   trainable_piper%   spancat_default_config"spancat_singlelabel_default_configDEFAULT_SPANS_KEYfrom_strDEFAULT_SPANCAT_MODEL!DEFAULT_SPANCAT_SINGLELABEL_MODELr)   r   rX   r   r_   rb   rh   rk   r~   r   r   r   rD  r1   r6   r3   <module>rV     s    !  T T T  V V 8 8 0    ) ) 1  ) 6& "4  ))*@A'J $*H$5$5&%	% !
 Y Y Y
 DH
3- $S	3;C=< BF
3-$'19#.1c 1y 1(# ( ( (@C @I @
2HW- 
2DcN 
2   (Gm GVGr6   