Exercise 6, Grammar Development

For this exercise you can work with grammar5.lfg, which has integrated a start on imperatives and coordination. Alternatively, you can look at what has been added in grammar5.lfg and use it as a model while continuing work on your own grammar version.

The grammar has been changed so that its top node is a category ROOT, rather than the S you have been working with (via the change in the configuration file under ROOTCAT). This conforms to the ParGram grammars and allows for the introduction of different types of main clauses (questions, imperatives, etc.).


Now add some imperatives to your grammar. The following sentences should work.

  1. Eat the beans!
  2. Give the gorilla a banana!
  3. Think a creative thought!
The following sentences should not work.
  1. Eats the beans!
  2. Gave a bone to the dog!

You will need to make (at least) the following changes to your grammar:

Metarulemacros and Coordination

XLE allows for Metarulemacros. Metarulemacros allow the grammar writer to express generalizations that hold for all the rules of a grammar. In the ParGram grammars, this is generally used at least for coordination.

Expand your grammar to include coordination. Read up on how to do it in the section on the Starter Grammar in the XLE documentation as well as in the documentation on Regular Expression Macros. Basically you will need to copy and paste the following from the eng-pargram.lfg: METARULEMACRO, SCCOORD, NPCOORD, NP-CONJUNCT. You will also need the lexical entry for and from eng-pargram-lex.lfg, Various templates are called by all of these. Most of the templates can be found in common.templates.lfg. By far the easiest approach to take is to integrate this file into your grammar as has been done in grammar5.lfg. Note that you need to add the file name under FILES and then specify the header (STANDARD COMMON) at TEMPLATES in the configuration section. Also add the OT-Mark GenBadPunct in GENOPTIMALITYORDER as has already been done in grammar5.lfg.

The following sentences should work:

Note that you will also have to add entries for proper names and decide on how to treat these in your grammar. Hint: check the output of the big English ParGram grammar via the INESS XLE-Web site for inspiration on how to treat proper nouns in your grammar and follow the steps outlined in Lesson 5 for pronouns in implementing your analysis.

Relevant Reading Material

Empty Strings and Nodes in the XLE Documentation.

XLE documentation on Metarulemacros

XLE documentation on Regular Expression Macros

Chapter 13 in Dalrymple (2001)

XLE documentation on Scope relations