Due: Wednesday, June 7 (by midnight)
Submit assignments electronically to both professors
(kaplan "at" parc.com and thking "at" parc.com)
| Turn in: | your modified transfer rules (eng-week9-xfr-rules.pl) |
| Please name your rules with name-eng-week9-xfr-rules.lfg |
There is one grammar this week and one almost empty set of transfer rules:
First, before starting XLE do:
setenv LD_LIBRARY_PATH /afs/ir.stanford.edu/data/linguistics/XLE/SunOS/lib
(If you are going to be logging in and out a lot, you might want to add this to your .cshrc where you originally put in the setenv for XLEPATH.)
Make an xlerc that says:
create-parser eng-week9.lfg create-transfer create-generator eng-week9.lfg load-transfer-rules eng-week9-xfr-rules.pl
Start up XLE. The bottom bit of the messages should say something like:
Initializing prolog engine. Loading prolog image at /project/xle/external/solaris/bin/transfer.sav. Loading rewrite rules: /tilde/thking/courses/ling187/hws/eng-week9-xfr-rules.pl... Building index for 0 rules... Rewrite rules loaded. /tilde/thking/courses/ling187/hws/xlerc loaded.
only with the Stanford paths in it. Importantly, you should not see:
Could not load prolog image.
If you see this, make sure you did the LD_LIBRARY_PATH bit above (on the command line you can do echo $LD_LIBRARY_PATH and see that it returns a reasonable path name). If you still see this, let me know and I will try to figure out what is going on.
Parse:
girls laugh
In the lower left window, under commands, choose Transfer. In the XLE command line window you should see:
Output Predicates: [ % Choices: [], % Equivalences: [], % Equalities: [], % Facts: [ cf(1, 'CASE'(var(1),nom)), cf(1, 'NTYPE'(var(1),common)), cf(1, 'NUM'(var(1),pl)), cf(1, 'PERS'(var(1),3)), cf(1, 'PRED'(var(0),laugh)), cf(1, 'PRED'(var(1),girl)), cf(1, 'STMT-TYPE'(var(0),declarative)), cf(1, 'SUBJ'(var(0),var(1))), cf(1, 'TENSE'(var(2),pres)), cf(1, 'TNS-ASP'(var(0),var(2))), cf(1, arg(var(0),1,var(1))), cf(1, lex_id(var(0),1)), cf(1, lex_id(var(1),0)) ]]
These are the f-structure facts. Since there are currently no transfer rules, nothing has been done to them.
When you are writing rules, you can ignore the cf(1 parts and the closing ),; these indicate the choice space (there is only one choice/analysis in this example). You can also ignore the ' which are a printout issue. The facts you will be manipulating are basically:
CASE(var(1),nom) NTYPE(var(1),common) NUM(var(1),pl) PERS(var(1),3) PRED(var(0),laugh) PRED(var(1),girl) STMT-TYPE(var(0),declarative) SUBJ(var(0),var(1)) TENSE(var(2),pres) TNS-ASP(var(0),var(2)) arg(var(0),1,var(1)) lex_id(var(0),1) lex_id(var(1),0)
Now, in the lower left window, under commands, choose Translate. This should display two new windows with an f-structure in them (ignore the fact that they say UNGRAMMATICAL) and will put a string Girls laugh. in the XLE command line window.
If XLE is not doing what is described above, let me know right away since I doubt any of the rest of this will work well if things are already not cooperating.
If doing the exercises you see a message like:
Warning: singleton variables in rule 6, lines 34-34: %Obj
file /tilde/thking/courses/ling187/hws/eng-week9-xfr-rules.pl
you should investigate the rule. This generally means either (1) you have a typo or cut-and-paste error in a variable name or (2) you should have had a %% variable instead of a named one.
If you want to see in more detail what your rules are doing, on the XLE command line do:
tdbg
which turns the debugging on. no-tdbg turns it off (or just restart XLE). The debugging will show you each rule and tell you if it matches and what its output is.
In this section we will write a rule that optionally deletes the object of verbs that can be both transitive and intransitive. We will do this step by step.
First, write a rule that obligatorily removes the object of a verb:
OBJ(%Verb,%Obj), arg(%Verb,%%,%Obj) ==> 0.
Save your file and under Commands in the lower left window choose Load Transfer Rules. It will prompt you for a name of a set of rules; just hit return since the default is to reload the existing rules. It should say:
Building index for 1 rules... Rewrite rules loaded.
Note that you can always just restart XLE to reload the rules if you prefer.
Parse:
monkeys eat bananas
and then translate this. You should get out a string Monkeys eat. If you look at the windows for the Transfer Result, you will notice a "floating" f-structure for banana; the generator ignores this which is why it can generate out the desired string.
The current rule will delete all objects. There is a problem with this: we only want to delete objects of verbs that have intransitive readings. First, "lexicalize" the rule by requiring the %Verb to have a PRED eat. Make sure to not delete the PRED. You should be able to generate Monkeys eat. from monkeys eat bananas but you should get Monkeys see bananas. from monkeys see bananas. Remember to reload your rules any time you make changes (or you can restart XLE which will reload the rules and the grammar).
There is more than one verb in the lexicon that can be both transitive and intranstive. Instead of repeating the rule several times or putting in a large disjunction, make a template for the rule. Have the INTRANS-TRANS verbs call it. The remplate should b of the form:
opt_detrans(%ARG) :: rule-with-%ARG-in-it. @opt_detrans(eat).
where you can call it as many times as you want (note that currently it is not optional, despite the name). Try translating:
monkeys eat bananas monkeys see bananas monkeys laugh monkeys push bananas
Now make the rule in opt_detrans optional using ?=>. When you translate verbs like transitive eat there should now be two resulting strings:
Monkeys {eat bananas.|eat.}
The goal here is to take passive sentences and make active ones.
bananas are eaten by monkeys
To make an active you will need to:
This can be done step by step, but no string will be generated until all of the pieces work. First make a rule that does (1). Make sure it is after your opt_detrans rules to avoid interactions with that. Inspect the Transfer Result window to make sure that the PASSIVE and VFORM feature have disappeared but that everything else looks the same.
To your rule, add in a part that rewrites the SUBJ to the OBJ (this rule will not have 0 as its right hand side, unlike before). Reload, re-translate, and look at the Transfer Result Window. You should have an f-structure with an OBJ and an OBL but no SUBJ.
Manipulating the OBL to create the SUBJ is the tricky part. First add in the part that rewrites the OBL OBJ as the SUBJ. You will need to add in two facts to the left hand side: one stating that there is an OBL for the verb and the other stating that that OBL has an OBJ. Once again, reload, re-translate, and look at the Transfer Result Window. You should have an f-structure with and OBJ with PRED banana, a SUBJ with PRED monkey, and a floating f-structure with PRED by.
Write two new rules to deal with the case marking. Have one look for f-structures with OBJ with CASE nom and turn them into acc and one look for f-structures with SUBJ with CASE acc.
Finally, add a rule to remove the PCASE by for anything that is not an OBJ (use a -OBJ fact).
You should now be able to generate Monkeys eat bananas. from bananas are eaten by monkeys. If you cannot, try parsing monkeys eat bananas and compare the f-structure for this with Transfer Result you got. They should be identical except for a floating f-structure for by. (Note that it will probably be easier to bring up two XLEs to compare these: parse the active in one and transfer the passive in the other.)
The above rules will not affect sentences like:
bananas are eaten
Try translating this to make sure that you generate back Bananas are eaten.
From these passives, we want to generate They eat bananas. To do this, add a rule after your current passive rule but before the CASE rules. The reason for this is that you want passives with obliques to be affected by your previous rule, but you wan to be able to use the case rules to fix up both types. As a first step, write a rule that removes PASSIVE + and VFORM pass and makes the SUBJ the OBJ. You can base this on your previous rule. Reload your rules and translate bananas are eaten. Nothing with generate, but you should have a Transfer Result f-structure with an OBJ but no SUBJ or PASSIVE or VFORM.
Now we need to insert a new SUBJ with the features of the pronoun they. To your rule, you will need to add to the left hand side:
arg(%V,%Num,NULL)
assuming that you referred to the verb's f-structure as %V (you can use whatever variable name you want as long as you are consistent within the rule). To the right hand side you will need to add:
arg(%V,%Num,%NewSubj)
You can then use %NewSubj to add in other facts such as that it is the SUBJ of the verb, that its PRED is they, etc. You may want to parse they eat bananas to figure out what features you will need for they.
Move the calls to opt_detrans after the passive rules. (You can leave the template at the top or move it down; either is ok as long as it is before the calls.) Reload the transfer rules and translate:
bananas are eaten
You should get two strings:
They {eat bananas.|eat.}
Now make both passive rules optional. After you reload, you should get:
{ They {eat bananas.|eat.}
|Bananas are eaten.}
Also translate bananas are eaten by monkeys. Put a comment in your grammar explaining where each of the strings comes from. (Even if you cannot get your rules to do this, you can put in a comment explaining why they should have done this.)
Turn in:
If you have any questions, you can send us email or call us (Ron: 812-4348; Tracy: 812-4808).