This python code takes as input grammar rules, a list of words and generates, and how many sentences you want to generate.  It then generates that number of sentences made up of the given possible words and conforming to the given rules of the grammar.