opinder2906 commited on
Commit
2c8fd9e
·
verified ·
1 Parent(s): eaf52e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,18 +1,28 @@
1
  # app.py
2
 
 
3
  from src.inference import predict
4
  from src.responses import get_response
5
 
6
  print("EmotiBot 🌿: Hi! How are you feeling today? (Type 'exit' to quit)")
7
 
8
  while True:
9
- user_raw = input("You: ").strip()
10
- if user_raw.lower() in ["exit", "quit"]:
11
  print("EmotiBot 🌿: Take care! I’m here whenever you want to talk.")
12
  break
 
 
13
 
14
- emotion = predict(user_raw)
15
- reply, done = get_response(emotion, user_raw)
 
 
 
 
 
 
16
  print(f"EmotiBot 🌿: {reply}")
17
  if done:
18
  break
 
 
1
  # app.py
2
 
3
+ from textblob import TextBlob
4
  from src.inference import predict
5
  from src.responses import get_response
6
 
7
  print("EmotiBot 🌿: Hi! How are you feeling today? (Type 'exit' to quit)")
8
 
9
  while True:
10
+ user = input("You: ").strip()
11
+ if user.lower() in ['exit','quit']:
12
  print("EmotiBot 🌿: Take care! I’m here whenever you want to talk.")
13
  break
14
+ # optional spelling fix:
15
+ user = str(TextBlob(user).correct())
16
 
17
+ # if any negative phrase → force sadness,
18
+ # else run model inference
19
+ if any(phrase in user.lower() for phrase in negative_inputs):
20
+ emotion = "sadness"
21
+ else:
22
+ emotion = predict(user)
23
+
24
+ reply, done = get_response(emotion, user)
25
  print(f"EmotiBot 🌿: {reply}")
26
  if done:
27
  break
28
+