Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ MODEL_NAME = "rahilv/financial-sentiment-model"
|
|
9 |
model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
|
10 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
11 |
|
12 |
-
LABEL_MAP = {0: "
|
13 |
|
14 |
# RSS Feed URLs
|
15 |
rss_feeds = {
|
@@ -34,23 +34,27 @@ def analyze_sentiment(text):
|
|
34 |
return LABEL_MAP[predictions]
|
35 |
|
36 |
def main():
|
37 |
-
st.
|
|
|
|
|
|
|
38 |
|
39 |
# Sidebar: Feed Selection
|
40 |
-
st.sidebar.header("
|
41 |
-
selected_feeds = st.sidebar.multiselect("
|
42 |
|
43 |
if not selected_feeds:
|
44 |
st.warning("Please select at least one RSS feed.")
|
45 |
return
|
46 |
|
47 |
-
st.sidebar.
|
48 |
st.sidebar.info(
|
49 |
-
"This app fetches financial news from RSS feeds and analyzes sentiment (
|
50 |
)
|
51 |
|
52 |
# Fetch and Display Articles
|
53 |
-
st.header("Latest Financial News")
|
|
|
54 |
articles = []
|
55 |
for feed_name in selected_feeds:
|
56 |
for url in rss_feeds[feed_name]:
|
@@ -60,11 +64,13 @@ def main():
|
|
60 |
st.write("No articles found.")
|
61 |
return
|
62 |
|
|
|
63 |
for article in articles:
|
64 |
sentiment = analyze_sentiment(article["title"])
|
65 |
st.subheader(article["title"])
|
66 |
st.write(f"Sentiment: **{sentiment}**")
|
67 |
-
st.
|
|
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
-
main()
|
|
|
9 |
model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
|
10 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
11 |
|
12 |
+
LABEL_MAP = {0: "Bullish", 1: "Bearish", 2: "Neutral"}
|
13 |
|
14 |
# RSS Feed URLs
|
15 |
rss_feeds = {
|
|
|
34 |
return LABEL_MAP[predictions]
|
35 |
|
36 |
def main():
|
37 |
+
st.set_page_config(page_title="Financial News Sentiment", layout="wide")
|
38 |
+
|
39 |
+
st.title("\U0001F4C8 Financial News Sentiment Analysis")
|
40 |
+
st.write("Analyze sentiment from the latest financial news articles.")
|
41 |
|
42 |
# Sidebar: Feed Selection
|
43 |
+
st.sidebar.header("Settings")
|
44 |
+
selected_feeds = st.sidebar.multiselect("Select RSS Feeds:", options=rss_feeds.keys(), default=list(rss_feeds.keys()))
|
45 |
|
46 |
if not selected_feeds:
|
47 |
st.warning("Please select at least one RSS feed.")
|
48 |
return
|
49 |
|
50 |
+
st.sidebar.markdown("---")
|
51 |
st.sidebar.info(
|
52 |
+
"This app fetches financial news from RSS feeds and analyzes the sentiment (Bullish, Bearish, Neutral) of news titles."
|
53 |
)
|
54 |
|
55 |
# Fetch and Display Articles
|
56 |
+
st.header("\U0001F4F0 Latest Financial News")
|
57 |
+
|
58 |
articles = []
|
59 |
for feed_name in selected_feeds:
|
60 |
for url in rss_feeds[feed_name]:
|
|
|
64 |
st.write("No articles found.")
|
65 |
return
|
66 |
|
67 |
+
# Display articles in a clean layout
|
68 |
for article in articles:
|
69 |
sentiment = analyze_sentiment(article["title"])
|
70 |
st.subheader(article["title"])
|
71 |
st.write(f"Sentiment: **{sentiment}**")
|
72 |
+
st.markdown(f"[Read more]({article['link']})", unsafe_allow_html=True)
|
73 |
+
st.markdown("---")
|
74 |
|
75 |
if __name__ == "__main__":
|
76 |
+
main()
|