%	Parses simple sentences such as 'the giraffe eats the apple'

error :- #'.', !, fail.
error :- #X, error.

sent(Y) :- np(X), vp(X, Y), #'.', !.
sent(_) :- error.

np(X) :- det, noun(X).
np(X) :- proper_noun(X).

vp(X, Y(X)) :- iverb(Y).
vp(X, Y(X, Z)) :- tverb(Y), np(Z).

det :- #the.
det :- #a.

noun(giraffe) :- #lion.
noun(apple) :- #apple.

proper_noun(john) :- #john.
proper_noun(mary) :- #mary.

iverb(eats) :- #eats.

tverb(dreams) :- #dreams.
tverb(eats) :- #eats.
