Instructions A very known application in natural language processing is to extract information from a given text. In this lab, you will be able to extract some emotions (Sad and Happy) from a given...


A very known application in natural language processing is to extract information from a given text. In this lab, you will be able to extract some emotions (Sad and Happy) from a given string and calculate the score of each emotion. You will be given below the words that express sadness, anger, and happiness. For each word, you will be given weight as well, so that when you are calculating for example the score for sadness in the text (string), you can use this formula:


Instructions<br>A very known application in natural language processing is to extract information from a given text. In this lab, you will be able to extract<br>some emotions (Sad and Happy) from a given string and calculate the score of each emotion. You will be given below the words that<br>express sadness, anger, and happiness. For each word, you will be given weight as well, so that when you are calculating for example the<br>score for sadness in the text (string), you can use this formula:<br>Sadness_Score = Weight_1 + Weight_3 +Weight_4<br>....<br>Sadness Words<br>Word<br>Weight<br>Word<br>Weight<br>Word<br>Weight Word Weight<br>abandon<br>2<br>ashamed<br>awful<br>4<br>bad<br>5<br>hard<br>3<br>belittle<br>3<br>betray<br>5<br>crash<br>4.<br>crazy<br>2<br>cry<br>3<br>disappoint<br>3<br>death<br>5<br>Happiness Words<br>Word<br>Weight<br>Word<br>Weight Word Weight<br>Word<br>Weight<br>accomplish<br>3<br>friend<br>3<br>beach<br>4<br>beautiful<br>5<br>dawn<br>4<br>adorable<br>3<br>enjoy<br>5<br>celebrate<br>4<br>cheer<br>3<br>bless<br>4.<br>baby<br>3<br>angel<br>5<br>1. Create the functions sadness_score, and happiness_score<br>2. Each function has only 1 parameter of type string: text<br>3. In each function, create a list of tuples for the words and their weights i.e in happiness_score you should have happiness_list<br>[ (

Extracted text: Instructions A very known application in natural language processing is to extract information from a given text. In this lab, you will be able to extract some emotions (Sad and Happy) from a given string and calculate the score of each emotion. You will be given below the words that express sadness, anger, and happiness. For each word, you will be given weight as well, so that when you are calculating for example the score for sadness in the text (string), you can use this formula: Sadness_Score = Weight_1 + Weight_3 +Weight_4 .... Sadness Words Word Weight Word Weight Word Weight Word Weight abandon 2 ashamed awful 4 bad 5 hard 3 belittle 3 betray 5 crash 4. crazy 2 cry 3 disappoint 3 death 5 Happiness Words Word Weight Word Weight Word Weight Word Weight accomplish 3 friend 3 beach 4 beautiful 5 dawn 4 adorable 3 enjoy 5 celebrate 4 cheer 3 bless 4. baby 3 angel 5 1. Create the functions sadness_score, and happiness_score 2. Each function has only 1 parameter of type string: text 3. In each function, create a list of tuples for the words and their weights i.e in happiness_score you should have happiness_list [ ("accomplish, 3), ....] 4. Loop over the tuples and check if the word is in the given text. If the word is found, increment the result by words score, otherwise do nothing 5. Return the final score Example Input: "This lab is driving me crazy. I want to accomplish more so I won't feel bad at the end of the day" Return from sadness_score function: 7 Return from happiness_score function: 3
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here