Upload
others
View
16
Download
0
Embed Size (px)
Citation preview
BasicParsingwithContext-FreeGrammars
1 Some slides adapted from Julia Hirschberg and Dan Jurafsky
Announcementsbull HW2togoouttodayNextTuesdaymostimportantforbackgroundtoassignment
bull Signupforpolleverywhere
bull Todaywrap-upfromlastclassandstartonparsing
2
Wrap-uponsyntax
3
GrammarEquivalencebull Canhavedifferentgrammarsthatgeneratesamesetofstrings(weakequivalence)bull Grammar1NPrarrDetPNandDetPrarra|thebull Grammar2NPrarraN|NPrarrtheN
bull CanhavedifferentgrammarsthathavesamesetofderivaLontrees(strongequivalence)bull WithCFGspossibleonlywithuselessrulesbull Grammar2NPrarraN|NPrarrtheNbull Grammar3NPrarraN|NPrarrtheNDetPrarrmany
bull Strongequivalenceimpliesweakequivalence
NormalFormsampcbull Thereareweaklyequivalentnormalforms(ChomskyNormalFormGreibachNormalForm)
bull TherearewaystoeliminateuselessproducLonsandsoon
ChomskyNormalFormACFGisinChomskyNormalForm(CNF)ifallproducLonsareofoneoftwoforms
bull ArarrBCwithABCnonterminalsbull ArarrawithAanonterminalandaaterminal
EveryCFGhasaweaklyequivalentCFGinCNF
NobodyUsesSimpleCFGs(ExceptIntroNLPCourses)
bull AllmajorsyntacLctheories(ChomskyLFGHPSGTAG-basedtheories)representbothphrasestructureanddependencyinonewayoranother
bull AllsuccessfulparserscurrentlyusestaLsLcsaboutphrasestructureandaboutdependency
bull DerivedependencythroughldquoheadpercolaLonrdquoforeachrulesaywhichdaughterishead
MassiveAmbiguityofSyntaxbull Forastandardsentenceandagrammarwithwidecoveragethereare1000sofderivaLons
bull Examplebull ThelargeportraitpaintertoldthedelegaLonthathesentmoneyordersinaleYeronWednesday
9
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Announcementsbull HW2togoouttodayNextTuesdaymostimportantforbackgroundtoassignment
bull Signupforpolleverywhere
bull Todaywrap-upfromlastclassandstartonparsing
2
Wrap-uponsyntax
3
GrammarEquivalencebull Canhavedifferentgrammarsthatgeneratesamesetofstrings(weakequivalence)bull Grammar1NPrarrDetPNandDetPrarra|thebull Grammar2NPrarraN|NPrarrtheN
bull CanhavedifferentgrammarsthathavesamesetofderivaLontrees(strongequivalence)bull WithCFGspossibleonlywithuselessrulesbull Grammar2NPrarraN|NPrarrtheNbull Grammar3NPrarraN|NPrarrtheNDetPrarrmany
bull Strongequivalenceimpliesweakequivalence
NormalFormsampcbull Thereareweaklyequivalentnormalforms(ChomskyNormalFormGreibachNormalForm)
bull TherearewaystoeliminateuselessproducLonsandsoon
ChomskyNormalFormACFGisinChomskyNormalForm(CNF)ifallproducLonsareofoneoftwoforms
bull ArarrBCwithABCnonterminalsbull ArarrawithAanonterminalandaaterminal
EveryCFGhasaweaklyequivalentCFGinCNF
NobodyUsesSimpleCFGs(ExceptIntroNLPCourses)
bull AllmajorsyntacLctheories(ChomskyLFGHPSGTAG-basedtheories)representbothphrasestructureanddependencyinonewayoranother
bull AllsuccessfulparserscurrentlyusestaLsLcsaboutphrasestructureandaboutdependency
bull DerivedependencythroughldquoheadpercolaLonrdquoforeachrulesaywhichdaughterishead
MassiveAmbiguityofSyntaxbull Forastandardsentenceandagrammarwithwidecoveragethereare1000sofderivaLons
bull Examplebull ThelargeportraitpaintertoldthedelegaLonthathesentmoneyordersinaleYeronWednesday
9
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Wrap-uponsyntax
3
GrammarEquivalencebull Canhavedifferentgrammarsthatgeneratesamesetofstrings(weakequivalence)bull Grammar1NPrarrDetPNandDetPrarra|thebull Grammar2NPrarraN|NPrarrtheN
bull CanhavedifferentgrammarsthathavesamesetofderivaLontrees(strongequivalence)bull WithCFGspossibleonlywithuselessrulesbull Grammar2NPrarraN|NPrarrtheNbull Grammar3NPrarraN|NPrarrtheNDetPrarrmany
bull Strongequivalenceimpliesweakequivalence
NormalFormsampcbull Thereareweaklyequivalentnormalforms(ChomskyNormalFormGreibachNormalForm)
bull TherearewaystoeliminateuselessproducLonsandsoon
ChomskyNormalFormACFGisinChomskyNormalForm(CNF)ifallproducLonsareofoneoftwoforms
bull ArarrBCwithABCnonterminalsbull ArarrawithAanonterminalandaaterminal
EveryCFGhasaweaklyequivalentCFGinCNF
NobodyUsesSimpleCFGs(ExceptIntroNLPCourses)
bull AllmajorsyntacLctheories(ChomskyLFGHPSGTAG-basedtheories)representbothphrasestructureanddependencyinonewayoranother
bull AllsuccessfulparserscurrentlyusestaLsLcsaboutphrasestructureandaboutdependency
bull DerivedependencythroughldquoheadpercolaLonrdquoforeachrulesaywhichdaughterishead
MassiveAmbiguityofSyntaxbull Forastandardsentenceandagrammarwithwidecoveragethereare1000sofderivaLons
bull Examplebull ThelargeportraitpaintertoldthedelegaLonthathesentmoneyordersinaleYeronWednesday
9
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
GrammarEquivalencebull Canhavedifferentgrammarsthatgeneratesamesetofstrings(weakequivalence)bull Grammar1NPrarrDetPNandDetPrarra|thebull Grammar2NPrarraN|NPrarrtheN
bull CanhavedifferentgrammarsthathavesamesetofderivaLontrees(strongequivalence)bull WithCFGspossibleonlywithuselessrulesbull Grammar2NPrarraN|NPrarrtheNbull Grammar3NPrarraN|NPrarrtheNDetPrarrmany
bull Strongequivalenceimpliesweakequivalence
NormalFormsampcbull Thereareweaklyequivalentnormalforms(ChomskyNormalFormGreibachNormalForm)
bull TherearewaystoeliminateuselessproducLonsandsoon
ChomskyNormalFormACFGisinChomskyNormalForm(CNF)ifallproducLonsareofoneoftwoforms
bull ArarrBCwithABCnonterminalsbull ArarrawithAanonterminalandaaterminal
EveryCFGhasaweaklyequivalentCFGinCNF
NobodyUsesSimpleCFGs(ExceptIntroNLPCourses)
bull AllmajorsyntacLctheories(ChomskyLFGHPSGTAG-basedtheories)representbothphrasestructureanddependencyinonewayoranother
bull AllsuccessfulparserscurrentlyusestaLsLcsaboutphrasestructureandaboutdependency
bull DerivedependencythroughldquoheadpercolaLonrdquoforeachrulesaywhichdaughterishead
MassiveAmbiguityofSyntaxbull Forastandardsentenceandagrammarwithwidecoveragethereare1000sofderivaLons
bull Examplebull ThelargeportraitpaintertoldthedelegaLonthathesentmoneyordersinaleYeronWednesday
9
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
NormalFormsampcbull Thereareweaklyequivalentnormalforms(ChomskyNormalFormGreibachNormalForm)
bull TherearewaystoeliminateuselessproducLonsandsoon
ChomskyNormalFormACFGisinChomskyNormalForm(CNF)ifallproducLonsareofoneoftwoforms
bull ArarrBCwithABCnonterminalsbull ArarrawithAanonterminalandaaterminal
EveryCFGhasaweaklyequivalentCFGinCNF
NobodyUsesSimpleCFGs(ExceptIntroNLPCourses)
bull AllmajorsyntacLctheories(ChomskyLFGHPSGTAG-basedtheories)representbothphrasestructureanddependencyinonewayoranother
bull AllsuccessfulparserscurrentlyusestaLsLcsaboutphrasestructureandaboutdependency
bull DerivedependencythroughldquoheadpercolaLonrdquoforeachrulesaywhichdaughterishead
MassiveAmbiguityofSyntaxbull Forastandardsentenceandagrammarwithwidecoveragethereare1000sofderivaLons
bull Examplebull ThelargeportraitpaintertoldthedelegaLonthathesentmoneyordersinaleYeronWednesday
9
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
ChomskyNormalFormACFGisinChomskyNormalForm(CNF)ifallproducLonsareofoneoftwoforms
bull ArarrBCwithABCnonterminalsbull ArarrawithAanonterminalandaaterminal
EveryCFGhasaweaklyequivalentCFGinCNF
NobodyUsesSimpleCFGs(ExceptIntroNLPCourses)
bull AllmajorsyntacLctheories(ChomskyLFGHPSGTAG-basedtheories)representbothphrasestructureanddependencyinonewayoranother
bull AllsuccessfulparserscurrentlyusestaLsLcsaboutphrasestructureandaboutdependency
bull DerivedependencythroughldquoheadpercolaLonrdquoforeachrulesaywhichdaughterishead
MassiveAmbiguityofSyntaxbull Forastandardsentenceandagrammarwithwidecoveragethereare1000sofderivaLons
bull Examplebull ThelargeportraitpaintertoldthedelegaLonthathesentmoneyordersinaleYeronWednesday
9
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
NobodyUsesSimpleCFGs(ExceptIntroNLPCourses)
bull AllmajorsyntacLctheories(ChomskyLFGHPSGTAG-basedtheories)representbothphrasestructureanddependencyinonewayoranother
bull AllsuccessfulparserscurrentlyusestaLsLcsaboutphrasestructureandaboutdependency
bull DerivedependencythroughldquoheadpercolaLonrdquoforeachrulesaywhichdaughterishead
MassiveAmbiguityofSyntaxbull Forastandardsentenceandagrammarwithwidecoveragethereare1000sofderivaLons
bull Examplebull ThelargeportraitpaintertoldthedelegaLonthathesentmoneyordersinaleYeronWednesday
9
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
MassiveAmbiguityofSyntaxbull Forastandardsentenceandagrammarwithwidecoveragethereare1000sofderivaLons
bull Examplebull ThelargeportraitpaintertoldthedelegaLonthathesentmoneyordersinaleYeronWednesday
9
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
9
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
10
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
PennTreebank(PTB)bull SyntacLcallyannotatedcorpusofnewspapertexts(phrasestructure)
bull ThenewspapertextsarenaturallyoccurringdatabutthePTBisnot
bull PTBannotaLonrepresentsaparLcularlinguisLctheory(butafairlyldquovanillardquoone)
bull ParLculariLesbull VeryindirectrepresentaLonofgrammaLcalrelaLons(needforheadpercolaLontables)
bull CompletelyflatstructureinNP(brownbaglunchpink-and-yellowchildseat)
bull HasflatSsflatVPs
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
ExamplefromPTB((S(NP-SBJIt)(VPs(NP-PRD(NP(NPthelatestinvestmentcraze) (VPsweeping (NPWallStreet))) (NP(NParash) (PPof (NP(NPnewclosed-endcountryfunds) (NP(NPthose (ADJPpubliclytraded) poraolios) (SBAR(WHNP-37that) (S(NP-SBJT-37) (VPinvest (PP-CLRin (NP(NPstocks) (PPof (NPasingleforeigncountry)))))))))))
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
SyntacticParsing
13
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
SyntacticParsingbull DeclaraLveformalismslikeCFGsFSAsdefinethelegalstringsofalanguage--butonlytellyoulsquothisisalegalstringofthelanguageXrsquo
bull Parsingalgorithmsspecifyhowtorecognizethestringsofalanguageandassigneachstringone(ormore)syntacLcanalyses
14
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
CFGExamplebull ManypossibleCFGsforEnglishhereisanexample(fragment)
bull SrarrNPVPbull VPrarrVNPbull NPrarrDetN|AdjNPbull Nrarrboy|girlbull Vrarrsees|likesbull Adjrarrbig|smallbull DetPrarra|the
bull bigthesmallgirlseesaboybull Johnlikesagirlbull Ilikeagirlbull Isleepbull Theolddogthefootstepsoftheyoung
the small boy likes a girl
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
ModiMiedCFGS agrave NP VP VP agrave V S agrave Aux NP VP VP -gt V PP S -gt VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
NP -gt Pronoun Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Parse Tree for lsquoThe old dog the footsteps of the youngrsquo for Prior CFG
S
NP VP
NP V
DET NOM
N PP
DET NOM
N
The old dog the
footsteps of the young
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
ParsingasaFormofSearchbull SearchingFSAs
bull Findingtherightpaththroughtheautomatonbull SearchspacedefinedbystructureofFSA
bull SearchingCFGsbull Findingtherightparsetreeamongallpossibleparsetrees
bull Searchspacedefinedbythegrammar
bull Constraintsprovidedbytheinputsentenceandtheautomatonorgrammar 18
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Top-DownParserbull BuildsfromtherootSnodetotheleavesbull ExpectaLon-basedbull Commonsearchstrategy
bull Top-downlei-to-rightbacktrackingbull TryfirstrulewithLHS=Sbull NextexpandallconsLtuentsinthesetreesrulesbull ConLnueunLlleavesarePOSbull BacktrackwhencandidatePOSdoesnotmatchinputstring 19
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
RuleExpansionbull ldquoTheolddogthefootstepsoftheyoungrdquo
bull Wheredoesbacktrackinghappen
bull WhatarethecomputaLonaldisadvantages
bull Whataretheadvantages
20
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
21
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Bottom-UpParsingbull ParserbeginswithwordsofinputandbuildsuptreesapplyinggrammarruleswhoseRHSmatches DetNVDetNPrepDetN TheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN TheolddogthefootstepsoftheyoungParseconLnuesunLlanSrootnodereachedornofurthernodeexpansionpossible
22
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
DetNVDetNPrepDetNTheolddogthefootstepsoftheyoungDetAdjNDetNPrepDetN
23
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Bottom-upparsingbull WhendoesdisambiguaLonoccur
bull WhatarethecomputaLonaladvantagesanddisadvantages
24
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
25
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Whatrsquosrightwrongwithhellip
bull Top-Downparsersndashtheyneverexploreillegalparses(egwhichcanrsquotformanS)--butwasteLmeontreesthatcannevermatchtheinput
bull BoYom-Upparsersndashtheyneverexploretreesinconsistentwithinput--butwasteLmeexploringillegalparses(withnoSroot)
bull Forbothfindacontrolstrategy--howexploresearchspaceefficientlybull Pursuingallparsesinparallelorbacktrackorhellipbull Whichruletoapplynextbull Whichnodetoexpandnext 26
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
SomeSolutionsDynamicProgrammingApproachesndashUseacharttorepresentparltalresults
bull CKYParsingAlgorithmbull BoYom-upbull GrammarmustbeinNormalFormbull TheparsetreemightnotbeconsistentwithlinguisLctheory
bull EarlyParsingAlgorithmbull Top-downbull ExpectaLonsaboutconsLtuentsareconfirmedbyinputbull APOStagforawordthatisnotpredictedisneveradded
bull ChartParser 27
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
EarleyParsingbull AllowsarbitraryCFGsbull Fillsatableinasinglesweepovertheinputwordsbull TableislengthN+1Nisnumberofwordsbull Tableentriesrepresent
bull CompletedconsLtuentsandtheirlocaLonsbull In-progressconsLtuentsbull PredictedconsLtuents 28
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Statesbull Thetable-entriesarecalledstatesandarerepresentedwithdoYed-rulesS-gtVP AVPispredicted
NP-gtDetNominal AnNPisinprogress
VP-gtVNP AVPhasbeenfound
29
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
StatesLocationsbull ItwouldbenicetoknowwherethesethingsareintheinputsohellipS-gtVP[00] AVPispredictedatthe
startofthesentence
NP-gtDetNominal[12] AnNPisinprogressthe Detgoesfrom1to2
VP-gtVNP [03] AVPhasbeenfound starLngat0andendingat3
30
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Graphically
31
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Earleybull Aswithmostdynamicprogrammingapproachestheanswerisfoundbylookinginthetableintherightplace
bull InthiscasethereshouldbeanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
32
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
EarleyAlgorithmbull Marchthroughchartlei-to-rightbull Ateachstepapply1of3operators
bull Predictorbull CreatenewstatesrepresenLngtop-downexpectaLons
bull Scannerbull MatchwordpredicLons(rulewithwordaierdot)towords
bull Completerbull WhenastateiscompleteseewhatruleswerelookingforthatcompletedconsLtuent
33
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Predictorbull Givenastate
bull Withanon-terminaltorightofdot(notapart-of-speechcategory)
bull Createanewstateforeachexpansionofthenon-terminalbull PlacethesenewstatesintosamechartentryasgeneratedstatebeginningandendingwheregeneraLngstateends
bull Sopredictorlookingatbull S-gtVP[00]
bull resultsinbull VP-gtVerb[00]bull VP-gtVerbNP[00]
34
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Scannerbull Givenastate
bull Withanon-terminaltorightofdotthatisapart-of-speechcategory
bull IfthenextwordintheinputmatchesthisPOSbull Createanewstatewithdotmovedoverthenon-terminalbull SoscannerlookingatVP-gtVerbNP[00]bull Ifthenextwordldquobookrdquocanbeaverbaddnewstate
bull VP-gtVerbNP[01]bull Addthisstatetochartentryfollowingcurrentonebull NoteEarleyalgorithmusestop-downinputtodisambiguatePOSOnlyPOSpredictedbysomestatecangetaddedtochart
35
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Completerbull Appliedtoastatewhenitsdothasreachedrightendofrole
bull Parserhasdiscoveredacategoryoversomespanofinput
bull Findandadvanceallpreviousstatesthatwerelookingforthiscategorybull copystatemovedotinsertincurrentchartentry
bull Givenbull NP-gtDetNominal[13]bull VP-gtVerbNP[01]
bull Addbull VP-gtVerbNP[03] 36
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Howdoweknowwearedonebull FindanSstateinthefinalcolumnthatspansfrom0ton+1andiscomplete
bull Ifthatrsquosthecaseyoursquoredonebull Sndashgtα[0n+1]
37
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Earleybull Morespecificallyhellip
1 Predictallthestatesyoucanupfront
2 Readaword
1 Extendstatesbasedonmatches2 AddnewpredicLons3 Goto2
3 LookatN+1toseeifyouhaveawinner 38
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Examplebull Bookthatflightbull WeshouldfindhellipanSfrom0to3thatisacompletedstatehellip
39
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
CFGforFragmentofEnglishS agrave NP VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN V agrave dog | include | prefer | book
Nom -gt Adj Nom Aux agrave does Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
S agrave NP VP S -gt VP VP agrave V S agrave Aux NP VP PP -gt Prep NP NP agrave Det Nom
N agrave old | dog | footsteps | young | flight
NP agravePropN NP -gt Pro
V agrave dog | include | prefer | book Aux agrave does
Nom agrave N Prep agravefrom | to | on | of Nom agrave N Nom PropN agrave Bush | McCain |
Obama Nom agrave Nom PP Det agrave that | this | a| the VP agrave V NP VP -gt V NP PP VP -gt V PP VP -gt VP PP
Adj -gt old | green | red
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Example
43
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Example
44
Completer
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Example
45
Completer
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Example
46
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Detailsbull Whatkindofalgorithmsdidwejustdescribebull Notparsersndashrecognizers
bull ThepresenceofanSstatewiththerightaYributesintherightplaceindicatesasuccessfulrecogniLon
bull Butnoparsetreehellipnoparserbull Thatrsquoshowwesolve(not)anexponenLalprobleminpolynomialLme
47
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
ConvertingEarleyfromRecognizertoParserbull WiththeaddiLonofafewpointerswehaveaparser
bull AugmenttheldquoCompleterrdquotopointtowherewecamefrom
48
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
Augmentingthechartwithstructuralinformation
S8 S9
S10
S11
S13 S12
S8
S9 S8
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
RetrievingParseTreesfromChartbull Allthepossibleparsesforaninputareinthetable
bull WejustneedtoreadoffallthebackpointersfromeverycompleteSinthelastcolumnofthetable
bull FindalltheS-gtX[0N+1]
bull FollowthestructuraltracesfromtheCompleter
bull OfcoursethiswonrsquotbepolynomialLmesincetherecouldbeanexponenLalnumberoftrees
bull Wecanatleastrepresentambiguityefficiently 50
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
LeftRecursionvsRightRecursion
bull Depth-firstsearchwillneverterminateifgrammarisle9recursive(egNP--gtNPPP)
51
)( εαα ⎯rarr⎯ΑΒ⎯rarr⎯Α
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
bull SoluLonsbull Rewritethegrammar(automaLcally)toaweaklyequivalentonewhichisnotlei-recursiveegThemanonthehillwiththetelescopehellipNPagraveNPPP(wantedNomplusasequenceofPPs)NPagraveNomPPNPagraveNomNomagraveDetNhellipbecomeshellipNPagraveNomNPrsquoNomagraveDetNNPrsquoagravePPNPrsquo(wantedasequenceofPPs)NPrsquoagraveebull Notsoobviouswhattheserulesmeanhellip
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
bull Hardertodetectandeliminatenon-immediatele9recursion
bull NP--gtNomPPbull Nom--gtNP
bull Fixdepthofsearchexplicitly
bull Ruleorderingnon-recursiverulesfirstbull NP--gtDetNombull NP--gtNPPP
53
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
AnotherProblemStructuralambiguity
bull MulLplelegalstructuresbull AYachment(egIsawamanonahillwithatelescope)
bull CoordinaLon(egyoungercatsanddogs)bull NPbrackeLng(egSpanishlanguageteachers)
54
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
55
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
56
NP vs VP Attachment
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
bull SoluLonbull Returnallpossibleparsesanddisambiguateusingldquoothermethodsrdquo
57
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58
SummingUpbull Parsingisasearchproblemwhichmaybeimplementedwithmanycontrolstrategiesbull Top-DownorBoYom-Upapproacheseachhaveproblemsbull Combiningthetwosolvessomebutnotallissues
bull Leirecursionbull SyntacLcambiguity
58