Computers don't understand feelings. They only understand numbers.
But can Robo read a text message and know if you are Happy or Sad?
This is called Natural Language Processing (NLP).
Robo counts special "feeling" words.
Sentence: "I love this great game!"
Score: 2 Positive Words -> HAPPY!
Our message is a list of words. (The computer has already split them for you).
message = ["i", "love", "this", "great", "game"] happy_score = 0
Check each word. If it's "love" or "great", add to score.
for word in message:
if word == "love":
happy_score = happy_score + 1
if word == "great":
happy_score = happy_score + 1
print(happy_score)
If the score is bigger than 0, it's a Positive message.
if happy_score > 0:
print("This person is Happy!")
else:
print("No happiness found.")
1. The sentence is: "The movie was not great". What score does our primitive robot give it?