Calculate the word frequency for text b in the same way

Assignment Help Computer Engineering
Reference no: EM132212270

Question :

You have to write a Python program (3.5) which take two text files. Start with the "wordfreq.py" script . As presented, it only calculates the frequency of each individual word in a text file, stored in a dictionary structure. Keep the input question that asks how many results you want displayed (n).

Note: Since you'll be doing many of the same operations twice, you should revise the code to write some sensibly-designed reusable functions instead of simply duplicating each chunk of code and changing variable names.

Revise and enhance the program so that the program ALSO does these things:

1. Ask the user for a second text file to compare with the first one. I'll refer to the files "A" and "B" below.

2. Calculate the word frequency for text "B" in the same way it does for "A".

3. For both files, compute and print out how many total words it contains and how many distinct words they contain.

4. For both files, print out the n most frequent individual words (sorted like the provided example already does), but also showing the percentage of the total words each represents in its file. This is simple to calculate, as: frequency_of_word / total_words * 100. Round that to 2 decimal places.

5. Last, as a simple comparison of the texts, your program should print all the words that occured more than once in text "A" but not at all in "B" and vice-versa.

Reference no: EM132212270

Questions Cloud

What you have learned in your graduate degree program : Assess your preparedness for a business leadership and management position based on what you have learned in your graduate degree program.
Define differences between carrying amounts and fair values : Goodwill was not impaired in any period. The plant and equipment had a further 5-year life at acquisition date and was expected to be used evenly over that time
Calculate a students average for a semester : How to write this in pseudocode and create flowchart: For this program, you will calculate a student's average for a semester.
Prepare a fully classified income statement : ACCT 1008 Accounting for Business Assignment, University of South Australia, Australia. Prepare a fully classified Income Statement
Calculate the word frequency for text b in the same way : For both files, compute and print out how many total words it contains and how many distinct words they contain.
Perform insertion on a doubly-linked list : Write a pseudocode to perform insertion on a doubly-linked list.
A python program that plays a modified yahtzee game : Write a Python 3.5 program that plays a modified Yahtzee game. You will allow a single player to play with 5 dice.
Which of the given is the correct equity method entry : Investor owns 40% of Investee and applies the equity method. In 2016, Investor sells merchandise costing $210,000 to Investee for $280,000.
Calculate the sum of consecutive integers from the lowest : Write pseudocode to calculate the SUM of consecutive integers from the lowest, L, through the highest, H, but without exceeding 100.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Justify the function of a mater patient indexdiscuss how

justify the function of a mater patient index.discuss how the mater patient index is an important resource in the

  Read about role base access control models

Look at the XACML operational model that is claimed to be a generic RBAC implementation. Do you agree with the last statement?

  Find article describing where physical security has failed

Project assignment is to have you do more research on the physical security topic. In theory, everything may look straight forward, however.

  Compare the role of share and ntfs permissions

"magz64"- Compare and contrast the role of share and New Technology File System (NTFS) permissions, and the manner in which an administrator uses them in order to secure resources (i.e., files, folders) on a computer.

  Write a routine to transform an environment map to surface

Devise an algorithm for implementing the progressive refinement radiosity method. Write a routine to transform an environment map to the surface of a sphere.

  Calculate the daily average distance walked by the user

Using Java, how can I use a loop that runs 7 times (using the final variable) to ask and get how many steps the user walks each day of the seven days.

  Webinars and other web conferencing processes

Webinars and other web conferencing methods have proved most beneficial for the provision of affordable quality corporate training.

  Give difference between testing and debugging

You have just been hired as the testing guru for the CatchAllBugs.com Company. Your first task is to write a set of test cases to debug a small VB program. Unfortunately, you do not have access to the code of program. All you have is the following ..

  Write a program that perform this simple substitution cipher

Print an appropriate error message if the user enters something other than a letter from the list [A...Za...z].

  Write a lisp function that multiplies a polynomial by a term

Using the polynomials code we have developed in class, write a Lisp function that multiplies a Polynomial by a term.

  Relationship between hardware and software

What are the relationship between hardware and software.

  Find the shortest sequence of mips instructions

Find the shortest sequence of MIPS instructions that extracts bits 16 down to 11 from register $t0 and use the value of this field to replace bits 31 down to 26 in register $t1 without changing the other 26 bits of register $t1

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd