Question
def analyze_word(word, pos_words, neg_words): ''' (str, list, list) -> int Given a word, a list of positive words (all in lowercase), and a list of
def analyze_word(word, pos_words, neg_words): ''' (str, list, list) -> int Given a word, a list of positive words (all in lowercase), and a list of negative words (all in lowercase), return whether or not the word is positive, negative or neutral.
For a positive word, return 1. For a negative word, return -1. For a neutral word (one that does not appear in either the negative words list nor the positive words list), return 0.
>>> ("happy", ['happy', 'love'], ['sad', 'angry']) 1 >>> ("angry", ['happy', 'love', 'joy'], ['sad', 'angry', 'bad']) -1
>>> ("LOVE", ['happy', 'love', 'joy'], ['sad', 'angry', 'bad']) 1
>>> ("sAd", ['happy', 'love', 'joy'], ['sad']) -1 >>> ("okay", ['happy', 'love', 'joy'], ['sad', 'angry']) 0 '''
Python
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started