如何在Prolog中实施复制运动理论?
使用此输入:
托马斯,饮食],[])
我想产生此
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将
whnp
移至所需位置,如下所示:示例:
You can move
WHNP
to the desired location as shown below:Example: