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
Which of the following may businesses use to screen out applicants for a position? A. social media B. applications C. resumes D.
Nataly_w [17]
The correct answer is E
8 0
3 years ago
Read 2 more answers
You have just installed the microsoft windows 7 operating system on your pc. which web browser is bundled with windows 7 and is
kirill [66]
The web browser that is automatically installed with windows 7 is Internet Explorer.

Hope this helps.
6 0
3 years ago
Explain why computer users should use the cloud?
Anvisha [2.4K]

Developing in the cloud enables users to get their applications to market quickly. Hardware failures do not result in data loss because of networked backups. Cloud computing uses remote resources, saving organizations the cost of servers and other equipment.

4 0
2 years ago
HELP ASAP WILL GIVE BRAINLY Question 19 Multiple Choice Worth 5 points) (05 03 MC) Network technologies specialist Hannah has be
nasty-shy [4]

Network technologies specialist Hannah would need to configure: C. RIP version 2 using Internet Protocol Version 4 (TCP/IPv4).

<h3>What is RIP?</h3>

RIP is an acronym for Routing Information Protocol and it can be defined as an intradomain routing protocol which is typically designed and developed based on distance vector routing.

<h3>The types of RIP.</h3>

In Computer networking, there are two main types of Routing Information Protocol (RIP) and these include:

  • RIP version 1.
  • RIP version 2.

RIP version 2 are generally designed and developed to include subnet masks unlike RIP version 1. Thus, Hannah would need to configure RIP version 2 using Internet Protocol Version 4 (TCP/IPv4) allow several machines on different subnets to communicate with each other using broadcasts.

Read more on routing protocol here: brainly.com/question/24812743

4 0
2 years ago
Define horizontal scroll bar​
Murrr4er [49]

Answer:

the thing thats on the bottom of your page when you zoom in that makes the page go left and right.

Explanation: birb

4 0
2 years ago
Read 2 more answers
Other questions:
  • Mathematical computations by a computer are faster than your quickest mathematical computations because the top speed of a neura
    13·1 answer
  • Sarah, a computer user, tells James, a computer technician, that the network she is connected to is running too slowly. Which of
    5·1 answer
  • The set of rules for how computers talk to one another
    6·1 answer
  • Write a SELECT statement that uses an aggregate window function to get the total amount of each order. Return these columns: The
    13·1 answer
  • What is the data and information with example? ​
    9·1 answer
  • Multiple Choice
    8·1 answer
  • What are the uses of DVD Ram​
    12·2 answers
  • How did machines get involved throughout the years?
    13·1 answer
  • "if" statements are part of creating computer programs, what are these instructions called and how would you use them?
    11·2 answers
  • Is iphone battery being draned if plugged into car charger when listening to podcasts
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!