Question: using python, Finding Unique Words in a File In this exercise you will read the words contained in a file and process them. Your program

using python,

Finding Unique Words in a File In this exercise you will read the words contained in a file and process them. Your program must create a list of the unique words found in the file (ignoring case). Words are only composed of alphabetic characters; digits and punctuation should be removed. Write a fruitful function named open_file() that prompts the user for a file name. The function then attempts to open the file for reading. When it is successful it returns the file handle. If the named file is not readable then the function displays a message and prompts for another file name. Use the os.path.isfile() function to check to see if the file exists. Do not use exception handling in this program. Write a main driver that uses open_file() to get a file handle for the file that the user requests. Then reads the file extracting all the words ignoring punctuation and non-alphabetic characters. Either during the reading process or after the entire file has been read (your choice) create a list containing the unique words. Change all words to lowercase before you process them. Then display a list of these words sorted in alphabetic order. As one of the tests for your final submission you should use the text of Robert Frosts Fire and Ice which is contained in FireAndIce.txt. You also should use Leunigs How To Get There contained in GettingThere.txt.

GettingThere.txt

Go to the end of the path until you get to the gate. Go through the gate and head straight out towards the horizon. Keep going towards the horizon. Sit down and have a rest every now and again, But keep on going, just keep on with it. Keep on going as far as you can. That's how you get there.

FireANdIce.txt

Some say the world will end in fire, Some say in ice. From what I've tasted of desire I hold with those who favor fire. But if it had to perish twice, I think I know enough of hate To say that for destruction ice Is also great And would suffice.

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!