ContextFree Parsing Part 2 Features and Unification Parsing

  • Slides: 21
Download presentation
Context-Free Parsing Part 2 Features and Unification

Context-Free Parsing Part 2 Features and Unification

Parsing with features • We need to constrain the rules in CFGs, for example

Parsing with features • We need to constrain the rules in CFGs, for example – to coerce agreement within and between constituents – to pass features around – to enforce subcategorisation constraints • Features can be easily added to our grammars • And later we’ll see that feature bundles can completely replace constituents 2

Parsing with features • Rules can stipulate values, or placeholders (variables) for values •

Parsing with features • Rules can stipulate values, or placeholders (variables) for values • Features can be used within the rule, or passed up via the mother nodes • Example: subject-verb agreement S NP VP [if NP and VP agree in number] number of NP depends on noun and/or determiner number of VP depends on verb S NP(num=X) VP (num=X) NP (num=X) det(num=X) n (num=X) VP(num=X) v(num=X) NP(num=? ) 3

Declarative nature of features The rules can be used in various ways NP (num=X)

Declarative nature of features The rules can be used in various ways NP (num=X) det(num=X) n (num=X) – To build an NP only if det and n agree (bottom-up) – When generating an NP, to choose an n which agrees with the det (if working L-to-R) (top-down) – To show that the num value for an NP comes from its components (percolation) – To ensure that the num value is correctly set when generating an NP (inheritance) – To block ill-formed input this det (num=sg) these det (num=pl) the det (num=? ) man n (num=sg) men n (num=pl) NP (num=sg) n(num=pl) det(num=sg) n(num=sg) this men man 4

Use of variables NP (num=X) det(num=X) n (num=X) • Unbound (unassigned) this det (num=sg)

Use of variables NP (num=X) det(num=X) n (num=X) • Unbound (unassigned) this det (num=sg) these det (num=pl) variables (ie variables the det (num=? ) with a free value): man n (num=sg) – the can combine with any value for num – Unification means that the num value for the is set to sg men n (num=pl) NP (num=sg) det(num=? ) n(num=sg) the man 5

Parsing with features • Features must be compatible • Formalism should allow features to

Parsing with features • Features must be compatible • Formalism should allow features to remain unspecified • Feature mismatch can be used to block false analyses, and disambiguate – e. g. they can fish ~ he cans fish • Formalism may have attribute-value pairs, or rely on argument position e. g. NP(_num, _sem) det(_num) n (_num, _sem) an = det(sing) the = det(_num) man = n(sing, hum) 6

Parsing with features • Using features to impose subcategorization constraints VP v e. g.

Parsing with features • Using features to impose subcategorization constraints VP v e. g. dance VP v NP e. g. eat VP v NP NP e. g. give VP v PP e. g. wait (for) VP(_num) v(_num, intr) VP(_num) v(_num, trans) NP VP(_num) v(_num, ditrans) NP NP VP(_num) v(_num, prepobj(_case)) PP(_case) prep(_case) NP dance = v(plur, intr) dances = v(sing, intr) danced = v(_num, intr) waits = v(sing, prepobj(for)) for = prep(for) 7

Parsing with features (top-down) S NP(_num) VP(_num) NP(_num) det(_num) n(_num) VP(_num) v(_num, intrans) VP(_num)

Parsing with features (top-down) S NP(_num) VP(_num) NP(_num) det(_num) n(_num) VP(_num) v(_num, intrans) VP(_num) v (_num, trans) NP(_1) the man shot those elephants S NP(_num) VP(_num) S NP(_num) det(_num) n(_num) the = det(_num) man = n(sing) _num=sing NP (_num) (sing) VP(sing) v(sing, intrans) shot = v(sing, trans) VP(sing) v(sing, trans) NP(_1) det (_num) (sing) v v NP n (sing, intrans) (sing, trans) (_1) (_num) (pl) shot = v(sing, trans) NP(_1) det(_1) n(_1) those = det(pl) the man shot det (_1) (pl) n (_1) (pl) elephants = n(pl) those elephants 8

Parsing with features (bottom-up) S NP(_num) VP(_num) NP(_num) det(_num) n(_num) VP(_num) v(_num, intrans) VP(_num)

Parsing with features (bottom-up) S NP(_num) VP(_num) NP(_num) det(_num) n(_num) VP(_num) v(_num, intrans) VP(_num) v (_num, trans) NP(_1) the man shot those elephants the = det(_num) man = n(sing) shot = v(sing, trans) those = det(pl) elephants = n(pl) S NP (sing) VP (sing, trans) NP(_num) det(_num) n(_num) VP(_num) v (_num, trans) NP(_1) S NP(_num) VP(_num) n det v (_num) (sing) (sing, trans) the man shot NP (pl) det (pl) n (pl) those elephants 9

Feature structures • Instead of attaching features to the symbols, we can parse with

Feature structures • Instead of attaching features to the symbols, we can parse with symbols made up entirely of attribute-value pairs: “feature structures” • Can be used in the same way as seen previously ATTR 1 VAL 1 • Values can be atomic … ATTR 2 VAL 2 ATTR 3 VAL 3 • … or embedded feature structures … CAT NP NUMBER SG PERSON 3 CAT AGR NP NUM SG PERS 3 10

Feature structures • … or they can be coindexed CAT HEAD S AGR 1

Feature structures • … or they can be coindexed CAT HEAD S AGR 1 SUBJ NUM SG PERS 3 [ AGR 1 ] 11

Parsing with feature structures • Grammar rules can specify assignments to or equations between

Parsing with feature structures • Grammar rules can specify assignments to or equations between feature structures • Expressed as “feature paths” e. g. HEAD. AGR. NUM = SG CAT HEAD S AGR 1 SUBJ NUM SG PERS 3 [ AGR 1 ] 12

Feature unification • Feature structures can be unified if – They have like-named attributes

Feature unification • Feature structures can be unified if – They have like-named attributes that have the same value: [NUM SG] = [NUM SG] – Like-named attributes that are “open” get the value assigned: CAT NP NUMBER ? ? PERSON 3 NUMBER SG PERSON 3 = CAT NP NUMBER SG PERSON 3 13

Feature unification – Complementary features are brought together CAT NP NUMBER SG [PERSON 3]

Feature unification – Complementary features are brought together CAT NP NUMBER SG [PERSON 3] = CAT NP NUMBER SG PERSON 3 – Unification is recursive CAT NP AGR [NUM SG] CAT NP AGR [PERS 3] = CAT AGR NP NUM SG PERS 3 – Coindexed structures are identical (not just copies): assignment to one effects all 14

Example CAT AGR SEM NP _1 _2 _3 CAT DET VAL INDEF AGR NUM

Example CAT AGR SEM NP _1 _2 _3 CAT DET VAL INDEF AGR NUM SG CAT DET AGR [VAL DEF] CAT LEX AGR SEM N “man” [NUM SG] HUM CAT DET AGR _1 a the man CAT N AGR _2 SEM _3 15

the man CAT NP AGR VAL _1 DEF NUM SG _2 SEM [_3] HUM

the man CAT NP AGR VAL _1 DEF NUM SG _2 SEM [_3] HUM CAT DET AGR [VAL DEF] CAT LEX AGR SEM N “man” [NUM SG] HUM CAT DET AGR [VAL _1 DEF] the man CAT N AGR LEX _2“man” SEM AGR_3 [NUM SG] SEM HUM 16

a man CAT AGR SEM CAT NP _1 VAL INDEF NUM VALSG INDEF NUM_2

a man CAT AGR SEM CAT NP _1 VAL INDEF NUM VALSG INDEF NUM_2 SG [NUM SG] AGR VAL _1 INDEF NUM SG CAT N AGR LEX _2“man” SEM AGR_3 [NUM SG] SEM HUM [_3] HUM DET VAL INDEF AGR NUM SG CAT LEX AGR SEM CAT DET N “man” [NUM SG] HUM a man 17

Types and inheritance • Feature typing allows us to constrain possible values a feature

Types and inheritance • Feature typing allows us to constrain possible values a feature can have – e. g. num = {sing, plur} – Allows grammars to be checked for consistency, and can make parsing easier • We can express general “feature co-occurrence conditions” … • And “feature inheritance rules” • Both these allow us to make the grammar more compact 18

Co-occurrence conditions and Inheritance rules • General rules (beyond simple unification) which apply automatically,

Co-occurrence conditions and Inheritance rules • General rules (beyond simple unification) which apply automatically, and so do not need to be stated (and repeated) in each rule or lexical entry • Examples: [cat=np] [num=? ? , gen=? ? , case=? ? ] [cat=v, num=sg] [tns=pres] [attr 1=val 1] [attr 2=val 2] 19

Inheritance rules • Inheritance rules can be over-ridden e. g. [cat=n] [gen=? ? ,

Inheritance rules • Inheritance rules can be over-ridden e. g. [cat=n] [gen=? ? , sem=? ? ] sex={male, female} gen={masc, fem, neut} [cat=n, gen=fem, sem=hum] [sex=female] uxor [cat=n, gen=fem, sem=hum] agricola [cat=n, gen=fem, sem=hum, sex=male] 20

Unification in Linguistics • Lexical Functional Grammar – If interested, see PARGRAM project •

Unification in Linguistics • Lexical Functional Grammar – If interested, see PARGRAM project • GPSG, HPSG • Construction Grammar • Categorial Grammar 21