EmmaL1 commited on
Commit
1e9a08e
·
verified ·
1 Parent(s): e3e8e9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -38,13 +38,13 @@ def textclassification():
38
  st.write(f"Sentiment: {sentiment}")
39
  st.write(f"Confidence: {confidence:.2f}")
40
 
41
- # Determine the rating based on confidence
42
  if sentiment == "POSITIVE":
43
- # Scale confidence to a rating of 1 to 5
44
- rating = int(confidence * 4) + 1
45
- else:
46
- # For negative sentiment, invert the confidence score
47
- rating = int((1 - confidence) * 4) + 1
48
 
49
  # Display the rating
50
  st.write(f"The rating is {rating} stars")
 
38
  st.write(f"Sentiment: {sentiment}")
39
  st.write(f"Confidence: {confidence:.2f}")
40
 
41
+ # Determine the rating based on sentiment
42
  if sentiment == "POSITIVE":
43
+ rating = 5 # Assign a rating of 5 stars for positive sentiment
44
+ elif sentiment == "NEUTRAL":
45
+ rating = 3 # Assign a neutral rating of 3 stars
46
+ else: # Assuming the other sentiment is "NEGATIVE"
47
+ rating = 1 # Assign a rating of 1 star for negative sentiment
48
 
49
  # Display the rating
50
  st.write(f"The rating is {rating} stars")