OatNapat commited on
Commit
8258f3b
·
1 Parent(s): aa87461

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -12,5 +12,21 @@ st.title("Sentiment Analysis App")
12
  user_input = st.text_input("Enter a sentence for sentiment analysis:")
13
  if user_input:
14
  result = nlp(user_input)
15
- sentiment = result[0]["label"]
16
- st.write(f"Sentiment: {sentiment}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  user_input = st.text_input("Enter a sentence for sentiment analysis:")
13
  if user_input:
14
  result = nlp(user_input)
15
+ sentiment_label = result[0]["label"]
16
+ sentiment_score = result[0]["score"]
17
+
18
+ # Define explanations for sentiment labels
19
+ sentiment_explanations = {
20
+ "LABEL_0": "Very negative",
21
+ "LABEL_1": "Negative",
22
+ "LABEL_2": "Neutral",
23
+ "LABEL_3": "Positive",
24
+ "LABEL_4": "Very positive"
25
+ }
26
+
27
+ # Get the explanation for the sentiment label
28
+ sentiment_explanation = sentiment_explanations.get(sentiment_label, "Unknown")
29
+
30
+ st.write(f"Sentiment: {sentiment_label} ({sentiment_explanation})")
31
+ st.write(f"Confidence: {sentiment_score:.4f}")
32
+