
    ha              	          S SK r 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/J0r0  SSK1J2r2  Sr3Sr4Sr5\" 5       Rm                  \35      S   r7\" 5       Rm                  \45      S   r8\ " S S\5      5       r9SS.S\
\'   S\\:   S\\   S\4S jjr;SS.S\
\'   S\<S\\   S\4S jjr=S\\:   S\94S  jr>S!\:S"\:S\94S# jr?S\<S\94S$ jr@S%\
\+   S\	\<\4   4S& jrAS' rB\ " S( S)5      5       rC " S* S+\25      rDS, rEg)-    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)registry)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)		SuggesterQ   Nopsdocsr-   returnc                    g N )selfr.   r-   s      P/home/james-whalen/.local/lib/python3.13/site-packages/spacy/pipeline/spancat.py__call__Suggester.__call__S   s        r2   )__name__
__module____qualname____firstlineno__r   r   r
   r   r   r5   __static_attributes__r2   r7   r4   r*   r*   Q   s,    DH Xc] HSM V  r7   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%   rB   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               r4   ngram_suggesterrY   W   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=="""Mr7   	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@   rC   )r   rP   rH   startendr   r   asarrayrF   r   rD   rN   )
r.   rZ   r-   rP   rQ   rR   rT   spanrW   rX   s
             r4   preset_spans_suggesterr`   t   s     {EG99Y		),djj$((34! - 	v  WC!@AM
5zA~E5}E M V37GMr7   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   rY   rb   s    r4   build_ngram_suggesterrc      s    
 ?%00r7   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rangerc   )rd   re   r=   s      r4   build_ngram_range_suggesterri      s"     xA./E ''r7   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.rZ   )r   r`   rk   s    r4   build_preset_spans_suggesterrl      s     )Y??r7   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_rZ   attrallow_overlapTgetterc                 T   > U R                   R                  U[        T5      S  / 5      $ r1   )rP   getrF   )rR   keyattr_prefixs     r4   <lambda>spancat_score.<locals>.<lambda>   s!    399==S5E5G1H"#Mr7   has_annotationc                 "   > TU R                   ;   $ r1   )rP   )rR   ru   s    r4   rw   rx      s    C3994Dr7   )dict
setdefaultr   score_spans)rm   kwargsrv   ru   s     @@r4   spancat_scorer      s    &\FK

C
fcU34
ot,
M &(DEh1&11r7   c                      [         $ r1   )r   r2   r7   r4   make_spancat_scorerr      s    r7   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 r1   )setrangesr3   s    r4   __init___Intervals.__init__   s    er7   c                 ^    [        X5       H  nU R                  R                  U5        M      g r1   )rh   r   add)r3   r?   jes       r4   r   _Intervals.add   s     qAKKOOA r7   c                 R    Uu  p#[        X#5       H  nX@R                  ;   d  M    g   g)NTF)rh   r   )r3   rangr?   r   r   s        r4   __contains___Intervals.__contains__   s)    qAKK  r7   )r   N)	r8   r9   r:   r;   __doc__r   r   r   r<   r2   r7   r4   r   r      s    r7   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
FrP         ?TNg      ?)add_negative_labelrZ   negative_weightrq   max_positive	thresholdscorervocabr(   	suggesternamer   rZ   r   rq   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
)labelsrZ   r   r   r   rq   Nr%   )r   )cfgr   r   r(   r   r   r   
ValueErrorr   E1051format)r3   r   r(   r   r   r   rZ   r   rq   r   r   r   s               r4   r   SpanCategorizer.__init__   sx    f ""(.*
 
"
	"4!9lQ>NV\\00l0KLL ?O!9}r7   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.
rZ   )strr   r   s    r4   ru   SpanCategorizer.key  s     488K())r7   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   )r3   r   s     r4   _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>r7   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   rH   r   stringsr   )r3   r   s     r4   	add_labelSpanCategorizer.add_label(  sk     %%%V[[))KK!!!%(

u%r7   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    r4   r   SpanCategorizer.labels9  s     TXXh'((r7   c                 ,    [        U R                  5      $ )zvRETURNS (List[str]): Information about the component's labels.

DOCS: https://spacy.io/api/spancategorizer#label_data
)rg   r   r   s    r4   
label_dataSpanCategorizer.label_dataA  s     DKK  r7   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   )r3   r?   r   s      r4   
_label_mapSpanCategorizer._label_mapI  s+     *34;;)?@)?XQ)?@@@s   +c                 ~    U R                   (       a  [        U R                  5      S-   $ [        U R                  5      $ )z RETURNS (int): Number of labels.r%   )r   rF   r   r   s    r4   r   SpanCategorizer._n_labelsN  s0     ""t{{#a''t{{##r7   c                 P    U R                   (       a  [        U R                  5      $ g)z8RETURNS (Union[int, None]): Index of the negative label.N)r   rF   r   r   s    r4   _negative_label_i!SpanCategorizer._negative_label_iV  s     ""t''r7   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-   rQ   sumalloc2fpredict)r3   r.   indicesscoress       r4   r   SpanCategorizer.predict^  su     ..::>>.:?? A%ZZ^^++Aq1F  ZZ''8Fr7   
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-   ziprP   rO   rH   )r3   r.   r   suggester_outputr   rR   indexs          r4   set_candidatesSpanCategorizer.set_candidatesm  sq      >>$JJNN>C"#3:OJ(*CIIn%#**		.)001Xa1IJ +  ;r7   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   rq   r   r%   N)
r   rO   r   boolr   _make_span_group_singlelabelrQ   rP   ru   _make_span_group_multilabel)
r3   r.   indices_scoresr   r   offsetr?   rR   	indices_irq   s
             r4   set_annotationsSpanCategorizer.set_annotations  s     )oFA
))I txx'@AMxx'1,&*&G&GF__Q-?$?@!	'		$((# '+&F&FF__Q-?$?@'		$((#
 ooa((F! &r7           )dropsgdlossesrm   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)	predictedrF   ).0egs     r4   	<genexpr>)SpanCategorizer.update.<locals>.<genexpr>  s"     Oh3r||$!;hs   46r,   r   )r|   r   r"   _validate_categoriesanyr   r   r(   r-   rQ   r   r   begin_updateget_lossfinish_update)r3   rm   r   r   r   r   r.   rP   r   backprop_scoreslossd_scoress               r4   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datarQ   numpyrN   rJ   rA   r   onesr   r   rO   rh   int_get_aligned_spansr\   r]   label_r^   nonzeror   r   floatr   r   )r3   rm   r   rP   r   targetnegative_spansr   	label_mapr?   r   spans_indexspans_ir   r\   r]   	gold_spanru   rowknegative_samplesr   
neg_weightr   s                           r4   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~r7   )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%   rb   r   )XY)r   	referencerP   rt   ru   r  rF   rH   _require_labelsxrc   r(   r-   r   rO   rJ   r   
initialize)r3   r  r  r   subbatchr   r   r_   r.   rP   r  s              r4   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 r1   r2   )r3   rm   s     r4   r   $SpanCategorizer._validate_categories(  s    r7   r   c                 ~    UR                  UR                  R                  R                  U R                  / 5      SS9$ )NT)rq   )get_aligned_spans_y2xr  rP   rt   ru   )r3   r   s     r4   r  "SpanCategorizer._get_aligned_spans,  s:    ''LL""488R0 ( 
 	
r7   rR   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   NrB   Fr%   r   r   )r    ru   rU   r(   r-   r   r   r   r  r   r   copyr   infargsortr   rh   rJ   rH   r   r   arrayattrs)r3   rR   r   r   rP   r   r   keepsnegative_scoresrankedspan_filterr?   r  attrs_scoresr\   r]   r   keeps                     r4   r   +SpanCategorizer._make_span_group_multilabel1  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r7   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   rB   r$  r   )rU   r    ru   r(   r-   r   argmaxr   take_along_axisexpand_dimsr   rJ   r   r   logical_andr   r   squeezer'  r   rh   r   rH   r   r   r(  r)  )r3   rR   r   r   rq   r   argmax_scoresr*  r   sort_idxseenrP   r.  r?   r   r\   r]   s                    r4   r   ,SpanCategorizer._make_span_group_singlelabelZ  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r7   )r   r   r(   r   r   r   r   )spancat)r/   N)T)1r8   r9   r:   r;   r   r   r$   r   r   r	   r   r   r   r*   r   r   r
   r  r  r   r   propertyru   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<   r2   r7   r4   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r7   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@  AttributeErrorr8   )r   modules     r4   __getattr__rE    sf    ~(()CD"""	+	+(()CD...
78*,>tfE
FFr7   )FrA  sys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"   utilr#   r   r$   trainable_piper&   spancat_default_config"spancat_singlelabel_default_configDEFAULT_SPANS_KEYfrom_strDEFAULT_SPANCAT_MODEL!DEFAULT_SPANCAT_SINGLELABEL_MODELr*   r  rY   r   r`   rc   ri   rl   r   r   r   r   rE  r2   r7   r4   <module>rY     s    
 !  T T T  V V 8 8 0    ) ) 1   ) 6& "4  ))*@A'J $*H$5$5&%	% !
    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r7   