A sentence generating interpreter

Working memory (WM)

If the intention is to generate a sentence - to rewrite the category S - then working memory should be set up initially to contain nothing but the category symbol s. make "wm [s]

In fact, it could just as well be set up at the start with any category which has an expansion provided for it in the rules or for that matter with any sequence of categories for which there are rules.

Core interpreter procedures

We can isolate three different tasks for a system which will make use of the knowledge in our production memory and the current state of the working memory. Each of these can be implemented by a simple procedure:

1. To check WM to determine if the condition part of a rule is met

to match.pat? :pat
op member? :pat :wm 
2. To interpret the parts of a rule as an action affecting WM
to do :cond :act
( pr "firing :cond "\-\> :act ) 
make "wm replace :cond 
          pickrandom :act :wm 
pr :wm  pr [ ] 
3. To control the cyclic passage through the rules
to go.through :current.rules
if empty? :current.rules [stop] 
local "condition local "action 
make "condition first first :current.rules 
make "action last first :current.rules 
if match.pat? :condition 	
[do :condition :action go.through :rules] 
;Nota bene :rules not :current.rules!
go.through bf :current.rules 

Auxiliary procedures

You will notice that pickrandom (defined here and discussed here) is needed. So too is a modified version of replace (see here for original version). This modified version substitutes strings for single elements and uses se not fput.
to replace :old.item :new.item :list
if empty? :list [op []] 
if :old.item = first :list 
         [op se :new.item bf :list] 
op se first :list 
         replace :old.item :new.item bf :list 

Ron Brasington
Department of Linguistic Science
The University of Reading

E-mail: ron.brasington@rdg.ac.uk