% Adapted from Covington p.421

s(String) :- concat_atom(Words, ' ', String), sentence(Words,[]).

sentence(Words, Left) :- 
    noun_phrase(Words, Left0), verb_phrase(Left0, Left).

noun_phrase(Words, Left) :- article(Words, Left0), noun(Left0, Left).

verb_phrase(Words, Left) :- verb(Words, Left0), noun_phrase(Left0, Left).
verb_phrase(Words, Left) :- verb(Words, Left0), sentence(Left0, Left).

article([the| Left], Left).
article([a| Left],  Left).

noun([Noun| Left], Left) :- member(Noun, [dog,cat,girl,boy]).

verb([Verb|Left], Left) :- member(Verb, [chased,saw,said,believed]).
