%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Base Grammar for Assignment A4 -- Parsing SMS text messages   
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

s --> s0, subconj, s.
s --> s0, conj, s.
s --> s0.
s0 --> adv, s.       % eg "Frequently John eats potatoes."
s0 --> pp, s.        % eg "In January, John eats potatoes."
s0 -->  np, vp.

np --> npr.         % proper name, eg "shrek", "edinburgh"
np --> pro.         % pronoun, eg "someone", "i", "he"
np --> det, nom0.
np --> nom0.
np --> det, nom2.

nom0 --> num, nom1.  % an NP can have one number premod -- eg "the two girls"
nom0 --> nom1.       % or no number premod -- eg "the girls"
nom1 --> adj, nom1.  % an NP can have >=1 adj premods -- eg "two big red eyes"
nom1 --> nom2.
nom2 --> n.          % an NP can have 0 pp postmods -- eg "the two girls"
nom2 --> nom3, pp.   % or one or two pp postmods.
nom3 --> n.
nom3 --> n, pp.

pp --> prep, np.

vp --> iv.
vp --> tv, np.
vp --> dv, np, np.   % for vps like "give Shrek a potato", "read Shrek a story"
vp --> dv, np, pp.   % for vps like "give a potato to Shrek", ...
vp --> copula, np.   % for vps like "is the winner", "are great films"
vp --> copula, adj.  % for vps like "are great", "is enough"

  %%%%%%%%%%%%%%%%%
  %%   Lexicon   %%
  %%%%%%%%%%%%%%%%%

%% Adjectives
adj --> [Word], {adj(Word)}.
adj(favorite).
adj(great).

%% Adverbs

adv --> [Word], {adv(Word)}.
adv(frequently).
adv(later).
adv(today).

%% Conjunctions

conj --> [Word], {conj(Word)}.
conj(and).

%% Copulas

copula --> [Word], {copula(Word)}.
copula(am).
copula(is).

%% Determiners

det --> [Word], {det(Word)}.
det(my).
det(the).

%% Ditransitive verbs

dv --> [Word], {dv(Word)}.
dv(gave).
dv(loaned).
dv(read).

%% Intransitive verbs

iv --> [Word], {iv(Word)}.
iv(awoke).
iv(played).
iv(slept).

%% Nouns

n  --> [Word], {n(Word)}.
n(book).
n(boy).
n(film).
n(guitar).

%% Number.

num --> [Word], {num(Word)}.
num(one).
num(two).
num(three).
num(four).

%% Prepositions.

prep --> [Word], {prep(Word)}.
prep(in).
prep(with).

%% Pronouns

pro --> [Word], {pro(Word)}.
pro(i).
pro(someone).
pro(they).

%% Proper nouns

npr --> [Word], {npr(Word)}.
npr(ai2).
npr(john).
npr(shrek).

%% Subordinate conjunction

subconj --> [Word], {subconj(Word)}.
subconj(because).
subconj(before).
subconj(until).

%% Transitive verbs

tv --> [Word], {tv(Word)}.
tv(played).
tv(read).
tv(saw).


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% The symbol "distinguished" is used to identify what can be the root
%% of complete grammatical analysis. Usually in English, it is the
%% sentence (s), though in spoken language, one also finds utterances
%% interpretable in context that are simply nps, vps, pps, etc.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

distinguished(s).
