def get_termfrequency_vector(word2wid, wordlist):
    """
    Calculate the term frequency vector.

    Parameters
    ----------
    word2wid : dict
        Map a word to a unique ID (0, ..., |vocabulary|)
    wordlist : list of str

    Returns
    -------
    termfrequency vector : list of ints
        List has the same length as vocabulary
    """
    document_tf_vector = [0 for term in range(len(word2wid))]
    for w in wordlist:
        if w not in word2wid:
            if '<OOV>' in word2wid:
                document_tf_vector[word2wid['<OOV>']] += 1
            continue
        document_tf_vector[word2wid[w]] += 1
    return document_tf_vector