/* File: parse0.pl Author: Mihaela Malita Title: Parsing a sentence ?- phrase(sentence(P),[the,girl,likes,the,dog]). P = sentence(noun_ph(det(the), noun(girl)), verb_ph(verb(likes), noun_ph(det(the), noun(dog)))) Yes ?- start. Input your sentence: [the,girl,likes,the,dog]. Parsed_OK! sentence(noun_ph(det(the), noun(girl)), verb_ph(verb(likes), noun_ph(det(the), noun(dog)))) Continue(y/n)?= n. ***********************************************************/ sentence(sentence(N,V)) --> noun_ph(N), verb_ph(V). noun_ph(noun_ph(D,N)) --> det(D),noun(N). verb_ph(verb_ph(V,N)) --> verb(V),noun_ph(N). det(det(the)) --> [the]. noun(noun(dog)) --> [dog]. noun(noun(girl)) --> [girl]. verb(verb(likes)) --> [likes]. start:- write('Input your sentence: '),read(X), (phrase(sentence(Parsed),X) -> write('Parsed_OK');write('Not parsed')),nl, write(Parsed),nl,yesorno,start. yesorno:- write('Continue(y/n)?= '),read(R),R=y.