Update app.py
Browse files
app.py
CHANGED
@@ -1,50 +1,33 @@
|
|
|
|
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
|
20 |
text = st.text_area("Enter the Financial News", "")
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
label_2 = ""
|
25 |
-
score_2 = 0.0
|
26 |
|
27 |
-
|
|
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
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("
|
42 |
-
st.write("
|
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__":
|
|
|
1 |
+
import os
|
2 |
import streamlit as st
|
3 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
|
4 |
|
5 |
def analyze_financial_news():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
st.title("Financial News Analysis")
|
7 |
st.write("Analyze corresponding Topic and Trend for Financial News!")
|
8 |
st.image("./Fin.jpg", use_column_width=True)
|
9 |
|
10 |
+
# Text input for user to enter the financial news
|
11 |
text = st.text_area("Enter the Financial News", "")
|
12 |
|
13 |
+
# Load the summarization pipeline
|
14 |
+
summarization_pipe = pipeline("summarization", model="facebook/bart-large-cnn")
|
|
|
|
|
15 |
|
16 |
+
# Use pipeline as a high-level helper
|
17 |
+
summary = summarization_pipe(text)[0]['summary_text']
|
18 |
|
19 |
+
# Perform sentiment analysis on the summarized text
|
20 |
+
sentiment_pipe = pipeline("sentiment-analysis")
|
21 |
+
sentiment_results = sentiment_pipe(summary)[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
# Display the results
|
24 |
st.write("Financial Text:", text)
|
25 |
+
st.write("Summary:", summary)
|
26 |
+
st.write("Sentiment:", sentiment_results["label"])
|
27 |
+
st.write("Sentiment Score:", sentiment_results["score"])
|
|
|
|
|
28 |
|
29 |
def main():
|
30 |
+
st.set_page_config(page_title="Financial News Analysis", page_icon="♕")
|
31 |
analyze_financial_news()
|
32 |
|
33 |
if __name__ == "__main__":
|