§
    'ê[f•  ã                   ó$   — d Z d„ Zd„ Zd„ Zdd„ZdS )z#
Tools for comparing ranked lists.
c              #   óœ   K  — t          | ¦  «        } t          |¦  «        }| D ](}	 || |         ||         z
  fV — Œ# t          $ r Y Œ%w xY wdS )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      úI/var/www/piapp/venv/lib/python3.11/site-packages/nltk/metrics/spearman.pyÚ_rank_distsr	      s}   è è € õ
 �&‰\Œ\€FÝ�&‰\Œ\€FØð ð ˆð	Ø�V˜A”Y ¨¤Ñ*Ð*Ð*Ð*Ð*Ð*øÝð 	ð 	ð 	ØˆDð	øøøðð s   ¦<¼
A	ÁA	c                 óœ   — d}d}t          | |¦  «        D ]\  }}|||z  z  }|dz  }Œ	 dd|z  |||z  dz
  z  z  z
  S # t          $ r Y dS w xY 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Á
Ac                 ó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  — | ]\  }}||fV — Œ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 nw xY w||fV — |}Œ;dS )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'   4   s”   è è € ð €JØ€DÝ$ VÑ,Ô,ð ð ‰ˆ‰<ˆC�ð	Ý�5˜:Ñ%Ñ&Ô&¨Ò1Ð1Ø�øøÝð 	ð 	ð 	ØˆDð	øøøð �4ˆiˆˆˆØˆ
ˆ
ðð s   Ÿ8¸
AÁAN)r   )Ú__doc__r	   r   r   r'   r   r   r   ú<module>r)      sZ   ððð ð
ð ð ðð ð ð$/ð /ð /ðð ð ð ð ð r   