Question: Write a function called filter_nonwords that takes a list of strings as input and returns a new list of strings that excludes anything that isnt

Write a function called filter_nonwords that takes a list of strings as input and returns a new list of strings that excludes anything that isnt entirely alphabetic. Use the str.isalpha() method to determine is a string is comprised of only alphabetic characters.

text = '"Oh no, no," said the little Fly, "to ask me is in vain."' tokens = tokenize(text, do_lower=True) filter_nonwords(tokens) ['oh', 'no', 'no', 'said', 'the', 'little', 'fly', 'to', 'ask', 'me', 'is', 'in', 'vain']

Use this function to list the top 5 most frequent words in carroll-alice.txt. Confirm that you get the following before moving on:

the 1642 and 872 to 729 a 632 it 595

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!