Update app.py
Browse files
app.py
CHANGED
@@ -23,24 +23,18 @@ def analyze_financial_news():
|
|
23 |
|
24 |
if analyze_clicked:
|
25 |
# Perform text classification on the input text
|
26 |
-
results = classification(text)
|
27 |
-
|
28 |
-
#
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
# Print the structure of each news to find the correct key for the news text
|
37 |
-
st.write(f"News {idx} structure:")
|
38 |
-
st.write(news)
|
39 |
-
|
40 |
-
# Uncomment the following line once you identify the correct key for the news text
|
41 |
-
# sentiment_results = sentiment_analysis(news["<correct_key_for_text>"])[0]
|
42 |
else:
|
43 |
-
st.write("
|
44 |
|
45 |
def main():
|
46 |
analyze_financial_news()
|
|
|
23 |
|
24 |
if analyze_clicked:
|
25 |
# Perform text classification on the input text
|
26 |
+
results = classification(text)[0]
|
27 |
+
|
28 |
+
# Check if the classification is "Energy | Oil"
|
29 |
+
if results["label"] == "Energy | Oil":
|
30 |
+
# If the news is related to Energy | Oil, perform sentiment analysis
|
31 |
+
sentiment_results = sentiment_analysis(text)[0]
|
32 |
+
|
33 |
+
# Display the sentiment analysis result
|
34 |
+
st.write("Sentiment:", sentiment_results["label"])
|
35 |
+
st.write("Sentiment Score:", sentiment_results["score"])
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
else:
|
37 |
+
st.write("The provided news is not relevant to Energy | Oil.")
|
38 |
|
39 |
def main():
|
40 |
analyze_financial_news()
|