Calculating TF-IDF and cosine similarity