def _compute_term_frequency(self, matrix, smooth=0.4):
    '\n        Computes TF metrics for each sentence (column) in the given matrix.\n        You can read more about smoothing parameter at URL below:\n        http://nlp.stanford.edu/IR-book/html/htmledition/maximum-tf-normalization-1.html\n        '
    assert (0.0 <= smooth < 1.0)
    max_word_frequencies = numpy.max(matrix, axis=0)
    (rows, cols) = matrix.shape
    for row in range(rows):
        for col in range(cols):
            max_word_frequency = max_word_frequencies[col]
            if (max_word_frequency != 0):
                frequency = (matrix[(row, col)] / max_word_frequency)
                matrix[(row, col)] = (smooth + ((1.0 - smooth) * frequency))
    return matrix
Computes TF metrics for each sentence (column) in the given matrix.
You can read more about smoothing parameter at URL below:
http://nlp.stanford.edu/IR-book/html/htmledition/maximum-tf-normalization-1.html
def _compute_term_frequency(self, matrix, smooth=0.4):
    '\n        Computes TF metrics for each sentence (column) in the given matrix.\n        You can read more about smoothing parameter at URL below:\n        http://nlp.stanford.edu/IR-book/html/htmledition/maximum-tf-normalization-1.html\n        '
    assert (0.0 <= smooth < 1.0)
    max_word_frequencies = numpy.max(matrix, axis=0)
    (rows, cols) = matrix.shape
    for row in range(rows):
        for col in range(cols):
            max_word_frequency = max_word_frequencies[col]
            if (max_word_frequency != 0):
                frequency = (matrix[(row, col)] / max_word_frequency)
                matrix[(row, col)] = (smooth + ((1.0 - smooth) * frequency))
    return matrix