def dot_product(tf1, tf2):
    """
    Calculates the dot product of two term frquency vectors.

    Returns the dot product of the frequencies of matching terms
    in two term frequency vectors. The term frequency vectors are
    dictionaries with the term as the key and the frequency as the value.

    Parameters:
    tf1 (dict): Term frequency vector 1 {(term, ): frequency}
    tf2 (dict): Term frequency vector 2 {(term, ): frequency}

    Returns:
    int: Dot product of the frequencies of matching terms
    """
    sum = 0.0
    for k1 in tf1:
        if k1 in tf2:
            sum = sum + (tf1[k1] * tf2[k1])
    return sum