feature-based grammar ling 571 deep techniques for nlp february 2, 2001
TRANSCRIPT
![Page 1: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/1.jpg)
Feature-based Grammar
Ling 571Deep Techniques for NLP
February 2, 2001
![Page 2: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/2.jpg)
RoadmapImplementing feature-based grammars
Features in NLTK
Designing feature grammarsA Complex Agreement Example
Semantic features
![Page 3: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/3.jpg)
SummaryFeatures defined
Modeling features:Attribute-Value Matrices (AVM)Directed Acyclic Graph (DAG)
Mechanisms for features:SubsumptionUnification
Parsing with features:Augmenting the Earley parser
![Page 4: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/4.jpg)
Feature Grammar in NLTKNLTK supports feature-based grammars
Includes ways of associating features with CFG rules
Includes readers for feature grammars.fcfg files
Includes parsers Nltk.parse.FeatureEarleyChartParse
![Page 5: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/5.jpg)
Creating and Accessing NLTK Feature Structures
Create with FeatStruct
![Page 6: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/6.jpg)
Creating and Accessing NLTK Feature Structures
Create with FeatStruct
>>> fs1 = nltk.FeatStruct(NUMBER=‘pl’,PERSON=3)
>>>print fs1[ NUMBER = ‘pl’][ PERSON = 3 ]
>>> print fs1[‘NUMBER’]pl>> fs1[‘NUMBER’] = ‘sg’
![Page 7: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/7.jpg)
Creating and Accessing NLTK Feature Structures
Create with FeatStruct
>>> fs1 = nltk.FeatStruct(NUMBER=‘pl’,PERSON=3)
![Page 8: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/8.jpg)
Creating and Accessing NLTK Feature Structures
Create with FeatStruct
>>> fs1 = nltk.FeatStruct(NUMBER=‘pl’,PERSON=3)
>>>print fs1[ NUMBER = ‘pl’][ PERSON = 3 ]
![Page 9: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/9.jpg)
Creating and Accessing NLTK Feature Structures
Create with FeatStruct
>>> fs1 = nltk.FeatStruct(NUMBER=‘pl’,PERSON=3)
>>>print fs1[ NUMBER = ‘pl’][ PERSON = 3 ]
>>> print fs1[‘NUMBER’]pl
![Page 10: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/10.jpg)
Creating and Accessing NLTK Feature Structures
Create with FeatStruct
>>> fs1 = nltk.FeatStruct(NUMBER=‘pl’,PERSON=3)
>>>print fs1[ NUMBER = ‘pl’][ PERSON = 3 ]
>>> print fs1[‘NUMBER’]pl>> fs1[‘NUMBER’] = ‘sg’
![Page 11: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/11.jpg)
Complex Feature Structures
>>>fs2 = nltk.FeatStruct(POS=‘N’,AGR=fs1)
![Page 12: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/12.jpg)
Complex Feature Structures
>>>fs2 = nltk.FeatStruct(POS=‘N’,AGR=fs1)>>>print fs2[ POS = ‘N’ ][ [ NUMBER = ‘sg’ ] ][ AGR = [ PERSON = 3 ] ]
![Page 13: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/13.jpg)
Complex Feature Structures
>>>fs2 = nltk.FeatStruct(POS=‘N’,AGR=fs1)>>>print fs2[ POS = ‘N’ ][ [ NUMBER = ‘sg’ ] ][ AGR = [ PERSON = 3 ] ]
Alternatively,>>> fs3 = nltk.FeatStruct(“[POS=‘N’,
AGR=[NUM=‘pl’,PER=3]]”)
![Page 14: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/14.jpg)
Reentrant Feature Structures
First instanceParenthesized integer: (1)
![Page 15: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/15.jpg)
Reentrant Feature Structures
First instanceParenthesized integer: (1)
Subsequent instances: ‘Pointer’: -> (1)
![Page 16: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/16.jpg)
Reentrant Feature Structures
First instanceParenthesized integer: (1)
Subsequent instances: ‘Pointer’: -> (1)
>>> print nltk.FeatStruct("[A='a', B=(1)[C='c'], D->(1)]”
![Page 17: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/17.jpg)
Reentrant Feature Structures
First instanceParenthesized integer: (1)
Subsequent instances: ‘Pointer’: -> (1)
>>> print nltk.FeatStruct("[A='a', B=(1)[C='c'], D->(1)]”
[ A = ‘a’ ][ B = (1) [ C = ‘c’]][ D -> (1) ]
![Page 18: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/18.jpg)
Augmenting GrammarsAttach feature information to non-terminals, on
N[AGR=[NUM='pl']] -> 'students’N[AGR=[NUM=’sg']] -> 'student’
![Page 19: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/19.jpg)
Augmenting GrammarsAttach feature information to non-terminals, on
N[AGR=[NUM='pl']] -> 'students’N[AGR=[NUM=’sg']] -> 'student’
So far, all values are literal or reentrant
![Page 20: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/20.jpg)
Augmenting GrammarsAttach feature information to non-terminals, on
N[AGR=[NUM='pl']] -> 'students’N[AGR=[NUM=’sg']] -> 'student’
So far, all values are literal or reentrantVariables allow generalization: ?a
Allows underspecification, e.g. Det[GEN=?a]
![Page 21: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/21.jpg)
Augmenting GrammarsAttach feature information to non-terminals, on
N[AGR=[NUM='pl']] -> 'students’N[AGR=[NUM=’sg']] -> 'student’
So far, all values are literal or reentrantVariables allow generalization: ?a
Allows underspecification, e.g. Det[GEN=?a]NP[AGR=?a] -> Det[AGR=?a] N[AGR=?a]
![Page 22: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/22.jpg)
Mechanics>>> fs3 = nltk.FeatStruct(NUM=‘pl’,PER=3)
>>> fs4 = nltk.FeatStruct(NUM=‘pl’)
>>> print fs4.unify(fs3)
[NUM = ‘pl’]
[PER = 3 ]
![Page 23: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/23.jpg)
Morphosyntactic FeaturesGrammatical feature that influences
morphological or syntactic behavior English:
Number: Dog, dogs
Person: Am; are; is
Case: I – me; he – him; etc
Countability:
![Page 24: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/24.jpg)
More Complex German Example
Subject – singular, mascder HundThe dog
Subject –plural, mascdie Hunde The dogs
![Page 25: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/25.jpg)
More Complex German Example
Objects – determined by verb
Dative – singular, mascdem HundThe dog
Accusative –plural, mascdie Hunde The dogs
![Page 26: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/26.jpg)
ContrastSubject:
Die KatzeThe cat
Subject: pluralDie KatzeThe cats
![Page 27: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/27.jpg)
ContrastObject:
Die KatzeThe cat
Object: Der KatzeThe cat
![Page 28: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/28.jpg)
AnalysisWhat are the key contrasts?
NumberSingular, plural
GenderMasc, Fem, ….
Case:Subject (nom), dative, accusative, ….
+ Interactions
![Page 29: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/29.jpg)
Feature InteractionInteractions of German case, number, gender
Case Masc Fem Neut PL
Nom Der Die Das Die
Gen Des Der Des Den
Dat Dem Der Dem Den
Acc Den Die Das Die
![Page 30: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/30.jpg)
Examples of InteractionDieThe.Nom.Fem.sgThe cat sees the dog
KatzeCat.3.FEM.SG
Sieht See.3.sg
DenThe.Acc.Masc.sg
HundDog.3.Masc.sg
![Page 31: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/31.jpg)
Examples of InteractionDieThe.Nom.Fem.sgThe cat sees the dog
KatzeCat.3.FEM.SG
Sieht See.3.sg
DenThe.Acc.Masc.sg
HundDog.3.Masc.sg
*DieThe.Nom.Fem.sgThe cat sees the dog
KatzeCat.3.FEM.SG
Sieht See.3.sg
DemThe.Dat.Masc.sg
HundDog.3.Masc.sg
![Page 32: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/32.jpg)
Examples of InteractionDieThe.Nom.Fem.sgThe cat sees the dog
KatzeCat.3.FEM.SG
Sieht See.3.sg
DenThe.Acc.Masc.sg
HundDog.3.Masc.sg
*DieThe.Nom.Fem.sgThe cat sees the dog
KatzeCat.3.FEM.SG
Sieht See.3.sg
DemThe.Dat.Masc.sg
HundDog.3.Masc.sg
DieThe.Nom.Fem.sgThe cat helps the dog
KatzeCat.3.FEM.SG
hilft help.3.sg
DemThe.Dat.Masc.sg
HundDog.3.Masc.sg
![Page 33: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/33.jpg)
Examples of Interaction
DieThe.Nom.Fem.sgThe cat sees the dog
KatzeCat.3.FEM.SG
Sieht See.3.sg
DenThe.Acc.Masc.sg
HundDog.3.Masc.sg
*DieThe.Nom.Fem.sgThe cat sees the dog
KatzeCat.3.FEM.SG
Sieht See.3.sg
DemThe.Dat.Masc.sg
HundDog.3.Masc.sg
DieThe.Nom.Fem.sgThe cat helps the dog
KatzeCat.3.FEM.SG
hilft help.3.sg
DemThe.Dat.Masc.sg
HundDog.3.Masc.sg
*DieThe.Nom.Fem.sgThe cat sees the dog
KatzeCat.3.FEM.SG
hilft help.3.sg
DemThe.Acc.Masc.sg
HundDog.3.Masc.sg
German verbs in, at least, 2 classes: assign diff’t object case
![Page 34: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/34.jpg)
Semantic FeaturesGrammatical features that influence
semantic(meaning) behavior of associated units
E.g.:
![Page 35: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/35.jpg)
Semantic FeaturesGrammatical features that influence
semantic(meaning) behavior of associated units
E.g.:?The rocks slept.
![Page 36: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/36.jpg)
Semantic FeaturesGrammatical features that influence
semantic(meaning) behavior of associated units
E.g.:?The rocks slept.
?Colorless green ideas sleep furiously.
![Page 37: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/37.jpg)
Semantic FeaturesMany proposed:
Animacy: +/-Natural gender: masculine, feminine, neuterHuman: +/-Adult: +/-Liquid: +/-Etc.The milk spilled.?The cat spilled.
![Page 38: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/38.jpg)
ExamplesThe climber hiked for six hours.
![Page 39: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/39.jpg)
ExamplesThe climber hiked for six hours.
The climber hiked on Saturday.
![Page 40: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/40.jpg)
ExamplesThe climber hiked for six hours.
The climber hiked on Saturday.
The climber reached the summit on Saturday.
![Page 41: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/41.jpg)
ExamplesThe climber hiked for six hours.
The climber hiked on Saturday.
The climber reached the summit on Saturday.
*The climber reached the summit for six hours.
Contrast:
![Page 42: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/42.jpg)
ExamplesThe climber hiked for six hours.
The climber hiked on Saturday.
The climber reached the summit on Saturday.
*The climber reached the summit for six hours.
Contrast:Achievement vs activity
![Page 43: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/43.jpg)
Semantic features & Parsing
Can filter some classes of ambiguity
Old men and women slept.
![Page 44: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/44.jpg)
Semantic features & Parsing
Can filter some classes of ambiguity
Old men and women slept.(Old men) and (women) slept.
![Page 45: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/45.jpg)
Semantic features & Parsing
Can filter some classes of ambiguity
Old men and women slept.(Old men) and (women) slept.(Old (men and women)) slept.
![Page 46: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/46.jpg)
Semantic features & Parsing
Can filter some classes of ambiguity
Old men and women slept.(Old men) and (women) slept.(Old (men and women)) slept.
Sleeping people and books lie flat.
![Page 47: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/47.jpg)
Semantic features & Parsing
Can filter some classes of ambiguity
Old men and women slept.(Old men) and (women) slept.(Old (men and women)) slept.
Sleeping people and books lie flat.(Sleeping people) and (books) lie flat.
![Page 48: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/48.jpg)
Semantic features & Parsing
Can filter some classes of ambiguity
Old men and women slept.(Old men) and (women) slept.(Old (men and women)) slept.
Sleeping people and books lie flat.(Sleeping people) and (books) lie flat.(Sleeping (people and books ))lie flat.
![Page 49: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/49.jpg)
Semantic features & Parsing
Can filter some classes of ambiguity
Old men and women slept.(Old men) and (women) slept.(Old (men and women)) slept.
Sleeping people and books lie flat.(Sleeping people) and (books) lie flat.*(Sleeping (people and books ))lie flat.
![Page 50: Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001](https://reader036.vdocuments.net/reader036/viewer/2022062318/55162446550346b2068b4781/html5/thumbnails/50.jpg)
SummaryFeatures
Enable compact representation of grammatical constraints
Capture basic linguistic patterns
UnificationCreates and maintains consistency over features
Integration with parsing allows filtering of ill-formed analyses