def kendall_tau(worder, normalize=True):
 worder_len = len(worder)
 increasing_sequences = find_increasing_sequences(worder)
 num_increasing_pairs = sum((choose(len(seq), 2) for seq in increasing_sequences))
 num_possible_pairs = choose(worder_len, 2)
 tau = (((2 * num_increasing_pairs) / num_possible_pairs) - 1)
 if normalize:
  return ((tau + 1) / 2)
 else:
  return tau

def kendall_tau ( worder , normalize = True ) : worder_len = len ( worder ) increasing_sequences = find_increasing_sequences ( worder ) num_increasing_pairs = sum ( ( choose ( len ( seq ) , 2 ) for seq in increasing_sequences ) ) num_possible_pairs = choose ( worder_len , 2 ) tau = ( ( ( 2 * num_increasing_pairs ) / num_possible_pairs ) - 1 ) if normalize : return ( ( tau + 1 ) / 2 ) else : return tau
calculates the kendalls tau correlation coefficient given the *worder* list of word alignments from word_rank_alignment() .