Update sentiment.py
Browse files- sentiment.py +4 -2
sentiment.py
CHANGED
@@ -41,6 +41,7 @@ reddit = praw.Reddit(
|
|
41 |
stemmer = PorterStemmer()
|
42 |
nlp = spacy.load("en_core_web_sm")
|
43 |
nltk.download('punkt')
|
|
|
44 |
|
45 |
|
46 |
# Model configs
|
@@ -103,8 +104,9 @@ def transform_text(text):
|
|
103 |
print('inside transformtext1')
|
104 |
text = [i for i in text if i.isalnum()]
|
105 |
print('inside transformtext2')
|
106 |
-
|
107 |
-
|
|
|
108 |
print('inside transformtext3')
|
109 |
text = [stemmer.stem(i) for i in text]
|
110 |
print('inside transformtext4')
|
|
|
41 |
stemmer = PorterStemmer()
|
42 |
nlp = spacy.load("en_core_web_sm")
|
43 |
nltk.download('punkt')
|
44 |
+
nltk.download('stopwords')
|
45 |
|
46 |
|
47 |
# Model configs
|
|
|
104 |
print('inside transformtext1')
|
105 |
text = [i for i in text if i.isalnum()]
|
106 |
print('inside transformtext2')
|
107 |
+
stopwords_set = set(stopwords.words('english'))
|
108 |
+
text = [i for i in text if i not in stopwords_set and i not in string.punctuation]
|
109 |
+
|
110 |
print('inside transformtext3')
|
111 |
text = [stemmer.stem(i) for i in text]
|
112 |
print('inside transformtext4')
|