% Subcategorization, Number, Case
% Baumstruktur (Behandlung der Terminalen vervollständigt)


% Regeln
% ------

s(s(NP,VP)) --> np(NP,Number,nom), vp(VP,Number).

vp(vp(V),Number)         --> v(1, V, Number).
vp(vp(V,NP),Number)      --> v(2, V, Number), np(NP,_,acc).
vp(vp(V,NP1,NP2),Number) --> v(3, V, Number), np(NP1,_,acc), np(NP2,_,acc).
vp(vp(V,S),Number)       --> v(4, V, Number), s(S).


np(np(Pron),Number,Case)    --> pron(Pron,Number, Case).
np(np(D,N),Number,_Case)    --> d(Number,D), n(Number,N).



% Lexikon
% -------

d(_, d(the))       --> [the].
d(singular, d(a))  --> [a].
d(plural, d(d0))   --> [].

pron(pron(String), singular, nom) --> lookup(String), ([he]; [she]).
pron(pron(String), singular, acc) --> lookup(String), ([him]; [her]). 
pron(pron(they), plural, nom)     --> [they]. 
pron(pron(them), plural, acc)     --> [them]. 

n(singular, n(S)) --> lookup(S),
	              ([butler]; [cat]; [dog]; [garden]; [gardener]; [mouse]; [policeman]).
n(plural, n(S))   --> lookup(S),
	              ([butlers]; [cats]; [dogs]; [gardens]; [gardeners]; [mice];
	               [policemen]).

v(1, v(S), singular) --> lookup(S), ([barks]; [sleeps]).
v(1, v(S), plural)   --> lookup(S), ([bark]; [sleep]).
v(1, v(S), _)        --> lookup(S), ([barked]; [slept]).
v(2, v(S), singular) --> lookup(S), ([chases]; [sees]).
v(2, v(S), plural)   --> lookup(S), ([chase]; [see]).
v(2, v(S), _)        --> lookup(S), ([chased]; [saw]).
v(3, v(S), singular) --> lookup(S), ([gives]; [sells]).
v(3, v(S), plural)   --> lookup(S), ([give]; [sell]).
v(3, v(S), _)        --> lookup(S), ([gave]; [sold]).
v(4, v(S), singular) --> lookup(S), ([says]; [thinks]).
v(4, v(S), plural)   --> lookup(S), ([say]; [think]).
v(4, v(S), _)        --> lookup(S), ([said]; [thought]).


lookup(A,[A|B],[A|B]).

% --------------------------------------------------------

parse(List,Tree) :- s(Tree,List,[]).
