From 56c76bdbe22ca21f8b8de682cd0ae5193bfa12d2 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Wed, 23 Oct 2019 17:40:04 -0500 Subject: Make a new generation --- csci1913/Python/project1_strap012.py | 40 +++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'csci1913/Python/project1_strap012.py') diff --git a/csci1913/Python/project1_strap012.py b/csci1913/Python/project1_strap012.py index 79b3f17..6cf6361 100644 --- a/csci1913/Python/project1_strap012.py +++ b/csci1913/Python/project1_strap012.py @@ -92,5 +92,43 @@ G.rule('Story', ('Phrase',)) # 09 G.rule('Story', ('Phrase', 'and', 'Story')) # 10 G.rule('Story', ('Phrase', 'but', 'Story')) # 11 G.rule('Start', ('Story', '.')) # 12 -for n in range (0,5): +for n in range (0, 5): print(G.generate()) + +# the cat bit the boy . +# the cat kissed the dog and the boy chased the boy . +# the cat chased the dog and the girl bit the boy but the girl chased the cat . +# the girl chased the dog . +# the boy kissed the girl and the cat kissed the girl . + +print() +print() + +# +# + +J = Grammar(1453) +J.rule('Noun', ('sentence',)) +J.rule('Noun', ('walrus',)) +J.rule('Noun', ('sky',)) +J.rule('Noun', ('diamond',)) +J.rule('Noun', ('Ottoman Empire',)) +J.rule('Verb', ('is',)) +J.rule('Verb', ('fanned',)) +J.rule('Verb', ('generated',)) +J.rule('Verb', ('hit',)) +J.rule('Phrase', ('the', 'Noun', 'Verb', 'the', 'Noun')) # 08 +J.rule('Phrase', ('Noun', 'Verb', 'the', 'Noun')) +J.rule('Story', ('Phrase',)) # 09 +J.rule('Story', ('Phrase', 'and', 'Story')) # 10 +J.rule('Story', ('Phrase', 'but', 'Story')) # 11 +J.rule('Start', ('Story', '.')) # 12 + +for f in range(0, 5): + print(J.generate()) + +# the walrus is the sentence and the diamond generated the walrus . +# the walrus generated the walrus and the walrus generated the sentence but diamond hit the sentence . +# sentence fanned the Ottoman Empire . +# the sky hit the diamond and sky is the sentence but the sky fanned the diamond . +# the walrus generated the diamond and the diamond generated the Ottoman Empire but the sky generated the sentence . -- cgit v1.2.3