A Learning Theoretic Framework for Clustering with Similarity Functions