############################################################################
# David Bullock (bullockd@u.washington.edu).
# LING-567 "Knowledge Engineering for NLP" (Bender).
# Lab 5, due 2006-Apr-30.
############################################################################

PRONOUNS, PERSON AND NUMBER DISTINCTIONS.

Changes to "lexicon.tdl":
- Changed noun-lex entries to common-noun-lex.
- Made pronoun-lex entries with appropriate PNG.PER and PNG.NUM values.

Changes to "mandarin.tdl":
- Added PER, NUM and NOUNCLASS features to the png type. (Instead of GENDER, Mandarin uses NOUNCLASS to identify noun classes that are compatible with different types of numeral classifiers.)
- Defined PER values: first, second, third.
- Defined NUM values: sg, non-sg, dual and pl. (Only sg and non-sg are used by Mandarin.)
- Defined NOUNCLASS values: clf-ben3, clf-ge, clf-wei4.
- Added quantifier PRED relations for pronouns, proper nouns and regular quantifiers.
- Replaced bare-np-phrase with subtypes of basic-head-spec-phrase using appropriate quantifiers for pronouns, proper nouns and common nouns.
- Added subtypes of noun-lex for pronouns, proper nouns and common nouns.

Changes to "rules.tdl":
- Replaced the bare-np rule instance with specific rule instances for pronouns, proper nouns and common nouns.

After making these changes, determiners could appear with common nouns, but not with pronouns. (But later, when adjectives were added and determiner were changed to NOM modifiers, some modifiers incorrectly appeared with pronouns. See the failure analysis below.).

############################################################################

NUMERAL CLASSIFIERS AND CLASSIFIER-NOUN AGREEMENT.

Changes to "lexicon.tdl":
- Restricted PNG.NOUNCLASS values to the appropriate classifier type for each common noun.
- Added classifiers "wei4", "ben3" and "ge" that are restricted to modify only nouns with a compatible PNG.NOUNCLASS.

Rules for pre-NOM modifiers:

1. Word order for noun phrases: Demonstrative Numeral Classifier Noun.

2. If a classifier is used, it must be preceded by a demonstrative or a numeral or both.

3. If a numeral is used, it must be followed by a classifier.

4. Adjectives must come after any demonstrative, numeral or classifier.

5. Possessives and relative clauses can come before all demonstratives, numerals and classifiers, or after all demonstratives, numerals and classifiers.

6. All parts of the noun phrase are optional, including the noun.

7. If a demonstrative is used, but the noun is dropped, a classifier is required.

8. Different classes of nouns require different classifiers.

Originally, I was planning to handle classifiers as part of determiner phrases headed by a demonstrative (with an optional classifier) or numeral (with a required classifier):

    [NP [DP this clf] [NOM book]]
    [NP [DP this] [NOM book]]
    [NP [DP one clf] [NOM book]]
    *[NP [DP one] [NOM book]]

But I have changed demonstratives, numerals and classifiers to be types of pre-NOM modifiers:

    [NP [NOM this [NOM one [NOM clf [NOM book]]]]]
    [NP [NOM this [NOM clf [NOM book]]]]
    [NP [NOM this [NOM book]]]
    [NP [NOM one [NOM clf [NOM book]]]]
    *[NP [NOM one [NOM book]]]

Classifier-noun agreement (requirement 8 above) is handled by defining common nouns to have a specific PNG.NOUNCLASS value, and defining classifiers so they are restricted to modify only nouns with a compatible PNG.NOUNCLASS. For example:

ge_adj := adjective-lex &
  [ STEM < "ge" >,
    SYNSEM.LOCAL.CAT.HEAD.MOD
      < [ LOCAL.CONT.HOOK.INDEX.PNG [ NOUNCLASS clf-ge ] ] > ].

All of the grammatical and ungrammatical test cases for classifier-noun agreement succeed in the test suite.

Noun phrases that omit the noun (requirements 6 and 7) could eventually be handled by some sort of non-branching NP rule.

The order of pre-NOM modifiers (requirements 1 to 5) has not yet been constrained, but might be handled with a modorder type with bool features. On a bare NOM these would be [ ALLOW-POSS +, ALLOW-DEM +, ALLOW-CLF +, REQUIRE-DEM-OR-NP - ]. They would control the order of allowed modifications:

- Relative clauses can modify NOM where [ REQUIRE-DEM-OR-NP - ]. The mother NOM copies the MODORDER values.

- Adjectives can modify NOM where [ ALLOW-CLF +, REQUIRE-DEM-OR-NP - ]. The mother NOM copies the MODORDER values.

- Possessives can modify NOM where [ ALLOW-POSS +, REQUIRE-DEM-OR-NP - ]. The mother NOM copies the MODORDER values, except it sets [ ALLOW-POSS - ].

- Classifiers can modify NOM where [ ALLOW-CLF + ]. The mother NOM copies the MODORDER values, except it sets [ ALLOW-CLF -, REQUIRE-DEM-OR-NP + ].

- Numerals can modify NOM where [ ALLOW-DEM +, REQUIRE-DEM-OR-NP + ]. The mother NOM copies the MODORDER values, except it sets [ ALLOW-CLF -, REQUIRE-DEM-OR-NP - ].

- Demonstratives can modify NOM where [ ALLOW-DEM + ]. The mother NOM copies the MODORDER values, except it sets [ ALLOW-DEM -, ALLOW-CLF -, REQUIRE-DEM-OR-NP - ].

- A non-branching rule can produce an NP mother for a NOM daughter where [ REQUIRE-DEM-OR-NP - ].

This would require some rule changes and additional lexical types with these new features and constraints. It seems more complicated than desirable.

############################################################################

LEXICAL RULES.

I did not add any lexical rules.

############################################################################

ADJECTIVES.

Changes to "lexicon.tdl":
- Added adjective entries for "xiao3" and "hao3" (in addition to their entries as intransitive stative verbs).
- Changed entries for "zhe4" and "na4" to be NOM modifiers (adjectives instead of determiners).
- Added numerals "yi1" and "liang3" and classifiers "wei4", "ben3" and "ge" as adjective NOM modifiers.

Changes to "mandarin.tdl":
- Added an adjective-lex lexical types (see below).

The adjective-lex lexical type modifies a NOM (the MOD list is restricted to a noun with a non-empty SPR):

adjective-lex := basic-adjective-lex &
  [ SYNSEM [ LOCAL [ CAT [ HEAD adj &
    [ MOD < [ LOCAL [ CAT.HEAD noun,
                      CAT.VAL.SPR < [ ] >,
                      CONT.HOOK [ INDEX #ind,
                                  LTOP #ltop ]]]>],
                           VAL [ SPR < >,
                                 SUBJ < >,
                                 COMPS < >,
                                 SPEC < > ],
                           POSTHEAD - ],
                     CONT.HOOK.LTOP #ltop ],
             LKEYS.KEYREL.ARG1 #ind ] ].

############################################################################

POSSESSIVES.

Changes to "label.tdl":
- Added Poss and PossP labels.

Changes to "lexicon.tdl":
- Added possessive-marker-lex "de" entry.

Changes to "mandarin.tdl":
- To make possessive phrases modify the following noun (rather than the preceding noun), I created basic-head-subj-phrase-without-posthead, a copy of basic-head-subj-phrase from matrix.tdl, but with the POSTHEAD feature removed. I then changed subj-head-phrase to inherit from basic-head-subj-phrase-without-posthead instead of from basic-head-subj-phrase.
- Added a link := head type and a possessive-marker-lex type (see below).

The possessive-marker-lex lexical type is for a possessive linker ("de") that is a modifier. It selects for the possessor NP through its SUBJ.

possessive-marker-lex := intersective-mod-lex &
                         norm-hook-lex-item &
                         single-rel-lex-item &
  [ SYNSEM [ LOCAL.CAT [ HEAD link &
    [ MOD < [ LOCAL.CAT.HEAD noun,
              LOCAL.CAT.VAL.SPR < [ ] > ]>],
                         VAL [ SUBJ < #subj >,
                               COMPS < >,
                               SPR < >,
                               SPEC < > ],
                         POSTHEAD - ],
             LKEYS.KEYREL.PRED "poss_rel" ],
    ARG-ST < #subj & [ LOCAL.CAT [ HEAD noun,
                                   VAL [ SPR < >,
                                         COMPS < > ]]] > ].

The possessee is restricted to a NOM (the MOD list contains a noun with a non-empty SPR).

Here is the Simple MRS for the sentence "wo3 de shu1 xiao3":

LTOP: h1
INDEX: e2

[ pronoun_n_rel 
  LBL: h3
  ARG0: x4 ]
[ pronoun_q_rel 
  LBL: h5
  ARG0: x4
  RSTR: h6
  BODY: h7 ]
[ poss_rel 
  LBL: h8
  ARG0: u10
  ARG1: x9 ]
[ "book_n_rel" 
  LBL: h8
  ARG0: x9 ]
[ reg_quant_rel 
  LBL: h11
  ARG0: x9
  RSTR: h12
  BODY: h13 ]
[ "_small_v_rel" 
  LBL: h1
  ARG0: e2
  ARG1: x9 ]

h6 qeq h3 h12 qeq h8

It looks like the poss_rel "possessed" relationship is hooked up to "book", but the "possessor" relationship is not hooked up to the pronoun. I think I might be missing a coindexing relationship in possessive-marker-lex.

############################################################################

TEST-SUITE RESULTS. (SORRY, STILL [DECR TSDB()].)

Lab4 Baseline Test-Suite Results:

    decr-tsdb.pl 2006-04-23.UpdatedTestSuite.out
    Coverage of current batch parse output:
        15 out of 98 grammatical sentences parsed = 15.30 percent
    Overgeneration of current batch parse output:
        3 out of 70 ungrammatical sentences parsed = 4.28 percent

Lab5 Final Test-Suite Results:

    decr-tsdb.pl 2006-04-30.ClassifierAgreementPossessive.out
        2006-04-23.UpdatedTestSuite.out
    Writing new-success.txt (36 sentences)
    Writing new-failure.txt (16 sentences)
    Coverage of current batch parse output:
        51 out of 98 grammatical sentences parsed = 52.04 percent
    Overgeneration of current batch parse output:
        19 out of 70 ungrammatical sentences parsed = 27.14 percent

Coverage improved by almost 37 percent (successful parses for 36 grammatical sentences that failed to parse before). Most of these new parses were because of grammar changes to support numeral-classifier agreement and possessives.

############################################################################

ANALYSIS OF FAILURES.

7 test cases failing because the order of pre-NOM modifiers is not restricted:

    *wo3 you3 liang3 zhe4 ben3 shu1
    *wo3 you3 ben3 zhe4 shu1
    *wei4 yi1 lao3shi1 kan4 wo3
    *wo3 kan4 zhe4 ni3 de liang3 ben3 shu1
    *wo3 kan4 zhe4 liang3 ni3 de ben3 shu1
    *wo3 kan4 zhe4 liang3 ben3 shu1 ni3 de
    *wo3 yao4 xiao3 na4 ben3 shu1

4 test cases failing because modifiers can incorrectly appear before pronouns:

    *wo3 kan4 zhe4 ge ta1
    *wo3 kan4 zhe4 ta1
    *wo3 kan4 liang3 ge ta1men
    *wo3 kan4 liang3 ta1men

2 test cases failing because a classifier can incorrectly appear without a preceding demonstrative or numeral:

    *wo3 you3 ben3 shu1
    *wei4 lao3shi1 kan4 wo3

1 test case failing because a classifier is incorrectly omitted after a numeral:

    *yi1 lao3shi1 kan4 wo3

1 test case failing because the grammar does not yet support a classifier in place of a noun:

    wo3 you3 zhe4 ben3

18 test cases failing because embedded/relative clauses and modals are not supported yet.

13 test cases failing because ditransitive verb "gei3" is not supported yet.

13 test cases failing because pro-drop and imperatives are not supported yet.

8 test cases failing because negation-marker agreement and verb-neg-verb are not supported yet.

############################################################################
