def get_words_prob(test_words_list:list, normal_words_freq:dict, spam_words_freq:dict, normal_file_number:int, spam_file_number:int,
                   max_prob_num:int):
    """
    Calculate the probability of spam for every words, p(s|wi)
    Args:
        test_words_list: the words list to test
        normal_words_freq: the words frequency in normal mail
        spam_words_freq: the words frequency in spam mail
        normal_file_number: the file number of normal mail
        spam_file_number: the file number of spam mail
        max_prob_num: the number of most max probability to consideration

    Returns: the dictionary of the most max-N probability

    """
    words_prob = {}
    for word in set(test_words_list):
        prob_ws = spam_words_freq[word] / spam_file_number if word in spam_words_freq.keys() else 0.01
        prob_wn = normal_words_freq[word] / normal_file_number if word in normal_words_freq.keys() else 0.01

        prob_sw = 0.4 if prob_ws == 0.01 and prob_wn == 0.01 else prob_ws / (prob_ws + prob_wn)
        words_prob[word] = prob_sw
    words_prob = dict(sorted(words_prob.items(), key=lambda d: d[1], reverse=True)[0:max_prob_num])
    return words_prob