norvig / paip-lisp

Lisp code for the textbook "Paradigms of Artificial Intelligence Programming"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent rewrite rules in chapter 2's rule-based grammar

wulab opened this issue · comments

In 2.3 A Rule-Based Solution, I notice that those parentheses around the right hand side of the the first 3 rules are unnecessary and wonder if they are intentionally put there.

(defparameter *simple-grammar*
  '((sentence -> (noun-phrase verb-phrase))
    (noun-phrase -> (Article Noun))
    (verb-phrase -> (Verb noun-phrase))
    (Article -> the a)
    (Noun -> man ball woman table)
    (Verb -> hit took saw liked))
  "A grammar for a trivial subset of English.")

It is unlikely that they are purely for decoration like the right arrow symbol (->) since the purpose of this representation is to make the rules consistent as written below.

The complication is that there can be two kinds of right-hand sides: a concatenated list of symbols, as in "Noun-Phrase => Article+Noun," or a list of alternate words, as in "Noun => man, ball, ..." We can account for these possibilities by deciding that every rule will have a list of possibilities on the right-hand side, ...

Sorry for my misunderstanding. It is clear from 2.5 Changing the Grammar without Changing the Program that when a right hand side is inside parentheses, all of its symbols will be generated as opposed to the one without parentheses. I'm closing this issue now.