如何在Prolog中实施复制运动理论?

发布于 01-22 03:58 字数 724 浏览 3 评论 0原文

使用此输入:

托马斯,饮食],[])

我想产生此

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

parse(解析,[什么,做, 副总裁?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心不设防 2025-01-29 03:58:28

您可以将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))))).

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))))).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文