diff options
author | RossTheRoss <msattr@gmail.com> | 2019-10-23 17:40:04 -0500 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-10-23 17:40:04 -0500 |
commit | 56c76bdbe22ca21f8b8de682cd0ae5193bfa12d2 (patch) | |
tree | c63a2fcef6f633552123627ad5678ad9f7c53765 | |
parent | s p a c i n g (diff) | |
download | homework-56c76bdbe22ca21f8b8de682cd0ae5193bfa12d2.tar homework-56c76bdbe22ca21f8b8de682cd0ae5193bfa12d2.tar.gz homework-56c76bdbe22ca21f8b8de682cd0ae5193bfa12d2.tar.bz2 homework-56c76bdbe22ca21f8b8de682cd0ae5193bfa12d2.tar.lz homework-56c76bdbe22ca21f8b8de682cd0ae5193bfa12d2.tar.xz homework-56c76bdbe22ca21f8b8de682cd0ae5193bfa12d2.tar.zst homework-56c76bdbe22ca21f8b8de682cd0ae5193bfa12d2.zip |
Make a new generation
-rw-r--r-- | csci1913/Python/project1_strap012.py | 40 |
1 files changed, 39 insertions, 1 deletions
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 . |