Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help to write the python code for the following three tasks, see what I have attempted in the image below. When you look
I need help to write the python code for the following three tasks, see what I have attempted in the image below.
When you look at the stemmed object above, you can see the results of using PorterStemmer. But what did this do to our top words?
1. Write code to count the words and show the top 20 used.
2. Produce a new horizontal bar graph with this new set of words.
3. Explain what stemming did to our set of words.
No additional files are attached.
Stemming - getting to the root word Stemming will take words such as enjoyed and enjoying to the root form of enjoy. A disadvantage of stemming is that it may stem a word to a nonsensical word, such as location to locat. Reference: Stemming vs Lemmatization In [82] \# create a List of words to_stem = list(itertools.chain(*my_final)) \# stemming section from nltk.stem.porter import Porterstemmer porter = Porterstemmer() stemmed = [porter.stem(word) for word in to_stem] print(stemmed[:50]) ['enjoy', 'best', 'western', 'pioneer', 'squar', 'husband', 'room', 'king', 'bed', 'clean', 'quiet', 'attract', 'son', 'roo m", 'twin", 'bed', "room', 'corner', "main', "street', "said', 'littl', "noisier", 'neon', 'light', 'shone', 'later', 'hote 1', 'trip', 'made', 'appreci', 'one', 'love', 'old', "wood', 'center', "staircas", 'breakfast', 'includ', 'everyon', 'happ i', 'waffl', 'toast', 'cereal', 'egg', 'meal', 'locat', 'great', 'could', 'walk'] Problem 8 ( 6 pts.): When you look at the stemmed object above, you can see the results of using PorterStemmer. But what did this do to our top words? 1. Write code to count the words and show the top 20 used. 2. Produce a new horizontal bar graph with this new set of words. 3. Explain what stemming did to our set of wordsStep 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