nlpblogs commited on
Commit
49549b5
·
verified ·
1 Parent(s): 9f04557

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -17
app.py CHANGED
@@ -32,13 +32,6 @@ import plotly.express as px
32
  import zipfile
33
  import torch
34
 
35
- import matplotlib.pyplot as plt
36
- from wordcloud import WordCloud
37
- from nltk.corpus import stopwords
38
-
39
- import nltk
40
- nltk.download('stopwords')
41
-
42
 
43
 
44
  with st.sidebar:
@@ -142,8 +135,7 @@ if st.button("Sentiment Analysis", type="secondary"):
142
  st.error(f"Exception during comment extraction: {e}")
143
  driver.quit()
144
  df = pd.DataFrame(data, columns=["Comment"])
145
-
146
-
147
 
148
  if tokenizer and model:
149
  inputs = tokenizer(df['Comment'].tolist(), return_tensors="pt", padding=True, truncation=True)
@@ -164,9 +156,12 @@ if st.button("Sentiment Analysis", type="secondary"):
164
  fig1.update_traces(textposition='inside', textinfo='percent+label')
165
  st.plotly_chart(fig1)
166
 
 
 
 
167
  with tab2:
168
  text = " ".join(comment for comment in df['Comment'])
169
- stopwords_set = set(stopwords.words('english')) # Correct import and usage
170
  text = re.sub('[^A-Za-z]+', ' ', text)
171
  words = text.split()
172
  clean_text = [word for word in words if word.lower() not in stopwords_set]
@@ -177,8 +172,6 @@ if st.button("Sentiment Analysis", type="secondary"):
177
  plt.axis('off')
178
  st.pyplot(fig)
179
 
180
- result = pd.concat([df, sentiment_df], axis=1)
181
-
182
 
183
  csv = result.to_csv(index=False)
184
  st.download_button(
@@ -193,11 +186,8 @@ if st.button("Sentiment Analysis", type="secondary"):
193
  else:
194
  st.warning(f"You have reached the maximum URL attempts ({max_attempts}).")
195
 
196
- if 'url_count' in st.session_state:
197
  st.write(f"URL pasted {st.session_state['url_count']} times.")
198
 
199
 
200
-
201
-
202
-
203
-
 
32
  import zipfile
33
  import torch
34
 
 
 
 
 
 
 
 
35
 
36
 
37
  with st.sidebar:
 
135
  st.error(f"Exception during comment extraction: {e}")
136
  driver.quit()
137
  df = pd.DataFrame(data, columns=["Comment"])
138
+ st.dataframe(df)
 
139
 
140
  if tokenizer and model:
141
  inputs = tokenizer(df['Comment'].tolist(), return_tensors="pt", padding=True, truncation=True)
 
156
  fig1.update_traces(textposition='inside', textinfo='percent+label')
157
  st.plotly_chart(fig1)
158
 
159
+ result = pd.concat([df, sentiment_df], axis=1)
160
+
161
+
162
  with tab2:
163
  text = " ".join(comment for comment in df['Comment'])
164
+ stopwords_set = set(stopwords.words('english'))
165
  text = re.sub('[^A-Za-z]+', ' ', text)
166
  words = text.split()
167
  clean_text = [word for word in words if word.lower() not in stopwords_set]
 
172
  plt.axis('off')
173
  st.pyplot(fig)
174
 
 
 
175
 
176
  csv = result.to_csv(index=False)
177
  st.download_button(
 
186
  else:
187
  st.warning(f"You have reached the maximum URL attempts ({max_attempts}).")
188
 
189
+ if 'url_count' in st.session_state: #added if statement.
190
  st.write(f"URL pasted {st.session_state['url_count']} times.")
191
 
192
 
193
+