prologlinguistics

How to implement the theory of copy movement in Prolog?


Using this input:

parse(Parse, [what,did,thomas,eat], [])

I want to produce this output:

sbarq(
whnp(
    wp(what)
    ),
sq(
    vbd(did),
    np(nnp(thomas)),
    vp(
        vb(eat),
        whnp(
            wp(what)
            )
      ) % this is not in the input, I need to copy the entire whnp here
)

with this code:

parse(Tree) --> sbarq(Tree).

% rules
sbarq(sbarq(WHNP, SQ)) --> whnp(WHNP), sq(SQ).
whnp(whnp(WP)) --> wp(WP).
sq(sq(VBD, NP, VP)) --> vbd(VBD), np(NP), vp(VP).
np(np(NNP)) --> nnp(NNP).
vp(vp(VB)) --> vb(VB).

% lexicon
wp(wp(what)) --> [what].
vbd(vbd(did)) --> [did].
nnp(nnp(thomas)) --> [thomas].
vb(vb(eat)) --> [eat].

how can I change my code to copy the whnp into the vp?


Solution

  • You can move WHNP to the desired location as shown below:

    enter image description here

    % rules
     
    sbarq(sbarq(WHNP, SQ)) --> whnp(WHNP), sq(WHNP, SQ).
    whnp(whnp(WP)) --> wp(WP).
    sq(WHNP, sq(VBD, NP, VP)) --> vbd(VBD), np(NP), vp(WHNP, VP).
    np(np(NNP)) --> nnp(NNP).
    vp(WHNP, vp(VB, WHNP)) --> vb(VB).
    
    % lexicon
     
    wp(wp(what)) --> [what].
    vbd(vbd(did)) --> [did].
    nnp(nnp(thomas)) --> [thomas].
    vb(vb(eat)) --> [eat].
    

    Example:

    ?- phrase(sbarq(T), [what,did,thomas,eat]).
    T = sbarq(whnp(wp(what)), sq(vbd(did), np(nnp(thomas)), vp(vb(eat), whnp(wp(what))))).