def generate_TF(corpus, corpus_dict):
    """
    Function to generate TF for queries.
    :param corpus: Corpus of words in the queries.
    :param corpus_dict: Mapping of query number and its corpus.
    :return tf_dict: Term Frequency Mapping.
    """

    tf_dict = dict()
    for document_number, words_in_it in corpus_dict.items():

        tf_dict_each = dict()
        for doc_word in words_in_it:

            tf_dict_each[doc_word] = words_in_it.count(doc_word) / len(words_in_it)

        tf_dict[document_number] = tf_dict_each

    return tf_dict