Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -81,23 +81,44 @@ def main():
|
|
| 81 |
st.title("YouTube Comments Sentiment Analysis")
|
| 82 |
|
| 83 |
# Create sidebar section for app description and links
|
| 84 |
-
st.sidebar.title("
|
| 85 |
-
st.sidebar.write("Welcome to the YouTube Comments Sentiment Analysis App
|
| 86 |
-
st.sidebar.write("
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
# Dropdown menu for other app links
|
| 90 |
app_links = {
|
| 91 |
-
"
|
| 92 |
-
"
|
| 93 |
}
|
| 94 |
selected_app = st.sidebar.selectbox("Select an App", list(app_links.keys()))
|
| 95 |
if st.sidebar.button("Go to App"):
|
| 96 |
st.sidebar.write(f"You are now redirected to {selected_app}")
|
| 97 |
st.sidebar.write(f"Link: {app_links[selected_app]}")
|
| 98 |
st.sidebar.success("Redirected successfully!")
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
|
|
|
| 101 |
video_url = st.text_input("YouTube Video URL:")
|
| 102 |
|
| 103 |
if st.button("Extract Comments and Analyze"):
|
|
@@ -106,12 +127,15 @@ def main():
|
|
| 106 |
comments_df = fetch_comments(video_id)
|
| 107 |
comments_df['sentiment'] = comments_df['comment'].apply(lambda x: analyze_sentiment(x[:512]))
|
| 108 |
sentiment_counts = comments_df['sentiment'].value_counts()
|
| 109 |
-
|
|
|
|
| 110 |
# Create pie chart
|
|
|
|
| 111 |
fig_pie = px.pie(values=sentiment_counts.values, names=sentiment_counts.index, title='Sentiment Distribution')
|
| 112 |
st.plotly_chart(fig_pie, use_container_width=True)
|
| 113 |
|
| 114 |
# Create bar chart
|
|
|
|
| 115 |
fig_bar = px.bar(x=sentiment_counts.index, y=sentiment_counts.values, labels={'x': 'Sentiment', 'y': 'Count'}, title='Sentiment Counts')
|
| 116 |
st.plotly_chart(fig_bar)
|
| 117 |
|
|
|
|
| 81 |
st.title("YouTube Comments Sentiment Analysis")
|
| 82 |
|
| 83 |
# Create sidebar section for app description and links
|
| 84 |
+
st.sidebar.title("Comment Feel")
|
| 85 |
+
st.sidebar.write("Welcome to the YouTube Comments Sentiment Analysis App π₯")
|
| 86 |
+
st.sidebar.write("""
|
| 87 |
+
|
| 88 |
+
**Description** π
|
| 89 |
+
This project utilizes a pre-trained sentiment analysis model based on BERT and TensorFlow to analyze the sentiment of comments from a YouTube video. Users can input a YouTube video URL, fetch related comments, and determine their sentiments (positive, negative, or neutral).
|
| 90 |
+
|
| 91 |
+
Input a valid YouTube video URL in the provided text box π.
|
| 92 |
+
Click "Extract Comments and Analyze" to fetch comments and analyze sentiments π.
|
| 93 |
+
View sentiment analysis results via pie and bar charts π.
|
| 94 |
+
|
| 95 |
+
Credits π
|
| 96 |
+
|
| 97 |
+
Coder: Aniket Panchal
|
| 98 |
+
GitHub: https://github.com/Aniket2021448
|
| 99 |
+
|
| 100 |
+
Contact π§
|
| 101 |
+
For any inquiries or feedback, please contact [email protected]
|
| 102 |
+
|
| 103 |
+
""")
|
| 104 |
+
st.sidebar.write("Feel free to check out my other apps:")
|
| 105 |
|
| 106 |
# Dropdown menu for other app links
|
| 107 |
app_links = {
|
| 108 |
+
"Movie-mind": "https://movie-mind.streamlit.app/",
|
| 109 |
+
"find-fake-news": "https://find-fake-news.streamlit.app/"
|
| 110 |
}
|
| 111 |
selected_app = st.sidebar.selectbox("Select an App", list(app_links.keys()))
|
| 112 |
if st.sidebar.button("Go to App"):
|
| 113 |
st.sidebar.write(f"You are now redirected to {selected_app}")
|
| 114 |
st.sidebar.write(f"Link: {app_links[selected_app]}")
|
| 115 |
st.sidebar.success("Redirected successfully!")
|
| 116 |
+
|
| 117 |
+
st.sidebar.write("In case the apps are down, because of less usage")
|
| 118 |
+
st.sidebar.write("Kindly reach out to me @ [email protected]")
|
| 119 |
|
| 120 |
+
|
| 121 |
+
st.write("Enter a YouTube video link below: :movie_camera:")
|
| 122 |
video_url = st.text_input("YouTube Video URL:")
|
| 123 |
|
| 124 |
if st.button("Extract Comments and Analyze"):
|
|
|
|
| 127 |
comments_df = fetch_comments(video_id)
|
| 128 |
comments_df['sentiment'] = comments_df['comment'].apply(lambda x: analyze_sentiment(x[:512]))
|
| 129 |
sentiment_counts = comments_df['sentiment'].value_counts()
|
| 130 |
+
|
| 131 |
+
st.write("Based on top :100: comments from this video")
|
| 132 |
# Create pie chart
|
| 133 |
+
st.write("Pie chart representation :chart_with_upwards_trend:")
|
| 134 |
fig_pie = px.pie(values=sentiment_counts.values, names=sentiment_counts.index, title='Sentiment Distribution')
|
| 135 |
st.plotly_chart(fig_pie, use_container_width=True)
|
| 136 |
|
| 137 |
# Create bar chart
|
| 138 |
+
st.write("Bar plot representation :bar_chart:")
|
| 139 |
fig_bar = px.bar(x=sentiment_counts.index, y=sentiment_counts.values, labels={'x': 'Sentiment', 'y': 'Count'}, title='Sentiment Counts')
|
| 140 |
st.plotly_chart(fig_bar)
|
| 141 |
|