Files
INTUIA/Programa final/spacy/pipeline/__pycache__/attributeruler.cpython-312.pyc
T

151 lines
18 KiB
Plaintext
Raw Normal View History

2026-03-15 13:27:50 +00:00
Ë
>û gÐ6ã
óLddlmZddlmZmZmZmZmZmZm Z m
Z
ddl Z ddl m
Z
ddlmZddlmZddlmZdd lmZdd
lmZdd lmZmZdd lmZmZdd
lmZddl
m Z m!Z!ddl"m#Z#ddl$m%Z%eee
e&e'fefZ(ee'e
e(ee&ffZ)ee'ee
e&e'fe
e&e'fffZ*ee'ee'ee
e&e'fe
e&e'ffffZ+ejXddddidœ¬«dede'de-deefd«Z.deedee'effdZ/e!j`d«d „«Z1Gd!„d"e%«Z2d#e3de e3e3ffd$„Z4y)%é)ÚPath)ÚAnyÚCallableÚDictÚIterableÚListÚOptionalÚTupleÚUnionNé)Úutil)ÚErrors)ÚLanguage)ÚMatcher)ÚScorer)ÚIDS)ÚDocÚSpan)Únormalize_token_attrsÚset_token_attrs)ÚExample)ÚSimpleFrozenListÚregistry)ÚVocabé)ÚPipeÚattribute_rulerFz@scorerszspacy.attribute_ruler_scorer.v1©ÚvalidateÚscorer)Údefault_configÚnlpÚnamerr có4t|j|||¬«S)Nr)ÚAttributeRulerÚvocab)r"r#rr s ú^C:\Users\garci\AppData\Roaming\Python\Python312\site-packages\spacy/pipeline/attributeruler.pyÚmake_attribute_rulerr(sô ˜#Ÿ)™) T°HÀVÔ ÚexamplesÚreturnc ó”d}i}|jtj|dfi|¤Ž«|jtj|dfi|¤Ž«|jtj|dfd|i|¤Ž«|jtj|dfd|i|¤Ž«|jtj|dfi|¤Ž«|S)Ncó.t||«jS©N)ÚgetattrÚkey)ÚtokenÚattrs r'Úmorph_key_getterz/attribute_ruler_score.<locals>.morph_key_getter'sÜu˜#×'r)ÚtagÚposÚmorphÚgetterÚlemma)ÚupdaterÚscore_token_attrÚscore_token_attr_per_feat)r*Úkwargsr3Úresultss r'Úattribute_ruler_scorer>&ò€GØ ‡NN”6×*¨8°UÑE¸ ‡NN”6×*¨8°UÑE¸fÑ ‡N×Ñ ¨'ÑUÐ:JÐUÈfÑð ‡N× 
Ø&6ð
Ø:@ñ
ôð
 ‡NN”6×*¨8°WÑÑ €Nr)cótSr.)r>©r)r'Úmake_attribute_ruler_scorerrA9sä Ð r)c
óFeZdZdZ d%dedœdedededee dd f
d
Z
d&d Z d d d d d œd
ee ge e
fdeedee edeedeedd f dZdedefdZdefdZdZdeeeeeefeeefffdd fdZdeeeeeeeefeeeffffdd fdZ d'de edededd fdZde edd fdZede efd«Z!e"«fde ede#fdZ$e"«fd e#de eddfd!„Z%e"«fd"ee&efde edd fd#„Z'e"«fd"ee&efde eddfd$„Z(y )(r%zÂSet token-level attributes for tokens matched by Matcher patterns.
Additionally supports importing patterns from tag maps and morph rules.
DOCS: https://spacy.io/api/attributeruler
Frr&r#rr r+Ncóž||_||_t|j|¬«|_||_g|_g|_g|_||_y)Create the AttributeRuler. After creation, you can add patterns
with the `.initialize()` or `.add_patterns()` methods, or load patterns
with `.from_bytes()` or `.from_disk()`. Loading patterns will remove
any patterns you've added previously.
vocab (Vocab): The vocab.
name (str): The pipe name. Defaults to "attribute_ruler".
scorer (Optional[Callable]): The scoring method. Defaults to
Scorer.score_token_attr for the attributes "tag", "pos", "morph" and
"lemma" and Scorer.score_token_attr_per_feat for the attribute
"morph".
RETURNS (AttributeRuler): The AttributeRuler component.
DOCS: https://spacy.io/api/attributeruler#init
©rN) r#r&rÚmatcherrÚattrsÚ_attrs_unnormedÚindicesr )Úselfr&r#rr s r'Ú__init__zAttributeRuler.__init__EsHð0ˆŒ ؈Œ
ܘtŸz™z°HÔŒ Ø ˆŒ
Ø!#ˆŒ
Ø+-ˆÔØ"$ˆŒ ؈ r)cózt|j|j¬«|_g|_g|_g|_y)zReset all patterns.rDN)rr&rrErFrGrH©rIs r'ÚclearzAttributeRuler.clearfs.ä˜tŸz™z°D·M±MÔŒ ؈Œ
ØÔ؈ r))r"ÚpatternsÚtag_mapÚ morph_rulesÚ get_examplesr"rNrOrPcó˜|j«|r|j|«|r|j|«|r|j|«yy)aInitialize the attribute ruler by adding zero or more patterns.
Rules can be specified as a sequence of dicts using the `patterns`
keyword argument. You can also provide rules using the "tag map" or
"morph rules" formats supported by spaCy prior to v3.
N)rMÚ add_patternsÚload_from_tag_mapÚload_from_morph_rules)rIrQr"rNrOrPs r'Ú
initializezAttributeRuler.initializemsEð
Œ Ù Ø × Ñ ˜hÔ Ø × "  Ø × &   r)ÚdoccóÆ|j«} |j|«}|j||«|S#t$r }||j||g|«cYd}~Sd}~wwxYw)zÛApply the AttributeRuler to a Doc and set all attribute exceptions.
doc (Doc): The document to process.
RETURNS (Doc): The processed Doc.
DOCS: https://spacy.io/api/attributeruler#call
N)Úget_error_handlerÚmatchÚset_annotationsÚ Exceptionr#)rIrWÚ
error_handlerÚmatchesÚes r'Ú__call__zAttributeRuler.__call__„s`ð×
ð—j‘j “oˆGØ × Ñ   gÔ ˆJøÜò  §¡¨D°3°%¸Ó ;ûð <ús$7· A ÁAÁA ÁA c óÒ|j|dd¬«}|Dcgc],\}}}t|jj|«|||fŒ.}}}}|j «|Scc}}}w)NTF)Ú
allow_missingÚas_spans)rEÚintr&ÚstringsÚsort)rIrWr^Úm_idÚsr_s r'rZzAttributeRuler.match”snØ—,,˜s°$ÀñKRõ
ÙJQ¹J¸DÀ!ÀQŒS×# DÑ
*¨D°!°QÒ 7È'ð ò
ð  ŒØˆùô 
s1A"c ó”|D]I\}}}}t||||¬«}|j|}|j|} || }
t|| |«ŒKy#t$rnt t
j j|jj|j«|D cgc]} | jŒncc} wc} | ¬««dwxYw)zModify the document in place)Úlabel)rNÚspanÚindexN)
rrFrHÚ
IndexErrorÚ
ValueErrorrÚE1001ÚformatrEÚgetrjÚtextr) rIrWr^Úattr_idÚmatch_idÚstartÚendrkrFrlr1Úts r'r[zAttributeRuler.set_annotationsã-4Ñ )ˆGX˜u cܘ˜U C¨xÔ8ˆ—JJ˜'ˆ—LL Ñ)ˆ
ð˜U™ ô
˜D ™K¨Õ /ñ%.5øôò
ô—LL×'Ø!%§¡×!1Ñ!1°$·*±*Ó!=Ù.2Ó3©d¨˜aŸf›f©dùÔóð ð
ð
ús¹AÁACÂB3Â2Ccó”|j«D\}}d|ig}t|«\}}d|vrB|jjj |«}|jj
||d<nD|jjj |d«}|jj
||d<|j |g|«Œ·y)zÿLoad attribute ruler patterns from a tag map.
tag_map (dict): The tag map that maps fine-grained tags to
coarse-grained tags and morphological features.
DOCS: https://spacy.io/api/attributeruler#load_from_morph_rules
ÚTAGÚMORPHN)ÚitemsÚ_split_morph_attrsr&Ú
morphologyÚaddre)rIrOr4rFÚpatternÚ morph_attrsr6s r'rTz AttributeRuler.load_from_tag_map³ð"Ÿ-™-ž/‰JˆCؘs|nˆGÜ!3°EÓ!:Ñ ˆE˜eÑŸ
×-×1°+Ó>Ø!%§¡×!3Ñ!3°EÑ!:gàŸ
×1°%¸±.ÓAØ!%§¡×!3Ñ!3°EÑ!:gØ H‰HgY Õ *r)cóœ|D}||D}||dœg}|||}t|«\}}d|vrE|jjj|d«}|jj||d<nC|rA|jjj|«}|jj||d<|j|g|«Œ¿ŒÉy)a+Load attribute ruler patterns from morph rules.
morph_rules (dict): The morph rules that map token text and
fine-grained tags to coarse-grained tags, lemmas and morphological
features.
DOCS: https://spacy.io/api/attributeruler#load_from_morph_rules
)ÚORTHryrzN)r|r&r}r~re)rIrPr4ÚwordrrFr€r6s r'rUz$AttributeRuler.load_from_morph_rulesÈóˆ# CÔ(Ø$(°Ñ6Ø# Ñ.Ü%7¸Ó%>Ñ"˜ ŸJ™J×1×5°e¸G±nÓEEØ%)§Z¡Z×%7Ñ%7¸Ñ%>E˜' Ø ŸJ™J×1×5°kÓBEØ%)§Z¡Z×%7Ñ%7¸Ñ%>E˜'˜'˜ r)rFrlcóŒtt|j««}|jj |j
j j |«|«|jj|«t|j
|«}|jj|«|jj|«y)aBAdd Matcher patterns for tokens that should be modified with the
provided attributes. The token at the specified index within the
matched span will be assigned the attributes.
patterns (Iterable[List[Dict]]): A list of Matcher patterns.
attrs (Dict): The attributes to assign to the target token in the
matched span.
index (int): The index of the token in the matched span to modify. May
be negative to index from the end of the span. Defaults to 0.
DOCS: https://spacy.io/api/attributeruler#add
N) ÚstrÚlenrFrEr~r&rerGÚappendrrH)rIrNrFrlr0s r'r~zAttributeRuler.addàs‡ô"”#d—jj“/ÓØ ×јŸ×Ó4°hÔ ×Ñ×# EÔ% d§j¡j°%Ó8ˆØ
×ј%Ô Ø ×ј"r)có6|D]}|jdi|¤ŽŒy)acAdd patterns from a list of pattern dicts with the keys as the
arguments to AttributeRuler.add.
patterns (Iterable[dict]): A list of pattern dicts with the keys
as the arguments to AttributeRuler.add (patterns/attrs/index) to
add as patterns.
DOCS: https://spacy.io/api/attributeruler#add_patterns
Nr@)r~)rIrNÚps r'rSzAttributeRuler.add_patternsøsóˆ ˆDH‰H‰Mqr)cóg}tt|j««D]c}i}|jj t |««d|d<|j ||d<|j||d<|j|«Œe|S)zAll the added patterns.rrNrFrl) Úranger†rFrErqr…rGrHr‡)rIÚ all_patternsÚir‰s r'rNzAttributeRuler.patternssðˆ Ü”s˜4Ÿ:™:“Ö'ˆA؈AØ ŸL™L×,¬S°«VÓ4°QÑ7ˆAˆj‰MØ×-¨aÑ0ˆAˆg‰JØŸ a™ˆAˆg‰JØ × Ñ  Õ  Ðr)ÚexcludecóXi}ˆˆfd|d<ˆfd|d<tj|«S)zõSerialize the AttributeRuler to a bytestring.
exclude (Iterable[str]): String names of serialization fields to exclude.
RETURNS (bytes): The serialized object.
DOCS: https://spacy.io/api/attributeruler#to_bytes
có<jj¬«S©N))r&Úto_bytes)rIs€€r'ú<lambda>z)AttributeRuler.to_bytes.<locals>.<lambda>sø€ T§Z¡Z×%8Ñ%8ÀÐ%8Ô%Ir)r&cóBtjj«Sr.)ÚsrslyÚ
msgpack_dumpsrNrLs€r'r“z)AttributeRuler.to_bytes.<locals>.<lambda>sø€¬×(;Ñ(;¸D¿M¹MÔ(Jr)rN)r
r)rIÚ serializes`` r'rzAttributeRuler.to_bytess/ù€ðˆ ÜIˆ Û Jˆ Ü}‰}˜Y¨Ó0r)Ú
bytes_datacóTˆfd}ˆˆfd|dœ}tj||«S)a'Load the AttributeRuler from a bytestring.
bytes_data (bytes): The data to load.
exclude (Iterable[str]): String names of serialization fields to exclude.
returns (AttributeRuler): The loaded object.
DOCS: https://spacy.io/api/attributeruler#from_bytes
cóNjtj|««yr.)rSr•Ú
msgpack_loads)ÚbrIs €r'Ú
load_patternsz0AttributeRuler.from_bytes.<locals>.load_patterns)sø€Ø × Ñ œe×1°!Ó 5r)có>jj|¬«Sr)r&Ú
from_bytes)rIs €€r'r“z+AttributeRuler.from_bytes.<locals>.<lambda>-sø€˜tŸz™z×4°QÀÐHr)©r&rN)r
)rIr˜rÚ deserializes` ` r'zAttributeRuler.from_bytess/ù€ôIØ
ˆ ô
˜
 K°Ôˆ r)ÚpathcóNˆˆfdˆfddœ}tj||«y)zôSerialize the AttributeRuler to disk.
path (Union[Path, str]): A path to a directory.
exclude (Iterable[str]): String names of serialization fields to exclude.