Spaces:
Sleeping
Sleeping
razanalsulami
commited on
Commit
β’
aa8764e
1
Parent(s):
d720951
Update app.py
Browse files
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 |
-
|
|
|
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:
|