| 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/nltk/metrics/__pycache__/ |
Upload File : |
�
T�cQ � �$ � d Z d� Zd� Zd� Zdd�ZdS )z#
Tools for comparing ranked lists.
c # � K � t | � � } t |� � }| D ](} || | || z
fV � �# t $ r Y �%w xY wdS )z�Finds the difference between the values in ranks1 and ranks2 for keys
present in both dicts. If the arguments are not dicts, they are converted
from (key, rank) sequences.
N)�dict�KeyError)�ranks1�ranks2�ks �7/usr/lib/python3/dist-packages/nltk/metrics/spearman.py�_rank_distsr
s} � � � �
�&�\�\�F�
�&�\�\�F�
� � �� ��V�A�Y����*�*�*�*�*�*��� � � ��D� ����� s �<�
A �A c � � d}d}t | |� � D ]\ }}|||z z
}|dz
}� dd|z |||z dz
z z z
S # t $ r Y dS w xY w)aU Returns the Spearman correlation coefficient for two rankings, which
should be dicts or sequences of (key, rank). The coefficient ranges from
-1.0 (ranks are opposite) to 1.0 (ranks are identical), and is only
calculated for keys in both rankings (for meaningful results, remove keys
present in only one list before ranking).� � � g )r �ZeroDivisionError)r r �n�resr �ds r �spearman_correlationr s� � �
�A�
�C��F�F�+�+� � ���1��q�1�u��� �Q������A��G�q�A��E�A�I��/�0�0��� � � ��s�s����s �= �
A�
Ac �4 � d� t | � � D � � S )z�Given a sequence, yields each element with an increasing rank, suitable
for use as an argument to ``spearman_correlation``.
c 3 �$ K � | ]\ }}||fV � �d S )N� )�.0�ir s r � <genexpr>z&ranks_from_sequence.<locals>.<genexpr>1 s* � � � �.�.�t�q�!�Q��F�.�.�.�.�.�.� )� enumerate)�seqs r �ranks_from_sequencer - s � � /�.�y��~�~�.�.�.�.r �V瞯�<c # � K � d}d}t | � � D ]:\ }\ }} t ||z
� � |k r|}n# t $ r Y nw xY w||fV � |}�;dS )z�Given a sequence of (key, score) tuples, yields each key with an
increasing rank, tying with previous key's rank if the difference between
their scores is less than rank_gap. Suitable for use as an argument to
``spearman_correlation``.
Nr )r �abs� TypeError)�scores�rank_gap�
prev_score�rankr �key�scores r �ranks_from_scoresr'