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]
3 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]3 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
4. In this problem, we consider sending real-time voice from Host A to Host B over a packet-switchednetwork (VoIP). Host A conve
mina [271]

Answer:

The time elapsed is 0.017224 s

Solution:

As per the question:

Analog signal to digital bit stream conversion by Host A =64 kbps

Byte packets obtained by Host A = 56 bytes

Rate of transmission = 2 Mbps

Propagation delay = 10 ms = 0.01 s

Now,

Considering the packets' first bit, as its transmission is only after the generation of all the bits in the packet.

Time taken to generate and convert all the bits into digital signal is given by;

t = \frac{Total\ No.\ of\ packets}{A/D\ bit\ stream\ conversion}

t = \frac{56\times 8}{64\times 10^{3}}          (Since, 1 byte = 8 bits)

t = 7 ms = 0.007 s

Time Required for transmission of the packet, t':

t' = \frac{Total\ No.\ of\ packets}{Transmission\ rate}

t' = \frac{56\times 8}{2\times 10^{6}} = 2.24\times 10^{- 4} s

Now, the time elapse between the bit creation and its decoding is given by:

t + t'  + propagation delay= 0.007 + 2.24\times 10^{- 4} s + 0.01= 0.017224 s

8 0
3 years ago
What is the answer ????​
gtnhenbr [62]

Answer:

<h2>iv. NINGUNO DE LOS ANTERIORES</h2>

Explanation:

<h2>Hola</h2>
8 0
3 years ago
(within 200 words) analyzing the importance of information and communication technology in personal life.
Volgvan

Explanation:

Information technology is inescapable in modern day life, turn on the coffee pot and there are tiny microprocessor inside. Start your automobile and every aspect of operation is controlled by dozens of computer control modules. The current mobile phone amazing power and speed for the user. Technology is transforming every aspect of our life. Nowever is this more apparent than our place of employment. Developing of it makes our family to live happy because it helps the members of family to spend their most time with their family. It helps us to communicate the family member who live far from their family. It is also used in house hold work. It's saves our time to do more better and better

6 0
3 years ago
4.8 Code Practice: Question 1
Furkat [3]

Answer:

c = 1 # global variable

    jhjl jh

def add(): c = 1 # global variable

def add():

   print(c)

add()

   c = c + 2 # increment c by 2

   print(c)

add()

Explanation:

4 0
2 years ago
Read 2 more answers
A technician wants to update the organization's disaster recovery plans. Which of the following will allow network devices to be
Illusion [34]

Answer:B) Archives/backups

Explanation: Archive is the group of records of data that are saved for the future use.These are the historic data that is not currently used in the actual location .

Backup is the the the copy of the group of data that is not in the original form to be used in future. Thus the correct option is option(B).

Updating of the plans by the technician cannot be done through other given options because they don't hold the historic records of the data for the renewing of the plans.

6 0
3 years ago
Other questions:
  • Dialogue is not a characteristic of functional text because...
    12·1 answer
  • Comparing tools made of stone, iron, and bronze: place them in the correct order from least to most durable
    14·1 answer
  • _________ are represented using diamonds linked withparticipant ETs
    6·1 answer
  • Leo noticed that attackers have breached his wireless network. They seem to have used a brute-force attack on the WiFi protected
    13·1 answer
  • Draw a dfd that shows how data will be stored, processed, and transformed in the tims system
    9·1 answer
  • 5. An entrepreneur who continues to find new and better ways of doing things is ____.
    10·1 answer
  • You are running your warehouse using Autonomous Data Warehouse (ADW) service and you noticed that a newly configured batch job i
    15·1 answer
  • What is a disadvantage of communicating on social media?
    14·1 answer
  • A ________ is a device used to illegally capture the data stored on the magnetic stripe of an ATM card, credit card, or debit ca
    10·1 answer
  • Write a program that takes a string as an input. If the string entered is equal to
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!