def spearman_rho(worder, normalize=True):
 worder_len = len(worder)
 sum_d_square = sum((((wi - i) ** 2) for (wi, i) in zip(worder, range(worder_len))))
 rho = (1 - (sum_d_square / choose((worder_len + 1), 3)))
 if normalize:
  return ((rho + 1) / 2)
 else:
  return rho

def spearman_rho ( worder , normalize = True ) : worder_len = len ( worder ) sum_d_square = sum ( ( ( ( wi - i ) ** 2 ) for ( wi , i ) in zip ( worder , range ( worder_len ) ) ) ) rho = ( 1 - ( sum_d_square / choose ( ( worder_len + 1 ) , 3 ) ) ) if normalize : return ( ( rho + 1 ) / 2 ) else : return rho
calculates the spearmans rho correlation coefficient given the *worder* list of word alignment from word_rank_alignment() .