Update app.py
Browse files
app.py
CHANGED
@@ -1,44 +1,51 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
-
|
|
|
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 |
-
label_1 = ""
|
22 |
-
score_1 = 0.0
|
23 |
-
label_2 = ""
|
24 |
-
score_2 = 0.0
|
25 |
|
26 |
-
analyze_clicked = st.button("Analyze")
|
27 |
|
28 |
-
if analyze_clicked:
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
# Display the results
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
def analyze_financial_news():
|
5 |
+
access = "hf_"
|
6 |
+
token = "hhbFNpjKohezoexWMlyPUpvJQLWlaFhJaa"
|
7 |
|
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 |
+
label_1 = ""
|
23 |
+
score_1 = 0.0
|
24 |
+
label_2 = ""
|
25 |
+
score_2 = 0.0
|
26 |
|
27 |
+
analyze_clicked = st.button("Analyze")
|
28 |
|
29 |
+
if analyze_clicked:
|
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 |
+
# Display the results
|
40 |
+
st.write("Financial Text:", text)
|
41 |
+
st.write("Trend:", label_1)
|
42 |
+
st.write("Trend_Score:", score_1)
|
43 |
|
44 |
+
st.write("Finance Topic:", label_2)
|
45 |
+
st.write("Topic_Score:", score_2)
|
46 |
+
|
47 |
+
def main():
|
48 |
+
analyze_financial_news()
|
49 |
+
|
50 |
+
if __name__ == "__main__":
|
51 |
+
main()
|