
    /hQ                     $    S r S rS rS rSS jrg)z#
Tools for comparing ranked lists.
c              #      #    [        U 5      n [        U5      nU  H  n X U   X   -
  4v   M     g! [         a     M#  f = f7f)zFinds 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      M/var/www/auris/envauris/lib/python3.13/site-packages/nltk/metrics/spearman.py_rank_distsr	      sO     
 &\F&\F	AY***   		s    A1A
?A?Ac                     SnSn[        X5       H  u  pEX5U-  -  nUS-  nM      SSU-  X"U-  S-
  -  -  -
  $ ! [         a     gf = f)aE  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      sh     	
A
CF+1u	Q ,AGqEAI/00 s   9 
AAc                 &    S [        U 5       5       $ )z|Given a sequence, yields each element with an increasing rank, suitable
for use as an argument to ``spearman_correlation``.
c              3   ,   #    U  H
  u  pX!4v   M     g 7f)N ).0ir   s      r   	<genexpr>&ranks_from_sequence.<locals>.<genexpr>1   s     .~tqQF~s   )	enumerate)seqs    r   ranks_from_sequencer   -   s     /y~..    c              #      #    SnSn[        U 5       H#  u  nu  pV [        Xb-
  5      U:  a  UnXS4v   UnM%     g! [         a     Nf = f7f)zGiven 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'   4   sa      JD$V,<C	5%&1 i
 -  		s%   A
:A

AA
AA
N)gV瞯<)__doc__r	   r   r   r'   r   r   r   <module>r)      s   
$/r   