JoanParanoid commited on
Commit
32983b2
·
verified ·
1 Parent(s): 5c6e809

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -17
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
- # Filter only the news related to "Energy | Oil"
29
- energy_oil_news = [news for news in results if news["label"] == "Energy | Oil"]
30
-
31
- st.write("Energy | Oil News:", energy_oil_news) # Debug statement to check the Energy | Oil news list
32
-
33
- if energy_oil_news:
34
- # If there are news related to "Energy | Oil", perform sentiment analysis for each news
35
- for idx, news in enumerate(energy_oil_news, start=1):
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("No news relevant to Energy | Oil.")
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()