Spaces:
Runtime error
Runtime error
Commit
β’
f746f70
1
Parent(s):
bd76069
first
Browse files
app.py
CHANGED
@@ -15,8 +15,12 @@ def search_callback():
|
|
15 |
if len(st.session_state.search_term) == 0:
|
16 |
st.error("Please enter a search term")
|
17 |
return
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
def twitter_form():
|
22 |
with st.form(key="search_form"):
|
@@ -43,7 +47,6 @@ with st.sidebar:
|
|
43 |
)
|
44 |
|
45 |
if "df" in st.session_state:
|
46 |
-
|
47 |
def make_dashboard(tweet_df, bar_color, wc_color):
|
48 |
# first row
|
49 |
col1, col2, col3 = st.columns([28, 34, 38])
|
@@ -98,16 +101,19 @@ if "df" in st.session_state:
|
|
98 |
|
99 |
st.write(adjust_tab_font, unsafe_allow_html=True)
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
15 |
if len(st.session_state.search_term) == 0:
|
16 |
st.error("Please enter a search term")
|
17 |
return
|
18 |
+
try:
|
19 |
+
st.session_state.df = hf.get_tweets(st.session_state.search_term, st.session_state.num_tweets)
|
20 |
+
st.session_state.df = hf.get_sentiment(st.session_state.df)
|
21 |
+
except:
|
22 |
+
st.error("Please enter a valid search term")
|
23 |
+
return
|
24 |
|
25 |
def twitter_form():
|
26 |
with st.form(key="search_form"):
|
|
|
47 |
)
|
48 |
|
49 |
if "df" in st.session_state:
|
|
|
50 |
def make_dashboard(tweet_df, bar_color, wc_color):
|
51 |
# first row
|
52 |
col1, col2, col3 = st.columns([28, 34, 38])
|
|
|
101 |
|
102 |
st.write(adjust_tab_font, unsafe_allow_html=True)
|
103 |
|
104 |
+
try:
|
105 |
+
tab1, tab2, tab3, tab4 = st.tabs(["All", "Positive π", "Negative βΉοΈ", "Neutral π"])
|
106 |
+
with tab1:
|
107 |
+
tweet_df = st.session_state.df
|
108 |
+
make_dashboard(tweet_df, bar_color="#1F77B4", wc_color="Blues")
|
109 |
+
with tab2:
|
110 |
+
tweet_df = st.session_state.df.query("Sentiment == 'Positive'")
|
111 |
+
make_dashboard(tweet_df, bar_color="#54A24B", wc_color="Greens")
|
112 |
+
with tab3:
|
113 |
+
tweet_df = st.session_state.df.query("Sentiment == 'Negative'")
|
114 |
+
make_dashboard(tweet_df, bar_color="#FF7F0E", wc_color="Oranges")
|
115 |
+
with tab4:
|
116 |
+
tweet_df = st.session_state.df.query("Sentiment == 'Neutral'")
|
117 |
+
make_dashboard(tweet_df, bar_color="#1F77B4", wc_color="Blues")
|
118 |
+
except:
|
119 |
+
st.error("No plots to display.")
|