Implement tf*idf weighting