File size: 1,728 Bytes
8ede0a2
 
 
 
 
 
 
2d550d7
8ede0a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import streamlit as st
from transformers import pipeline

access = "hf_"
token = "hhbFNpjKohezoexWMlyPUpvJQLWlaFhJaa"

# Load the text classification model pipeline
analysis = pipeline("text-classification", model='ZephyruSalsify/FinNews_SentimentAnalysis')
classification = pipeline("text-classification", model="nickmuchi/finbert-tone-finetuned-finance-topic-classification", token=access+token)

st.set_page_config(page_title="Financial News Analysis", page_icon="♕")

# Streamlit application layout
st.title("Financial News Analysis")
st.write("Analyze corresponding Topic and Trend for Financial News!")
st.image("./Fin.jpg", use_column_width = True)

# Text input for user to enter the text
text = st.text_area("Enter the Financial News", "")

# Perform text classification when the user clicks the "Classify" button
if st.button("Analyze"):

    # Perform text analysis on the input text
    results_1 = analysis(text)[0]
    results_2 = classification(text)[0]
    
    # Display the analysis result
    #max_score_1 = float('-inf')
    #max_label_1 = ''
    
    #for result_1 in results_1:
    #    if result_1['score'] > max_score_1:
    #        max_score_1 = result_1['score']
    #        max_label_1 = result_1['label']

    # Display the classification result
    #max_score_2 = float('-inf')
    #max_label_2 = ''
    
    #for result_2 in results_2:
    #    if result_2['score'] > max_score_2:
    #        max_score_2 = result_2['score']
    #        max_label_2 = result_2['label']
            
st.write("Financial Text:", text)
st.write("Trend:", results_1["label"])
st.write("Trend_Score:", results_1["score"])

st.write("Finance Topic:", results_2["label"])
st.write("Topic_Score:", results_2["score"])