Update sentiment.py
Browse files- sentiment.py +6 -1
sentiment.py
CHANGED
@@ -97,12 +97,17 @@ def get_reddit_results(query):
|
|
97 |
|
98 |
|
99 |
def transform_text(text):
|
|
|
100 |
text = text.lower()
|
101 |
text = nltk.word_tokenize(text)
|
|
|
102 |
text = [i for i in text if i.isalnum()]
|
|
|
103 |
text = [i for i in text if i not in stopwords.words(
|
104 |
'english') and i not in string.punctuation]
|
|
|
105 |
text = [stemmer.stem(i) for i in text]
|
|
|
106 |
return ' '.join(text)
|
107 |
|
108 |
|
@@ -126,7 +131,7 @@ def analyze_comments(results, query):
|
|
126 |
for comment in all_comments:
|
127 |
print('inside comment')
|
128 |
comment_body = comment.body
|
129 |
-
|
130 |
text = transform_text(comment_body)
|
131 |
print(text)
|
132 |
comments_for_cloud.append(comment_body)
|
|
|
97 |
|
98 |
|
99 |
def transform_text(text):
|
100 |
+
print('inside transformtext0')
|
101 |
text = text.lower()
|
102 |
text = nltk.word_tokenize(text)
|
103 |
+
print('inside transformtext1')
|
104 |
text = [i for i in text if i.isalnum()]
|
105 |
+
print('inside transformtext2')
|
106 |
text = [i for i in text if i not in stopwords.words(
|
107 |
'english') and i not in string.punctuation]
|
108 |
+
print('inside transformtext3')
|
109 |
text = [stemmer.stem(i) for i in text]
|
110 |
+
print('inside transformtext4')
|
111 |
return ' '.join(text)
|
112 |
|
113 |
|
|
|
131 |
for comment in all_comments:
|
132 |
print('inside comment')
|
133 |
comment_body = comment.body
|
134 |
+
print(comment_body)
|
135 |
text = transform_text(comment_body)
|
136 |
print(text)
|
137 |
comments_for_cloud.append(comment_body)
|