import math


def doc_distance(tf1, tf2):
    """
    Computes a dot-product for the two term-frequency dictionaries provided. Returns float; higher numbers mean better correlation.
    """
    common_words = set(tf1.keys()) & set(tf2.keys())
    ret = 0.0
    for word in common_words:
        ret += tf1[word] * tf2[word] * math.log(len(word))
    return ret