Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Problem 1 (Text Analysis) create a Python file called analysis.py that will perform text analysis on files. For this question, assume that each space (" ") in the document separates one word from the next - so any use of the term 'word' means a string that occurs between two spaces (or in two special cases, between the start of the file and a space, or between a space and the end of the file). You can also assume there is no punctuation or other symbols present in the files - only words separated by spaces. If you want to see examples of the type of text, look in the testfile_.txt files included on cuLearn. You must implement and test the following functions inside of your analysis.py file:

1) load(str) - Takes a single string argument, representing a filename. The program must open the file and parse the text inside. This function should initialize the variables (e.g., lists, dictionaries, other variables) you need to solve the remainder of the problem. This way, the file contents can be parsed once and the functions below can be executed many times without re-reading the file, which is a slow process. This function should also remove any information stored from a previous file when it is called (i.e., you start from nothing every time load is called).

2) commonword(list) - Takes a single list-type argument which contains string values. The function should operate as follows: a. If the list is empty or none of the words specified in the list occur in the text that has been loaded, the function should return None. b. Otherwise, the function should return the word contained in the list that occurs most often in the loaded text - or any one of the most common, in the case of a tie.

3) commonletter(list) - Takes a single list-type argument which contains single character strings (i.e., letters/characters). The function should operate as follows: a. If the list is empty or none of the letters specified in the list occur in the text that has been loaded, the function should return None. COMP 1005/1405 - S17 - A5 Due Tuesday, June 13 at 11:55 PM 2 b. Otherwise, the function should return the letter contained in the list that occurs most often in the loaded text - or any one of the most common, in the case of a tie.

4) commonpair(str) - Takes a single string argument, representing the first word. This function should return the word that most frequently followed the given argument word (or one of, in case of ties). If the argument word does not appear in the text at all, or is never followed by another word (i.e., is the last word in the file), this function should return None.

5) countall() - Returns the total number of words found in the text that has been loaded. That is, the word count of the document.

6) countunique() - Returns the number of unique words in the text that has been loaded. This is different than the previous function, as it should not count the same word more than once. You can use the analysistester.py file from cuLearn, along with the posted text files, to test your functions. You can also create additional text files of your own to further test the correctness of your program. If you want an easy way to find out the necessary information about a file you created, you can copy/paste the contents into the form at http://textalyser.net. It can give you the total word count, unique word count, word frequency to determine the most common word, and common word pairs.

Use python pls. i'm currently using python 3.6.2

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92524909
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Computer Engineering

What do you gain from being able to see the data in a

What do you gain from being able to "see" the data in a graphic presentation, that a table of the data may not readily provide? Discuss and explain why.

An article in the wall street journal noted that an

An article in The Wall Street Journal noted that an" increase in the price of crude oil quickly reduces demand for oil". Do you agree with this statement? Briefly explain.

Please discuss the data hazards associated with pipelining

Please discuss the data hazards associated with pipelining with an example and how these hazards impact the performance gain associated with pipelining.

Question suppose you wish to encrypt the messsge beyonce

Question : Suppose you wish to encrypt the messsge BEYONCE using the one time pad with the key RIHANNA. What is the keyspace of the one-time pad for a ciphertext of length L? Justify.

Babies weighing less than 55 pounds at birth are considered

Babies weighing less than 5.5 pounds at birth are considered "low-birth-weight babies." In the United States, 7.6% of newborns are low-birth-weight babies. The following information was accumulated from samples of new bi ...

Using c language how to write a function name bsqrt that

Using C++ language, how to write a function name bsqrt that will compute the square root of a number using the Babylonian method. This function will take the number x to compute the square root for and the number of iter ...

In a survey of 100 people 40 were casual drinkers event d

In a survey of 100 people, 40 were casual drinkers (event D), and 60 did not drink (event D). Of the ones who drank, 6 had minor headaches. Of the non-drinkers, 9 had minor headaches. Let D represent set of surveyed peop ...

Question why most of the researchers in the field of arabic

Question : Why most of the researchers in the field of Arabic text classification collected their own corpus and what is In-house Arabic corpus. The response must be typed, single spaced, must be in times new roman font ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Program in cit is often times advantageous to be able to

*Program in C* It is often times advantageous to be able to transfer data between two arrays. Need a help with program (transfer.c) that add a range (by start index and end index) of numbers from array #1 to array #2 at ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As