Ling239e: Grammar Engineering

Homework Assignment for Week 7

Due: Tuesday, February 24 (by midnight)
Submit assignments electronically to both professors (rmkaplan@stanford.edu and thking@stanford.edu)


Turn in: 1. the final grammar you end up with for the sublexical rule part (eng-week7.lfg)
Please name your grammars with name-eng-week7.lfg
Exercises on:
PART 1: OT marks
PART 2: OT marks for robustness

There is one grammar this week; it uses the same default tokenizer and morphology as last time:

If you put a file called .xlerc in the directory with your grammar and in .xlerc you put:

  create-parser eng-week7.lfg

then whenever you start xle in that directory, it will automatically load eng-week7.lfg. This will save a lot of time when making and testing changes.


PART 1: OT Marks

For this part, you should use the grammar eng-week7.lfg and the tokenizer default-parse-tokenizer.fsmfile and the morphological guesser basic.english.fst.

EXERCISE 1: Dispreference Mark

In some contexts what seem to be strictly transitive verbs can appear without an object (often in "recipe" contexts). The task is to allow transitive verbs to have a null object and then disprefer this analysis with an OT mark.

Alter the V-TRANS template to have a second disjunct which provides a null object. If you parse:

   they donate.

you should get an f-structure that looks roughly like:

   [ PRED 'donate'
     SUBJ [ PRED 'they' ]
     OBJ  [ PRED 'pro'
            NTYPE null ]
     TENSE present ]

The trouble with this is that verbs that can be both transitive and intransitive, like eat will now get two analyses: one where the verb is intransitive and one where it is transitive but with a null object. To see this, parse:

  they eat.

Add an OT mark ObjDrop to the V-TRANS template disjunction that you just added and make it a dispreference mark in the OPTIMALITYORDER. Note that there is a template OT-MARK that you can use for this to avoid dealing with the o:: notation. The call would look like:

  @(OT-MARK ObjDrop)

If you now parse:

  they eat.

you should get 1+1 readings. The analysis you see should be the intranstive version of eat. If you click on the "u" in the lower right window, you should be able to see the other analysis with the null object.

EXERCISE 2: Removing part of a rule

This grammar allows for N-N compounds like tractor trailers. It also allows adjectives to modify the first N of a N-N compound. Try parsing:

  NP: the purple box
  NP: the good purple box

The first will have two analyses: one where purple is an adjective and one where it is a noun. The second will have four analyses (NN, AA, and two AN ones with different scopes).

The task is to remove the possibility of having an adjective modify the first N in a N-N compound. Do not do this by commenting out that part of the rule. Instead, add an OT mark RemoveAinNmod to the appropriate part of the grammar and make the mark a NOGOOD mark (i.e. to the left of NOGOOD in OPTIMALITYORDER).

Now when you parse:

  NP: the good purple box

You should only get three readings.

EXERCISE 3: Passive by OBL

This will probably be the hardest part of this assignment. First you need to get the passive to work properly (if you cannot get it to work properly, you can still do the OT part below). Try parsing:

  they were pushed.

This gets two analyses. One is correctly the passive. The other is an intransitive reading. You need to block the intransitive reading. The basic idea is that the auxiliary should only show up when there is a participle (passive or progressive) and conversely the participles should only show up when there is an auxiliary. One way to do this is by using a combination of defining and constraining equations for PASSIVE and for a new feature VFORM which has the values pass and prog (parse they were eating bananas. to see it for the progressive). Note that the tense of a passive depends on the tense of the auxiliary; in this grammar the passive participle is the same as the past tense and hence picks up the +Past tag whose lexical entry may need to be altered.

Now try parsing with a by phrase. (If you did not manage to constrain the passive, you may have more parses than reported here; however, you can still constrain the overall number of optimal parses as described here.)

  they were pushed by them.

There should be two readings: one with the by phrase being an ADJUNCT and one with it being an OBL.

The task is to prefer the OBL reading. Insert an OT mark ByObl in the PASSIVE template. Make it a preference mark by putting a + in front of it in the OPTIMALITYORDER in the CONFIG (warning: do not put a + in front of it in the template). When you parse:

  they were pushed by them.

you should now get 1+1 parses, with the displayed parse being the one with the OBL. Once again, you can click on the "u" in the lower right window to see the other parse (you might have to click through the f-structures in the lower left window to actually display it).

PART 2: OT Marks for Robustness

Use the grammar you created for Part 1 and the input grammar for Part 2. You will just be making some additional changes.

To make the grammar more "robust", you can make it so that you can parse mismatched subject-verb agreement. First, to make sure the grammar is behaving as you expect, parse:

  they devour bananas.
  he devours bananas.

  they devours bananas.
  he devour bananas.

The first two should parse. The second two should get a c-structure but not an f-structure.

Put an OT mark BadVAgr into the relevant templates so that the last two sentences get a parse. In the OPTIMALITYORDER, put an * in front of it (warning: do not put an * in front of it in the templates). When you parse:

  they devours bananas.
  he devour bananas.

They should now get *1 solutions. Also, the lower left window should say "UNGRAMMATICAL" in it. The first two sentences should still get 1 parse, and no ungrammatical warning.

Turn in: The new version of your grammar.


If you have any questions, you can send us email (rmkaplan@stanford.edu and thking@stanford.edu), call us (Ron: 812-4348; Tracy: 812-4808), or talk to us during office hours.