Feature-based Grammar Ling 571 Deep Techniques for NLP February - - PowerPoint PPT Presentation

feature based grammar
SMART_READER_LITE
LIVE PREVIEW

Feature-based Grammar Ling 571 Deep Techniques for NLP February - - PowerPoint PPT Presentation

Feature-based Grammar Ling 571 Deep Techniques for NLP February 2, 2001 Roadmap Implementing feature-based grammars Features in NLTK Designing feature grammars A Complex Agreement Example Semantic features Summary


slide-1
SLIDE 1

Feature-based Grammar

Ling 571 Deep Techniques for NLP February 2, 2001

slide-2
SLIDE 2

Roadmap

— Implementing feature-based grammars

— Features in NLTK — Designing feature grammars

— A Complex Agreement Example — Semantic features

slide-3
SLIDE 3

Summary

— Features defined — Modeling features:

— Attribute-Value Matrices (AVM) — Directed Acyclic Graph (DAG)

— Mechanisms for features:

— Subsumption — Unification

— Parsing with features:

— Augmenting the Earley parser

slide-4
SLIDE 4

Feature Grammar in NLTK

— NLTK supports feature-based grammars

— Includes ways of associating features with CFG rules — Includes readers for feature grammars

— .fcfg files

— Includes parsers

— Nltk.parse.FeatureEarleyChartParse

slide-5
SLIDE 5

Creating and Accessing NLTK Feature Structures

— Create with FeatStruct

slide-6
SLIDE 6

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’

slide-7
SLIDE 7

Creating and Accessing NLTK Feature Structures

— Create with FeatStruct

— >>> fs1 = nltk.FeatStruct(NUMBER=‘pl’,PERSON=3)

slide-8
SLIDE 8

Creating and Accessing NLTK Feature Structures

— Create with FeatStruct

— >>> fs1 = nltk.FeatStruct(NUMBER=‘pl’,PERSON=3) — >>>print fs1 — [ NUMBER = ‘pl’] — [ PERSON = 3 ]

slide-9
SLIDE 9

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

slide-10
SLIDE 10

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’

slide-11
SLIDE 11

Complex Feature Structures

— >>>fs2 = nltk.FeatStruct(POS=‘N’,AGR=fs1)

slide-12
SLIDE 12

Complex Feature Structures

— >>>fs2 = nltk.FeatStruct(POS=‘N’,AGR=fs1) — >>>print fs2 — [ POS = ‘N’ ] — [ [ NUMBER = ‘sg’ ] ] — [ AGR = [ PERSON = 3 ] ]

slide-13
SLIDE 13

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]]”)

slide-14
SLIDE 14

Reentrant Feature Structures

— First instance

— Parenthesized integer: (1)

slide-15
SLIDE 15

Reentrant Feature Structures

— First instance

— Parenthesized integer: (1)

— Subsequent instances:

— ‘Pointer’: -> (1)

slide-16
SLIDE 16

Reentrant Feature Structures

— First instance

— Parenthesized integer: (1)

— Subsequent instances:

— ‘Pointer’: -> (1) — >>> print nltk.FeatStruct("[A='a', B=(1)[C='c'], D->(1)]”

slide-17
SLIDE 17

Reentrant Feature Structures

— First instance

— Parenthesized 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) ]

slide-18
SLIDE 18

Augmenting Grammars

— Attach feature information to non-terminals, on

— N[AGR=[NUM='pl']] -> 'students’ — N[AGR=[NUM=’sg']] -> 'student’

slide-19
SLIDE 19

Augmenting Grammars

— Attach feature information to non-terminals, on

— N[AGR=[NUM='pl']] -> 'students’ — N[AGR=[NUM=’sg']] -> 'student’

— So far, all values are literal or reentrant

slide-20
SLIDE 20

Augmenting Grammars

— Attach feature information to non-terminals, on

— N[AGR=[NUM='pl']] -> 'students’ — N[AGR=[NUM=’sg']] -> 'student’

— So far, all values are literal or reentrant

— Variables allow generalization: ?a

— Allows underspecification, e.g. Det[GEN=?a]

slide-21
SLIDE 21

Augmenting Grammars

— Attach feature information to non-terminals, on

— N[AGR=[NUM='pl']] -> 'students’ — N[AGR=[NUM=’sg']] -> 'student’

— So far, all values are literal or reentrant

— Variables allow generalization: ?a

— Allows underspecification, e.g. Det[GEN=?a]

— NP[AGR=?a] -> Det[AGR=?a] N[AGR=?a]

slide-22
SLIDE 22

Mechanics

— >>> fs3 = nltk.FeatStruct(NUM=‘pl’,PER=3) — >>> fs4 = nltk.FeatStruct(NUM=‘pl’) — >>> print fs4.unify(fs3) — [NUM = ‘pl’] — [PER = 3 ]

slide-23
SLIDE 23

Morphosyntactic Features

— Grammatical feature that influences morphological

  • r syntactic behavior

— English:

— Number:

— Dog, dogs

— Person:

— Am; are; is

— Case:

— I – me; he – him; etc

— Countability:

slide-24
SLIDE 24

More Complex German Example

— Subject – singular, masc

— der Hund — The dog

— Subject –plural, masc

— die Hunde — The dogs

slide-25
SLIDE 25

More Complex German Example

— Objects – determined by verb — Dative – singular, masc

— dem Hund — The dog

— Accusative –plural, masc

— die Hunde — The dogs

slide-26
SLIDE 26

Contrast

— Subject:

— Die Katze — The cat

— Subject: plural

— Die Katze — The cats

slide-27
SLIDE 27

Contrast

— Object:

— Die Katze — The cat

— Object:

— Der Katze — The cat

slide-28
SLIDE 28

Analysis

— What are the key contrasts?

— Number

— Singular, plural

— Gender

— Masc, Fem, ….

— Case:

— Subject (nom), dative, accusative, …. + Interactions

slide-29
SLIDE 29

Feature Interaction

— Interactions 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

slide-30
SLIDE 30

Examples of Interaction

Die The.Nom.Fem.sg The cat sees the dog Katze Cat.3.FEM.SG Sieht See.3.sg Den The.Acc.Masc.sg Hund Dog.3.Masc.sg

slide-31
SLIDE 31

Examples of Interaction

Die The.Nom.Fem.sg The cat sees the dog Katze Cat.3.FEM.SG Sieht See.3.sg Den The.Acc.Masc.sg Hund Dog.3.Masc.sg *Die The.Nom.Fem.sg The cat sees the dog Katze Cat.3.FEM.SG Sieht See.3.sg Dem The.Dat.Masc.sg Hund Dog.3.Masc.sg

slide-32
SLIDE 32

Examples of Interaction

Die The.Nom.Fem.sg The cat sees the dog Katze Cat.3.FEM.SG Sieht See.3.sg Den The.Acc.Masc.sg Hund Dog.3.Masc.sg *Die The.Nom.Fem.sg The cat sees the dog Katze Cat.3.FEM.SG Sieht See.3.sg Dem The.Dat.Masc.sg Hund Dog.3.Masc.sg Die The.Nom.Fem.sg The cat helps the dog Katze Cat.3.FEM.SG hilft help.3.sg Dem The.Dat.Masc.sg Hund Dog.3.Masc.sg

slide-33
SLIDE 33

Examples of Interaction

Die The.Nom.Fem.sg The cat sees the dog Katze Cat.3.FEM.SG Sieht See.3.sg Den The.Acc.Masc.sg Hund Dog.3.Masc.sg *Die The.Nom.Fem.sg The cat sees the dog Katze Cat.3.FEM.SG Sieht See.3.sg Dem The.Dat.Masc.sg Hund Dog.3.Masc.sg Die The.Nom.Fem.sg The cat helps the dog Katze Cat.3.FEM.SG hilft help.3.sg Dem The.Dat.Masc.sg Hund Dog.3.Masc.sg *Die The.Nom.Fem.sg The cat sees the dog Katze Cat.3.FEM.SG hilft help.3.sg Dem The.Acc.Masc.sg Hund Dog.3.Masc.sg

German verbs in, at least, 2 classes: assign diff’t object case

slide-34
SLIDE 34

Semantic Features

— Grammatical features that influence semantic

(meaning) behavior of associated units

— E.g.:

slide-35
SLIDE 35

Semantic Features

— Grammatical features that influence semantic

(meaning) behavior of associated units

— E.g.:

— ?The rocks slept.

slide-36
SLIDE 36

Semantic Features

— Grammatical features that influence semantic

(meaning) behavior of associated units

— E.g.:

— ?The rocks slept. — ?Colorless green ideas sleep furiously.

slide-37
SLIDE 37

Semantic Features

— Many proposed:

— Animacy: +/- — Natural gender: masculine, feminine, neuter — Human: +/- — Adult: +/- — Liquid: +/- — Etc. — The milk spilled. — ?The cat spilled.

slide-38
SLIDE 38

Examples

— The climber hiked for six hours.

slide-39
SLIDE 39

Examples

— The climber hiked for six hours. — The climber hiked on Saturday.

slide-40
SLIDE 40

Examples

— The climber hiked for six hours. — The climber hiked on Saturday. — The climber reached the summit on Saturday.

slide-41
SLIDE 41

Examples

— The 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:

slide-42
SLIDE 42

Examples

— The 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

slide-43
SLIDE 43

Semantic features & Parsing

— Can filter some classes of ambiguity

— Old men and women slept.

slide-44
SLIDE 44

Semantic features & Parsing

— Can filter some classes of ambiguity

— Old men and women slept. — (Old men) and (women) slept.

slide-45
SLIDE 45

Semantic features & Parsing

— Can filter some classes of ambiguity

— Old men and women slept. — (Old men) and (women) slept. — (Old (men and women)) slept.

slide-46
SLIDE 46

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. —

slide-47
SLIDE 47

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.

slide-48
SLIDE 48

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. —

slide-49
SLIDE 49

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. —

slide-50
SLIDE 50

Summary

— Features

— Enable compact representation of grammatical

constraints

— Capture basic linguistic patterns

— Unification

— Creates and maintains consistency over features

— Integration with parsing allows filtering of ill-

formed analyses