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
Misha Larkins [42]
2 years ago
8

Define a function called 'findWordFreq, which takes two parameters. The first parameter, 'text" is an nltk.text.Text object and

the second parameter, 'word' is a string. The function definition code stub is given in the editor. Perform the given operation for the 'text' object and print the results: 11 Determine the frequency distribution of all words having only alphabets in "text", store into a variable 'textfreq 15 • Find the frequency for the given 'word, and store it into the variable 'wordfreq'. • Find the word which has a maximum frequency from the textfreq , and store into the variable 'maxfreq! 16 17 19 Return 'wordfreq' and 'maxfreq. variables from the function. Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. Python 3 • Autocomplete Ready O 8 import zipfile from nltk.corpus import gutenberg 10 from nltk. text import Text import nltk 12 13 14 # Complete the 'findWordFreq' function below. def findWordFreq(text, word): # Write your code here textfreq = nltk. FreqDist(text) 18 wordfreq = nltk.FreqDist(word) maxfreq = nltk.FreqDist(text) 20 return wordfreq, maxfreq 21 22 vif -_name__ == '__main__': 23 text = input() 24 word = input() 25 if not os.path.exists(os.getcwd() + "/nltk_data"): 26 with zipfile.ZipFile("nltk_data.zip", 'r') as zip_ref: 27 zip_ref.extractall(os.getcwd()) 28 os.environ['NLTK_DATA'] = os.getcwd() + "/nltk_data" 30 text = Text(gutenberg.words (text)) 31 32 word_freq, max_freq = findWordFreq(text, word) 33 34 print(word_freq) 35 print(max_freq) The first line contains a string 'text', which should be one of the text collection file names from gutenberg corpora. The second line contains a string 'word. Find the frequency for the word, Sample Case Sample Input 29 Function Parameters STDIN ----- ------- austen-sense.txt John → text = nltk.Text(nltk.gutenberg.words ('austen-sense.txt → word = 'John! Line: 19 Col Sample Output Test Results Custom Inpus Run Submit Cod 163 to No test case passed. Input (stdin) 1 austen-sense.txt 2. John Your Output (stdout) 1 2. Expected Output 1 163 2 to
Computers and Technology
1 answer:
MakcuM [25]2 years ago
4 0

Answer:

import os

import nltk

import zipfile

from nltk. corpus import gutenberg

from nltk. text import Text

def findWordFreq(text, word):

   textfreq = nltk. FreqDist(text)

   wordfreq = nltk.FreqDist(word)

   maxfreq = max(textfreq)

   return wordfreq, maxfreq

if -_name__ == '__main__':

   text = input()

   word = input()

   if not os.path.exists(os.getcwd() + "/nltk_data"):

       with zipfile.ZipFile("nltk_data.zip", 'r') as zip_ref:

           zip_ref.extractall(os.getcwd())

   os.environ['NLTK_DATA'] = os.getcwd() + "/nltk_data"

   text = Text(gutenberg.words (text))

   word_freq, max_freq = findWordFreq(text, word)

   print(word_freq)

   print(max_freq)

Explanation:

The natural language package in python is used to get and analyse word from voice input. The python code above get words from a zipfile extract, and the 'findWordFreq' function gets the word count and the maximum number of alphabet used in the word distribution.

You might be interested in
A(n) ____________ specifies a variable's name and data type.
Alla [95]
I think that would be a function
4 0
3 years ago
Read 2 more answers
. Which of the following are container elements?
lions [1.4K]
It’s c cba to explain
4 0
2 years ago
Read 2 more answers
Refer to the exhibit. An administrator is examining the message in a syslog server. What can be determined from the message? Thi
ad-work [718]

Answer:

This is a notification message for a normal but significant condition

Explanation:

Syslog represents the standard for logging message, it sends messages through UDP port 514. Familiar syslog facilities includes IP, OSPF protocols, etc. The messages from syslog are both about facility and level.

A syslog server is a means through which network devices sends messages about events into a logging server which is called syslog server. Since a syslog protocol supports so many devices, it can also be used to log a good number of events.

8 0
2 years ago
Read 2 more answers
Which is a major drawback of muliuser procesing of a database
-BARSIC- [3]

The main drawback of multiuser processing of a database is:

  • Lost-update problem.

<h3>What is  lost-update problem?</h3>

In the area of lost update problem, an update that has been carried on to a data item by a transaction is said to be lost as it is known to be overwritten by the update that has been carried on by another transaction.

Therefore, The main drawback of multiuser processing of a database is:

  • Lost-update problem.

Learn more about database from

brainly.com/question/26096799

#SPJ12

3 0
1 year ago
Which html attributes are required in the image () element - check as many as apply
kotykmax [81]

Answer:

The correct answer for the given question is option(3) i.  src.

Explanation:

In HTML if we insert a image on the screen we use<img> tag

the img have following attribute

1.src

2.height.

3 alt

4 width

The required attribute in img tag is src i.e source or path of image

The following are the syntax of image tag

<img src=" path of image" alt="not visible"  height="100px" width="100px"/>

The height and width attribute describe the height and width of image in pixel.

The alt attribute is not mendatory attribute in image tag.The alt attribute display the message when image is not visible in the web page .

All the other attribute like alt,height,width are used as per the requirement but src is an required attribute .

so the option(3) is correct.

6 0
2 years ago
Other questions:
  • Pendant Publishing edits multi-volume manuscripts for many authors. For each volume, they want a label that contains the author'
    14·1 answer
  • What contains the computer brain the central processing unit
    8·2 answers
  • Mr. Mathis asked his students to add a comment to a cell the students recorded the steps they followed in a chart. Which student
    12·2 answers
  • What is one difference between a web page and a web application? Web pages provide information, while web applications allow the
    8·1 answer
  • How to make a water bottle rocket??
    6·1 answer
  • Apps are designed by___.
    11·2 answers
  • How do you measure the capacity of speed and memory of computer system<br>Explain.​
    13·1 answer
  • If the list [8,1,4,2,10,0] is sorted with the selection sort algorithm, what is the list at the 4th step of the algorithm?
    13·1 answer
  • 4. The volume of a sphere is (4.0/3.0)rr3 and the surface area is 4.0rr2, where r is the radius of
    12·1 answer
  • Write a recursive decent algorithm for a java while statement, a Javas if statement , an logical/mathematical expression based o
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!