Question: python In this problem you will write a function to parse a Shakespearean text (a short monologue) and glean information from the text file. There

python

python In this problem you will write a function to parse a

In this problem you will write a function to parse a Shakespearean text (a short monologue) and glean information from the text file. There are a few parts to this problem; you will be required to print 1. The number of words in the document 2. The number of different (unique) words in the document 3. The total number of words that contain apostrophes. 4. A list of words in the document-that have a frequency of 5 or greater-paired with their corresponding frequency. Any words that contain apostrophes must keep them if they appear in the list! The list should be sorted in descending order by frequency (see example below). Additionally, words like "Mother" and "mother" should be only one key in your dictionary (use lower. Note that words paired by a hyphen or dashorare counted as separate words. For example, "five-year-old" is considered to contain three separate words: "five", "year", and "old". You can assume that the file being mined (fname) exists in the same repository as the program Your function should be named: def mine file(fname): Where fname is the file name (such as "shakespeare.txt"). You will need to use file I/O methods such as open ),close, and readline ) to accomplish this problem. Here isa sample output of the program: For the file macbeth.txt: Word Count: 205 Unique Word Count: 127 Apostrophe Word Count: 8 to: 10 the: 8 of: 8 and 7 my: 5 be: 5 We have provided you with one Shakespearean text file to use when writing this problem (macbeth.txt) In this problem you will write a function to parse a Shakespearean text (a short monologue) and glean information from the text file. There are a few parts to this problem; you will be required to print 1. The number of words in the document 2. The number of different (unique) words in the document 3. The total number of words that contain apostrophes. 4. A list of words in the document-that have a frequency of 5 or greater-paired with their corresponding frequency. Any words that contain apostrophes must keep them if they appear in the list! The list should be sorted in descending order by frequency (see example below). Additionally, words like "Mother" and "mother" should be only one key in your dictionary (use lower. Note that words paired by a hyphen or dashorare counted as separate words. For example, "five-year-old" is considered to contain three separate words: "five", "year", and "old". You can assume that the file being mined (fname) exists in the same repository as the program Your function should be named: def mine file(fname): Where fname is the file name (such as "shakespeare.txt"). You will need to use file I/O methods such as open ),close, and readline ) to accomplish this problem. Here isa sample output of the program: For the file macbeth.txt: Word Count: 205 Unique Word Count: 127 Apostrophe Word Count: 8 to: 10 the: 8 of: 8 and 7 my: 5 be: 5 We have provided you with one Shakespearean text file to use when writing this problem (macbeth.txt)

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!