如何在Prolog中实现复制移动理论?

How to implement the theory of copy movement in Prolog?

使用此输入:

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

我想产生这个输出:

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
)

使用此代码:

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].

如何更改我的代码以将 whnp 复制到 vp 中?

您可以将 WHNP 移动到所需位置,如下所示:

% 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].

示例:

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