Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python: Create a new function called score_sentence which takes in two arguments: a string representing a sentence, and a score dictionary. It should then take
Python: Create a new function called score_sentence which takes in two arguments: a string representing a sentence, and a score dictionary. It should then take the unique words in the sentence and output a score for the sentence by summing the corresponding score from the dictionary for each word. If the word is not in the dictionary, the corresponding value should be 0.
Example:
my_sentence = "Welcome, welcome to my house!" scores = {'welcome': 0.5, 'house': -0.25} final_score = score_sentence(my_sentence, scores) # Should output 0.25
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