Computer Science 1026A/B Chapter 7: COMPSCI-1026-Lab-7-Code

289 views1 pages
text = open("keywords.txt", "r")
for x in range(0,10):
line = text.readline()
words = line.rsplit(',')
if int(words[1]) == 20:
elif int(words[1]) == 0:
elif int(words[1]) == -10:
print("The positive keywords are", POSITIVE_WORDS)
print("The negative keywords are", NEGATIVE_WORDS)
print("The neutral keywords are", NEUTRAL_WORDS)
TWEET = "I really am very happy for you I love the weather I am also sad and have some
regrets about being so tired"
tweetWords = TWEET.rsplit()
sentiment = 0
for word in tweetWords:
if word in POSITIVE_WORDS:
sentiment = sentiment + 20
elif word in NEGATIVE_WORDS:
sentiment = sentiment - 10
print("The sentiment of the tweet is", sentiment)
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 pages and 3 million more documents.

Already have an account? Log in

Get OneClass Notes+

Unlimited access to class notes and textbook notes.

YearlyBest Value
75% OFF
$8 USD/m
$30 USD/m
You will be charged $96 USD upfront and auto renewed at the end of each cycle. You may cancel anytime under Payment Settings. For more information, see our Terms and Privacy.
Payments are encrypted using 256-bit SSL. Powered by Stripe.