added functions to calculate the tf.idf of terms in documents