Skip to content

Commit c6cd61c

Browse files
committed
Update 7-NltkAnalysis.py
1 parent 8864e3f commit c6cd61c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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)