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.