CSCI 587 - Solution to Assignment 6 Parsing with Features


Date: Mar 20, 1997
Date Due: Mar 29, 1997
  1. p 154 #1: Distinguish between local and non-local movement.
    See page 128, bottom of the page.
  2. p 154 #2: Expand the following to fully specified format
  3. Extend nlp4 to include the feature AGR. Basicallly one needs to add another argument to several predicate to account for the AGR feature.
    % NLP parser (derived from nlp4) to Handle the feature AGR (agreement
    % as in subject verb agreement (number/person.)
    % This program assumes that AGR only takes on two values sing3 and notsing3.
    
    sentence(X,s(TN,TV), AGR):- np(X, Y, TN, AGR), vp(Y, [], TV, AGR).
    
    np(X, Y, np(TD, TN), AGR):- det(X, Z, TD), noun(Z, Y, TN, AGR).
    
    np(X, Y, np(TD, TAL, TN), AGR):- det(X, Z, TD), adjlist(Z, R,TAL), noun(Z, Y, TN, AGR).
    
    np(X,Y, TN, AGR) :- noun(X,Y,TN, AGR).
    
    np(X,Y, conj(TN1,Tconj, TN2), notsing3) :- np(X,Z,TN1, AGR1),conj(Z,W,Tconj),np(W,Y,TN2, AGR2).
    
    adjlist([A|X], X,TA) :- a(A, TA).
    adjlist([A|X],Z,adjlist(TA, TAL)) :- a(A, TA),adjlist(X, Z, TAL).
    
    vp(X, Y, vp(TV, TNP), AGR):- verb(X, Z, TV, AGR), np(Z, Y, TNP, AGR2).
    
    det([A|X], X, T) :- d(A, T).
    noun([A|X], X, T, AGR) :- nn(A, T, AGR).
    verb([A|X], X, T, AGR) :- v(A, T, AGR).
    conj([A|X], X, T) :- cj(A, T).
    
    v(likes, verb(likes), sing3).
    v(hates, verb(hates), sing3).
    v(like, verb(likes), notsing3).
    v(hate, verb(hates), notsing3).
    nn(boy, noun(boy), sing3).
    nn(girl, noun(girl), sing3).
    nn(frog, noun(frog), sing3).
    nn(boys, noun(boys), notsing3).
    nn(girls, noun(girls), notsing3).
    nn(frogs, noun(frogs), notsing3).
    a(big, adj(big)).
    a(fat, adj(fat)).
    d(the, det(the)).
    d(a, det(a)).
    cj(and, conj(and)).
    
    
    test1(T, AGR) :- sentence([the, boys, like, girls], T, AGR).
    test2(T, AGR) :- sentence([the, boy, likes, girls], T, AGR).
     
  4. Extend nlp4 to handle Yes/No questions, including the features AGR, VFORM>, SUBCAT>, COMPFORM> (but explicitly not requiring GAP and WH).
    % NLP parser (derived from nlp4) that illustrates how to 
    % AUX-SUB inversion questions and to handle the features AGR and VFORM.
    % This program assumes that AGR only takes on two values sing3 and notsing3.
    % Also, that VFORM only takes on present and past.
    
    % Passive  assertion of the form "is sleeping"
    sentence(X,s(assertion, TN, TV), V1):- 
            np(X, Y, TN, AGR), 
            aux(Y,Z,AGR, V, be, V1),
            verb(Z, [], TV, _, V, none_).
    
    % Do addition type questions
    sentence(X, s(quesYesNo, TN, TV), V1):- aux(X,Z, AGR, V, _, V1), 
            np(Z, Y, TN, AGR), vp(Y, [], TV, _, V).
    
    % Is-subject inversion questions
    sentence(X, s(quesYesNo, TN, TV), V1):- aux(X, Z, AGR, V, _, V1), 
            np(Z, Y, TN, AGR),  verb(Y, [], TV, _, V).
    
    
    %simple assertions
    sentence(X,s(assertion, TN,TV), VFORM):- 
            np(X, Y, TN, AGR), 
            vp(Y, [], TV, AGR, VFORM).
    
    
    np(X, Y, np(TD, TN), AGR):- det(X, Z, TD), noun(Z, Y, TN, AGR).
    
    np(X, Y, np(TD, TAL, TN), AGR):- 
            det(X, Z, TD), adjlist(Z, R,TAL), noun(R, Y, TN, AGR).
    
    np(X,Y, TN, AGR) :- noun(X,Y,TN, AGR).
    
    %%%np(X,Y, conj(TN1,Tconj, TN2), plural) :- np(X,Z,TN1, AGR1),conj(Z,W,Tconj),np(W,Y,TN2, AGR2).
    
    adjlist([A|X], X,TA) :- a(A, TA).
    adjlist([A|X],Z,adjlist(TA, TAL)) :- a(A, TA),adjlist(X, Z, TAL).
    
    vp(X, Y, vp(TV, none_), AGR, VFORM):- 
            verb(X, Y, TV, AGR, VFORM, none_). 
    
    vp(X, Y, vp(TV, TNP), AGR, VFORM):- 
            verb(X, Z, TV, AGR, VFORM, np_), 
            np(Z, Y, TNP, _).
    
    det([A|X], X, T) :- d(A, T).
    noun([A|X], X, T, AGR) :- nn(A, T, AGR).
    verb([A|X], X, T, AGR, VFORM, SUBCAT) :- v(A, T, AGR, VFORM, SUBCAT).
    conj([A|X], X, T) :- cj(A, T).
    aux([A|X], X, AGR, COMPFORM, MR, VFORM) :- aaux(A, AGR, COMPFORM, MR, VFORM).
    
    %aaux(word, AGR, COMPFORM, MODALROOT, VFORM) 
    % Here MODALROOT is combination of MODAL and Root
    aaux(do,        notsing3,       base,   modal,  present).
    aaux(does,      sing3,          base,   modal,  present).
    aaux(did,       _,              base,   modal,  past).
    aaux(is,        sing3,          ing,    be,     present).
    aaux(was,       _,              ing,    be,     past).
    aaux(has,       sing3,          pastptr,have,   present).
    
    %v(word,       Tree,            AGR,     VFORM,   SUBCAT).
    v(likes,       verb(like1),     sing3,   present,  np_).
    v(like,        verb(like1),     notsing3,present,  np_).
    v(like,        verb(like1),     _,       base,     np_).
    v(hate,        verb(hate1),     notsing3,present,  np_).
    v(hates,       verb(hate1),     sing3,   present,  np_).
    v(hated,       verb(hated),     _,       past,     np_).
    v(sleeps,      verb(sleep1),    sing3,   present,  none_).
    v(sleep,       verb(sleep1),    notsing3,present,  none_).
    v(slept,       verb(sleep1),    _,       past,     none_).
    v(sleeping,    verb(sleep1),    _,       ing,      none_).
    v(sleep,       verb(sleep1),    _,       base,     none_).
    
    % nn(word, Tree, AGR).
    nn(boy, noun(boy), sing3).
    nn(girl, noun(girl), sing3).
    nn(frog, noun(frog), sing3).
    nn(boys, noun(boys), notsing3).
    nn(girls, noun(girls), notsing3).
    nn(frogs, noun(frogs), notsing3).
    
    a(big, adj(big)).
    a(fat, adj(fat)).
    
    d(the, det(the)).
    d(a, det(a)).
    cj(and, conj(and)).
    
    
    %Test cases
    %sentence([the, boys, like, girls], T, VFORM).
    %sentence([the, boy, hated, girls], T, VFORM).
    %sentence([do, the, boys, like, girls], T, VFORM).
    %sentence([the, boys, is, sleeping], T, VFORM).
    %sentence([the, boy, is, sleeping], T, VFORM).
    %sentence([the, boy, was, sleeping], T, VFORM).
    %sentence([is, the, boys, sleeping], T, VFORM).
    %sentence([the, boys, slept], T, VFORM).
    %sentence([the, boy, slept], T, VFORM).
    %sentence([did, the, boy, like, the, girl],T,V).
    %sentence([does, the, boy, like, the, girl],T,V).