Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python 3 class: class Input An object of this class represents information about the input data. This class should implement (at least) the following methods:

python 3 class:

image text in transcribed

class Input An object of this class represents information about the input data. This class should implement (at least) the following methods: . init_(self) uses input ) to read in the name of an input file, opens the file, and initializes an attribute of the object with the file object returned by open () word list self : reads in the contents o the input le, splits t into a list o words, remo es any punctuation at either end of the word un tuation characters side he wor si d not e removed), discards any empty strings that may result, and returns the resulting list. class Ngrams An object of this class represents n-gram information about the input list of words. This class should implement (at least) the following methods . init(self) : uses input) to read in the value of n for computing n-grams and initializes an attribute of the object with this value. It also initializes the data structure that will be used to keep track of the number of times each n-gram occurs in the input. . update (self, ngram) updates the count for the n-gram ngram . process wordlist (self, wordlist) processes the list of words wordlist read from the input file to compute the number of times each n-gram occurs in wordlist. print_max_ngrams (self) : prints out the n-grams that have the highest number of occurrences according to the output format specified above (see Output) class Input An object of this class represents information about the input data. This class should implement (at least) the following methods: . init_(self) uses input ) to read in the name of an input file, opens the file, and initializes an attribute of the object with the file object returned by open () word list self : reads in the contents o the input le, splits t into a list o words, remo es any punctuation at either end of the word un tuation characters side he wor si d not e removed), discards any empty strings that may result, and returns the resulting list. class Ngrams An object of this class represents n-gram information about the input list of words. This class should implement (at least) the following methods . init(self) : uses input) to read in the value of n for computing n-grams and initializes an attribute of the object with this value. It also initializes the data structure that will be used to keep track of the number of times each n-gram occurs in the input. . update (self, ngram) updates the count for the n-gram ngram . process wordlist (self, wordlist) processes the list of words wordlist read from the input file to compute the number of times each n-gram occurs in wordlist. print_max_ngrams (self) : prints out the n-grams that have the highest number of occurrences according to the output format specified above (see Output)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions