Due: Tuesday, February 3 (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 coordination part (eng-week4-coord.lfg) |
| 2. the final grammar you end up with for the ambiguity part (eng-week4-ambi.lfg) | |
| One again, please name your grammars with name-eng-week3-feat.lfg and name-eng-week3-mltsec.lfg |
| Exercises on: | |
| PART 1: | coordination |
| PART 2: | ambiguity |
There are two grammars this week; one for each part (the two parts are unrelated and so if you get stuck, you might want to switch to the other part for a bit):
Do not use capital letters; in later grammars we will add these in. You can use an ending period and some pronouns (see the lexicon).
If you put a file called .xlerc in the directory with your grammar and in .xlerc you put:
create-parser eng-week4-coord.lfg
then whenever you start xle in that directory, it will automatically load eng-week4-coord.lfg (change this to eng-week4-ambi.lfg when you do that part). This will save a lot of time when making and testing changes.
For this part, you should use the grammar eng-week4-coord.lfg. This grammar has two basic coordination macros already defined:
SC-COORD(_CAT) NP-COORD(_CAT)
Put in a call to NP-COORD in the NP rule. To do this, you will need to create a disjunction between what the rule currently has as its right hand side and the call. The call will look like:
@(NP-COORD NP)
The value NP is passed in because this is the category you are going to be coordinating at this level. If you had been putting this in another nominal rule, like Nbar (no, there is not one in this grammar), then the call would have been:
@(NP-COORD Nbar)
Your grammar should be able to parse:
the monkey and the girl devoured a banana.
Note: Do not get over-zealous and start putting this in for all the nominals; the third exercise will have you do this via the METARULEMACRO. The same goes for SC-COORD.
Put in a call to SC-COORD in the PP rule. As with the NP coordination, you will need to create a disjunction in the PP rule. Your grammar should be able to parse:
they laughed in the park and in the garden.
Make sure you can still parse non-coordinated PPs like:
they laughed in the park.
Many meaning oriented applications want to know what c-structure level the coordination occurred at. This information can be stored as a feature in the f-structure (instead of having to look back at the c-structure to derive it).
Alter NP-COORD and SC-COORD so that they assign a feature COORD-LEVEL to every coordination. This feature should appear at the same level as the CONJ-FORM feature. So, a sentence like:
the girl and the monkey devoured the banana.
Should look roughly like:
[ PRED 'devour' SUBJ [ { [ PRED 'girl' SPEC def ] [ PRED 'monkey' SPEC def ] } CONJ-FORM and COORD-LEVEL NP NUM pl ] ]
As discussed last week, METARULEMACRO is a predefined macro that applies to all of the rules in the grammar. Currently, it is set to just give back the right hand side of the rule that you already defined.
Add a disjunct to METARULEMACRO that calls SC-COORD. You will need to pass in _CAT to the template:
@(SC-COORD _CAT)
Remove the call to SC-COORD that is currently in the PP rule.
Parse the following sentences to see if things are working right (the second one will have two parses):
the monkey ate in the park and in the garden. the monkey ate and devours a banana. the monkey ate a banana and devours a orange.
With this formulation, NPs will be affected by both NP-COORD which is called in the NP and by SC-COORD which is called by METARULEMACRO. It is also applying to N, which should be going through NP-COORD. This can be constrained in METARULEMACRO by adding a constraint in the disjunct:
e: _CAT ~$ { N NP };
@(SC-COORD _CAT)
Finally, add another disjunct into METARULEMACRO for NP-COORD. This should be restricted to only apply to NP and N. To do this, you need set notation similar to that above only instead of a negative condition, this is positive condition with $.
Parse the testsuite eng-week4-coord-test.lfg with your grammar. Make sure that everything parses. If you look at the comments in the grammar, you will see that some of the examples will get more than one parse (it is possible that the way you did the assignment will result in slightly different parse statistics).
Turn in: The new version of your grammar.
The .new version of your testsuite.
You can try this for extra credit.
When you coordinate NPs, the PERS of the coordinated NP depends on the PERS feature of the conjuncts. The rules are basically:
Mary and I saw ourselves in the mirror.
You are Mary saw yourselves in the mirror.
John and Mary saw themselves in the mirror.
The goal of this task is to encode this in the grammar in the NP-COORD macro so that the coordinated NP has a PERS feature with the correct value. What you are going to want to do is have a set of equations on the _CAT in NP-COORD (you will want to keep the @IN-SET part as is). These equations will look down into the _CAT (!) to determine its PERS and then sometimes assign a PERS feature to the coordinated NP (^). You will probably need a combination of constraining and defining equations to do this properly. The same set of equations can go on both instances of _CAT; you can put these in a template (NP-COORD-PERS) and call it from NP-COORD so that you don't have to keep retyping the equations in both places.
Some NPs to try:
NP: the girl and the monkey NP: the girl and I NP: you and the girl NP: you and I
Note: The equations are likely to be quite ugly. Don't worry about this.
For this part, you should use the grammar eng-week4-ambi.lfg.
This grammar has been poorly engineered and contains a number of spurious ambiguities. The task is to remove them.
Parse the sentences:
he saw her. he saw the telescope.
These sentences both get two parses; they should only get one. Alter the grammar so that they each get only one parse. Make sure that you can still parse:
they ate. he gave her a telescope.
Parse the sentences:
he eats. he sees her. he gives her the telescope.
These sentences all get two parses; they should only get one. Alter the grammar so that they only get one parse. [Hint: try parsing some sentences plural subjects and see how they behave.]
Count nouns in English either need to be plural or to have a specifier; this grammar was meant to encode that generalization. This was done by having count nouns like girl and banana call COUNT-NOUN-SG and COUNT-NOUN-PL.
Parse:
the girls ate. she ate the bananas.
These both get two parses; they should only get one. Compare them to sentences with plurals without determiners (girls ate.) and with singulars with determiners (the girl ate.). Alter the grammar so that they only get one parse and you can still parse:
girls ate. the girl ate.
But you should not be able to parse:
girl ate.
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.