86
Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen Rambow, Dan Jurafsky and James Martin

Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Embed Size (px)

Citation preview

Page 1: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

IntroductiontoSyntaxandContext-FreeGrammars

Slides with contributions from Owen Rambow, Dan Jurafsky and James Martin

Page 2: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Announcements• Thanksforansweringpoll(60votedsofar)• Pollre-openedsopleaseanswerifyouhaven’t

• Majoritylikesinclassinterac@on•  SlimmermajorityfeelsPiazzaisusefuldespiteflaws• MajoritywouldpreferanotherplaEorm• Majoritypreferonlineques@onstoverbalones• Majoritywouldprefermorelecturetodiscussion

• Comments•  Certainkindsofques@onsaremoresuitable•  Somereallylikethepolls(e.g.,Videostudents)

Page 3: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Lookingahead• Today:grammars,ContextFreeandDependency

• Thursday:ContextFreeGrammars

• Tuesday:Dependencyparsing

• Yourhomework:Learningadependencyparser

Page 4: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

WhatisSyntax?

• Studyofstructureoflanguage

• Howwordsarearrangedinasentenceandtherela@onshipbetweenthem.

• Goal:relatesurfaceform(percep@on)toseman@cs(meaning)

Page 5: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

WhatSyntaxisNot

• Phonology:studyofsoundsystemsandhowsoundscombine

• Morphology:studyofhowwordsareformedfromsmallerparts(morphemes)

• Seman@cs:studyofmeaningoflanguage

Page 6: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Syntaxasaninterface

Morphology Syntax Semantics

Representational Device

Page 7: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Simpli<iedViewofLinguistics

⇔ /waddyasai/ Phonology

Morphology /waddyasai/ ⇔ what did you say What did you say ⇔ what do+past2ndP say

Syntax what do you say ⇔ say Q

you what

obj subj

Semantics say Q

you what

obj subj ⇔ Q[ λx. say(you, x) ]

Page 8: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

TheBigPicture Empirical Matter Formalisms

• Data structures • Formalisms (e.g., CFG) • Algorithms • Distributional Models

Maud expects there to be a riot *Teri promised there to be a riot Maud expects the shit to hit the fan *Teri promised the shit to hit the fan

Linguistic Theory

?

?

? ?

Page 9: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

WhatAboutChomsky?•  Atbirthofformallanguagetheory(compsci)andformallinguis@cs

•  Majorcontribu@on:syntaxiscogni'vereality

•  Humansabletolearnlanguagesquickly,butnotalllanguages⇒universalgrammarisbiological

•  Goalofsyntac@cstudy:finduniversalprinciplesandlanguage-specificparameters

•  SpecificChomskyantheorieschangeregularly

•  Generalideasadoptedbyalmostallcontemporarysyntac@ctheories(“principles-and-parameters-typetheories”)

Page 10: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

TypesofLinguisticTheories• Prescrip've:“prescrip@velinguis@cs”isanoxymoron•  Prescrip'vegrammar:howpeopleoughttotalk

• Descrip've:provideaccountofsyntaxofalanguage•  Descrip'vegrammar:howpeopledotalk•  oXenappropriateforNLPengineeringwork

• Explanatory:provideprinciples-and-parametersstyleaccountofsyntaxof(preferably)severallanguages

Page 11: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

TheBigPictureEmpirical Matter

Formalisms

• Data structures • Formalisms (e.g., CFG) • Algorithms • Distributional Models

Maud expects there to be a riot *Teri promised there to be a riot Maud expects the shit to hit the fan *Teri promised the shit to hit the fan

Linguistic Theory

?

?

? or

Page 12: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

NeedforSyntax• Grammarcheckers• Ques@onanswering• Informa@onextrac@on• Machinetransla@on

• Givenvariabilityinlanguage,helpstonormalize

Page 13: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

keyideasofsyntax• Cons@tuency(we’llspendmostofour@meonthis)• Subcategoriza@on• Gramma@calrela@ons• Movement/long-distancedependency

Page 14: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

StructureinStrings• Somewords:theasmallnicebigveryboygirlseeslikes

• Somegoodsentences:•  theboylikesagirl•  thesmallgirllikesthebiggirl• averysmallniceboyseesaveryniceboy

• Somebadsentences:• *theboythegirl•  *smallboylikesnicegirl

• Canwefindsubsequencesofwords(cons'tuents)whichinsomewaybehavealike?

Page 15: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

StructureinStringsProposal1

• Somewords:theasmallnicebigveryboygirlseeslikes

• Somegoodsentences:•  (the)boy(likesagirl)•  (thesmall)girl(likesthebiggirl)•  (averysmallnice)boy(seesaveryniceboy)

• Somebadsentences:•  *(the)boy(thegirl)•  *(small)boy(likesthenicegirl)

Page 16: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

StructureinStringsProposal2

•  Somewords:theasmallnicebigveryboygirlseeslikes

•  Somegoodsentences:•  (theboy)likes(agirl)•  (thesmallgirl)likes(thebiggirl)•  (averysmallniceboy)sees(averyniceboy)

•  Somebadsentences:•  *(theboy)(thegirl)•  *(smallboy)likes(thenicegirl)

Page 17: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

• Isproposal1orproposal2be8er?

• Why?

Page 18: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

MoreStructureinStrings• Somewords:theasmallnicebigveryboygirlseeslikes

• Somegoodsentences:•  ((the)boy)likes((a)girl)•  ((the)(small)girl)likes((the)(big)girl)•  ((a)((very)small)(nice)boy)sees((a)((very)nice)girl)

• Somebadsentences:•  *((the)boy)((the)girl)•  *((small)boy)likes((the)(nice)girl)

Page 19: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

FromSubstringstoTrees• (((the)boy)likes((a)girl))

boy the

likes girl

a

Page 20: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

NodeLabels?• (((the)boy)likes((a)girl))

• Choosecons@tuentssoeachonehasonenon-bracketedword:thehead

• Groupwordsbydistribu@onofcons@tuentstheyhead(part-of-speech,POS):• Noun(N),verb(V),adjec@ve(Adj),adverb(Adv),determiner(Det)

• Categoryofcons@tuent:XP,whereXisPOS• NP,S,AdjP,AdvP,DetP

Page 21: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

NodeLabels• (((the/Det)boy/N)likes/V((a/Det)girl/N))

boy

the

likes

girl

a

DetP

NP NP

DetP

S

Page 22: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

TypesofNodes• (((the/Det)boy/N)likes/V((a/Det)girl/N))

boy

the

likes

girl

a

DetP

NP NP

DetP

S

Phrase-structure tree

nonterminal symbols = constituents

terminal symbols = words

Page 23: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 24: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 25: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 26: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 27: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Constituency(Review)• E.g.,Nounphrases(NPs)

• Areddogonabluetree• Abluedogonaredtree•  Somebigdogsandsomeli8ledogs• Adog• We• Bigdogs,li8ledogs,reddogs,bluedogs,yellowdogs,greendogs,blackdogs,andwhitedogs

• Howdoweknowtheseformacons@tuent?

Page 28: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Constituency(II)

•  Theycanallappearbeforeaverb:– Somebigdogsandsomelibledogsaregoingaroundincars…

– Bigdogs,libledogs,reddogs,bluedogs,yellowdogs,greendogs,blackdogs,andwhitedogsareallatadogparty!

– Idonot•  Butindividualwordscan’talwaysappearbeforeverbs:

– *liblearegoing…– *blueare…– *andare

• Mustbeabletostategeneraliza@onslike:– Nounphrasesoccurbeforeverbs

Page 29: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Constituency(III)

•  Preposingandpostposing:• Underatreeisayellowdog.• Ayellowdogisunderatree.

• Butnot:•  *Under,isayellowdogatree.•  *Underaisayellowdogtree.

•  Preposi@onalphrasesnotableforambiguityinabachment

Page 30: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 31: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

PhraseStructureandDependencyStructure

likes/V

boy/N girl/N

the/Det a/Det boy

the

likes

girl

a

DetP

NP NP

DetP

S

All nodes are labeled with words! Only leaf nodes labeled with words!

Page 32: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

PhraseStructureandDependencyStructure(ctd)

likes/V

boy/N girl/N

the/Det a/Det boy

the

likes

girl

a

DetP

NP NP

DetP

S

Representationally equivalent if each nonterminal node has one lexical daughter (its head)

Page 33: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

TypesofDependency

likes/V

boy/N girl/N

a/Det small/Adj the/Det

very/Adv

sometimes/Adv Obj Subj

Adj(unct)

Fw Fw

Adj

Adj

Page 34: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

GrammaticalRelations• Typesofrela@onsbetweenwords

• Arguments:subject,object,indirectobject,preposi@onalobject

• Adjuncts:temporal,loca@ve,causal,manner,…

•  Func@onWords

Page 35: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Subcategorization• Listofargumentsofaword(typically,averb),withfeaturesaboutrealiza@on(POS,perhapscase,verbformetc)

• IncanonicalorderSubject-Object-IndObj• Example:

•  like:N-N,N-V(to-inf)•  see:N,N-N,N-N-V(inf)

• Note:J&Mtalkaboutsubcategoriza@ononlywithinVP

Page 36: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Subcategorizationexamples• Give

• Pretend

• Tell

• Bet

Page 37: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

WhatAbouttheVP?

boy

the

likes

girl

a

DetP

NP NP

DetP

S

boy

the

likes DetP

NP

girl

a

NP

DetP

S

VP

Page 38: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

WhatAbouttheVP?•  ExistenceofVPisalinguis@c(i.e.,empirical)claim,notamethodologicalclaim

•  Seman@cevidence???•  Syntac@cevidence

•  VP-fron@ng(andquicklycleanthecarpethedid!)•  VP-ellipsis(Hecleanedthecarpetsquickly,andsodidshe)•  CanhaveadjunctsbeforeandaXerVP,butnotinVP(HeoHeneatsbeans,*heeatsoHenbeans)

•  Note:VPcannotberepresentedinadependencyrepresenta@on

Page 39: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Context-FreeGrammars

• Definedinformallanguagetheory(compsci)

• Terminals,nonterminals,startsymbol,rules

• String-rewri@ngsystem

• Startwithstartsymbol,rewriteusingrules,donewhenonlyterminalsleX

• NOTALINGUISTICTHEORY,justaformaldevice

Page 40: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

CFG:Example• ManypossibleCFGsforEnglish,hereisanexample(fragment):•  S→NPVP•  VP→VNP•  NP→DetPN|AdjPNP•  AdjP→Adj|AdvAdjP•  N→boy|girl•  V→sees|likes•  Adj→big|small•  Adv→very•  DetP→a|the

the very small boy likes a girl

Page 41: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

DerivationsinaCFG

S→NPVPVP→VNPNP→DetPN|AdjPNPAdjP→Adj|AdvAdjPN→boy|girlV→sees|likesAdj→big|smallAdv→veryDetP→a|the

S

S

Page 42: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

DerivationsinaCFG

S→NPVPVP→VNPNP→DetPN|AdjPNPAdjP→Adj|AdvAdjPN→boy|girlV→sees|likesAdj→big|smallAdv→veryDetP→a|the

NP VP

NP

S

VP

Page 43: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

DerivationsinaCFG

S→NPVPVP→VNPNP→DetPN|AdjPNPAdjP→Adj|AdvAdjPN→boy|girlV→sees|likesAdj→big|smallAdv→veryDetP→a|the

DetP N VP

DetP

NP

S

VP

N

Page 44: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

DerivationsinaCFG

S→NPVPVP→VNPNP→DetPN|AdjPNPAdjP→Adj|AdvAdjPN→boy|girlV→sees|likesAdj→big|smallAdv→veryDetP→a|the

the boy VP

boy the

DetP

NP

S

VP

N

Page 45: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

DerivationsinaCFG

S→NPVPVP→VNPNP→DetPN|AdjPNPAdjP→Adj|AdvAdjPN→boy|girlV→sees|likesAdj→big|smallAdv→veryDetP→a|the

the boy likes NP

boy the likes

DetP

NP

NP

S

VP

N V

Page 46: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

DerivationsinaCFG

S→NPVPVP→VNPNP→DetPN|AdjPNPAdjP→Adj|AdvAdjPN→boy|girlV→sees|likesAdj→big|smallAdv→veryDetP→a|the

the boy likes a girl

boy the likes

DetP

NP

girl a

NP

DetP

S

VP

N

N

V

Page 47: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

DerivationsinaCFG;OrderofDerivationIrrelevant

S→NPVPVP→VNPNP→DetPN|AdjPNPAdjP→Adj|AdvAdjPN→boy|girlV→sees|likesAdj→big|smallAdv→veryDetP→a|the

NP likes DetP girl

likes

NP

girl

NP

DetP

S

VP

N

V

Page 48: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

DerivationsofCFGs• Stringrewri@ngsystem:wederiveastring(=derivedstructure)

• Butderiva@onhistoryrepresentedbyphrase-structuretree(=deriva'onstructure)!

boy the likes

DetP NP

girl a

NP

DetP

S

VP

N

N

V the boy likes a girl

Page 49: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

FormalDe<initionofaCFGG=(V,T,P,S)

• V:finitesetofnonterminalsymbols

•  T:finitesetofterminalsymbols,VandTaredisjoint

• P:finitesetofproduc@onsoftheformA→α,A∈Vandα∈(T∪V)*

•  S∈V:startsymbol

Page 50: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Context?•  Theno@onofcontextinCFGshasnothingtodowiththeordinarymeaningofthewordcontextinlanguage

• Allitreallymeansisthatthenon-terminalontheleX-handsideofaruleisoutthereallbyitself(freeofcontext)A->BCMeansthatIcanrewriteanAasaBfollowedbyaCregardlessofthecontextinwhichAisfound

Page 51: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

KeyConstituents(English)• Sentences• Nounphrases• Verbphrases• Preposi@onalphrases

Page 52: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 53: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 54: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 55: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Sentence-Types

• Declara@ves:Idonot.S->NPVP

•  Impera@ves:Godogs!Go!S->VP

• Yes-NoQues@ons:Doyoulikemyhat?S->AuxNPVP

• WHQues@ons:Whataretheygoingtodo?S->WHAuxNPVP

Page 56: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

NPs•  NP->Pronoun

•  Icame,yousawit,theyconquered•  NP->Proper-Noun

•  NewJerseyiswestofNewYorkCity•  LeeBollingeristhepresidentofColumbia

•  NP->DetNoun•  Thepresident

•  NP->Nominal•  Nominal->NounNoun

•  AmorningflighttoDenver

Page 57: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

NPs•  NP->Pronoun

•  Icame,yousawit,theyconquered•  NP->Proper-Noun

•  NewJerseyiswestofNewYorkCity•  LeeBollingeristhepresidentofColumbia

•  NP->DetNoun•  Thepresident

•  NP->Nominal•  Nominal->NounNoun

•  AmorningflighttoDenver

What other types of nominals do you find in English? Give examples.

Page 58: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

PPs• PP->Preposi@onNP

• Overthehouse• Underthehouse•  Tothetree• Atplay• Atapartyonaboatatnight

Page 59: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 60: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen
Page 61: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

It is hot out here in the sun. It is not hot here under the house. What is “here”?

Page 62: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Recursion• We’llhavetodealwithrulessuchasthefollowingwherethenon-terminalontheleXalsoappearssomewhereontheright(directly)NP->NPPP [[Theflight][toBoston]]VP->VPPP [[departedMiami][atnoon]]

(indirectly)NP->NPSrelSrel->NPVP[[thedog][[thecat]likes]]

Page 63: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Recursion

• Ofcourse,thisiswhatmakessyntaxinteres@ngThedogbitesThedogthemousebitbitesThedogthemousethecatatebitbites

Page 64: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Recursion

[[Flights][fromDenver]][[[Flights][fromDenver]][toMiami]][[[[Flights][fromDenver]][toMiami]][inFebruary]][[[[[Flights][fromDenver]][toMiami]][inFebruary]][onaFriday]]

Etc.NP->NPPP

Page 65: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

ImplicationsofRecursionandContext-Freeness•  VP->VNP•  (I)hate

flightsfromDenverflightsfromDenvertoMiamiflightsfromDenvertoMiamiinFebruaryflightsfromDenvertoMiamiinFebruaryonaFridayflightsfromDenvertoMiamiinFebruaryonaFridayunder$300flightsfromDenvertoMiamiinFebruaryonaFridayunder$300withlunch

•  Thisiswhycontext-freegrammarsareappealing!IfyouhavearulelikeVP->VNP•  ItonlycaresthatthethingaXertheverbisanNPItdoesn’thavetoknowabouttheinternalaffairsofthatNP

Page 66: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

GrammarEquivalence• Canhavedifferentgrammarsthatgeneratesamesetofstrings(weakequivalence)•  Grammar1:NP→DetPNandDetP→a|the•  Grammar2:NP→aN|NP→theN

• Canhavedifferentgrammarsthathavesamesetofderiva@ontrees(strongequivalence)• WithCFGs,possibleonlywithuselessrules•  Grammar2:NP→aN|NP→theN•  Grammar3:NP→aN|NP→theN,DetP→many

• Strongequivalenceimpliesweakequivalence

Page 67: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

NormalForms&c• Thereareweaklyequivalentnormalforms(ChomskyNormalForm,GreibachNormalForm)

• Therearewaystoeliminateuselessproduc@onsandsoon

Page 68: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

ChomskyNormalFormACFGisinChomskyNormalForm(CNF)ifallproduc@onsareofoneoftwoforms:

•  A→BCwithA,B,Cnonterminals•  A→a,withAanonterminalandaaterminal

EveryCFGhasaweaklyequivalentCFGinCNF

Page 69: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

“GenerativeGrammar”• Formallanguages:formaldevicetogenerateasetofstrings(suchasaCFG)

• Linguis@cs(Chomskyanlinguis@csinpar@cular):approachinwhichalinguis@ctheoryenumeratesallpossiblestrings/structuresinalanguage(=competence)

• Chomskyantheoriesdonotreallyuseformaldevices–theyuseCFG+informallydefinedtransforma@ons

Page 70: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

NobodyUsesSimpleCFGs(ExceptIntroNLPCourses)

• Allmajorsyntac@ctheories(Chomsky,LFG,HPSG,TAG-basedtheories)representbothphrasestructureanddependency,inonewayoranother

• Allsuccessfulparserscurrentlyusesta@s@csaboutphrasestructureandaboutdependency

• Derivedependencythrough“headpercola@on”:foreachrule,saywhichdaughterishead

Page 71: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

MassiveAmbiguityofSyntax• Forastandardsentence,andagrammarwithwidecoverage,thereare1000sofderiva@ons!

• Example:•  Thelargeportraitpaintertoldthedelega@onthathesentmoneyordersinaleberonWednesday

Page 72: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

PennTreebank(PTB)• Syntac@callyannotatedcorpusofnewspapertexts(phrasestructure)

• Thenewspapertextsarenaturallyoccurringdata,butthePTBisnot!

• PTBannota@onrepresentsapar@cularlinguis@ctheory(butafairly“vanilla”one)

• Par@culari@es•  Veryindirectrepresenta@onofgramma@calrela@ons(needforheadpercola@ontables)

•  CompletelyflatstructureinNP(brownbaglunch,pink-and-yellowchildseat)

•  HasflatSs,flatVPs

Page 73: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

ExamplefromPTB((S(NP-SBJIt)(VP's(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) : (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) , (NP(NPthose (ADJPpubliclytraded) porEolios) (SBAR(WHNP-37that) (S(NP-SBJ*T*-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))

Page 74: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions• Isthisthesameconstruc@on?

• Anelfdecidedtocleanthekitchen• AnelfseemedtocleanthekitchenAnelfcleanedthekitchen

• Isthisthesameconstruc@on?• Anelfdecidedtobeinthekitchen• AnelfseemedtobeinthekitchenAnelfwasinthekitchen

Page 75: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions(ctd)

• Isthisthesameconstruc@on?Thereisanelfinthekitchen•  Theredecidedtobeanelfinthekitchen•  Thereseemedtobeanelfinthekitchen

• Isthisthesameconstruc@on?Itisraining/itrains•  Itdecidedtorain/beraining•  Itseemedtorain/beraining

Page 76: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions(ctd)

• Isthisthesameconstruc@on?• Anelfdecidedthathewouldcleanthekitchen•  AnelfseemedthathewouldcleanthekitchenAnelfcleanedthekitchen

Page 77: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions(ctd)Conclusion:• toseem:whateverisembeddedsurfacesubjectcanappearinupperclause

• todecide:onlyfullnounsthatarereferen@alcanappearinupperclause

• Twotypesofverbs

Page 78: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions:Analysis

an elf

S

NP VP

V

to decide

S

NP VP

V

to be

PP

in the kitchen

S

VP

V

to seem

S

NP VP

V

to be

PP

in the kitchen

an elf an elf

Page 79: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions:Analysis

an elf

S

NP VP

V

decided

S

NP

PRO

VP

V

to be

PP

in the kitchen

S

VP

V

seemed

S

NP VP

V

to be

PP

in the kitchen

an elf

Page 80: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions:Analysis

an elf

S

NP VP

V

decided

S

NP

PRO

VP

V

to be

PP

in the kitchen

S

VP

V

seemed

S

NP VP

V

to be

PP

in the kitchen

an elf

Page 81: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions:Analysis

an elf

S

NP VP

V

decided

S

NP

PRO

VP

V

to be

PP

in the kitchen

S

NPi VP

V

seemed

S

NP VP

V

to be

PP

in the kitchen

an elf

ti

Page 82: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions:Analysis

toseem:lowersurfacesubjectraisestoupperclause;raisingverbseems(theretobeanelfinthekitchen)thereseems(ttobeanelfinthekitchen)itseems(thereisanelfinthekitchen)

Page 83: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

Typesofsyntacticconstructions:Analysis(ctd)

• todecide:subjectisinupperclauseandco-referswithanemptysubjectinlowerclause;controlverb

anelfdecided(anelftocleanthekitchen)anelfdecided(PROtocleanthekitchen)anelfdecided(hecleans/shouldcleanthekitchen)*itdecided(anelfcleans/shouldcleanthekitchen)

Page 84: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

LessonsLearnedfromtheRaising/ControlIssue• Usedistribu@onofdatatogroupphenomenaintoclasses

• Usedifferentunderlyingstructureasbasisforexplana@ons

• Allowthingsto“move”aroundfromunderlyingstructure->transforma'onalgrammar

• Checkwhetherexplana@onyougivemakespredic@ons

Page 85: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

ExamplesfromPTB(S(NP-SBJ-1Theropes)(VPseem(S(NP-SBJ*-1)(VPto(VPmake(NPmuchsound))))))(S(NP-SBJ-1Theancientchurchvicar)(VPrefuses(S(NP-SBJ*-1)(VPto(VPtalk(PP-CLRabout (NPit)))))

Page 86: Introduction to Syntax and Context-Free Grammarskathy/NLP/2017/ClassSlides/Class7-Syntax/... · Introduction to Syntax and Context-Free Grammars Slides with contributions from Owen

TheBigPicture Empirical Matter

Formalisms

• Data structures • Formalisms • Algorithms • Distributional Models

Maud expects there to be a riot *Teri promised there to be a riot Maud expects the shit to hit the fan *Teri promised the shit to hit the

or

Linguistic Theory Content: Relate morphology to semantics •  Surface representation (eg, ps) •  Deep representation (eg, dep) •  Correspondence

uses

descriptive theory is

about

explanatory theory is about

predicts