This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tweet_string = "Thanks to the historic TAX CUTS that I signed into law, your paychecks are going way UP, your taxes are going way DOWN, and America is once again OPEN FOR BUSINESS!" | |
tweet_words = tweet_string.split() | |
number_of_words = len(tweet_words) | |
print(tweet_words) | |
print("Number of words in this tweet is: " + str(number_of_words)) | |
# Iterate through the words in the tweet string | |
print("Words in the tweet are:") | |
for w in tweet_words: | |
len_of_w = len(w) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
To evaluate the good or bad score of a tweet, we count the number of good and | |
bad words in it. | |
if a word is good, increase the value of good_words by one | |
else if a word is bad, increase the value of bad_words by one | |
if good_words > bad_words then it's a good tweet otherwise it's a bad tweet | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
To evaluate the good or bad score of a tweet, we first split our tweet. | |
We then associate each word with positive and negative values, respectively, using a dictionary. | |
Finally, we caculate the average word weight of a tweet, and decide if it's a good or bad one | |
based on that. | |
""" | |
# Break down a string into words |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
To evaluate the good or bad score of a tweet, we first tokenize the tweet, and then | |
stemmize each word in our tweet. We also associate each stem with positive and negative values, | |
respectively, using a dictionary. | |
Finally, we caculate the average word weight of a tweet, and decide if it's a good or bad one | |
based on that. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"thank": 1.0, | |
"to": 0.0, | |
"the": 0.0, | |
"histor": 0.5, | |
"cut": 0.0, | |
"that": 0.0, | |
"I": 0.0, | |
"sign": 0.0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
To evaluate the good or bad score of a tweet, we first tokenize the tweet, and then | |
stemmize each word in our tweet. We also associate each stem with positive and negative values, | |
respectively, using a dictionary. | |
Finally, we caculate the average word weight of a tweet, and decide if it's a good or bad one | |
based on that. | |
""" | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = open('sample.json') | |
myJson = json.load(f) | |
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('sample.json') as f: | |
myJson = json.load(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"consumer_key": "YOUR CONSUMER KEY", | |
"consumer_secret": "YOUR CUSTOMER SECRET", | |
"access_token_key": "YOUR ACCESS TOKEN KEY", | |
"access_token_secret": "YOUR ACCESS TOKEN SECRET" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
To evaluate the good or bad score of a tweet, we count the number of good and | |
bad words in it. | |
if a word is good, increase the value of good_words by one | |
else if a word is bad, increase the value of bad_words by one | |
if good_words > bad_words then it's a good tweet otherwise it's a bad tweet | |
""" | |
import json |
OlderNewer