A
sentence parsing interpreter
Core
procedures
The core procedures
are as for the generator with the following changes.
to go.through
:current.rules
if empty? :current.rules [stop]
local "condition
local "action
make "condition
match last first :current.rules
make
"action first first
:current.rules
if not empty? :condition
[do
:condition :action
go.through :rules]
go.through
bf :current.rules
end
to do :cond :act
(
pr "firing :act "\<\- :cond )
make "wm replace
:cond :act :wm
pr :wm pr [ ]
end
to match :rule.part
if
empty? :rule.part [op []]
if substr? first :rule.part
:wm
[op first
:rule.part]
op match bf :rule.part
end
to replace
:old.item :new.item :list
if empty? :list [op [ ]]
if
starts.with? :list :old.item
[op se :new.item
strip :list
count :old.item]
op se first :list
replace :old.item :new.item bf
:list
end
Extra utilities needed
to
substr? :sub :context
if
empty? :sub [op "true]
if
empty? :context [op "false]
if starts.with? :context :sub [op "true]
op substr? :sub bf :context
end
to starts.with?
:list :start
if empty? :start [op "true]
if empty? :list
[op "false]
if ( first :list ) = ( first :start )
[op starts.with?
bf :list bf :start]
op "false
end
to strip
:thing :amount
if :amount < 1 [op :thing]
if :amount > count
:thing
[if list?
:thing [op [ ]] [op "]]
op strip bf :thing :amount - 1
end
Ron Brasington
Department of Linguistic Science
The University of Reading
Reading
UK
E-mail: ron.brasington@rdg.ac.uk