Gap threading with WH-Questions
s(X,Y,F1,F3, sentence(TNP,TVP)):-
np(X,Z,F1,F2,TNP), vp(Z,Y,F2,F3,TVP).
s(X,Y,F1,F3, sentence(Wh,TNP,TVP)):-
whQ(X,Z,Wh),
np(Z,U,[W|F1],F2,TNP),
vp(U,Y,F2,F3,TVP).
np(X,Y,F,F,np(TA,TN)) :-
art(X,Z,TA), noun(Z,Y,TN).
np(X,Y,[X|T],T,np(X)). % (Empty ) Missing np
whQ([W|[Dword|Z]],Z,WhT1) :-
whWord(W,WhT), qaux(Dword), WhT1 = wh(WhT, Dword).
whQ([W|Z],Z,WhT) :- whWord(W,WhT).
qaux(did). qaux(does). qaux(do).
vp(X,Y,F,F1,vp(TV,TNP)) :-
verb(X, Z, TV), np(Z, Y, F, F1, TNP).
vp(X,Y,F,F1,vp(TV,TS)) :-
verb(X, Z, TV), s(Z, Y, F, F1, TS).
go(T) :- s([the, boy, kissed, the, girl],[],[],_,T).
go2(T) :- s([Who, did, the, boy, kiss],[],[],_,T).
go3(T) :- s([the, boy, saw, the, frog, kiss, the, girl],[],[],_,T).
go4(T) :- s([Who, did, the, boy, see, kiss, the, girl],[],[],_,T).
go5(T) :- s([Who, did, the, boy, see, the, frog, kiss],[],[],_,T).