import math


def compute_idf(df_corpus, doc_size, math_log=False):
    """
    Compute IDF (Inverted Document Frequency)
    
    Args:
        df_corpus (dict): terms in document
        doc_size (int): total document size
        math_log (bool): logarithm of the result
    """
    return {k: doc_size * 1.0 / v if math_log is False \
        else math.log(doc_size * 1.0 / v) \
            for k, v in df_corpus.items()}