Ë
    _›¾jf*  ã            	       óÔ   — d dl mZ d dlmZ d dlmZmZmZmZm	Z	 d dl
Z
d dlmZ ddlmZ ddlmZ dd	lmZmZmZmZ  e«       Zdd
edee   deddfd„Z G d„ de«      Z G d„ d«      Zy)é    )Ú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        «       }| t        j                  vrK|rGt        |«      dkD  r9t	        t
        j                  j                  dj                  |«      | ¬«      «      ‚|S t        j                  j                  | «      }|D ]U  }||vr/|r*t	        t
        j                  j                  || ¬«      «      ‚i }nt        ||   «      }|j                  ||«       ŒW |S )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          úW/home/spazio/kingdom_calls/work5/transenv/lib/python3.12/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Øò 0ˆØ˜ÑÙÜ ¤§¡×!3Ñ!3¸%ÀdÐ!3Ó!KÓLÐLØ‰Mä.¨t°E©{Ó;ˆMØ×Ñ˜% Õ/ð0ð €Nó    c                   ó
  — e Zd ZdZeddedee   dd fd„«       Zddee   dee   ddfd„Z	de
eef   d	eddfd
„Zde
eef   d	eddfd„Zde
eef   defd„Zdde
eef   dee   defd„Zde
eef   defd„Zdefd„Zdedd fd„Zy)Ú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!   Únamer   c                 ó:   —  | |¬«      }|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_dictzTable.from_dict3   s   € ñ ˜Œ~ˆØ�‰�DÔØˆr%   c                 óì   — t        j                  | «       || _        d| _        |�t	        t        |«      d«      n| j                  }t        j                  |«      | _        |r| j                  |«       yy)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#   r0   zTable.__init__@   sd   € ô 	×Ñ˜TÔ"ØˆŒ	àˆÔØ$(Ð$4Œs”3�t“9˜aÔ ¸$×:KÑ:KˆÜ ×0Ñ0°Ó6ˆŒ
ÙØ�K‰K˜Õð r%   ÚkeyÚvaluec                 ó~   — t        |«      }t        j                  | ||«       | j                  j	                  |«       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-   r6   r7   s      r#   r9   zTable.__setitem__Q   s0   € ô ˜CÓ ˆÜ×Ñ  c¨5Ô1Ø�
‰
�‰�sÕ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.
        N© r;   s      r#   Úsetz	Table.set[   s   € ð ˆˆSŠ	r%   c                 óD   — t        |«      }t        j                  | |«      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-   r6   s     r#   r@   zTable.__getitem__d   s!   € ô ˜CÓ ˆÜ×&Ñ& t¨SÓ1Ð1r%   Údefaultc                 óF   — t        |«      }t        j                  | ||«      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   r   r   )r-   r6   rB   s      r#   r   z	Table.getm   s!   € ô ˜CÓ ˆÜ�‰˜t S¨'Ó2Ð2r%   c                 ób   — t        |«      }|| j                  vryt        j                  | |«      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   r4   r   Ú__contains__rA   s     r#   rE   zTable.__contains__w   s0   € ô ˜CÓ ˆà�d—j‘jÑ ØÜ×'Ñ'¨¨cÓ2Ð2r%   c                 óª   — | j                   t        | j                  «       «      | j                  j	                  «       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#   rI   zTable.to_bytesƒ   sC   € ð —I‘IÜ˜Ÿ™›Ó&Ø—Z‘Z×(Ñ(Ó*ñ
ˆô
 ×"Ñ" 4Ó(Ð(r%   Ú
bytes_datac                 óì   — t        j                  |«      }|j                  di «      }|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
        rG   r(   r4   )	rJ   Úmsgpack_loadsr   r(   r
   Ú
from_bytesr4   Úclearr+   )r-   rL   Úloadedr!   s       r#   rO   zTable.from_bytes‘   sa   € ô ×$Ñ$ ZÓ0ˆØ�z‰z˜& "Ó%ˆØ˜6‘NˆŒ	Ü “]×-Ñ-¨f°W©oÓ>ˆŒ
Ø�
‰
ŒØ�‰�DÔØˆr%   )N)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚclassmethodrG   r   Ústrr.   r0   r	   Úintr   r9   r>   r@   r   ÚboolrE   ÚbytesrI   rO   r=   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                   ó  — e Zd ZdZdd„Zdedefd„Zdefd„Z	e
dee   fd„«       Z e«       fded	edefd
„Zdededdfd„Zefdededefd„Zdedefd„Zdedefd„Zdefd„Zdedd fd„Z	 ddeeef   deddfd„Z	 ddeeef   dedd fd„Zy)r   aS  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                 ó   — i | _         y)zXInitialize the Lookups object.

        DOCS: https://spacy.io/api/lookups#init
        N©Ú_tables©r-   s    r#   r0   zLookups.__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#   rE   zLookups.__contains__±   s   € ð �~‰~˜dÓ#Ð#r%   c                 ó,   — t        | j                  «      S )z3RETURNS (int): The number of tables in the lookups.)r   r^   r_   s    r#   Ú__len__zLookups.__len__º   s   € ä�4—<‘<Ó Ð r%   c                 óH   — t        | j                  j                  «       «      S )z8RETURNS (List[str]): Names of all tables in the lookups.)Úlistr^   Úkeysr_   s    r#   r   zLookups.tables¾   s   € ô �D—L‘L×%Ñ%Ó'Ó(Ð(r%   r!   c                 ó¬   — || j                   v r)t        t        j                  j	                  |¬«      «      ‚t        ||¬«      }|| j                  |<   |S )a  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'   r^   )r-   r(   r!   r   s       r#   r    zLookups.add_tableÃ   sL   € ð �4—;‘;ÑÜœVŸ[™[×/Ñ/°TÐ/Ó:Ó;Ð;Ü˜4 dÔ+ˆØ"ˆ�‰�TÑØˆr%   r   c                 ó"   — || 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(   r   s      r#   Ú	set_tablezLookups.set_tableÒ   s   € ð #ˆ�‰�TÒr%   rB   c                 óº   — || j                   vr?|t        k(  r4t        t        j                  j                  || 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   ÚE159r   r   )r-   r(   rB   s      r#   Ú	get_tablezLookups.get_tableÜ   sO   € ð �t—|‘|Ñ#Øœ%ÒÜœvŸ{™{×1Ñ1°tÀDÇKÁKÐ1ÓPÓQÐQØˆNØ�|‰|˜DÑ!Ð!r%   c                 ó¼   — || j                   vr4t        t        j                  j	                  || j
                  ¬«      «      ‚| j                   j                  |«      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^   ro   r   rp   r   r   Úpoprb   s     r#   Úremove_tablezLookups.remove_tableì   sH   € ð �t—|‘|Ñ#Üœ6Ÿ;™;×-Ñ-°4ÀÇÁÐ-ÓLÓMÐMØ�|‰|×Ñ Ó%Ð%r%   c                 ó   — || j                   v S )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]   rb   s     r#   ra   zLookups.has_tableø   s   € ð �t—|‘|Ð#Ð#r%   c                 ó@   — t        j                  | j                  «      S )z–Serialize the lookups to a bytestring.

        RETURNS (bytes): The serialized Lookups.

        DOCS: https://spacy.io/api/lookups#to_bytes
        )rJ   rK   r^   )r-   Úkwargss     r#   rI   zLookups.to_bytes  s   € ô ×"Ñ" 4§<¡<Ó0Ð0r%   rL   c                 óœ   — i | _         t        j                  |«      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^   rJ   rN   rH   r'   )r-   rL   rw   r6   r7   s        r#   rO   zLookups.from_bytes  sL   € ð ˆŒÜ×-Ñ-¨jÓ9×?Ñ?ÓAò 	2‰JˆC�Ü % c¨5Ó 1ˆD�L‰L˜Òð	2àˆr%   ÚpathÚfilenamec                 óî   — t        |«      }|j                  «       s|j                  «        ||z  }|j                  d«      5 }|j	                  | j                  «       «       ddd«       y# 1 sw Y   yxY w)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ÚwriterI   )r-   ry   rz   rw   ÚfilepathÚfile_s         r#   Úto_diskzLookups.to_disk  s^   € ô ˜4Ó ˆØ�{‰{Œ}Ø�J‰JŒLØ˜(‘?ˆØ�]‰]˜4Ó ð 	) EØ�K‰K˜Ÿ™›Ô(÷	)÷ 	)ñ 	)ús   Á A+Á+A4c                 óÔ   — t        |«      }||z  }|j                  «       r;|j                  d«      5 }|j                  «       }ddd«       | j	                  «      S | S # 1 sw Y   ŒxY w)a
  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   ÚreadrO   )r-   ry   rz   rw   r�   r‚   r!   s          r#   Ú	from_diskzLookups.from_disk)  sc   € ô ˜4Ó ˆØ˜(‘?ˆØ�?‰?ÔØ—‘˜tÓ$ð $¨Ø—z‘z“|�÷$à—?‘? 4Ó(Ð(Øˆ÷$ð $ús   ²AÁA')r   N)zlookups.bin)rR   rS   rT   rU   r0   rW   rY   rE   rX   rd   Úpropertyr   r   r   rG   r'   r    rk   rn   r   rq   rt   ra   rZ   rI   rO   r	   r   rƒ   r‡   r=   r%   r#   r   r   ¢   sC  „ ñó,ð$ ð $¨ó $ð!˜ó !ð ð)˜˜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	   rJ   Úpreshed.bloomr
   Úerrorsr   Ústringsr   Úutilr   r   r   r   Úobjectrn   rW   rY   r$   r'   r   r=   r%   r#   ú<module>r‘      sj   ðÝ #Ý ß 3Õ 3ã Ý %å Ý "ß MÓ Má‹€ñ�sð  D¨¡Ið °tð Àyó ô:sˆKô s÷lXò Xr%   