Code for similarity matrix construction from tfidf scores