Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions