Question: HELP ME QUICK. Please READ everything in order to understand this problem. This is ONE problem. Below is the link for a file that contains

HELP ME QUICK. Please READ everything in order to understand this problem. This is ONE problem. Below is the link for a file that contains the text files needed for this homework assignment, it ALSO contains the output of the program labeled ex_out.txt. Once you click on the link it will lead you to a google drive. Download the file from the google drive and start reading the problem :). I have put a sample output below the question.

LINK TO THE GOOGLE DRIVE FILE:

https://drive.google.com/drive/folders/1g3BlIq-k_zKBoUZxae5LW9MwCJqCUdnQ?usp=sharing

HELP ME QUICK. Please READ everything in order to understand this problem.

1. Calculate and output the average word length, accurate to two decimal places. The idea here is that word length is a rough indicator of sophistication. 2. Calculate and output, accurate to three decimal places, the ratio between the number of distinct words and the total number of words. This is a measure of the variety of language used (although it must be remembered that some authors use words and phrases repeatedly to strengthen their message.) 3. For each word length starting at 1, find the set of words having that length. Print the length, the number of different words having that length, and at most six of these words. If for a certain length, there are six or fewer words, then print all six, but if there are more than six print the first three and the last three in alphabetical order. For example, suppose our simple text example above were expanded to the list ['weather' , 'puppy' , 'challenge' , 'house' , 'whistle', 'nation', 'vest', 'safety' , 'house' , 'puppy' , 'card', 'weather', 'card', 'bike', 'equality' , 'justice', 'pride', 'orange' , 'track' , 'truck' , 'basket ' , 'bakery' , 'apples', 'bike' , 'truck', 'horse', 'house' 'scratch' , 'matter' , 'trash'] Then the output should be 1 : 0: 2: 0: 3: 0: 4 : 3: bike card vest 5: 7: horse house pride . . . track trash truck 6: 7: apples bakery basket . . . nation orange safety 7: 4: justice scratch weather whistle 8: 1: equality 9: 1: challenge 4. Find the distinct word pairs for this document. A word pair is a two-tuple of words that appear max_sep or fewer positions apart in the document list. For example, if the user input resulted in max_sep == 2, then the first six word pairs generated will be: ('puppy' , 'weather' ), ('challenge' , 'weather' ), ('challenge' , 'puppy' ), ('house' , 'puppy' ) , ('challenge', 'house' ), ('challenge' , 'whistle') Your program should output the total number of distinct word pairs. (Note that ('puppy' , 'weather and ( 'weather' , 'puppy' ) should be considered the same word pair.) It should also output the first 5 word pairs in alphabetical order (as opposed to the order they are formed, which is what is written above) and the last 5 word pairs. You may assume, without checking, that there are enough words to generate these pairs. Here is the output for the longer example above (assuming that the name of the file they are read from is ex2. txt): Word pairs for document ex2. txt 54 distinct pairs apples bakery apples basket apples bike apples truck bakery basket puppy weather safety vest scratch trash track truck vest whistle 5. Finally, as a measure of how distinct the word pairs are, calculate and output, accurate to three decimal places, the ratio of the number of distinct word pairs to the total number of word pairs

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 Programming Questions!