Question: Part 3: How Do You Feel about Homework? (20 pts) In this part of the homework, you will implement a very rough sentiment analysis tool.

 Part 3: How Do You Feel about Homework? (20 pts) In

Part 3: How Do You Feel about Homework? (20 pts) In this part of the homework, you will implement a very rough sentiment analysis tool. While the real tools use natural language processing, they all use word counts similar to the one we use here. Understanding the sentiment in messages is a crucial part of a lot of artificial intelligence tools. Write a program that will ask the user for a string containing a sentence. The program will then compute the happincss and sadncss level of the scntence using the two functions described bclow If the happincss leve is higher than sadness level, then the tone of the sentence is happy. If the sadness level is higher, then the tone of the sentence is sad. Otherwise, it is neutral. Find and print the tone of the sentence by first printing a sentiment line with a number of equal to the number of happy words followed by the number of cqual to the number of sad words, followed by a simple statement of the analysis. Two cxamples of the program run (how it will look when you run it using Wing IDE 101) arc provided in files hw2 part3 output.01.txt and hw2 part3 output.02.txt. (Can be found inside the hu02_files.zip file.) To accomplish this you will write a function called number happy(sentence) which returns the number of words in a given string called sentence that are happy. To do this, find the total count of the following 6 words: laugh happiness love excellent good smile. Here is an example run of this function: number_happy("I laughed and laughed at her excellent joke.") This is because the count of happy words is 3 (laugh is repeated twic). Your code should work even if there are upper and lower case words and extra spaces in the beginning and end of the scntencc. number_happy(Happiness is the state of a student who started homework early.) Next, write a sccond function called number_sad (sentence) that works the same way but instead counts the number of the following 6 sad words in English: bad sad terrible horrible problem hate (there are sadder words for sure, but no reason to depress ourselves) number sad ("Dr. Horrible's Sing-Along Blog is an excellent show.") >number_sad ("Alexander and the Terrible, Horrible, No Good, Very Bad Day") Of courses, there are more than 6 words of each category. file and use lists to process the i future classes. We will see how to feed them using a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!