from typing import OrderedDict
import math


def calc_idf(word_tf: dict, docs_word: OrderedDict):
    """
    idf = natural log of (total number of docs / docs in which target word occurs)
    :param word_tf: dict returned by calc_tf
    :param docs_word: OrderedDict returned by count_tweets_for_word
    :return: dict of dict, each tweet has dict of inverse document frequency values
    """
    idf_matrix = {}
    doc_count: int = len(word_tf)
    for sent, tf in word_tf.items():
        idf_table = {}
        for word in tf.keys():
            idf_table[word] = math.log(doc_count / int(docs_word[word]))
        idf_matrix[sent] = idf_table

    return idf_matrix