def textListToColors(names):
 Dnames = np.zeros((len(names), len(names)))
 for i in range(len(names)):
  for j in range(len(names)):
   Dnames[(i, j)] = (1 - ((2.0 * levenshtein(names[i], names[j])) / float(len((names[i] + names[j])))))
 pca = sklearn.decomposition.PCA(n_components=1)
 pca.fit(Dnames)
 textToColor = pca.transform(Dnames)
 textToColor = ((255 * (textToColor - textToColor.min())) / (textToColor.max() - textToColor.min()))
 textmaps = generateColorMap()
 colors = [textmaps[int(c)] for c in textToColor]
 return colors

def textListToColors ( names ) : Dnames = np . zeros ( ( len ( names ) , len ( names ) ) ) for i in range ( len ( names ) ) : for j in range ( len ( names ) ) : Dnames [ ( i , j ) ] = ( 1 - ( ( 2.0 * levenshtein ( names [ i ] , names [ j ] ) ) / float ( len ( ( names [ i ] + names [ j ] ) ) ) ) ) pca = sklearn . decomposition . PCA ( n_components = 1 ) pca . fit ( Dnames ) textToColor = pca . transform ( Dnames ) textToColor = ( ( 255 * ( textToColor - textToColor . min ( ) ) ) / ( textToColor . max ( ) - textToColor . min ( ) ) ) textmaps = generateColorMap ( ) colors = [ textmaps [ int ( c ) ] for c in textToColor ] return colors
generates a list of colors based on a list of names .