Linguistics 567: Grammar Engineering

Lab 9 Due 3/5

Matrix patch

This will fix a bug in negation for anyone with negation expressed as an adverb. Everyone should update. Run a testsuite before and after to make sure nothing broke... Here's the new matrix.tdl.


This lab asks you to do two things: First, do some spring cleaning on your grammar.

Second, you will be assigned one other grammar from the class and given the task of making transfer rules so that you can translate from your language to that language. The class will be divided into two groups of two and one group of three. Within each group, you should decide a deadline for exchanging you cleaned-up grammars (I suggest Saturday noon). You will also need to communicate with each other to answer questions about your grammars.

Task one: Spring Cleaning

Note that you'll want to take notes of what you're doing along the way to facilitate doing the write up of this part.

Testing your grammar

You should include before and after snapshots of your grammar's performance on your test suite.

Check generation across a variety of examples, to make sure it works everywhere.

Task two: Transfer Component

It's difficult for me to anticipate in advance what the remaining differences in semantics are going to be. These instructions therefore tell you how to get started playing with the system and then ask you to post to EPost as soon as you find interesting differences, so we can work them out together!

First, try running the translation system, to see if things work off the shelf.

  1. Run two emacses (emacsen?), and start the lkb in each. One will be for your source language, and one for your target language.
  2. Edit the file lkb/script (in your source grammar, i.e., your own grammar) to include the following line in the list of arguments to read-tdl-type-files-aux
    (lkb-pathname (this-directory) "transfer.tdl")
  3. Add the following lines to lkb/script (again, source grammar):
    (lkb-load-lisp (this-directory) "mt.lsp" t)
      (lkb-pathname (this-directory) ""))
     "567 transfer rules"
     :filter nil)
  4. Create a file called in your lkb subdirectory (source grammar). It can be empty for now. This is where you'll put transfer rules if you have any.
  5. If your language has a GEND (or noun class) feature, edit lkb/mt.lisp so that the line setting %transfer-properties-filter% to nil is commented out and the other version (with the appropriate feature name) is not commented out.
  6. Load your source grammar in one LKB and the target grammar in the other.
  7. In the *commmon-lisp* buffer of the source emacs, evaluate the following expression:
    (setf *translate-grid* '(0 1))
  8. In the *common-lisp* buffer of the target emacs, evaluate the following expression:
    (setf *translate-grid* '(1 0))
  9. Choose Options > Expand menu in both LKBs.
  10. Choose Generate > Start Generator Server in the target language LKB.
  11. Parse a sentence in the source language LKB. Click on the little parse tree and select "Rephrase". See what happens.

If the above steps produce output in the target language, try a few more input sentences to see if you can find any ones that *won't* translate. (Stick with the shared vocabulary, of course.)

If the above do *not* produce output in the target language, it's time to explore why. First, load your own grammar in both LKBs. See if you can translate from your language to itself. If that doesn't work, post to EPost :-) If it does, it's time to explore the differences between the grammars.

Ask the author of your target grammar how you would expect the sentence to be. Parse it, and compare the MRS to the transfer outputs generated. Post to EPost with the differences, and we will work out whether they should be handled by a transfer rule or some other way.

Transfer Rules

Updated 3/5/07

To go from a language with pronouns to one with prodrop, you need to squash the pronouns. This is pretty easy. In, definte a transfer rule like this:

pro-drop-omtr := monotonic_omtr &
 [ INPUT [ RELS <! [ PRED "_pronoun_n_rel",
                        LBL #larg,
                        ARG0 #x ],
                      [ PRED "_exist_q_rel",
                        LBL #harg,
                        ARG0 #x ] !>,
          HCONS <! [ HARG #harg,
                        LARG #larg ] !> ],
   OUTPUT [ RELS <! !>,
            HCONS <! !> ]].

To insert pronoun relations if your source has prodrop and your target doesn't,it's a little more subtle. This appears to work (again in

pro-insert-arg1-omtr := monotonic_omtr &
 [ INPUT.RELS <! !>,
   CONTEXT.RELS <! [ ARG1 ref-ind & #x ] !>,
   FILTER.RELS <! [ ARG0 #x ] !>,
   OUTPUT [ RELS <! noun-relation &
                    [ PRED "_pronoun_n_rel",
		      ARG0 #x,
                      LBL #larg ],
                    quant-relation &
                    [ PRED "_exist_q_rel",
                      ARG0 #x,
                      RSTR #harg ] !>,
            HCONS <! qeq &
                    [ HARG #harg,
                      LARG #larg ] !> ],
   FLAGS.EQUAL < #x > ].

To get this to work, you need to edit tdl/transfer.tdl so that the definition of the type flags has a feature called EQUAL instead of UNIQUE.

To replace a more specific demonstrative predicate with a more general one, you'll need to write two rules (to keep things from spinning). The first changes the pred and puts in an extra marker relation. The second, loaded in a separate step, erases the marker pred.

First, you need to create a second .mtr file and load it. Edit lkb/script to add a second mt:read-transfer-rules declaration, which loads (instead of Be sure this is after the first one.

Now add a couple of new types to the bottom of lkb/transfer.tdl:

marker-pred := predsort.
dem-rule-pred := marker-pred.

Now define the first rule in lkb/

dem-gen-omtr := monotonic_omtr &
 [ INPUT.RELS <! [ PRED proximal+dem_a_rel,
                   LBL #h,
                   ARG1 #x ] !>,
   OUTPUT.RELS <! [ PRED proximal+dem_a_rel,
                    LBL #h,
                    ARG1 #x ],
                  [ PRED dem-rule-pred,
                    ARG0 #x ] !>,
   FILTER.RELS <! [ PRED dem-rule-pred,
                    ARG0 #x ] !> ].

And finally, the clean-up rule in lkb/

clean-up-mtr := monotonic_mtr &
 [ INPUT.RELS <! [ PRED marker-pred ] !>,
   OUTPUT.RELS <! !> ].

Write up

Submit via ESubmit

Back to main course page