# This is just an excerpt of code. For the full program, please
# visit the Jupyter notebook on github.

#Setup our data
theTweet = "We have some delightful new food in the cafeteria. Awesome!!!"
positive_words=['awesome','good','nice','super','fun','delightful']
negative_words=['awful','lame','horrible','bad']

#Tokenize the text
import re
theTokens = re.findall(r'\b\w[\w-]*\b', theTweet.lower())

#Calculate the number of positive words
numPosWords = 0
for word in theTokens:
    if word in positive_words:
        numPosWords += 1

#Calculate the number of negative words
numNegWords = 0
for word in theTokens:
    if word in negative_words:
        numNegWords += 1

#Calculate the percentages of positive and negative words
numWords = len(theTokens)
percntPos = numPosWords / numWords
percntNeg = numNegWords / numWords
print("Positive: " + "{:.0%}".format(percntPos) + "  Negative: " + "{:.0%}".format(percntNeg))

#Determine whether the tweet is positive or negative, print the result
if numPosWords &gt; numNegWords:
    print("Positive " + str(numPosWords) + ":" + str(numNegWords))
elif numNegWords &gt; numPosWords:
    print("Negative " + str(numPosWords) + ":" + str(numNegWords))
elif numNegWords == numPosWords:
    print("Neither " + str(numPosWords) + ":" + str(numNegWords))
    
print()
