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
In which type of attack do you get malicious code in links from seemingly reliable websites?
natali 33 [55]

I think it is C. cross-site scripting

6 0
3 years ago
. In many instances an IP address is used to access a server rather than a URL because a URL is more difficult to set up and eas
Sloan [31]

Answer:

IP's allow for anyone to have direct connection to the Server including attackers, I'd say that this is false primarily because setting up a domain being too "hard" isn't a reason to cop out on security

Explanation:

5 0
2 years ago
8. Software ____ are individual programs that can be purchased, installed, and run separately, but extract data from the common
oee [108]
System software are software that can be installed and run separately
6 0
2 years ago
If you created a variable called name, what data type would that value be? Group of answer choices a float a string a Boolean an
Semenov [28]

I think its an integer

8 0
2 years ago
Read 2 more answers
ImmuneEarth, a research and development company, has "eradicate all diseases" as its motto. It has numerous departments that res
anastassius [24]

Answer:

Grid computing.

Explanation:

Grid computing is a study utilizing Immune Earth to test AIDS treatment because the following are the reasons that describe the answer is true about the scenario.

  • Grid computing seems to be a scattered network with a vast amount for systems linked to handle a difficult issue.
  • Systems can be linked straightly or through organized systems.

Other options are incorrect.

  • Green computing is not the correct answer according to the scenario because the usage of systems and its energy is socially safe and economically sustainable.
  • Trusted Computing is not the correct answer according to the scenario because it helps a part of information to show which os as well as program to be required to access this.
  • Edge computing is not the correct answer according to the scenario because it optimizes web apps as well as software programs while getting computation back to the information base.
4 0
3 years ago
Other questions:
  • PLS HELP ASAP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    15·1 answer
  • The ListIterator interface
    13·1 answer
  • A ____________ variable is available throughout a program.
    7·1 answer
  • Given half a chance other people at work will take advantage of you
    11·1 answer
  • Each row in a database is a set of unique information called a(n) (A.)table,(B.)record,(C.)object,(D.)field
    12·2 answers
  • ________________ occur when a system produces incorrect, inconsistent, or duplicate data.
    6·2 answers
  • How do you know if something is in the public domain
    5·1 answer
  • Which of the following statements accurately describes linked data?
    5·1 answer
  • Directions: Arrange the jumbled letters to make/form a new word. Then give a
    12·1 answer
  • Can somebody please help me with these few questions?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!