JoanParanoid
commited on
Commit
•
5e62651
1
Parent(s):
ad6f8da
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
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()
|