richardorama commited on
Commit
f79a195
1 Parent(s): 8655834

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -30,7 +30,7 @@ def is_valid_list_string(string):
30
  # Define the summarization function
31
  def analyze_sentiment(txt):
32
 
33
- st.write('\n\n')
34
  #st.write(txt[:100]) # Display the first 100 characters of the article
35
  #st.write('--------------------------------------------------------------')
36
 
@@ -40,13 +40,13 @@ def analyze_sentiment(txt):
40
  # Perform Hugging sentiment analysis on multiple texts
41
  results = sentiment_pipeline(txt_converted)
42
  for i, text in enumerate(txt_converted):
43
- st.write(f"Text: {text}")
44
- st.write(f"Sentiment: {results[i]['label']}, Score: {results[i]['score']:.2f}\n")
45
  else:
46
  # Perform Hugging sentiment analysis on multiple texts
47
  results = sentiment_pipeline(txt)
48
- st.write(f"Text: {txt}")
49
- st.write(f"Sentiment: {results[0]['label']}, Score: {results[0]['score']:.2f}\n")
50
 
51
  st.sidebar.markdown("<h3 style='text-align: center; font-size: 16px; background-color: white; color: black;'>Sentiment Analysis</h3>", unsafe_allow_html=True)
52
  DEFAULT_SENTIMENT = ""
 
30
  # Define the summarization function
31
  def analyze_sentiment(txt):
32
 
33
+ #st.write('\n\n')
34
  #st.write(txt[:100]) # Display the first 100 characters of the article
35
  #st.write('--------------------------------------------------------------')
36
 
 
40
  # Perform Hugging sentiment analysis on multiple texts
41
  results = sentiment_pipeline(txt_converted)
42
  for i, text in enumerate(txt_converted):
43
+ st.sidebar.write(f"Text: {text}")
44
+ st.sidebar.write(f"Sentiment: {results[i]['label']}, Score: {results[i]['score']:.2f}\n")
45
  else:
46
  # Perform Hugging sentiment analysis on multiple texts
47
  results = sentiment_pipeline(txt)
48
+ st.sidebar.write(f"Text: {txt}")
49
+ st.sidebar.write(f"Sentiment: {results[0]['label']}, Score: {results[0]['score']:.2f}\n")
50
 
51
  st.sidebar.markdown("<h3 style='text-align: center; font-size: 16px; background-color: white; color: black;'>Sentiment Analysis</h3>", unsafe_allow_html=True)
52
  DEFAULT_SENTIMENT = ""