subject

Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of text files at startup. The filenames are nouns. txt, verbs. txt, articles. txt, and prepositions. txt. (Hint: Define a single new function, getWords. This function should expect a filename as an argument. The function should open an input file with this name, define a temporary list, read words from the file, and add them to the list. The function should then convert the list to a tuple and return this tuple. Call the function with an actual filename to ini- tialize each of the four variables for the vocabulary.)Case Study: Generating Sentences code:import randomarticles = ("A", "THE")nouns = ("BOY", "GIRL", "BAT", "BALL")verbs = ("HIT", "SAW", "LIKED")prepositions = ("WITH", "BY")def sentence():return nounPhrase() + " " + verbPhrase()def nounPhrase():return random. choice(articles) + " " + random. choice(nouns)def verbPhrase():return random. choice(verbs) + " " + nounPhrase() + " " + \prepositionalPhrase()def prepositionalPhrase():return random. choice(prepositions) + " " + nounPhrase()def main():number = int(input("Enter the number of sentences: "))for count in range(number):print(sentence())if __name__ == "__main__":main()

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 07:30
To check spelling errors in a document, the word application uses the to determine appropriate spelling. internet built-in dictionary user-defined words other text in the document
Answers: 2
question
Computers and Technology, 23.06.2019 21:00
Uget brainliest if accurate mary has been given the responsibility of hiring a person for the position of a software testing officer. which management function would mary achieve this responsibility?
Answers: 1
question
Computers and Technology, 24.06.2019 00:20
Describe a data structures that supports the stack push and pop operations and a third operation findmin, which returns the smallest element in the data structure, all in o(1) worst-case time.
Answers: 2
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
Answers: 1
You know the right answer?
Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of t...
Questions
question
Mathematics, 05.10.2019 07:30
question
Mathematics, 05.10.2019 07:30
Questions on the website: 13722367