Question: Produce a code based on the following: Stop words are basically words that appear so frequently they don t mean much. For example, in English,
Produce a code based on the following:
Stop words are basically words that
appear so frequently they dont mean much. For example, in English, some common stop
words are andabutthe and so on
Your job for this assignment is to write a python program that processes The Bee Movie
script provided to determine likely stop words. Your program should go through the file
and count the number of times each word appears, taking into account case and
punctuation bee Bee and Bee. should all count as the same word Your program should
then create a file, counts.txt that consists of each word followed by the number of times it
appears in the text, from most frequent to least frequent.
Your module should implement the following functions, readfile, writefile, and
builddictionary.
readfile: will take in a file to be read and return the contents of the file as a string
writefile: will take in a dictionary and an output file name and write each word
with its corresponding count to the output file in descending order this is where
you will sort your dictionary this function will not have a return statement
builddictionary: will take in a string and build a word count dictionary again, be
sure to account for case and punctuation
To sort a dictionary, you can use a call from the operator module, so be sure to import
operator. This will sort a dictionary, adict, in ascending value order try it out and
convince yourself it works. Make note of what type of object this line of code returns.:
sortedlist sortedadict.items keyoperator.itemgetter
Keep in mind that you should be calling functions within other functions when necessary.
Your main program may not need to be more than lines.
Use this script : BeeMovieScript.txt
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
