[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Perform the weekly set up instructions for project 1, homework d.
Report (a) all the lisp functions you’ve written and (b) a file containing your deftest
s
for all parts of the following and (c)
‘repl.txt’ coming from you
saving the REPL showing these all running.
Convert the file ‘1/d/scifi.txt’ into a grammar.
Run your terminal and lint tools over the result and show that your grammar is looking good. Fix any errors you find.
Write a deftest
that generates 10 scifi stories.
The current grammar is stupid. Once it chooses a rewrite, then that rewrite is forgotten. So if it chooses a Boy’s name to be John then it instantly forgets it and the next reference to Boy might be John or Pima. For example, look at the mixed up sentences in the following:
(!generate2) ( (JOHN RUNS VERY VERY VERY QUICKLY SLOWLY WITH JOHN) ; ok (AJIT WALKS VERY VERY VERY VERY QUICKLY SLOWLY WITH JOHN) ; mixed up (JOHN WALKS VERY QUICKLY SLOWLY WITH AJIT) ; mixed up (JOHN WALKS QUICKLY SLOWLY WITH AJIT) ; mixed up (JOHN RUNS QUICKLY SLOWLY WITH JOHN) ; ok (AJIT WALKS QUICKLY SLOWLY WITH JOHN) ; mixed up (AJIT RUNS QUICKLY SLOWLY WITH JOHN) ; mixed up )
This came from following grammar
(defparameter *grammar2* '((Sentence -> (Nounphrase Verbphrase)) (Nounphrase -> (Boy)) (Nounphrase -> (Girl)) (Boy -> john ajit) (Girl -> pima barkha) (Verbphrase -> (Verb Modlist Adverb with Nounphrase)) (Verb -> runs walks ) (Modlist -> () (very Modlist)) (Adverb -> (quickly slowly))))
Fix this. Rewrite ‘1/d/story.lisp’ such that for a set of pre-defined lefties (in our case Boy and Girl), once they are rewritten they always rewrite to the same thing. If you succeed then each generated sentence should never mix two boy or two girl names.
Test this caching version of ‘1/d/story.lisp’ on *grammar2*
.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on April 19, 2011 using texi2html 5.0.