403Webshell
Server IP : 54.37.205.81  /  Your IP : 216.73.216.76
Web Server : nginx/1.22.1
System : Linux vps-249481fa 6.1.0-50-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1 (2026-07-02) x86_64
User : debian ( 1000)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/lunr/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/lunr/__pycache__/vector.cpython-311.pyc
�

WIb���8�ddlmZddlmZGd�d��ZdS)�)�sqrt��BaseLunrExceptionc�h�eZdZdZdd�Zd�Zd�Zd�Zd�Zdd�Z	d	�Z
d
�Zed���Z
d�Zd
�ZdS)�Vectora�A vector is used to construct the vector space of documents and queries.
    These vectors support operations to determine the similarity between two
    documents or a document and a query.

    Normally no parameters are required for initializing a vector, but in the
    case of loading a previously dumped vector the raw elements can be provided
    to the constructor.

    For performance reasons vectors are implemented with a flat array, where an
    elements index is immediately followed by its value.
    E.g. [index, value, index, value].

    TODO: consider implemetation as 2-tuples.

    This allows the underlying array to be as sparse as possible and still
    offer decent performance when being used for vector calculations.
    Nc�&�d|_|pg|_dS)Nr)�
_magnitude�elements)�selfr
s  �-/usr/lib/python3/dist-packages/lunr/vector.py�__init__zVector.__init__s����� ��B��
�
�
�c�6�d�|j��S)Nz<Vector magnitude={}>)�format�	magnitude�rs r�__repr__zVector.__repr__s��&�-�-�d�n�=�=�=rc�*�t|j��S�N)�iterr
rs r�__iter__zVector.__iter__ s���D�M�"�"�"rc�|�|jsdSd}tt|j��dz��}||z
}t|dz��}|j|dz}|dkrC||kr|}n
||kr|}nn0||z
}|t|dz��z}|j|dz}|dk�C||kr|dzS||kr|dzS|dzdzS)acCalculates the position within the vector to insert a given index.

        This is used internally by insert and upsert. If there are duplicate
        indexes then the position is returned as if the value for that index
        were to be updated, but it is the callers responsibility to check
        whether there is a duplicate at that index
        r��)r
�int�len)r�index�start�end�slice_length�pivot_point�pivot_indexs       r�position_for_indexzVector.position_for_index#s	���}�	��1����#�d�m�$�$�q�(�)�)���U�{���,��*�+�+���m�K�!�O�4���Q����U�"�"�#����u�$�$�!������;�L��#�l�Q�&6�"7�"7�7�K��-��a��8�K��Q����%�����?�"�
�5�
 �
 ���?�"��!�O�q�(�(rc�:�d�}|�|||��dS)z�Inserts an element at an index within the vector.

        Does not allow duplicates, will throw an error if there is already an
        entry for this index.
        c� �td���)NzDuplicate indexr)r�vals  r�prevent_duplicatesz)Vector.insert.<locals>.prevent_duplicatesNs��#�$5�6�6�6rN)�upsert)r�insert_indexr&r's    r�insertz
Vector.insertGs0��	7�	7�	7�	
���L�#�'9�:�:�:�:�:rc�T�|pd�}d|_|�|��}|t|j��kr8|j||kr'||j|dz|��|j|dz<dS|j�||��|j�||��dS)a�Inserts or updates an existing index within the vector.

        Args:
            - insert_index (int): The index at which the element should be
                inserted.
            - val (int|float): The value to be inserted into the vector.
            - fn (callable, optional): An optional callable taking two
                arguments, the current value and the passed value to generate
                the final inserted value at the position in case of collision.
        c��|Sr�)�current�passeds  r�<lambda>zVector.upsert.<locals>.<lambda>^s��F�rrrN)r	r#rr
r*)rr)r&�fn�positions     rr(z
Vector.upsertSs����
3�2�2������*�*�<�8�8���c�$�-�(�(�(�(�T�]�8�-D��-T�-T�*,�"�T�]�8�a�<�-H�#�*N�*N�D�M�(�Q�,�'�'�'��M� � ��3�/�/�/��M� � ��<�8�8�8�8�8rc��g}tdt|j��d��D]"}|�|j|���#|S)zAConverts the vector to an array of the elements within the vectorrr)�rangerr
�append)r�output�is   r�to_listzVector.to_listgsM�����q�#�d�m�,�,�a�0�0�	,�	,�A��M�M�$�-��*�+�+�+�+��
rc�$�d�|jD��S)Nc�.�g|]}t|d����S)�)�round)�.0�elements  r�
<listcomp>z$Vector.serialize.<locals>.<listcomp>qs"��?�?�?�g��g�q�!�!�?�?�?r)r
rs r�	serializezVector.serializens��@�?���?�?�?�?rc��|jsQd}tdt|j��d��D]}|j|}|||zz
}�t	|��|_|jS)Nrrr)r	r4rr
r)r�sum_of_squaresr7�values    rrzVector.magnitudessi����	3��N��1�c�$�-�0�0�!�4�4�
0�
0���
�a�(���%�%�-�/���"�>�2�2�D�O���rc�2�d}|j}|j}t|��}t|��}dx}}||kr^||krX||}	||}
|	|
kr|dz
}n0|	|
kr|dz
}n$|||dz||dzzz
}|dz
}|dz
}||kr||k�X|S)z=Calculates the dot product of this vector and another vector.rrr)r
r)r�other�dot_product�a�b�a_len�b_lenr7�j�a_val�b_vals           r�dotz
Vector.dots������M���N���A�����A�����	��A��%�i�i�A��I�I��a�D�E��a�D�E��u�}�}��Q���������Q�����q��Q��x�!�A��E�(�2�2���Q����Q����%�i�i�A��I�I��rc�l�|jdks|jdkrdS|�|��|jzS)zPCalculates the cosine similarity between this vector and another
        vector.r)rrN)rrEs  r�
similarityzVector.similarity�s9���>�Q���%�/�Q�"6�"6��1��x�x������/�/rr)�__name__�
__module__�__qualname__�__doc__r
rrr#r*r(r8r@�propertyrrNrPr-rrrrs���������$'�'�'�'�>�>�>�#�#�#�")�")�")�H
;�
;�
;�9�9�9�9�(���@�@�@�
�	�	��X�	����.0�0�0�0�0rrN)�mathr�lunr.exceptionsrrr-rr�<module>rXse��������-�-�-�-�-�-�V0�V0�V0�V0�V0�V0�V0�V0�V0�V0r

Youez - 2016 - github.com/yon3zu
LinuXploit