Files changed (1) hide show
  1. app.py +41 -37
app.py CHANGED
@@ -4,40 +4,44 @@ from transformers import pipeline
4
  access = "hf_"
5
  token = "hhbFNpjKohezoexWMlyPUpvJQLWlaFhJaa"
6
 
7
- # Load the text classification model pipeline
8
- analysis = pipeline("text-classification", model='ZephyruSalsify/FinNews_SentimentAnalysis')
9
- classification = pipeline("text-classification", model="nickmuchi/finbert-tone-finetuned-finance-topic-classification", token=access+token)
10
-
11
- st.set_page_config(page_title="Financial News Analysis", page_icon="♕")
12
-
13
- # Streamlit application layout
14
- st.title("Financial News Analysis")
15
- st.write("Analyze corresponding Topic and Trend for Financial News!")
16
- st.image("./Fin.jpg", use_column_width = True)
17
-
18
- # Text input for user to enter the text
19
- text = st.text_area("Enter the Financial News", "")
20
-
21
- # Perform text classification when the user clicks the "Classify" button
22
- if st.button("Analyze"):
23
-
24
- label_1 = ""
25
- score_1 = 0.0
26
- label_2 = ""
27
- score_2 = 0.0
28
-
29
- # Perform text analysis on the input text
30
- results_1 = analysis(text)[0]
31
- results_2 = classification(text)[0]
32
-
33
- label_1 = results_1["label"]
34
- score_1 = results_1["score"]
35
- label_2 = results_2["label"]
36
- score_2 = results_2["score"]
37
-
38
- st.write("Financial Text:", text)
39
- st.write("Trend:", label_1)
40
- st.write("Trend_Score:", score_1)
41
-
42
- st.write("Finance Topic:", label_2)
43
- st.write("Topic_Score:", score_2)
 
 
 
 
 
4
  access = "hf_"
5
  token = "hhbFNpjKohezoexWMlyPUpvJQLWlaFhJaa"
6
 
7
+ def main():
8
+ # Load the text classification model pipeline
9
+ analysis = pipeline("text-classification", model='ZephyruSalsify/FinNews_SentimentAnalysis')
10
+ classification = pipeline("text-classification", model="nickmuchi/finbert-tone-finetuned-finance-topic-classification", token=access+token)
11
+
12
+ st.set_page_config(page_title="Financial News Analysis", page_icon="♕")
13
+
14
+ # Streamlit application layout
15
+ st.title("Financial News Analysis")
16
+ st.write("Analyze corresponding Topic and Trend for Financial News!")
17
+ st.image("./Fin.jpg", use_column_width = True)
18
+
19
+ # Text input for user to enter the text
20
+ text = st.text_area("Enter the Financial News", "")
21
+
22
+ # Perform text classification when the user clicks the "Classify" button
23
+ if st.button("Analyze"):
24
+
25
+ label_1 = ""
26
+ score_1 = 0.0
27
+ label_2 = ""
28
+ score_2 = 0.0
29
+
30
+ # Perform text analysis on the input text
31
+ results_1 = analysis(text)[0]
32
+ results_2 = classification(text)[0]
33
+
34
+ label_1 = results_1["label"]
35
+ score_1 = results_1["score"]
36
+ label_2 = results_2["label"]
37
+ score_2 = results_2["score"]
38
+
39
+ st.write("Financial Text:", text)
40
+ st.write("Trend:", label_1)
41
+ st.write("Trend_Score:", score_1)
42
+
43
+ st.write("Finance Topic:", label_2)
44
+ st.write("Topic_Score:", score_2)
45
+
46
+ if_name_== "_main_":
47
+ main()