ó
    Í’Œj +  ã            	       óØ   • S SK Jr  S SKJr  S SKJrJrJrJrJ	r	  S SK
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Jr  \" 5       rSS
\S\\   S\SS4S jjr " S S\5      r " S S5      rg)é    )ÚOrderedDict)ÚPath)ÚAnyÚDictÚListÚOptionalÚUnionN)ÚBloomFilteré   )ÚErrors)Úget_string_id)ÚSimpleFrozenDictÚensure_pathÚload_language_dataÚregistryÚlangÚtablesÚstrictÚreturnÚLookupsc                 óÔ  • [        5       nU [        R                  ;  aN  U(       aE  [        U5      S:”  a6  [	        [
        R                  R                  SR                  U5      U S95      eU$ [        R                  R                  U 5      nU HV  nXT;  a0  U(       a&  [	        [
        R                  R                  XPS95      e0 nO[        XE   5      nUR                  XV5        MX     U$ )aö  Load 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.
r   z, )Útabler   )r   r   ÚlookupsÚlenÚ
ValueErrorr   ÚE955ÚformatÚjoinÚgetr   Ú	add_table)r   r   r   r   Údatar   Úlanguage_datas          Ú›C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\spacy/lookups.pyÚload_lookupsr$      s¿   € ô ‹i€GØ”8×#Ñ#Ó#Þ”c˜&“k A“oÜœVŸ[™[×/Ñ/°d·i±iÀÓ6GÈdÐ/ÐSÓTÐTØˆÜ×Ñ×Ñ Ó%€DÛˆØÓÞÜ ¤§¡×!3Ñ!3¸%Ð!3Ð!KÓLÐLØ‰Mä.¨t©{Ó;ˆMØ×Ñ˜%Ö/ñ ð €Nó    c                   ó*  • \ rS rSrSr\SS\S\\   SS 4S jj5       r	SS\\   S\\   SS4S jjr
S	\\\4   S
\SS4S jrS	\\\4   S
\SS4S jrS	\\\4   S\4S jrSS	\\\4   S\\   S\4S jjrS	\\\4   S\4S jrS\4S jrS\SS 4S jrSrg)ÚTableé,   z¢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!   Únamer   c                 ó4   • U " US9nUR                  U5        U$ )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_dictÚTable.from_dict3   s   € ñ ˜‰~ˆØ�‰�DÔØˆr%   c                 óú   • [         R                  " U 5        Xl        SU l        Ub  [	        [        U5      S5      OU R                  n[        R                  " U5      U l        U(       a  U R                  U5        gg)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Úmaxr   r
   Úfrom_error_rateÚbloomr,   )r.   r)   r!   Úsizes       r#   r2   ÚTable.__init__@   sb   € ô 	×Ò˜TÔ"ØŒ	àˆÔØ$(Ñ$4Œs”3�t“9˜aÔ ¸$×:KÑ:KˆÜ ×0Ò0°Ó6ˆŒ
ÞØ�K‰K˜Õð r%   ÚkeyÚvaluec                 ó~   • [        U5      n[        R                  " XU5        U R                  R	                  U5        g)zoSet 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__r6   Úadd©r.   r9   r:   s      r#   r<   ÚTable.__setitem__Q   s.   € ô ˜CÓ ˆÜ×Ò ¨5Ô1Ø�
‰
�‰�sÕr%   c                 ó   • X U'   g)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.
N© r>   s      r#   ÚsetÚ	Table.set[   s   € ð ˆSŠ	r%   c                 óD   • [        U5      n[        R                  " X5      $ )zqGet 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.   r9   s     r#   rE   ÚTable.__getitem__d   s   € ô ˜CÓ ˆÜ×&Ò& tÓ1Ð1r%   Údefaultc                 óF   • [        U5      n[        R                  " XU5      $ )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   r   r   )r.   r9   rH   s      r#   r   Ú	Table.getm   s   € ô ˜CÓ ˆÜ�Š˜t¨'Ó2Ð2r%   c                 ód   • [        U5      nXR                  ;  a  g[        R                  " X5      $ )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   r6   r   Ú__contains__rF   s     r#   rL   ÚTable.__contains__w   s,   € ô ˜CÓ ˆà—j‘jÓ ØÜ×'Ò'¨Ó2Ð2r%   c                 ó¬   • U R                   [        U R                  5       5      U R                  R	                  5       S.n[
        R                  " U5      $ )z|Serialize table to a bytestring.

RETURNS (bytes): The serialized table.

DOCS: https://spacy.io/api/lookups#table.to_bytes
)r)   Údictr6   )r)   rO   Úitemsr6   Úto_bytesÚsrslyÚmsgpack_dumps)r.   r!   s     r#   rQ   ÚTable.to_bytesƒ   sC   € ð —I‘IÜ˜Ÿ™›Ó&Ø—Z‘Z×(Ñ(Ó*ñ
ˆô
 ×"Ò" 4Ó(Ð(r%   Ú
bytes_datac                 óî   • [         R                  " U5      nUR                  S0 5      nUS   U l        [	        5       R                  US   5      U l        U R                  5         U R                  U5        U $ )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
rO   r)   r6   )	rR   Úmsgpack_loadsr   r)   r
   Ú
from_bytesr6   Úclearr,   )r.   rU   Úloadedr!   s       r#   rX   ÚTable.from_bytes‘   sa   € ô ×$Ò$ ZÓ0ˆØ�z‰z˜& "Ó%ˆØ˜6‘NˆŒ	Ü “]×-Ñ-¨f°W©oÓ>ˆŒ
Ø�
‰
ŒØ�‰�DÔØˆr%   )r6   r3   r)   )N)NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚclassmethodrO   r   Ústrr/   r2   r	   Úintr   r<   rB   rE   r   ÚboolrL   ÚbytesrQ   rX   Ú__static_attributes__rA   r%   r#   r'   r'   ,   s  † ñð ñ
˜Tð 
¨°#©ð 
À'ô 
ó ð
ñ˜X c™]ð ¸À$¹ð ÐSWõ ð"˜u S¨# X™ð °sð ¸tô ð�u˜S #˜X‘ð ¨sð °tô ð2˜u S¨# X™ð 2°3ô 2ñ3�u˜S #˜X‘ð 3°¸#±ð 3È#õ 3ð
3  c¨3 h¡ð 
3°Dô 
3ð)˜%ô )ð Uð ¨w÷ r%   r'   c                   óH  • \ rS rSrSrSS jrS\S\4S jrS\	4S jr
\S\\   4S	 j5       r\" 5       4S\S
\S\4S jjrS\S\SS4S jr\4S\S\S\4S jjrS\S\4S jrS\S\4S jrS\4S jrS\SS 4S jr SS\\\4   S\SS4S jjr SS\\\4   S\SS 4S jjrSrg)r   é¢   a?  Container 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.
r   Nc                 ó   • 0 U l         g)zHInitialize the Lookups object.

DOCS: https://spacy.io/api/lookups#init
N©Ú_tables©r.   s    r#   r2   ÚLookups.__init__ª   s   € ð
 *,ˆ�r%   r)   c                 ó$   • U R                  U5      $ )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#   rL   ÚLookups.__contains__±   s   € ð �~‰~˜dÓ#Ð#r%   c                 ó,   • [        U R                  5      $ )z3RETURNS (int): The number of tables in the lookups.)r   rk   rl   s    r#   Ú__len__ÚLookups.__len__º   s   € ä�4—<‘<Ó Ð r%   c                 óH   • [        U R                  R                  5       5      $ )z8RETURNS (List[str]): Names of all tables in the lookups.)Úlistrk   Úkeysrl   s    r#   r   ÚLookups.tables¾   s   € ô �D—L‘L×%Ñ%Ó'Ó(Ð(r%   r!   c                 óž   • XR                   ;   a&  [        [        R                  R	                  US95      e[        XS9nX0R                  U'   U$ )zîAdd 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!   )r   r   r   ÚE158r   r'   rk   )r.   r)   r!   r   s       r#   r    ÚLookups.add_tableÃ   sF   € ð —;‘;ÓÜœVŸ[™[×/Ñ/°TÐ/Ð:Ó;Ð;Ü˜4Ñ+ˆØ"�‰�TÑØˆr%   r   c                 ó    • X R                   U'   g)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
Nrj   )r.   r)   r   s      r#   Ú	set_tableÚLookups.set_tableÒ   s   € ð #�‰�TÒr%   rH   c                 ó¶   • XR                   ;  a<  U[        :X  a0  [        [        R                  R                  XR                  S95      eU$ U R                   U   $ )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   )rk   ÚUNSETÚKeyErrorr   ÚE159r   r   )r.   r)   rH   s      r#   Ú	get_tableÚLookups.get_tableÜ   sK   € ð —|‘|Ó#Øœ%ÓÜœvŸ{™{×1Ñ1°tÇKÁKÐ1ÐPÓQÐQØˆNØ�|‰|˜DÑ!Ð!r%   c                 ó¶   • XR                   ;  a0  [        [        R                  R	                  XR
                  S95      eU R                   R                  U5      $ )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
r€   )rk   r‚   r   rƒ   r   r   Úpoprp   s     r#   Úremove_tableÚLookups.remove_tableì   sD   € ð —|‘|Ó#Üœ6Ÿ;™;×-Ñ-°4ÇÁÐ-ÐLÓMÐMØ�|‰|×Ñ Ó%Ð%r%   c                 ó   • XR                   ;   $ )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
rj   rp   s     r#   ro   ÚLookups.has_tableø   s   € ð —|‘|Ñ#Ð#r%   c                 óB   • [         R                  " U R                  5      $ )z~Serialize the lookups to a bytestring.

RETURNS (bytes): The serialized Lookups.

DOCS: https://spacy.io/api/lookups#to_bytes
)rR   rS   rk   )r.   Úkwargss     r#   rQ   ÚLookups.to_bytes  s   € ô ×"Ò" 4§<¡<Ó0Ð0r%   rU   c                 óž   • 0 U l         [        R                  " U5      R                  5        H  u  p4[	        X45      U R                   U'   M     U $ )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
)rk   rR   rW   rP   r'   )r.   rU   r�   r9   r:   s        r#   rX   ÚLookups.from_bytes  sD   € ð ˆŒÜ×-Ò-¨jÓ9×?Ñ?ÖA‰JˆCÜ % cÓ 1ˆD�L‰L˜Óñ Bàˆr%   ÚpathÚfilenamec                 ó   • [        U5      nUR                  5       (       d  UR                  5         X-  nUR                  S5       nUR	                  U R                  5       5        SSS5        g! , (       d  f       g= f)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.

path (str / Path): The file path.

DOCS: https://spacy.io/api/lookups#to_disk
ÚwbN)r   ÚexistsÚmkdirÚopenÚwriterQ   )r.   r‘   r’   r�   ÚfilepathÚfile_s         r#   Úto_diskÚLookups.to_disk  sU   € ô ˜4Ó ˆØ�{‰{�}‰}Ø�J‰JŒLØ‘?ˆØ�]‰]˜4Ô  EØ�K‰K˜Ÿ™›Ô(÷ !× Ö ús   Á A/Á/
A=c                 óæ   • [        U5      nX-  nUR                  5       (       a;  UR                  S5       nUR                  5       nSSS5        U R	                  W5      $ U $ ! , (       d  f       N!= f)zâLoad lookups from a directory containing a lookups.bin. Will skip
loading if the file doesn't exist.

path (str / Path): The directory path.
RETURNS (Lookups): The loaded lookups.

DOCS: https://spacy.io/api/lookups#from_disk
ÚrbN)r   r•   r—   ÚreadrX   )r.   r‘   r’   r�   r™   rš   r!   s          r#   Ú	from_diskÚLookups.from_disk)  s]   € ô ˜4Ó ˆØ‘?ˆØ�?‰?×ÑØ—‘˜tÔ$¨Ø—z‘z“|�÷ %à—?‘? 4Ó(Ð(Øˆ÷ %Õ$ús   ¶A"Á"
A0rj   )r   N)zlookups.bin) r\   r]   r^   r_   r`   r2   rb   rd   rL   rc   rs   Úpropertyr   r   r   rO   r'   r    r}   r�   r   r„   rˆ   ro   re   rQ   rX   r	   r   r›   r    rf   rA   r%   r#   r   r   ¢   sH  † ñô,ð$ ð $¨ô $ð!˜ô !ð ð)˜˜S™	ó )ó ð)ñ 1AÓ0Bñ ˜cð ¨ð Àuõ ð#˜cð #¨%ð #°Dô #ð 38ñ "˜cð "¨Cð "¸Eõ "ð 
& ð 
&¨ô 
&ð$˜cð $ dô $ð1 Eô 1ð Uð ¸ô ð 7Dñ)Ø˜#˜t˜)Ñ$ð)Ø03ð)à	õ)ð$ 7DñØ˜#˜t˜)Ñ$ðØ03ðà	÷ð r%   )T)Úcollectionsr   Úpathlibr   Útypingr   r   r   r   r	   rR   Úpreshed.bloomr
   Úerrorsr   Ústringsr   Úutilr   r   r   r   Úobjectr�   rb   rd   r$   r'   r   rA   r%   r#   Ú<module>r«      sj   ðÝ #Ý ß 3Õ 3ã Ý %å Ý "ß MÓ Má‹€ñ�sð  D¨¡Ið °tð Àyõ ô:sˆKô s÷lXò Xr%   