There are TF-IDF implementations in scikit-learn
and gensim
.
There are simple implementations Simple implementation of N-Gram, tf-idf and Cosine similarity in Python
To avoid reinventing the wheel,
In this blogpost, it says NLTK doesn't have it. Is that true? http://www.bogotobogo.com/python/NLTK/tf_idf_with_scikit-learn_NLTK.php