def generate_TFIDF(corpus, corpus_dict, tf_dict, idf_dict):
    """
    Function to generate TF-IDF for all the words.
    :param corpus: Corpus of words in the queries.
    :param corpus_dict: Mapping of query number and its corpus.
    :param tf_dict: Term Frequency Mapping.
    :param idf_dict: Inverse Document Frequency Mapping.
    :return tf_idf_dict: Term Frequency-Inverse Document Frequency Mapping.
    """

    tf_idf_dict = dict()

    for document_number, words_in_it in corpus_dict.items():

        tf_idf_dict_each = dict()
        for word in words_in_it:

            tf_idf_dict_each[word] = tf_dict[document_number][word] * idf_dict[word]

        tf_idf_dict[document_number] = tf_idf_dict_each

    return tf_idf_dict