1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dimaraw [331]
3 years ago
10

1. (4 points) Write a function, called word_frequency, which takes a file name as a formal parameter and find the occurrence fre

quency of each distinct word in the file. Consider to use the following algorithm: A. Prepare a dictionary to keep track of the count of each word. B. Open the file. C. For each line in the file do: C.A Break the line into words using spaces in between. C.B Clean each word: strip leading and trailing whitespaces, digits and punctuation characters and convert uppercase letters to lowercase. C.C Update word occurrence count in the word count dictionary. Each item in the dictionary has a word as key and the count of the word as value. D. Close the file. E. Return the dictionary. These are the symbols and digits to be stripped off from words: punctuation

Computers and Technology
1 answer:
Troyanec [42]3 years ago
8 0

Answer:

Check the explanation

Explanation:

CODE

def total_word_count(words):

total = 0

#Loop through all words

for word in words:

#Find total

total = total + words[word]

return total

Kindly check the attached image below for the code output.

You might be interested in
In tableData the column variable of the first column should be RowerNames, the second RowingEvent, the third RowerWeight and the
maxonik [38]

Answer:

Required MatLab code is given below:

Explanation:

function tableData=CreateTable(Names, Event, Weight)

% Matlab function to create a table from the given input arrays

% Inputs:

% Names will be n x 1 string array,

% Event will be n x 1 string array,

% Weight will be n x 1 double column array.

% Outputs:

% tableData : where column variables are : RowerNames, RowingEvent,

% RowerWeight and WeightCategories

WeightCategories = ""; % create an empty WeightCategories array

% loop over the Weight column array, populate the WeightCategories

% based on Weight

for i=1:length(Weight)

if(Weight(i) >= 100 && Weight(i) < 150)

WeightCategories(i) = "light weight";

elseif(Weight(i) >= 150 && Weight(i) < 200)

WeightCategories(i) = "medium weight";

else

WeightCategories(i) = "heavy weight";

end

end

% create the table with arrays Names, Events, Weight and

% WeightCategories by taking transpose of WeightCategories as WeightCategories is a row array

tableData = table(Names,Event,Weight,WeightCategories','VariableNames',{'RowerNames','RowingEvent','RowerWeight','WeightCategories'});

end

%end of function

8 0
4 years ago
D. What is the work of the following features:<br>1. Foot note​
Bess [88]

Answer:

In footnotes, information is separated by commas, while in the bibliography, it is separated by periods.

In footnotes, the author's first name is listed first, while in the bibliography, the author's last name is listed first.

The titles of books and journals are put in italics.

The titles of articles are put in quotation marks.

All key words in titles are capitalized.

Explanation:

3 0
3 years ago
We can save our data peremently on a
riadik2000 [5.3K]

Answer:

modem

Explanation:

hope it helps

4 0
3 years ago
Read 2 more answers
Write a constructor for BaseballPlayer. The constructor takes three int parameters: numHits, numRuns, and numRBIs storing the va
Monica [59]

Answer:

Following are the code to the given question:

public class BaseballPlayer//defining a class BaseballPlayer

{

BaseballPlayer(int numHits, int numRuns, int numRBIs)//defining a parameterized cons

{

}

}

Explanation:

Some of the data is missing, which is why the solution can be represented as follows:

In this code, a class BaseballPlayer is defined, and inside the class a parameterized constructor is defined that holds three integer variable "numHits, numRuns, and numRBIs".

5 0
3 years ago
Consider the following code segment.
Gekata [30.6K]

Answer:

D

Explanation:

(n+n)(n+n)

(2n)^2

4n^2

8 0
3 years ago
Other questions:
  • How can the connection to salesforce be restricted only to the employee portal server? Universal containers (UC) uses a legacy E
    13·1 answer
  • In your presentation you added a text box to?
    5·1 answer
  • Which events occurred during the Space Race?
    5·1 answer
  • The program has a compilation error because s is not initialized, but it is referenced in the println statement. The program has
    8·1 answer
  • Disk mirroring is a method of storing data that generates extra bits of data from existing data, allowing the system to create a
    14·1 answer
  • Your essay is due tomorrow and you don't have time to write it. You decide to buy an essay online. You've paid for it, so it can
    8·1 answer
  • 4. Explain the term prejudice. What is an example of prejudice as it relates to parenting?
    11·1 answer
  • Assignment 1 is to write a program that will write the lyrics to "X number of beers on the wall". Use only the main method. Prom
    11·1 answer
  • Define operator precedence ? explain with an example.​
    13·1 answer
  • Which of the following can be used to help find the error
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!