Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,38 +1,34 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
st.set_page_config(page_title="Stock News Sentiment Analysis", layout="centered")
|
| 4 |
-
|
| 5 |
from func import fetch_news, analyze_sentiment, extract_org_entities
|
| 6 |
import time
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
st.
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
unsafe_allow_html=True
|
| 33 |
-
)
|
| 34 |
|
| 35 |
-
#
|
| 36 |
free_text = st.text_area("Enter text mentioning companies:", height=100)
|
| 37 |
tickers = extract_org_entities(free_text)
|
| 38 |
|
|
@@ -41,7 +37,7 @@ if tickers:
|
|
| 41 |
else:
|
| 42 |
tickers = []
|
| 43 |
|
| 44 |
-
#
|
| 45 |
if st.button("Get News and Sentiment"):
|
| 46 |
if not tickers:
|
| 47 |
st.warning("Please mention at least one recognizable company.")
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 2 |
from func import fetch_news, analyze_sentiment, extract_org_entities
|
| 3 |
import time
|
| 4 |
|
| 5 |
+
# 必须放在最前
|
| 6 |
+
st.set_page_config(page_title="Stock News Sentiment Analysis", layout="centered")
|
| 7 |
+
|
| 8 |
+
# ----------- Header Section with Logo and Title (Safe for all environments) -----------
|
| 9 |
+
col1, col2 = st.columns([1, 10])
|
| 10 |
+
with col1:
|
| 11 |
+
st.image(
|
| 12 |
+
"https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Finance_Icon_Set_2013_-_Analytics.svg/1024px-Finance_Icon_Set_2013_-_Analytics.svg.png",
|
| 13 |
+
width=48
|
| 14 |
+
)
|
| 15 |
+
with col2:
|
| 16 |
+
st.markdown("<h1 style='margin-bottom: 0;'>Stock News Sentiment Analysis</h1>", unsafe_allow_html=True)
|
| 17 |
|
| 18 |
+
# ----------- Description Below Title -----------
|
| 19 |
+
st.markdown("""
|
| 20 |
+
<p style='font-size:17px; margin-top: 0.5rem;'>
|
| 21 |
+
Analyze the latest news sentiment of companies mentioned in your input.
|
| 22 |
+
</p>
|
| 23 |
+
<p style='font-size:17px;'>
|
| 24 |
+
<strong>💡 Try input like:</strong> <em>I want to check Apple, Tesla, and Microsoft.</em>
|
| 25 |
+
</p>
|
| 26 |
+
<p style='font-size:17px;'>
|
| 27 |
+
<strong>Note:</strong> News may fail to load if the Finviz website structure changes or access is restricted.
|
| 28 |
+
</p>
|
| 29 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
# ----------- User Input -----------
|
| 32 |
free_text = st.text_area("Enter text mentioning companies:", height=100)
|
| 33 |
tickers = extract_org_entities(free_text)
|
| 34 |
|
|
|
|
| 37 |
else:
|
| 38 |
tickers = []
|
| 39 |
|
| 40 |
+
# ----------- Button Trigger Logic -----------
|
| 41 |
if st.button("Get News and Sentiment"):
|
| 42 |
if not tickers:
|
| 43 |
st.warning("Please mention at least one recognizable company.")
|