Question
Question 1. (20 points) Load the sentences of Jane Austen's Emma as lists from NLTK Gutenburg corpus. In this Assignment, for simplicity, we regard each
Question 1. (20 points)Load the sentences of Jane Austen's "Emma" as lists from NLTKGutenburgcorpus. In this Assignment, for simplicity, we regard each sentence as a "line" from the raw text. Print the first 20 sentences / lines.
Question 2. (20 points)Make a Pandas Dataframedf. It should contain two columns. One is the line number (namedline, starting from 0), the other is theword. Convert all the words in lower cases, and get rid of all punctuations. Print the first 10 rows ofdf.
Question 3. (20 points)Load the data from theNRC Emotion Lexiconinto a Pandas Dataframenrc. Make the words as index, different emotions as column names, and fill in the values correspondingly. Print the first 5 rows ofnrc.
Question 4. (20 points)Joindfandnrctogether. Sum the values of different emotions on each line, and put the result into a new Dataframenew_df. Print the first 5 rows ofnew_df.
Question 5. (20 points)Make a plot of emotions "anger", "anticipation", "disgust", "fear", "joy", "sadness", "surprise" and "trust" from the first 500 lines. Put each emotion into a differentsubplot. All the subplots should share one single x axis.
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