Assignment 1 and Lectures 1-2 Discussions

The deadline seems to be extended again. Ask some group questions here first. The global forum is here as well.

Hey guys. I have wondered something about the last optional question: “Q (Optional): What is the fraction of tweets that are neutral i.e. neither happy nor sad.”

The obvious solution would be to determine

number_of_neutral_tweets = 0

from the previously determined variables,
number_of_sad_tweets and number_of_happy_tweets

My question is if it will be possible to determine this without first calculating the happy and sad tweets?

I tried

all_sentiment_words = happy_words + sad_words

for tweet in tweets:
    for word not in all_sentiment_words:
        if word in tweet:
            number_of_neutral_tweets += 1

print(number_of_neutral_tweets)

This of course counts every word that is not a happy or sad word for every tweet. So my total of neutral tweets add up to 122 which is more than the actual tweets.

Does anyone know of a way to do this without calculating the happy/sad tweets first?

2 Likes