Prolog 人工智能语言中文论坛---打造优质Prolog学习交流园地
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Prolog 人工智能语言中文论坛---打造优质Prolog学习交流园地

一个供Prolog爱好者学习与交流的地方


您没有登录。 请登录注册

帮忙看个句子递归的问题,我已经迷糊了

2 posters

向下  留言 [第1页/共1页]

specialco



题目:
write a recursive transition network for the following sentences
1.jane joined the book club
2.she woke up early today
3.he borrowed a racquet from his friend to play in the tournament.
4.Estha did not leave for home yet.
5.the oranges from nagpur are delicious

我自己写的语句,编译不出来.
代码:

%Drive predicate which sets up initial configuration
recognise(String):-
                initial(s,state),
                config(s:state, String, []).
%Final configuration
config(s:state, [],[]):-
                      final(s,state).

%If in final state for network pop back to previous network
config(Network:state,String,[Network1:state1|Stack]):-
                                         final(Network,state),
                                         config(Network1:state1,String,Stack).
%Process next lexical item
config(Network:state,[word|String],Stack):-
                                 word(word,cat),
                                 arc(Network, state, cat, state1),
                                 config(Network:state1, String, Stack).

%If next arc label refers to a network push to it
config(Network:state, String, Stack):-
                                    arc(Network, state, Network1, state1),
                           initial(Network1,state2),
                           config(Network1:state2,String,[Network:state1|Stack]).
%lexicon
word(jane,n).
word(joined,v).
word(the,det).
word(book,n).
word(club,n).
word(sid,n).
word(woke,v).
word(up,prep).
word(early,adj).
word(today,n).
word(he,n).
word(borrowed,v).
word(a,det).
word(racquet,n).
word(from,prep).
word(his,pron).
word(friend,n).
word(to,prep).
word(play,v).
word(in,prep).
word(tournament,n).
word(estha,n).
word(did,aux).
word(not,adv).
word(leave,v).
word(for,prep).
word(home,n).
word(yet,adv).
word(oranges,n).
word(nagpur,n).
word(delicious,adj).

%S-network
initial(s,1).
final(s,6).
arc(s,1,np,2).
arc(s,2,vp,3).
arc(s,3,np,4).
arc(s,4,pp,5).
arc(s,5,vp,6).
arc(s,3,vp,6).

%NP-network
initial(np,1).
final(np,5).
arc(np,1,det,2).
arc(np,2,n,3).
arc(np,3,prep,4).
arc(np,4,n,5).
arc(np,3,n,5).
arc(np,1,n,5).

%VP-network
initial(vp,1).
final(vp,8).
arc(vp,1,v,2).
arc(vp,2,prep,8).
arc(vp,8,adj,9).
arc(vp,9,n,10).
arc(vp,2,adj,10).
arc(vp,1,prep,3).
arc(vp,3,v,4).
arc(vp,4,pp,10).
arc(vp,1,aux,5).
arc(vp,5,adv,6).
arc(vp,6,v,7).
arc(vp,7,pp,10).

%PP-network
initial(pp,1).
final(pp,4).
arc(pp,1,prep,2).
arc(pp,2,pron,3).
arc(pp,3,n,4).
arc(pp,2,n,3).
arc(pp,3,adv,4).

yauhsien



Arguments写成小写英文字,则变成原子了,而非变量。网络中没有任何一个符号称为state,所以你无法读任何句子。

至於程序,由S-Network可读出你认为只有np-vp-np-pp-vp或np-vp-np-vp是句子,但是问题的第一句[jane,joined,the,book,club]格式可能是np-v-np或者是np-vp(而vp是v-np)。

程序中config/3第二句to pop back to previous network与第四句to refer to other network可以放在一起,因为,不管是否走到final state,随时可以询问下一个是否为network。

http://yauhsien.wordpress.com

返回页首  留言 [第1页/共1页]

您在这个论坛的权限:
不能在这个论坛回复主题