ZephyruSalsify commited on
Commit
16412a7
1 Parent(s): 13c73ae

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the text classification model pipeline
5
+ analysis = pipeline("text-analysis", model='ZephyruSalsify/FinNews_SentimentAnalysis_Test')
6
+ classification = pipeline("text-classification", model="nickmuchi/finbert-tone-finetuned-finance-topic-classification")
7
+
8
+ st.set_page_config(page_title="Financial News Analysis", page_icon="♕")
9
+ st.header("Make Analysis for Financial News")
10
+
11
+ # Streamlit application layout
12
+ st.title("Financial News Analysis")
13
+ st.write("Classify corresponding Topic and Trend for Financial News")
14
+ st.image("./Fin.jpg", use_column_width = True)
15
+
16
+ # Text input for user to enter the text
17
+ text = st.text_area("Enter the Financial News", "")
18
+
19
+ # Perform text classification when the user clicks the "Classify" button
20
+ if st.button("Analyze"):
21
+
22
+ # Perform text analysis on the input text
23
+ results_1 = analysis(text)[0]
24
+ results_2 = classification(text)[0]
25
+
26
+ # Display the analysis result
27
+ max_score_1 = float('-inf')
28
+ max_label_1 = ''
29
+
30
+ for result in results_1:
31
+ if result['score'] > max_score_1:
32
+ max_score_1 = result['score']
33
+ max_label_1 = result['label']
34
+
35
+ # Display the classification result
36
+ max_score_2 = float('-inf')
37
+ max_label_2 = ''
38
+
39
+ for result in results_2:
40
+ if result['score'] > max_score_2:
41
+ max_score_2 = result['score']
42
+ max_label_2 = result['label']
43
+
44
+ st.write("Financial Text:", text)
45
+ st.write("Trend:", max_label_1)
46
+ st.write("Trend_Score:", max_score_1)
47
+
48
+ st.write("Finance Topic:", max_label_2)
49
+ st.write("Topic_Score:", max_score_2)