Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,43 @@ import re
|
|
21 |
|
22 |
nltk.download('stopwords')
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
st.subheader("YouTube Comments Sentiment Analysis", divider="red")
|
25 |
tokenizer = transformers.DistilBertTokenizer.from_pretrained("tabularisai/robust-sentiment-analysis")
|
26 |
model = transformers.DistilBertForSequenceClassification.from_pretrained("tabularisai/robust-sentiment-analysis")
|
@@ -83,6 +120,7 @@ if st.button("Sentiment Analysis", type="secondary"):
|
|
83 |
driver.quit()
|
84 |
df = pd.DataFrame(data, columns=["Comment"])
|
85 |
st.dataframe(df)
|
|
|
86 |
if tokenizer and model:
|
87 |
inputs = tokenizer(df['Comment'].tolist(), return_tensors="pt", padding=True, truncation=True)
|
88 |
with torch.no_grad():
|
@@ -92,7 +130,11 @@ if st.button("Sentiment Analysis", type="secondary"):
|
|
92 |
results = []
|
93 |
for i, label in enumerate(predicted_labels):
|
94 |
results.append({'Review Number': i + 1, 'Sentiment': model.config.id2label[label.item()]})
|
95 |
-
|
|
|
|
|
|
|
|
|
96 |
value_counts1 = sentiment_df['Sentiment'].value_counts().rename_axis('Sentiment').reset_index(name='count')
|
97 |
final_df = value_counts1
|
98 |
tab1, tab2 = st.tabs(["Pie Chart", "Word Cloud"])
|
|
|
21 |
|
22 |
nltk.download('stopwords')
|
23 |
|
24 |
+
with st.sidebar:
|
25 |
+
st.button("DEMO APP", type="primary")
|
26 |
+
|
27 |
+
|
28 |
+
expander = st.expander("**Important notes on the YouTube Comments Sentiment Analysis App**")
|
29 |
+
expander.write('''
|
30 |
+
|
31 |
+
|
32 |
+
**How to Use**
|
33 |
+
This app works with a YouTube URL. Paste the URL and press the 'Sentiment Analysis' button to perform sentiment analysis on your YouTube Comments.
|
34 |
+
|
35 |
+
|
36 |
+
**Usage Limits**
|
37 |
+
You can perform sentiment analysis on YouTube Comments up to 5 times.
|
38 |
+
|
39 |
+
|
40 |
+
**Subscription Management**
|
41 |
+
This demo app offers a one-day subscription, expiring after 24 hours. If you are interested in building your own YouTube Comments Sentiment Analysis Web App, we invite you to explore our NLP Web App Store on our website. You can select your desired features, place your order, and we will deliver your custom app in five business days. If you wish to delete your Account with us, please contact us at [email protected]
|
42 |
+
|
43 |
+
|
44 |
+
**Customization**
|
45 |
+
To change the app's background color to white or black, click the three-dot menu on the right-hand side of your app, go to Settings and then Choose app theme, colors and fonts.
|
46 |
+
|
47 |
+
|
48 |
+
**Charts**
|
49 |
+
Hover to interact with and download the charts.
|
50 |
+
|
51 |
+
|
52 |
+
**File Handling and Errors**
|
53 |
+
For any errors or inquiries, please contact us at [email protected]
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
''')
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
st.subheader("YouTube Comments Sentiment Analysis", divider="red")
|
62 |
tokenizer = transformers.DistilBertTokenizer.from_pretrained("tabularisai/robust-sentiment-analysis")
|
63 |
model = transformers.DistilBertForSequenceClassification.from_pretrained("tabularisai/robust-sentiment-analysis")
|
|
|
120 |
driver.quit()
|
121 |
df = pd.DataFrame(data, columns=["Comment"])
|
122 |
st.dataframe(df)
|
123 |
+
|
124 |
if tokenizer and model:
|
125 |
inputs = tokenizer(df['Comment'].tolist(), return_tensors="pt", padding=True, truncation=True)
|
126 |
with torch.no_grad():
|
|
|
130 |
results = []
|
131 |
for i, label in enumerate(predicted_labels):
|
132 |
results.append({'Review Number': i + 1, 'Sentiment': model.config.id2label[label.item()]})
|
133 |
+
sentiment_df1 = pd.DataFrame(results)
|
134 |
+
sentiment_df = sentiment_df1.drop(sentiment_df.columns[['Review Number']], axis=1)
|
135 |
+
|
136 |
+
|
137 |
+
|
138 |
value_counts1 = sentiment_df['Sentiment'].value_counts().rename_axis('Sentiment').reset_index(name='count')
|
139 |
final_df = value_counts1
|
140 |
tab1, tab2 = st.tabs(["Pie Chart", "Word Cloud"])
|