## Natural Language Toolkit: chat80.cfg
##
##
## Grammar used to illustrate querying the Chat-80 database.
## 
## Author: Ewan Klein <ewan@inf.ed.ac.uk> 
## URL: <http://nltk.sourceforge.net>
## For license information, see LICENSE.TXT

% start S
# ###########################
# Grammar Rules
# ############################

S[sem=<app(?subj,?vp)>] -> NP[-pred,num=?n,sem=?subj] VP[num=?n,sem=?vp]

Rel[num=?n,sem=<app(?comp,?vp)>] -> Comp[sem=?comp] VP[num=?n,sem=?vp]

NP[-pred, num=pl,sem=<(\P Q. some x. ((Q x) and (P x)) ?nom)>] -> Nom[num=pl,sem=?nom]
NP[wh=?wh,-pred,num=?n,sem=<app(?det,?nom)>] -> Det[wh=?wh, num=?n,sem=?det] Nom[num=?n,sem=?nom]


NP[+pred,num=sg,sem=?nom] -> Det[num=sg,sem=?det]  Nom[num=sg,sem=?nom]
NP[+pred,num=pl,sem=?nom] -> Nom[num=pl,sem=?nom]

NP[loc=?l,num=?n,sem=?np] -> PropN[loc=?l,num=?n,sem=?np]

Nom[num=?n,sem=?nom] -> N[num=?n,sem=?nom]
Nom[num=sg,sem=<app(?pp,?nom)>] -> N[subcat=11,num=sg,sem=?nom] PP[pform=of,sem=?pp]
Nom[num=?n,sem=<app(?mod,?nom)>] -> Nom[num=?n,sem=?nom] Rel[num=?n,sem=?mod]
Nom[num=?n,sem=<app(?adj,?nom)>] -> A[sem=?adj] Nom[num=?n,sem=?nom]

##VP[num=?n,sem=?v] -> V[subcat=1,num=?n,sem=?v]
VP[num=?n,sem=<app(?v,?obj)>] -> V[subcat=2, num=?n,sem=?v] NP[-pred,sem=?obj]
VP[num=?n,sem=<app(?v,?pred)>] -> V[subcat=3, num=?n,sem=?v] NP[+pred,sem=?pred]

PP[pform=?pf,sem=<app(?p,?np)>] -> P[pform=?pf, loc=?l,sem=?p] NP[loc=?l,sem=?np]


# ############################
# Lexical Rules
# ############################

% include chat_pnames.cfg

Comp[sem=<\P Q x. ((P x) and (Q x))>] -> 'that'

NP[+wh, num=sg, sem=<\P.\x.(P x)>] -> 'what'  

Det[-wh,num=sg,sem=<\P Q. all x. ((P x) implies (Q x))>] -> 'every'
Det[-wh,num=pl,sem=<\P Q. all x. ((P x) implies (Q x))>] -> 'all'
Det[-wh,sem=<\P Q. some x. ((P x) and (Q x))>] -> 'some'
Det[-wh,num=sg,sem=<\P Q. some x. ((P x) and (Q x))>] -> 'a'
Det[-wh,num=sg,sem=<\P Q. some x. ((P x) and (Q x))>] -> 'the'
Det[+wh,sem=<\P Q x. ((Q x) and (P x))>] -> 'which'

N[subcat=10,num=sg,sem=<city>] -> 'city'
N[subcat=10,num=pl,sem=<city>] -> 'cities'
N[subcat=10,num=sg,sem=<continent>] -> 'continent'
N[subcat=10,num=pl,sem=<continent>] -> 'continents'
N[subcat=10,num=sg,sem=<country>] -> 'country'
N[subcat=10,num=pl,sem=<country>] -> 'countries'
N[subcat=10,num=sg,sem=<sea>] -> 'sea'
N[subcat=10,num=pl,sem=<sea>] -> 'seas'
N[subcat=10,num=sg,sem=<ocean>] -> 'ocean'
N[subcat=10,num=pl,sem=<ocean>] -> 'oceans'

PL[sem=<\P Q. some x. ((P x) and (Q x))>] -> ' '

N[subcat=11,num=sg,sem=<\x y. (area_of y x))>] -> 'area'
N[subcat=11,num=sg,sem=<\x y. (capital_of y x))>] -> 'capital'
N[subcat=11,num=sg,sem=<\x y. (currency_of y x))>] -> 'currency'
N[subcat=11,num=sg,sem=<\x y. (region_of y x))>] -> 'region'
N[subcat=11,num=sg,sem=<\x y. (longitude_of y x))>] -> 'longitude'
N[subcat=11,num=sg,sem=<\x y. (latitude_of y x))>] -> 'latitude'
N[subcat=11,num=sg,sem=<\x y. (population_of y x))>] -> 'population'



## V[subcat=3,num=sg,sem=<\X y. (X \x. (x = y))>,tns=pres] -> 'is'
## V[subcat=3,num=pl,sem=<\P. P))>,tns=pres] -> 'are'
V[subcat=3,num=sg,sem=<\P. P>,tns=pres] -> 'is'
V[subcat=3,num=pl,sem=<\P. P>,tns=pres] -> 'are'
V[subcat=2,num=sg,sem=<\X y. (X \x. (border x y))>,tns=pres] -> 'borders'
V[subcat=2,num=pl,sem=<\X y. (X \x. (border x y))>,tns=pres] -> 'border'
V[subcat=2,num=sg,sem=<\X y. (X \x. (contain x y))>,tns=pres] -> 'contains'
V[subcat=2,num=pl,sem=<\X y. (X \x. (contain x y))>,tns=pres] -> 'contain'

A[sem=<\P x. ((contain x asia) and (P x))>] -> 'Asian'

P[pform=of,sem=<\X.X>] -> 'of'
P[+loc,sem=<\X P x. (X \y. ((P x) and (in y x)))>] -> 'in'
P[-loc,sem=<\X P x. (X \y. ((P x) and (with y x)))>] -> 'with'



