Andreagus commited on
Commit
fcf5fa3
1 Parent(s): e5f4408

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -57
app.py CHANGED
@@ -3,67 +3,62 @@ from aggregator import get_articles_sentiment
3
 
4
  st.title("Real time financial news fast sentiment")
5
 
6
- model_to_use = ""
7
 
8
- model_selected = st.radio("Choose your model", ["fin_distilBert", "fin_tinyBert", "fin_miniLM"])
9
 
10
- ticker = st.text_input("Insert the company ticker")
11
 
12
- col1, col2 = st.columns(2)
13
- if model_selected != None and ticker:
14
-
15
- st.write("You chose", model_selected)
16
 
17
- if model_selected == "fin_distilBert":
18
- model_to_use = "Andreagus/fin_distilbert_16"
19
- if model_selected == "fin_tinyBert":
20
- model_to_use = "Andreagus/fin_tinyBert_32"
21
- if model_selected == "fin_miniLM":
22
- model_to_use = "Andreagus/fin_miniLM_16"
23
-
24
- with st.spinner("Loading the model"):
25
- results = get_articles_sentiment(ticker, model_to_use)
26
 
27
- with col1:
28
- st.text("Bezinga news provider")
29
- if results['bezinga']['bezinga_articles'] == 0:
30
- st.text('Bezinga returned 0 articles')
31
- else:
32
- st.json(results['bezinga'], expanded=False)
33
-
34
- st.text("finhub news provider")
35
- if results['finhub']['finhub_articles'] == 0:
36
- st.text('finhub returned 0 articles')
37
- else:
38
- st.json(results['finhub'], expanded=False)
39
-
40
- st.text("marketaux news provider")
41
- if results['marketaux']['marketaux_articles'] == 0:
42
- st.text('marketaux returned 0 articles')
43
- else:
44
- st.json(results['marketaux'], expanded=False)
45
-
46
- st.text("Newsapi news provider")
47
- if results['newsapi']['newsapi_articles'] == 0:
48
- st.text('newsapi returned 0 articles')
49
- else:
50
- st.json(results['newsapi'], expanded=False)
51
-
52
- st.text('Newsdata news provider')
53
- if results['newsdata']['newsdata_articles'] == 0:
54
- st.text('newsdata returned 0 articles')
55
- else:
56
- st.json(results['newsdata'], expanded=False)
57
-
58
- st.text("Vantage news provider")
59
- if results['vantage']['vantage_articles'] == 0:
60
- st.text('vantage returned 0 articles')
61
- else:
62
- st.json(results['vantage'], expanded=False)
63
 
64
- with col2:
65
- st.text("Summary results")
66
- st.metric("Total articles", results['total_articles'])
67
- st.metric("Total positive articles", results['total_positives'])
68
- st.metric("Total negative articles", results['total_negatives'])
 
 
 
 
 
 
69
 
 
3
 
4
  st.title("Real time financial news fast sentiment")
5
 
6
+ st.subheader("Using finTinyBert")
7
 
8
+ with st.form("my_form"):
9
 
10
+ ticker = st.text_input("Insert the company ticker")
11
 
12
+ submitted = st.form_submit_button("Submit")
 
 
 
13
 
14
+ col1, col2 = st.columns(2)
15
+ if submitted:
 
 
 
 
 
 
 
16
 
17
+ st.write("You chose", ticker)
18
+
19
+ with st.spinner("Loading the model"):
20
+ results = get_articles_sentiment(ticker, "Andreagus/fin_tinyBert_32")
21
+
22
+ with col1:
23
+ st.text("Benzinga news provider")
24
+ if results['bezinga']['bezinga_articles'] == 0:
25
+ st.text('Benzinga returned 0 articles')
26
+ else:
27
+ st.json(results['benzinga'], expanded=False)
28
+
29
+ st.text("finhub news provider")
30
+ if results['finhub']['finhub_articles'] == 0:
31
+ st.text('finhub returned 0 articles')
32
+ else:
33
+ st.json(results['finhub'], expanded=False)
34
+
35
+ st.text("marketaux news provider")
36
+ if results['marketaux']['marketaux_articles'] == 0:
37
+ st.text('marketaux returned 0 articles')
38
+ else:
39
+ st.json(results['marketaux'], expanded=False)
40
+
41
+ st.text("Newsapi news provider")
42
+ if results['newsapi']['newsapi_articles'] == 0:
43
+ st.text('newsapi returned 0 articles')
44
+ else:
45
+ st.json(results['newsapi'], expanded=False)
46
+
47
+ st.text('Newsdata news provider')
48
+ if results['newsdata']['newsdata_articles'] == 0:
49
+ st.text('newsdata returned 0 articles')
50
+ else:
51
+ st.json(results['newsdata'], expanded=False)
 
52
 
53
+ st.text("Vantage news provider")
54
+ if results['vantage']['vantage_articles'] == 0:
55
+ st.text('vantage returned 0 articles')
56
+ else:
57
+ st.json(results['vantage'], expanded=False)
58
+
59
+ with col2:
60
+ st.text("Summary results")
61
+ st.metric("Total articles", results['total_articles'])
62
+ st.metric("Total positive articles", results['total_positives'])
63
+ st.metric("Total negative articles", results['total_negatives'])
64