next up previous
Next: Sample traces from the Up: 13.11.2001: Grammatik: prozedurale Aspekte Previous: LISP implementation of a

Test lexicon and grammar for the LISP left-corner recogniser

; cf_grammar.lm
; grammar.lsp
; D. Gibbon
; 10 April 1988 / 10 Nov 2001
; LISP2 class material

(define *eg1* '(man saw woman))
(define *eg2* '(man saw woman near man))
(define *eg3* '(the man saw the woman near this man))

(define *count* 0)

(define (nl)
	(display ##0a))

(define (member? sym set)
	(pair? (member sym set)))

(define *initial* 's)

(define (productions)
	'(	(s np vp)
		(s np vp pp)
		(np n)
		(np det n)
		(np n pp)
		(np det n pp)
		(vp v)
		(vp v np)
		(vp v pp)
		(vp v np pp)
		(pp p np)
		))

(define (match word term)
	(eq?	term
		(category word)))

(define (category word)
  (cadr
    (assoc
      'cat
      (cdr
        (assoc
          word
          (lexicon))))))

(define (lexicon)
	'(	(the (cat det))
		(this (cat det))
		(man (cat n))
		(woman (cat n))
		(saw (cat v))
		(visited (cat v))
		(with (cat p))
		(near (cat p))))

(define (terminal sym)
	(member?	sym
			'(det n v p)))

(define (nonterminal sym)
	(member?	sym
			'(s np vp pp)))



Dafydd Gibbon, Wed Feb 12 10:50:41 MET 2003 Automatically generated, links may change - update every session.