Implementation of document-term sparse matrix construction and re-weighting.