A Python language Programming in Natural Language Many researchers today now use data from Twitter to analyze and predict the future events. Questions such as which place in a country is the happiest one, who will be the next US president and which place has the highest rate of depressed people, sometimes depend on the information extracted from thousands of tweets. In case of predicting the happiest state in the US, NLP experts have a set of words that also contains their rates, respectively. For example, the word “great” may have a rate from a scale of 1 to 10, 10; the word "awesome" may have a rate of 8; the word “sad” may have a rate 1 and so on. By computing the average score of a tweet using this set of words, researchers would now be able to measure and categorize the mood of a tweet depending on a certain threshold. In this problem, you will be an assistant of an NLP expert who will determine the mood of a tweet. The category would be: < 5 is "sad" >= 5 is "happy" Let say, we have a tweet: OMG! I am so happy today #easyMachineExam When input, “OMG! I am so happy today #easyMachineExam” And consider our list of words are the following: wth 4, omg 7, happy 10, great 10, awesome 8, sad 1, disappointing 2, hello 2, relieved 9, damn 3, hard 4 We get only the scores of the words that exist in our list. Since OMG and happy are the only words in the list, we will have {7(OMG) + 10(happy) } / 2 = (7+10)/2 = 8.5 , thus "happy" Let’s limit our set of words to what is stated above. Note: Punctuations should be included when giving an input. Thus, you should find a way to remove the punctuations when quantifying its mood. Otherwise, OMG! will not get that rate 7. Also, it should not be case-sensitive(i.e. “HeLlo, HELLO, hellO, and hellO are the same words.) Let’s limit our inputs to words separated by one whitespace. Do not include the words with hashtags. OmG! I AM SO HAPPY TODAY #easymachineexam should also get 8.5 which is “happy” Another example, Damn! I studied so hard but this is quite disappointing #tooEasyToAnswer #justOnce (3(damn)+4(hard)+2(disappointing))/3 = 9/3 = 3, thus "sad"
A Python language
Programming in Natural Language Many researchers today now use data from Twitter to analyze and predict the future events. Questions such as which place in a country is the happiest one, who will be the next US president and which place has the highest rate of depressed people, sometimes depend on the information extracted from thousands of tweets. In case of predicting the happiest state in the US, NLP experts have a set of words that also contains their rates, respectively. For example, the word “great” may have a rate from a scale of 1 to 10, 10; the word "awesome" may have a rate of 8; the word “sad” may have a rate 1 and so on. By computing the average score of a tweet using this set of words, researchers would now be able to measure and categorize the mood of a tweet depending on a certain threshold. In this problem, you will be an assistant of an NLP expert who will determine the mood of a tweet. The category would be:
< 5 is "sad"
>= 5 is "happy"
Let say, we have a tweet:
OMG! I am so happy today #easyMachineExam
When input, “OMG! I am so happy today #easyMachineExam”
And consider our list of words are the following:
wth 4, omg 7, happy 10, great 10, awesome 8, sad 1, disappointing 2, hello 2, relieved 9, damn 3, hard 4
We get only the scores of the words that exist in our list. Since OMG and happy are the only words in the list, we will have
{7(OMG) + 10(happy) } / 2 = (7+10)/2 = 8.5 , thus "happy" Let’s limit our set of words to what is stated above.
Note: Punctuations should be included when giving an input. Thus, you should find a way to remove the punctuations when quantifying its mood. Otherwise, OMG! will not get that rate 7.
Also, it should not be case-sensitive(i.e. “HeLlo, HELLO, hellO, and hellO are the same words.) Let’s limit our inputs to words separated by one whitespace.
Do not include the words with hashtags.
OmG! I AM SO HAPPY TODAY #easymachineexam should also get 8.5 which is “happy”
Another example,
Damn! I studied so hard but this is quite disappointing #tooEasyToAnswer #justOnce
(3(damn)+4(hard)+2(disappointing))/3 = 9/3 = 3, thus "sad"
Step by step
Solved in 2 steps with 1 images