LinkLinkWu commited on
Commit
8b6f436
·
verified ·
1 Parent(s): 829be4d

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -77
app.py DELETED
@@ -1,77 +0,0 @@
1
- """app.py – Streamlit front‑end for EquiPulse
2
- Logic tweak: remove possibility of overall "Neutral" (2025‑05‑18).
3
- UI unchanged from prior version.
4
-
5
- Changes
6
- =======
7
- * Overall sentiment now binary – Positive or Negative – based on which
8
- ratio is higher (≥50%).
9
- * Headline‑level labels already binary via `func.analyze_sentiment`, so
10
- neutral will never appear anywhere.
11
-
12
- Run with `streamlit run app.py`.
13
- """
14
-
15
- from __future__ import annotations
16
-
17
- import streamlit as st
18
- from func import (
19
- analyze_sentiment,
20
- fetch_news,
21
- get_ner_pipeline,
22
- extract_org_entities,
23
- )
24
-
25
- # ------------------------------------------------------------
26
- # Page title & instructions (original minimalist UI)
27
- # ------------------------------------------------------------
28
- st.title("📊 EquiPulse – Stock Sentiment Tracker")
29
- st.write("Enter company names or tickers (comma‑separated) and click **Analyze**.")
30
-
31
- user_input = st.text_input("Companies / Tickers", placeholder="Apple, AAPL, Tesla, NVDA")
32
-
33
- # Ticker extraction
34
- ner_pipe = get_ner_pipeline()
35
- extracted = extract_org_entities(user_input, ner_pipe)
36
- if extracted:
37
- st.info(f"Recognized tickers: {', '.join(extracted)}")
38
-
39
- # ------------------------------------------------------------
40
- # Fetch news & sentiment on button click
41
- # ------------------------------------------------------------
42
- if st.button("Analyze"):
43
- if not extracted:
44
- st.warning("Please enter at least one valid company or ticker.")
45
- st.stop()
46
-
47
- progress = st.progress(0.0)
48
-
49
- for idx, ticker in enumerate(extracted, start=1):
50
- st.subheader(f"Results for {ticker}")
51
- news_items = fetch_news(ticker)
52
-
53
- if not news_items:
54
- st.write("No recent news found.")
55
- progress.progress(idx / len(extracted))
56
- continue
57
-
58
- # Headline‑level sentiment (binary)
59
- sentiments = [analyze_sentiment(item["title"]) for item in news_items]
60
-
61
- pos_cnt = sentiments.count("Positive")
62
- neg_cnt = sentiments.count("Negative")
63
- total = len(sentiments)
64
-
65
- # Binary overall judgement – whichever ratio is higher
66
- overall = "Positive" if pos_cnt >= neg_cnt else "Negative"
67
-
68
- # Display first few headlines
69
- for i, item in enumerate(news_items[:5]):
70
- st.write(f"{i+1}. {item['title']} — **{sentiments[i]}**")
71
-
72
- st.success(
73
- f"Overall Sentiment: {overall} (Pos: {pos_cnt}/{total}, Neg: {neg_cnt}/{total})"
74
- )
75
- progress.progress(idx / len(extracted))
76
-
77
- progress.empty()