Skip to content

Commit 16e38ac

Browse files
Ryan MitchellRyan Mitchell
authored andcommitted
2 parents d8750ae + c6cd61c commit 16e38ac

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

chapter4/3-getTwitterStatus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from twitter import Twitter
1+
from twitter import Twitter, OAuth
22

33
#Make sure to add the access tokens and consumer keys for your application
44
t = Twitter(auth=OAuth("Access Token","Access Token Secret","Consumer Key","Consumer Secret"))
55
pythonStatuses = t.statuses.user_timeline(screen_name="montypython", count=5)
6-
print(pythonStatuses)
6+
print(pythonStatuses)

chapter5/8-sendEmailWhenChristmas.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ def sendMail(subject, body):
1010
msg['From'] = "[email protected]"
1111
msg['To'] = "[email protected]"
1212

13-
s = smtplib.SMTP('localhost')
14-
s.send_message(msg)
15-
s.quit()
13+
s = smtplib.SMTP('localhost')
14+
s.send_message(msg)
15+
s.quit()
1616

1717
bsObj = BeautifulSoup(urlopen("https://isitchristmas.com/"))
1818
while(bsObj.find("a", {"id":"answer"}).attrs['title'] == "NO"):
1919
print("It is not Christmas yet.")
2020
time.sleep(3600)
21-
bsObj = BeautifulSoup(urlopen("https://isitchristmas.com/"))
22-
sendMail("It's Christmas!", "According to http://itischristmas.com, it is Christmas!")
21+
bsObj = BeautifulSoup(urlopen("https://isitchristmas.com/"))
22+
sendMail("It's Christmas!", "According to http://itischristmas.com, it is Christmas!")

chapter8/7-NltkAnalysis.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from nltk import word_tokenize, sent_tokenize, pos_tag
2-
sentences = sent_tokenize("Google is one of the best companies in the world.
3-
I constantly google myself to see what I'm up to.")
2+
sentences = sent_tokenize("Google is one of the best companies in the world. I constantly google myself to see what I'm up to.")
43
nouns = ['NN', 'NNS', 'NNP', 'NNPS']
54

65
for sentence in sentences:
76
if "google" in sentence.lower():
87
taggedWords = pos_tag(word_tokenize(sentence))
98
for word in taggedWords:
109
if word[0].lower() == "google" and word[1] in nouns:
11-
print(sentence)
10+
print(sentence)

0 commit comments

Comments
 (0)