Update app.py
Browse files
app.py
CHANGED
@@ -23,18 +23,24 @@ def analyze_financial_news():
|
|
23 |
|
24 |
if analyze_clicked:
|
25 |
# Perform text classification on the input text
|
26 |
-
results = classification(text)
|
27 |
-
|
28 |
-
#
|
29 |
-
if
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
else:
|
37 |
-
st.write("
|
38 |
|
39 |
def main():
|
40 |
analyze_financial_news()
|
|
|
23 |
|
24 |
if analyze_clicked:
|
25 |
# Perform text classification on the input text
|
26 |
+
results = classification(text)
|
27 |
+
|
28 |
+
# Filter only the news related to "Energy | Oil"
|
29 |
+
energy_oil_news = [news for news in results if news["label"] == "Energy | Oil"]
|
30 |
+
|
31 |
+
if energy_oil_news:
|
32 |
+
# If there are news related to "Energy | Oil", perform sentiment analysis for each news
|
33 |
+
for news in energy_oil_news:
|
34 |
+
text = news["sequence"]
|
35 |
+
sentiment_results = sentiment_analysis(text)[0]
|
36 |
+
|
37 |
+
# Display the sentiment analysis result for each news
|
38 |
+
st.write("Original Text:", text)
|
39 |
+
st.write("Sentiment:", sentiment_results["label"])
|
40 |
+
st.write("Sentiment Score:", sentiment_results["score"])
|
41 |
+
st.write("---")
|
42 |
else:
|
43 |
+
st.write("No news relevant to Energy | Oil.")
|
44 |
|
45 |
def main():
|
46 |
analyze_financial_news()
|