nltk.ranks_from_scores()

nltk.ranks_from_scores(scores, rank_gap=1e-15)[source]

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.