numpy version of tfidf.py