% HW 9: see the end of this file % Example of DCG sentence(sentence(N,V)) --> noun_phrase(N,Num), verb_phrase(V,Num). noun_phrase(np(D,N),Num) --> determiner(D,Num), noun_phrase2(N,Num). noun_phrase(np(N),Num) --> noun_phrase2(N,Num). noun_phrase2(np2(A,N),Num) --> adjective(A),noun_phrase2(N,Num). noun_phrase2(np2(N),Num) --> noun(N,Num). verb_phrase(vp(V),Num) --> verb(V,Num). verb_phrase(vp(V,N),Num) --> verb(V,Num), noun_phrase(N,Num1). determiner(det(the),Num) --> [the]. determiner(det(a),singular) --> [a]. determiner(det(an),singular) --> [an]. noun(noun(pieplate),singular) --> [pieplate]. noun(noun(pieplates),plural) --> [pieplates]. noun(noun(man),singular) --> [man]. noun(noun(men),plural) --> [men]. noun(noun(apple),singular) --> [apple]. noun(noun(apples),plural) --> [apples]. noun(noun(surprise),singular) --> [surprise]. noun(noun(surprises),plural) --> [surprises]. adjective(adj(decorated)) --> [decorated]. adjective(adj(red)) --> [red]. verb(verb(contains),singular) --> [contains]. verb(verb(contain),plural) --> [contain]. verb(verb(eats),singular) --> [eats]. verb(verb(eat),plural) --> [eat]. %query is of the form: %?-sentence(Z,[the,man,eats,the,apple],[]). %Z will contain the parse tree after execution is done. %?-sentence(Z,[the,man,eat,the,apple],[]). %this query will fail because of number disagreement %between the verb and subject. %?-sentence(Z,[the,man,eats,the,red,apple],[]). %?-sentence(Z,[the,decorated,pieplate,contains,a,surprise],[]). %%add some verbs, adjectives, and nouns to the grammar above. %%load the system on sicstus, then run some queries to compute. %%the parse trees of some sentences. Do this for 5 sentences. %%submit your script.