context-free parsing part 2 features and unification
Post on 22-Dec-2015
222 views
TRANSCRIPT
Context-Free Parsing
Part 2
Features and Unification
2/21
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
3/21
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=?)
4/21
Declarative nature of featuresThe rules can be used in
various ways– 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
NP (num=X) det(num=X) n (num=X)
this det (num=sg)
these det (num=pl)
the det (num=?)
man n (num=sg)
men n (num=pl)
det(num=sg) n(num=sg)
this man
NP (num=sg)
n(num=pl)
men
5/21
Use of variables• Unbound
(unassigned) variables (ie variables with a free value):– the can combine with
any value for num– Unification means that
the num value for the is set to sg
NP (num=X) det(num=X) n (num=X)
this det (num=sg)
these det (num=pl)
the det (num=?)
man n (num=sg)
men n (num=pl)
det(num=?) n(num=sg)
the man
NP (num=sg)
6/21
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 can fish ~ he cans fish
• Formalism may have attribute-value pairs, or rely on argument positione.g. NP(_num,_sem) det(_num) n (_num,_sem) an = det(sing) the = det(_num) man = n(sing,hum)
7/21
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)
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)
8/21
v(sing,intrans)
S NP(_num) VP(_num)NP(_num) det(_num) n(_num)VP(_num) v(_num,intrans)VP(_num) v (_num,trans) NP(_1)
Parsing with features (top-down)
S NP(_num) VP(_num)S
NP VP(_num) (_num)
NP(_num) det(_num) n(_num)
the man shot those elephants
det n(_num) (_num)
the = det(_num)
the
man = n(sing)
man
VP(sing) v(sing,intrans)
shot = v(sing,trans)
(sing)
(sing)(sing)
(sing)VP(sing) v(sing,trans) NP(_1)
shot = v(sing,trans)
v NP(sing,trans) (_1)
shot det n (_1) (_1)
those elephants
(pl)
(pl)
NP(_1) det(_1) n(_1)
those = det(pl)
elephants = n(pl)
_num=sing
(pl)
9/21
S NP(_num) VP(_num)NP(_num) det(_num) n(_num)VP(_num) v(_num,intrans)VP(_num) v (_num,trans) NP(_1)
Parsing with features (bottom-up)
S NP(_num) VP(_num)
NP(_num) det(_num) n(_num)
the man shot those elephants
NP (sing)
the = det(_num)
det (_num)
the
man = n(sing)
shot = v(sing,trans)
(sing)
S
VP(_num) v (_num,trans) NP(_1)
VP (sing,trans)
those = det(pl)
elephants = n(pl)
n(sing)
man
v(sing,trans)
shotdet (pl)
those
n(pl)
elephants
NP (pl)
10/21
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• Values can be atomic …• … or embedded feature structures …
CAT NPNUMBER SGPERSON 3
ATTR1 VAL1ATTR2 VAL2ATTR3 VAL3
CAT NP
AGRNUM SGPERS 3
11/21
Feature structures
• … or they can be coindexed
CAT S
HEADAGR 1
SUBJ [ AGR 1 ]
NUM SGPERS 3
12/21
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 S
HEADAGR 1
SUBJ [ AGR 1 ]
NUM SGPERS 3
13/21
Feature unification
• Feature structures can be unified if– They have like-named attributes that have the
same value:
[NUM SG] [NUM SG] = [NUM SG]– Like-named attributes that are “open” get the
value assigned:
CAT NPNUMBER ??PERSON 3
NUMBER SGPERSON 3 =
CAT NPNUMBER SGPERSON 3
14/21
Feature unification
– Complementary features are brought together
– Unification is recursive
– Coindexed structures are identical (not just copies): assignment to one effects all
CAT NPNUMBER SG
[PERSON 3] =CAT NPNUMBER SGPERSON 3
CAT NPAGR [NUM SG]
CAT NP
AGRNUM SGPERS 3
=CAT NPAGR [PERS 3]
15/21
ExampleCAT NPAGR _1 _2SEM _3
CAT DETAGR _1
CAT NAGR _2 SEM _3
CAT DET
AGRVAL INDEFNUM SG
a
CAT DETAGR [VAL DEF]
the
CAT NLEX “man”AGR [NUM SG]SEM HUM
man
16/21
the manthe
CAT NAGR _2 SEM _3
CAT DETAGR [VAL DEF]
the
CAT NPAGR _1 _2SEM [_3]
CAT DETAGR _1 [VAL DEF]VAL DEF
CAT NLEX “man”AGR [NUM SG]SEM HUM
man
LEX “man”AGR [NUM SG]SEM HUM
the man
NUM SGHUM
17/21
a mana
CAT NAGR _2 SEM _3
CAT NPAGR _1
_2
SEM [_3]
CAT DET
AGR _1
CAT NLEX “man”AGR [NUM SG]SEM HUM
man
LEX “man”AGR [NUM SG]SEM HUM
a man
[NUM SG]
HUM
CAT DET
AGRVAL INDEFNUM SG
a
VAL INDEFNUM SG
VAL INDEFNUM SG
VAL INDEFAGR NUM SG
18/21
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
19/21
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]
[attr1=val1] [attr2=val2]
20/21
Inheritance rules
• Inheritance rules can be over-riddene.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]
21/21
Unification in Linguistics
• Lexical Functional Grammar– If interested, see PARGRAM project
• GPSG, HPSG
• Construction Grammar
• Categorial Grammar