题目:
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
我自己写的语句,编译不出来.
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).