; SLIME 2006-11-26 CL-USER> (load "make.lisp") ; Evaluation aborted CL-USER> (load "make.lisp") STYLE-WARNING: redefining MAKER in DEFUN STYLE-WARNING: redefining MAKE in DEFUN STYLE-WARNING: redefining MAKE-EXAMPLE in DEFUN STYLE-WARNING: redefining EG in DEFUN STYLE-WARNING: redefining EGS in DEFUN STYLE-WARNING: redefining EG0 in DEFUN STYLE-WARNING: redefining DEMO in DEFUN STYLE-WARNING: redefining DEMOF in DEFUN STYLE-WARNING: redefining SHOW-OF in DEFUN STYLE-WARNING: redefining SENTENCE in DEFUN STYLE-WARNING: redefining NOUN-PHRASE in DEFUN STYLE-WARNING: redefining VERB-PHRASE in DEFUN STYLE-WARNING: redefining ARTICLE in DEFUN STYLE-WARNING: redefining NOUN in DEFUN STYLE-WARNING: redefining VERB in DEFUN STYLE-WARNING: redefining ONE-OF in DEFUN STYLE-WARNING: redefining RANDOM-ELT in DEFUN STYLE-WARNING: redefining MAPPEND in DEFUN STYLE-WARNING: redefining RULE-LHS in DEFUN STYLE-WARNING: redefining RULE-RHS in DEFUN STYLE-WARNING: redefining REWRITES in DEFUN STYLE-WARNING: redefining GENERATE in DEFUN ; compiling file "/home/ctobrey/opt/lisp/proj1/ch2/2-5.lisp" (written 30 JAN 2008 11:54:30 AM): ; compiling (DEFPARAMETER *BIGGER-GRAMMAR* ...) ; compiling (EGS :|2.5| ...) ; /home/ctobrey/opt/lisp/proj1/ch2/2-5.fasl written ; compilation finished in 0:00:01 T CL-USER> (demo :all) ;;;; 1) using lisp to define a simple grammer ;IN: (DEMO 2.2) ;;;; 1) the first generated sentence ;IN: (SENTENCE) ;GOT: (THE BALL TOOK A BALL) ;ok ;;;; 2) sentence 2 ;IN: (SENTENCE) ;GOT: (THE BALL HIT THE MAN) ;ok ;;;; 3) sentence3 ;IN: (SENTENCE) ;GOT: (THE MAN LIKED THE WOMAN) ;ok ;;;; 4) sentence 4 ;IN: (SENTENCE) ;GOT: (A BALL HIT THE MAN) ;ok ;;;; 5) a noun phrase ;IN: (NOUN-PHRASE) ;GOT: (THE MAN) ;ok ;;;; 6) a verb phrase ;IN: (VERB-PHRASE) ;GOT: (SAW THE TABLE) ;ok ;;;; 7) turning trace on ;IN: (TRACE SENTENCE NOUN-PHRASE VERB-PHRASE ARTICLE NOUN VERB) ;GOT: (SENTENCE NOUN-PHRASE VERB-PHRASE ARTICLE NOUN VERB) ;ok ;;;; 8) tracing the sentence function ;IN: (SENTENCE) 0: (SENTENCE) 1: (NOUN-PHRASE) 2: (ARTICLE) 2: ARTICLE returned (THE) 2: (NOUN) 2: NOUN returned (BALL) 1: NOUN-PHRASE returned (THE BALL) 1: (VERB-PHRASE) 2: (VERB) 2: VERB returned (SAW) 2: (NOUN-PHRASE) 3: (ARTICLE) 3: ARTICLE returned (THE) 3: (NOUN) 3: NOUN returned (BALL) 2: NOUN-PHRASE returned (THE BALL) 1: VERB-PHRASE returned (SAW THE BALL) 0: SENTENCE returned (THE BALL SAW THE BALL) ;GOT: (THE BALL SAW THE BALL) ;ok ;;;; 9) untracing a sentence ;IN: (UNTRACE) ;GOT: T ;ok ;GOT: 0 ;ok ;;;; 2) using a rule base solution to defin a simple grammer ;IN: (DEMO 2.3) ;;;; 1) using assoc to take a key and a list of lists to return the first element of the list of lists that starts with the key ;IN: (ASSOC 'NOUN *GRAMMAR*) ;GOT: (NOUN -> MAN BALL WOMAN TABLE) ;ok ;;;; 2) generating a sentence ;IN: (GENERATE 'SENTENCE) ;GOT: (A WOMAN HIT A TABLE) ;ok ;;;; 3) generating a sentence ;IN: (GENERATE 'SENTENCE) ;GOT: (THE TABLE LIKED THE TABLE) ;ok ;;;; 4) generating a noun-phrase ;IN: (GENERATE 'NOUN-PHRASE) ;GOT: (THE TABLE) ;ok ;;;; 5) generating a verb-phrase ;IN: (GENERATE 'VERB-PHRASE) ;GOT: (LIKED THE TABLE) ;ok ;GOT: 0 ;ok ;;;; 3) using a bigger grammar set ;IN: (DEMO 2.5) ;;;; 1) using *bigger-grammar* ;IN: (SETF *GRAMMAR* *BIGGER-GRAMMAR*) ;GOT: ((SENTENCE -> (NOUN-PHRASE VERB-PHRASE)) (NOUN-PHRASE -> (ARTICLE ADJ* NOUN PP*) (NAME) (PRONOUN)) (VERB-PHRASE -> (VERB NOUN-PHRASE PP*)) (PP* -> NIL (PP PP*)) (ADJ* -> NIL (ADJ ADJ*)) (PP -> (PREP NOUN-PHRASE)) (PREP -> TO IN BY WITH ON) (ADJ -> BIG LITTLE BLUE GREEN ADIABATIC) (ARTICLE -> THE A) (NAME -> PAT KIM LEE TERRY ROBIN) (NOUN -> MAN BALL WOMAN TABLE) (VERB -> HIT TOOK LIKED SAW) (PRONOUN -> HE SHE IT THESE THOSE THAT)) ;ok ;;;; 2) sentence with bigger grammar ;IN: (GENERATE 'SENTENCE) ;GOT: (LEE HIT TERRY IN PAT) ;ok ;;;; 3) sentence with bigger grammar. ;IN: (GENERATE 'SENTENCE) ;GOT: (TERRY LIKED A MAN) ;ok ;;;; 4) yet another sentence with *bigger-grammar* ;IN: (GENERATE 'SENTENCE) ;GOT: (KIM SAW ROBIN WITH A MAN) ;ok ;GOT: 0 ;ok 0 CL-USER>