def textListToColors(names):
	'''
	Generates a list of colors based on a list of names (strings). Similar strings correspond to similar colors.
	'''
	# STEP A: compute strings distance between all combnations of strings
	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]))

	# STEP B: pca dimanesionality reduction to a single-dimension (from the distance space)
	pca = mlpy.PCA(method='cov') 
	pca.learn(Dnames)
	coeff = pca.coeff()
	
	# STEP C: mapping of 1-dimensional values to colors in a jet-colormap
	textToColor = pca.transform(Dnames, k=1)
	textToColor = 255 * (textToColor - textToColor.min()) / (textToColor.max() - textToColor.min())
	textmaps = generateColorMap();
	colors = [textmaps[int(c)] for c in textToColor]
	return colors
dataset/ETHPy150Open tyiannak/pyAudioAnalysis/audioVisualization.py/textListToColors/original