% ========================================================================== % $Id: parsetree.pl,v 1.1 2014/02/13 05:47:10 jlang Exp $ % CSI2120 example Code for lecture 9 % ========================================================================== % (C)opyright: % % Jochen Lang % EECS, University of Ottawa % 800 King Edward Ave. % Ottawa, On., K1N 6N5 % Canada. % http://www.eecs.uottawa.ca/~jlang % % Creator: jlang (Jochen Lang) based on Clocksin & Mellish % Email: jlang@eecs.uottawa.ca % ========================================================================== % $Log: parsetree.pl,v $ % Revision 1.1 2014/02/13 05:47:10 jlang % Added grammar examples for lecture 9. % % ========================================================================== sentence(PT) --> sentence(_,PT). sentence(X,sentence(NP,VP)) --> noun_phrase(X,NP), verb_phrase(X,VP). noun_phrase(X,noun_phrase(D,N)) --> determiner(X,D), noun(X,N). verb_phrase(X,verb_phrase(V)) --> verb(X,V). verb_phrase(X,verb_phrase(VP,NP)) --> verb(X,VP), noun_phrase(_,NP). determiner(_,determiner(the)) --> [the]. determiner(singular,determiner(a)) --> [a]. noun(singular,noun(tomato)) --> [tomato]. noun(plural,noun(tomatos)) --> [tomatos]. noun(singular,noun(bird)) --> [bird]. noun(plural,noun(birds)) --> [birds]. noun(singular,noun(man)) --> [man]. noun(plural,noun(men)) --> [men]. noun(singular,noun(cat)) --> [cat]. noun(plural,noun(cats)) --> [cats]. verb(singular,verb(eats)) --> [eats]. verb(plural,verb(eat)) --> [eat]. verb(singular,verb(sings)) --> [sings]. verb(plural,verb(sing)) --> [sing]. verb(singular,verb(loves)) --> [loves]. verb(plural,verb(love)) --> [love].