Spaces:
Runtime error
Runtime error
jmansfield89
commited on
Commit
•
5b0d194
1
Parent(s):
c025aa9
Update app.py
Browse filesCenter chart title and update header and footer
app.py
CHANGED
@@ -36,15 +36,13 @@ def data_manipulation(df_redacted):
|
|
36 |
return sentiment_counts, sentiment
|
37 |
|
38 |
|
39 |
-
def display_header(
|
40 |
"""
|
41 |
Displays the header section of the app.
|
42 |
"""
|
43 |
-
st.
|
44 |
-
|
45 |
-
|
46 |
-
st.markdown('**Results:** Most frequent sentiment category for the replies to this Tweet: **{}**'.format(sentiment))
|
47 |
-
|
48 |
|
49 |
def display_chart(sentiment_counts):
|
50 |
"""
|
@@ -54,20 +52,24 @@ def display_chart(sentiment_counts):
|
|
54 |
fig = px.bar(sentiment_counts,
|
55 |
x='Sentiment',
|
56 |
y='Count',
|
57 |
-
title='Tweet Replies
|
58 |
-
|
59 |
st.plotly_chart(fig, use_container_width=True)
|
60 |
|
61 |
|
62 |
-
def display_footer():
|
63 |
"""
|
64 |
Displays the footer section of the app.
|
65 |
"""
|
|
|
|
|
|
|
|
|
66 |
st.markdown('**Notes:** ')
|
67 |
st.markdown('- The VADER model was used to analyze the sentiment of each reply: '
|
68 |
'https://github.com/cjhutto/vaderSentiment')
|
69 |
st.markdown('- Due to Twitter developer policies, I am not able to share the data set of downloaded Tweet replies '
|
70 |
-
'so my DATA EXTRACTION and DATA CLEANSING steps are not shown at this time
|
71 |
st.markdown('**Plans for Version 2.0:**')
|
72 |
st.markdown('- Formulate method for cleaning Tweet replies, such as removing those that are from bots or are spam.')
|
73 |
st.markdown('- Analyze the sentiment of replies using the BERTweet model, which would be more appropriate for this '
|
@@ -85,9 +87,9 @@ def main():
|
|
85 |
sentiment_counts, sentiment = data_manipulation(df_redacted)
|
86 |
|
87 |
# DISPLAY DATA
|
88 |
-
display_header(
|
89 |
display_chart(sentiment_counts)
|
90 |
-
display_footer()
|
91 |
|
92 |
|
93 |
if __name__ == '__main__':
|
|
|
36 |
return sentiment_counts, sentiment
|
37 |
|
38 |
|
39 |
+
def display_header(sentiment):
|
40 |
"""
|
41 |
Displays the header section of the app.
|
42 |
"""
|
43 |
+
st.header('This app runs a sentiment analysis of the replies to a Facebook Tweet '
|
44 |
+
'announcing their rebranding to Meta.')
|
45 |
+
st.header('RESULT: {}'.format(sentiment))
|
|
|
|
|
46 |
|
47 |
def display_chart(sentiment_counts):
|
48 |
"""
|
|
|
52 |
fig = px.bar(sentiment_counts,
|
53 |
x='Sentiment',
|
54 |
y='Count',
|
55 |
+
title='Tweet Replies Count by Sentiment Category')
|
56 |
+
fig.update_layout(title_x=0.5)
|
57 |
st.plotly_chart(fig, use_container_width=True)
|
58 |
|
59 |
|
60 |
+
def display_footer(tweet_url, sentiment):
|
61 |
"""
|
62 |
Displays the footer section of the app.
|
63 |
"""
|
64 |
+
st.markdown('**Objective:** Understand public sentiment of a Tweet by analyzing the sentiment of each reply.')
|
65 |
+
st.markdown('**Analysis:** This app runs sentiment analysis on 10,948 replies to a Facebook Tweet announcing '
|
66 |
+
'their rebranding to Meta on 10/28/2021. Link to Tweet: {}'.format(tweet_url))
|
67 |
+
st.markdown('**Results:** Most frequent sentiment category for the replies to this Tweet: **{}**'.format(sentiment))
|
68 |
st.markdown('**Notes:** ')
|
69 |
st.markdown('- The VADER model was used to analyze the sentiment of each reply: '
|
70 |
'https://github.com/cjhutto/vaderSentiment')
|
71 |
st.markdown('- Due to Twitter developer policies, I am not able to share the data set of downloaded Tweet replies '
|
72 |
+
'so my DATA EXTRACTION and DATA CLEANSING steps are not shown at this time but will be added soon!')
|
73 |
st.markdown('**Plans for Version 2.0:**')
|
74 |
st.markdown('- Formulate method for cleaning Tweet replies, such as removing those that are from bots or are spam.')
|
75 |
st.markdown('- Analyze the sentiment of replies using the BERTweet model, which would be more appropriate for this '
|
|
|
87 |
sentiment_counts, sentiment = data_manipulation(df_redacted)
|
88 |
|
89 |
# DISPLAY DATA
|
90 |
+
display_header(sentiment)
|
91 |
display_chart(sentiment_counts)
|
92 |
+
display_footer(tweet_url, sentiment)
|
93 |
|
94 |
|
95 |
if __name__ == '__main__':
|