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

174 lines
15 KiB
Plaintext
Raw Normal View History

2026-03-15 13:27:50 +00:00
Ë
=û g+ã óÔddlmZddlmZddlmZmZmZmZm Z ddl
Z
ddl m Z ddl
mZddlmZdd lmZmZmZmZe«Zdd
ed eed ed
dfdZGdde«ZGdd«Zy)é)Ú OrderedDict)ÚPath)ÚAnyÚDictÚListÚOptionalÚUnionN)Ú BloomFilteré)ÚErrors)Ú
get_string_id)ÚSimpleFrozenDictÚ ensure_pathÚload_language_dataÚregistryÚlangÚtablesÚstrictÚreturnÚLookupscóÆt«}|tjvrK|rGt|«dkDr9t t
j jdj|«|¬««|Stjj|«}|D]U}||vr/|r*t t
j j||¬««i}nt||«}|j||«ŒW|S)aLoad the data from the spacy-lookups-data package for a given language,
if available. Returns an empty `Lookups` container if there's no data or if the package
is not installed.
lang (str): The language code (corresponds to entry point exposed by
the spacy-lookups-data package).
tables (List[str]): Name of tables to load, e.g. ["lemma_lookup", "lemma_exc"]
strict (bool): Whether to raise an error if a table doesn't exist.
RETURNS (Lookups): The lookups container containing the loaded tables.
rz, )Útabler) rrÚlookupsÚlenÚ
ValueErrorr ÚE955ÚformatÚjoinÚgetrÚ add_table)rrrrÚdatarÚ
language_datas úNC:\Users\garci\AppData\Roaming\Python\Python312\site-packages\spacy/lookups.pyÚ load_lookupsr$ô‹i€GØ ”8× ”c˜&“k AœVŸ[™[×/°d·i±iÀÓ6GÈdÐ ˆÜ × Ñ × Ñ  Ó %€DÛˆØ ˜Ñ ÙÜ ¤§¡×!3Ñ!3¸%ÀdÐ!3Ó!KÓ‰Mä.¨t°E©{Ó;ˆMØ×ј% Õð €Nócó
eZdZdZeddedeeddfd«ZddeedeeddfdZ de
ee fd e ddfd
Z
de
ee fd e ddfd Zde
ee fde fd Zdde
ee fd
ee de fdZde
ee fdefdZdefdZdeddfdZy)ÚTablez®A table in the lookups. Subclass of builtin dict that implements a
slightly more consistent and unified API.
Includes a Bloom filter to speed up missed lookups.
Nr!Únamercó:||¬«}|j|«|S)zÅInitialize a new table from a dict.
data (dict): The dictionary.
name (str): Optional table name for reference.
DOCS: https://spacy.io/api/lookups#table.from_dict
©r()Úupdate)Úclsr!r(Úselfs r#Ú from_dictzTable.from_dict3sñ˜Œ~ˆØ ؈ r%cóìtj|«||_d|_|t t |«d«n |j}t
j|«|_|r|j|«yy)zÍInitialize a new table.
name (str): Optional table name for reference.
data (dict): Initial data, used to hint Bloom Filter.
DOCS: https://spacy.io/api/lookups#table.init
g€„.ANr )
rÚ__init__r(Ú default_sizeÚmaxrr
Úfrom_error_rateÚbloomr+)r-r(r!Úsizes r#r0zTable.__init__@sdô ×јTÔˆŒ àˆÔØ$(Ð$4Œs”3t“9˜aÔ ¸$×:KÑ:KˆÜ ×ÓŒ
Ù Ø K‰K˜Õ ð r%ÚkeyÚvaluecó~t|«}tj|||«|jj |«y)z‡Set new key/value pair. String keys will be hashed.
key (str / int): The key to set.
value: The value to set.
N)r
rÚ __setitem__r4Úadd©r-r6r7s r#r9zTable.__setitem__Qs0ô ˜ ˆÜ×Ñ  c¨5Ô
r%có|||<y)z«Set new key/value pair. String keys will be hashed.
Same as table[key] = value.
key (str / int): The key to set.
value: The value to set.
r;s r#Úsetz Table.set[s
ðˆˆSŠ r%cóDt|«}tj||«S)z‰Get the value for a given key. String keys will be hashed.
key (str / int): The key to get.
RETURNS: The value.
)r
rÚ __getitem__©r-r6s r#r@zTable.__getitem__ds!ô ˜ ˆÜ×& t¨SÓ1r%ÚdefaultcóFt|«}tj|||«S)z·Get the value for a given key. String keys will be hashed.
key (str / int): The key to get.
default: The default value to return.
RETURNS: The value.
)r
rr)r-r6rBs r#rz Table.getms!ô˜ ˆÜ˜t S¨'Ó2r%cóbt|«}||jvrytj||«S)z®Check whether a key is in the table. String keys will be hashed.
key (str / int): The key to check.
RETURNS (bool): Whether the key is in the table.
F)r
r4rÚ __contains__rAs r#rEzTable.__contains__ws0ô ˜ ˆà d—j‘jÑ ØÜרcÓ2r%cóª|jt|j««|jj «dœ}t j |«S)z”Serialize table to a bytestring.
RETURNS (bytes): The serialized table.
DOCS: https://spacy.io/api/lookups#table.to_bytes
)r(Údictr4)r(rGÚitemsr4Úto_bytesÚsrslyÚ
msgpack_dumps)r-r!s r#rIzTable.to_bytesƒsCð—I‘IܘŸÓ—Z‘Z×
ˆô
×" (r%Ú
bytes_datacóìtj|«}|jdi«}|d|_t «j |d«|_|j«|j|«|S)z¿Load a table from a bytestring.
bytes_data (bytes): The data to load.
RETURNS (Table): The loaded table.
DOCS: https://spacy.io/api/lookups#table.from_bytes
rGr(r4) rJÚ
msgpack_loadsrr(r
Ú
from_bytesr4Úclearr+)r-rLÚloadedr!s r#rOzTable.from_bytessaô×$ 0ˆØz‰z˜& %ˆØ˜6NˆŒ Ü “]×-¨f°W©oÓ>ˆŒ
Ø
Œ Ø Øˆ r%)N)NN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú classmethodrGrÚstrr.r0r Úintrr9r>r@rÚboolrEÚbytesrIrOr=r%r#r'r',sñð ñ
˜
¨°#©ð
À'ò
óð
ñ˜X c™]ð¸À$¹ðÐSWóð"˜u S¨# X™ð°sð¸tóðu˜S #˜X‘ð¨sð°tóð2˜u S¨# X™ð2°3ó3u˜S #˜X‘ð¸#±ð3È#ó
3  c¨3 ð
3°Dó
 )˜%ó  ¨wôr%r'cóeZdZdZddZdedefdZdefdZ e
de efd«Z e
«fded edefd
Zded eddfd Zefded
edefdZdedefdZdedefdZdefdZdeddfdZ ddeeefdeddfdZ ddeeefdeddfdZy)raSContainer for large lookup tables and dictionaries, e.g. lemmatization
data or tokenizer exception lists. Lookups are available via vocab.lookups,
so they can be accessed before the pipeline components are applied (e.g.
in the tokenizer and lemmatizer), as well as within the pipeline components
via doc.vocab.lookups.
rNcói|_y)zXInitialize the Lookups object.
DOCS: https://spacy.io/api/lookups#init
Ú_tables©r-s r#r0zLookups.__init__ªs ð
*,ˆ r%r(có$|j|«S)zÖCheck if the lookups contain a table of a given name. Delegates to
Lookups.has_table.
name (str): Name of the table.
RETURNS (bool): Whether a table of that name is in the lookups.
)Ú has_table©r-r(s r#rEzLookups.__contains__±sð~‰~˜#r%có,t|j«S)z3RETURNS (int): The number of tables in the lookups.)rr^r_s r#Ú__len__zLookups.__len__ºsä4—< Ð r%cóHt|jj««S)z8RETURNS (List[str]): Names of all tables in the lookups.)Úlistr^Úkeysr_s r#rzLookups.tables¾sôD—LL×(r%r!có¬||jvr)ttjj |¬««t ||¬«}||j |<|S)aAdd a new table to the lookups. Raises an error if the table exists.
name (str): Unique name of table.
data (dict): Optional data to add to the table.
RETURNS (Table): The newly added table.
DOCS: https://spacy.io/api/lookups#add_table
r*)r(r!)rrr ÚE158rr'r^)r-r(r!rs r#r zLookups.add_tableÃsLð 4—;‘;Ñ ÜœVŸ[™[×/°TÐ ˜4 +ˆØ"ˆ ؈ r%rcó"||j|<y)z£Set a table.
name (str): Name of the table to set.
table (Table): The Table to set.
DOCS: https://spacy.io/api/lookups#set_table
Nr])r-r(rs r#Ú set_tablezLookups.set_tableÒsð#ˆ r%rBcóº||jvr?|tk(r4ttjj ||j ¬««|S|j|S)a<Get a table. Raises an error if the table doesn't exist and no
default value is provided.
name (str): Name of the table.
default (Any): Optional default value to return if table doesn't exist.
RETURNS (Table): The table.
DOCS: https://spacy.io/api/lookups#get_table
©r(r)r^ÚUNSETÚKeyErrorr ÚE159rr)r-r(rBs r#Ú get_tablezLookups.get_tableÜsOð t—|‘|Ñ œ%ÒÜœvŸ{™{×1°tÀDÇKÁKЈ|‰|˜!r%có¼||jvr4ttjj ||j
¬««|jj
|«S)zÛRemove a table. Raises an error if the table doesn't exist.
name (str): Name of the table to remove.
RETURNS (Table): The removed table.
DOCS: https://spacy.io/api/lookups#remove_table
rm)r^ror rprrÚpoprbs r#Ú remove_tablezLookups.remove_tableìsHð t—|‘|Ñ œ6Ÿ;™;×-°4ÀÇ Á Ð |‰|×Ñ Ó%r%có||jvS)zÙCheck if the lookups contain a table of a given name.
name (str): Name of the table.
RETURNS (bool): Whether a table of that name exists.
DOCS: https://spacy.io/api/lookups#has_table
r]rbs r#razLookups.has_tableøsðt—|#r%c ó@tj|j«S)zSerialize the lookups to a bytestring.
RETURNS (bytes): The serialized Lookups.
DOCS: https://spacy.io/api/lookups#to_bytes
)rJrKr^)r-Úkwargss r#rIzLookups.to_bytessô×" 4§<¡<Ó0r%rLc óœi|_tj|«j«D]\}}t ||«|j|<Œ |S)zÁLoad the lookups from a bytestring.
bytes_data (bytes): The data to load.
RETURNS (Lookups): The loaded Lookups.
DOCS: https://spacy.io/api/lookups#from_bytes
)r^rJrNrHr')r-rLrwr6r7s r#rOzLookups.from_bytes sHðˆŒ Ü×-¨jÓA‰JˆCÜ % c¨5Ó 1ˆDL‰L˜Ò ðBàˆ r%ÚpathÚfilenamec óît|«}|j«s|j«||z }|jd«5}|j |j ««ddd«y#1swYyxYw)zéSave the lookups to a directory as lookups.bin. Expects a path to a
directory, which will be created if it doesn't exist.