A sample grammar

To give an idea of how a DepPattern grammar can be built, let's propose the following set of rules:

AdjunctRight : VERB ADV

Recursivity: 1

%

AdjunctLeft : ADV VERB

Recursivity: 1

%

AdjunctLeft : ADJ NOUN

Recursivity: 1

Agreement: number, gender

%

AdjunctLeft : DT NOUN

Recursivity: 1

Agreement: number, gender

%

SubjLeft : NOUN|PRO VERB

Agreement: number, person

%

DObjRight : VERB NOUN|PRO

%

This small grammar is able to correctly analyse expressions such as “fast cars”, whose output analysis (with flag -a) is the following:

SENT::<fast_ADJ_0_<number:0|function:0|degree:0|lemma:fast|gender:0|type:0|token:fast|> 
cars_NOUN_1_<number:P|lemma:car|gender:0|person:3|type:C|token:cars|> ._SENT>

(AdjnL;car_NOUN_1;fast_ADJ_0)
---
Fim do parsing...

“a nice fast car”:

SENT::<a_DT_0_<number:0|lemma:a|possessor:0|gender:0|person:0|type:0|token:a|> 
nice_ADJ_1_<number:0|function:0|degree:0|lemma:nice|gender:0|type:0|token:nice|> 
fast_ADJ_2_<number:0|function:0|degree:0|lemma:fast|gender:0|type:0|token:fast|> 
car_NOUN_3_<number:S|lemma:car|gender:0|person:3|type:C|token:car|> ._SENT>

(SpecL;car_NOUN_3;a_DT_0)
(AdjnL;car_NOUN_3;nice_ADJ_1)
(AdjnL;car_NOUN_3;fast_ADJ_2)
---
Fim do parsing...

“all the nice fast cars”:

SENT::<all_DT_0_<number:0|lemma:all|possessor:0|gender:0|person:0|type:0|token:all|> 
the_DT_1_<number:0|lemma:the|possessor:0|gender:0|person:0|type:0|token:the|> 
nice_ADJ_2_<number:0|function:0|degree:0|lemma:nice|gender:0|type:0|token:nice|> 
fast_ADJ_3_<number:0|function:0|degree:0|lemma:fast|gender:0|type:0|token:fast|> 
cars_NOUN_4_<number:P|lemma:car|gender:0|person:3|type:C|token:cars|> ._SENT>

(SpecL;car_NOUN_4;all_DT_0)
(SpecL;car_NOUN_4;the_DT_1)
(AdjnL;car_NOUN_4;nice_ADJ_2)
(AdjnL;car_NOUN_4;fast_ADJ_3)
---
Fim do parsing...

“all the fast cars run fast”:

SENT::<all_DT_0_<number:0|lemma:all|possessor:0|gender:0|person:0|type:0|token:all|> 
the_DT_1_<number:0|lemma:the|possessor:0|gender:0|person:0|type:0|token:the|> 
nice_ADJ_2_<number:0|function:0|degree:0|lemma:nice|gender:0|type:0|token:nice|> 
fast_ADJ_3_<number:0|function:0|degree:0|lemma:fast|gender:0|type:0|token:fast|> 
cars_NOUN_4_<number:P|lemma:car|gender:0|person:3|type:C|token:cars|> 
run_VERB_5_<number:0|mode:0|lemma:run|gender:0|tense:0|person:0|type:0|token:run|> 
fast_ADV_6_<degree:0|lemma:fast|token:fast|> ._SENT>

(SpecL;car_NOUN_4;all_DT_0)
(SpecL;car_NOUN_4;the_DT_1)
(AdjnL;car_NOUN_4;nice_ADJ_2)
(AdjnL;car_NOUN_4;fast_ADJ_3)
(SubjL;run_VERB_5;car_NOUN_4)
(AdjnR;run_VERB_5;fast_ADV_6)
---
Fim do parsing...

“Bill bought a fast car”:

SENT::<Bill_NOUN_0_<number:S|person:3|type:C|lemma:bill|token:Bill|gender:0|> 
bought_VERB_1_<number:0|mode:0|lemma:buy|gender:0|tense:S|person:0|type:0|token:bought|> 
a_DT_2_<number:0|lemma:a|possessor:0|gender:0|person:0|type:0|token:a|> 
fast_ADJ_3_<number:0|function:0|degree:0|lemma:fast|gender:0|type:0|token:fast|> 
car_NOUN_4_<number:S|lemma:car|gender:0|person:3|type:C|token:car|> ._SENT>

(SubjL;buy_VERB_1;bill_NOUN_0)
(SpecL;car_NOUN_4;a_DT_2)
(AdjnL;car_NOUN_4;fast_ADJ_3)
(DobjR;buy_VERB_1;car_NOUN_4)
---
Fim do parsing...

“the rich man bought yesterday a nice fast car”:

SENT::<the_DT_0_<number:0|lemma:the|possessor:0|gender:0|person:0|type:0|token:the|> 
rich_ADJ_1_<number:0|function:0|degree:0|lemma:rich|gender:0|type:0|token:rich|> 
man_NOUN_2_<number:S|lemma:man|gender:0|person:3|type:C|token:man|> 
bought_VERB_3_<number:0|mode:0|lemma:buy|gender:0|tense:S|person:0|type:0|token:bought|> 
yesterday_ADV_4_<degree:0|lemma:yesterday|token:yesterday|> 
a_DT_5_<number:0|lemma:a|possessor:0|gender:0|person:0|type:0|token:a|> 
nice_ADJ_6_<number:0|function:0|degree:0|lemma:nice|gender:0|type:0|token:nice|> 
fast_ADJ_7_<number:0|function:0|degree:0|lemma:fast|gender:0|type:0|token:fast|> 
car_NOUN_8_<number:S|lemma:car|gender:0|person:3|type:C|token:car|> ._SENT>

(SpecL;man_NOUN_2;the_DT_0)
(AdjnL;man_NOUN_2;rich_ADJ_1)
(SubjL;buy_VERB_3;man_NOUN_2)
(AdjnR;buy_VERB_3;yesterday_ADV_4)
(SpecL;car_NOUN_8;a_DT_5)
(AdjnL;car_NOUN_8;nice_ADJ_6)
(AdjnL;car_NOUN_8;fast_ADJ_7)
(DobjR;buy_VERB_3;car_NOUN_8)
---
Fim do parsing...

“he really wants another car”.

SENT::<he_PRO_0_<number:0|lemma:he|possessor:0|case:0|gender:0|person:0|politeness:0
|type:P|token:he|> 
really_ADV_1_<degree:0|lemma:really|token:really|> 
wants_VERB_2_<number:0|mode:0|lemma:want|gender:0|tense:P|person:3|type:0|token:wants|> 
another_DT_3_<number:0|lemma:another|possessor:0|gender:0|person:0|type:0|token:another|> 
car_NOUN_4_<number:S|lemma:car|gender:0|person:3|type:C|token:car|> ._SENT>

(SubjL;want_VERB_2;he_PRO_0)
(AdjnL;want_VERB_2;really_ADV_1)
(SpecL;car_NOUN_4;another_DT_3)
(DobjR;want_VERB_2;car_NOUN_4)
---
Fim do parsing...

Rules can be ordered in different ways, since they fill the basic constraints stated berore in this tutorial. However, to be efficient, a DepPattern grammar should be written by cascades of rules representing linguistic layers or modules. An optimal grammar should contain first rules concerning adverb phrases, then adjective phrases, then nominal phrases, and finally verb phrases.