import string


def get_sentiment(text, word_map):
    """
    Identifies the overall sentiment of the text by taking the average
    of each word.

    Note: Words not found in the word_map dict are give zero value.
    """

    # remove all punctuation
    text = text.translate(str.maketrans("", "", string.punctuation))

    # split into tokens
    text = text.split()
    total_score, length = 0, 0

    # get score for each word, put zero if not found
    scores = (word_map.get(token.lower(), 0) for token in text)

    # find average score
    for score in scores:
        total_score += score
        length += 1

    return total_score / length