Write program that generates simple English sentences..solved

Write program that generates simple English sentences..solved

    Write program that generates simple English sentences. Sentences are defined by rules of grammar along with vocabulary of the language. In this assignment, we will restrict ourselves to a simplified subset of the English language. The vocabulary will consist of sample words from several parts of speech, including subject, nouns, verbs, articles, and prepositions. From these words, you can build build simple sentences. For example, "The girl hit a ball" contains one noun, one verb, an article, one subject, and one preposition. In this assignment, we will assume that all sentences constitute the rule:

 

Sentence = Subject + Verb + Preposition + Article + Noun

 

In writing this program, you are given a set of files, each with words from parts of the speech. Your program should read each of the files and generate a random sentence following the above rule. The sentence generated should be based on random selection of words from the parts of the speech. You are to use the function random() from the module random in Python. Your program should ask the user for the number of sentences to be generated and print the randomly generated sentences.

 

I have attached the .txt files to this question

 
Powered by