razanalsulami commited on
Commit
aa8764e
β€’
1 Parent(s): d720951

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -5,14 +5,15 @@ from transformers import pipeline
5
  sentiment_analysis = pipeline("sentiment-analysis", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
6
 
7
  # Function to analyze user's mood based on input
8
- def analyze_mood(user_input):
9
  # Analyze the mood from input text
10
  result = sentiment_analysis(user_input)[0]
11
  # Define mood and suggestion based on sentiment analysis
12
- if result["label"] == "POSITIVE":
 
13
  mood = "Happy"
14
  suggestion = "Keep doing what you're doing! 😊"
15
- elif result["label"] == "NEGATIVE":
16
  mood = "Sad"
17
  suggestion = "Try to talk to someone, or take a break πŸ’‘"
18
  else:
 
5
  sentiment_analysis = pipeline("sentiment-analysis", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
6
 
7
  # Function to analyze user's mood based on input
8
+ def analyze_mood(user_input):
9
  # Analyze the mood from input text
10
  result = sentiment_analysis(user_input)[0]
11
  # Define mood and suggestion based on sentiment analysis
12
+ score = result["score"]
13
+ if result["label"] == "POSITIVE" and score > 0.85:
14
  mood = "Happy"
15
  suggestion = "Keep doing what you're doing! 😊"
16
+ elif result["label"] == "NEGATIVE" and score > 0.85:
17
  mood = "Sad"
18
  suggestion = "Try to talk to someone, or take a break πŸ’‘"
19
  else: