def calc_tf_idf(tf_matrix, idf_matrix):
    """
    creates dict of doc dict, each doc dict has key:val pais of: word : tf*idf value
    :param tf_matrix: returned by calc_tf
    :param idf_matrix: returned by calc_idf
    :return: dict of dict with word and tf*idf score for each doc in corpus
    """
    tf_idf_matrix = {}

    for (sent1, f_table1), (sent2, f_table2) in zip(tf_matrix.items(), idf_matrix.items()):
        tf_idf_table = {}
        for (word1, value1), (word2, value2) in zip(f_table1.items(),
                                                    f_table2.items()):
            tf_idf_table[word1] = float(value1 * value2)
        tf_idf_matrix[sent1] = tf_idf_table
    return tf_idf_matrix