Date post: | 31-Dec-2015 |
Category: |
Documents |
Upload: | portia-roman |
View: | 34 times |
Download: | 0 times |
Parsing with Context Free Grammars
Reading Chap 13 Jurafsky amp Martin
This slide set was adapted from J Martin U Colorado
Instructor Paul Tarau based on Rada Mihalcearsquos original slides
Slide 1
Parsing
bull Parsing with CFGs refers to the task of assigning correct trees to input strings
bull Correct here means a tree that covers all and only the elements of the input and has an S at the top
bull It doesnrsquot actually mean that the system can select the correct tree from among the possible trees
bull As with everything of interest parsing involves a search that involves the making of choices
Slide 1
Some assumptions
bull Assumehellipndash You have all the words already in some bufferndash The input isisnrsquot pos taggedndash All the words are known
bull These are all (quite) feasiblendash State-of-the art in POS taggingndash ldquoall words are knownrdquo
Slide 1
Top-Down Parsing
bull Since we are trying to find trees rooted with an S (Sentences) start with the rules that give us an S
bull Then work your way down from there to the words
Slide 1
Top Down Space
Slide 1
Bottom-Up Parsing
bull Of course we also want trees that cover the input words So start with trees that link up with the words in the right way
bull Then work your way up from there
Slide 1
Bottom-Up Space
Slide 1
Top-Down VS Bottom-Up
bull Top-downndash Only searches for trees that can be answersndash But suggests trees that are not consistent with the wordsndash Guarantees that tree starts with S as rootndash Does not guarantee that tree will match input words
bull Bottom-upndash Only forms trees consistent with the wordsndash Suggest trees that make no sense globallyndash Guarantees that tree matches input wordsndash Does not guarantee that parse tree will lead to S as a root
bull Combine the advantages of the two by doing a search constrained from both sides (top and bottom)
Slide 1
Top-Down Depth-First Left-to-Right Search + Bottom-up Filtering
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Parsing
bull Parsing with CFGs refers to the task of assigning correct trees to input strings
bull Correct here means a tree that covers all and only the elements of the input and has an S at the top
bull It doesnrsquot actually mean that the system can select the correct tree from among the possible trees
bull As with everything of interest parsing involves a search that involves the making of choices
Slide 1
Some assumptions
bull Assumehellipndash You have all the words already in some bufferndash The input isisnrsquot pos taggedndash All the words are known
bull These are all (quite) feasiblendash State-of-the art in POS taggingndash ldquoall words are knownrdquo
Slide 1
Top-Down Parsing
bull Since we are trying to find trees rooted with an S (Sentences) start with the rules that give us an S
bull Then work your way down from there to the words
Slide 1
Top Down Space
Slide 1
Bottom-Up Parsing
bull Of course we also want trees that cover the input words So start with trees that link up with the words in the right way
bull Then work your way up from there
Slide 1
Bottom-Up Space
Slide 1
Top-Down VS Bottom-Up
bull Top-downndash Only searches for trees that can be answersndash But suggests trees that are not consistent with the wordsndash Guarantees that tree starts with S as rootndash Does not guarantee that tree will match input words
bull Bottom-upndash Only forms trees consistent with the wordsndash Suggest trees that make no sense globallyndash Guarantees that tree matches input wordsndash Does not guarantee that parse tree will lead to S as a root
bull Combine the advantages of the two by doing a search constrained from both sides (top and bottom)
Slide 1
Top-Down Depth-First Left-to-Right Search + Bottom-up Filtering
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Some assumptions
bull Assumehellipndash You have all the words already in some bufferndash The input isisnrsquot pos taggedndash All the words are known
bull These are all (quite) feasiblendash State-of-the art in POS taggingndash ldquoall words are knownrdquo
Slide 1
Top-Down Parsing
bull Since we are trying to find trees rooted with an S (Sentences) start with the rules that give us an S
bull Then work your way down from there to the words
Slide 1
Top Down Space
Slide 1
Bottom-Up Parsing
bull Of course we also want trees that cover the input words So start with trees that link up with the words in the right way
bull Then work your way up from there
Slide 1
Bottom-Up Space
Slide 1
Top-Down VS Bottom-Up
bull Top-downndash Only searches for trees that can be answersndash But suggests trees that are not consistent with the wordsndash Guarantees that tree starts with S as rootndash Does not guarantee that tree will match input words
bull Bottom-upndash Only forms trees consistent with the wordsndash Suggest trees that make no sense globallyndash Guarantees that tree matches input wordsndash Does not guarantee that parse tree will lead to S as a root
bull Combine the advantages of the two by doing a search constrained from both sides (top and bottom)
Slide 1
Top-Down Depth-First Left-to-Right Search + Bottom-up Filtering
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Top-Down Parsing
bull Since we are trying to find trees rooted with an S (Sentences) start with the rules that give us an S
bull Then work your way down from there to the words
Slide 1
Top Down Space
Slide 1
Bottom-Up Parsing
bull Of course we also want trees that cover the input words So start with trees that link up with the words in the right way
bull Then work your way up from there
Slide 1
Bottom-Up Space
Slide 1
Top-Down VS Bottom-Up
bull Top-downndash Only searches for trees that can be answersndash But suggests trees that are not consistent with the wordsndash Guarantees that tree starts with S as rootndash Does not guarantee that tree will match input words
bull Bottom-upndash Only forms trees consistent with the wordsndash Suggest trees that make no sense globallyndash Guarantees that tree matches input wordsndash Does not guarantee that parse tree will lead to S as a root
bull Combine the advantages of the two by doing a search constrained from both sides (top and bottom)
Slide 1
Top-Down Depth-First Left-to-Right Search + Bottom-up Filtering
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Top Down Space
Slide 1
Bottom-Up Parsing
bull Of course we also want trees that cover the input words So start with trees that link up with the words in the right way
bull Then work your way up from there
Slide 1
Bottom-Up Space
Slide 1
Top-Down VS Bottom-Up
bull Top-downndash Only searches for trees that can be answersndash But suggests trees that are not consistent with the wordsndash Guarantees that tree starts with S as rootndash Does not guarantee that tree will match input words
bull Bottom-upndash Only forms trees consistent with the wordsndash Suggest trees that make no sense globallyndash Guarantees that tree matches input wordsndash Does not guarantee that parse tree will lead to S as a root
bull Combine the advantages of the two by doing a search constrained from both sides (top and bottom)
Slide 1
Top-Down Depth-First Left-to-Right Search + Bottom-up Filtering
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Bottom-Up Parsing
bull Of course we also want trees that cover the input words So start with trees that link up with the words in the right way
bull Then work your way up from there
Slide 1
Bottom-Up Space
Slide 1
Top-Down VS Bottom-Up
bull Top-downndash Only searches for trees that can be answersndash But suggests trees that are not consistent with the wordsndash Guarantees that tree starts with S as rootndash Does not guarantee that tree will match input words
bull Bottom-upndash Only forms trees consistent with the wordsndash Suggest trees that make no sense globallyndash Guarantees that tree matches input wordsndash Does not guarantee that parse tree will lead to S as a root
bull Combine the advantages of the two by doing a search constrained from both sides (top and bottom)
Slide 1
Top-Down Depth-First Left-to-Right Search + Bottom-up Filtering
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Bottom-Up Space
Slide 1
Top-Down VS Bottom-Up
bull Top-downndash Only searches for trees that can be answersndash But suggests trees that are not consistent with the wordsndash Guarantees that tree starts with S as rootndash Does not guarantee that tree will match input words
bull Bottom-upndash Only forms trees consistent with the wordsndash Suggest trees that make no sense globallyndash Guarantees that tree matches input wordsndash Does not guarantee that parse tree will lead to S as a root
bull Combine the advantages of the two by doing a search constrained from both sides (top and bottom)
Slide 1
Top-Down Depth-First Left-to-Right Search + Bottom-up Filtering
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Top-Down VS Bottom-Up
bull Top-downndash Only searches for trees that can be answersndash But suggests trees that are not consistent with the wordsndash Guarantees that tree starts with S as rootndash Does not guarantee that tree will match input words
bull Bottom-upndash Only forms trees consistent with the wordsndash Suggest trees that make no sense globallyndash Guarantees that tree matches input wordsndash Does not guarantee that parse tree will lead to S as a root
bull Combine the advantages of the two by doing a search constrained from both sides (top and bottom)
Slide 1
Top-Down Depth-First Left-to-Right Search + Bottom-up Filtering
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Top-Down Depth-First Left-to-Right Search + Bottom-up Filtering
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flight flight
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
flightflight
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Possible Problem Left-Recursion
What happens in the following situationS -gt NP VPS -gt Aux NP VPNP -gt NP PPNP -gt Det NominalhellipWith the sentence starting with
Did the flighthellip
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Solution Rule Ordering
S -gt Aux NP VPS -gt NP VPNP -gt Det NominalNP -gt NP PP
The key for the NP is that you want the recursive option after any base case
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Avoiding Repeated Work
Parsing is hard and slow Itrsquos wasteful to redo stuff over and over and over
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
flight
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
flight
flight
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Dynamic Programming
bull We need a method that fills a table with partial results thatndash Does not do (avoidable) repeated workndash Does not fall prey to left-recursionndash Solves an exponential problem in (approximately) polynomial
time
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Earley Parsing
Fills a table in a single sweep over the input wordsTable is length N+1 N is number of wordsTable entries represent
Completed constituents and their locationsIn-progress constituentsPredicted constituents
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
States
The table-entries are called states and are represented with dotted-rulesS -gt VP A VP is predicted
NP -gt Det Nominal An NP is in progress
VP -gt V NP A VP has been found
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
StatesLocations
It would be nice to know where these things are in the input sohellipS -gt VP [00] Predictor
A VP is predicted at the start of the
sentence
NP -gt Det Nominal [12] ScannerAn NP is in progress the
Det goes from 1 to 2
VP -gt V NP [03] Completer A VP has been found
starting at 0 and ending at 3
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Graphically
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Earley
bull As with most dynamic programming approaches the answer is found by looking in the table in the right place
bull In this case there should be an S state in the final column that spans from 0 to n+1 and is complete
bull If thatrsquos the case yoursquore donendash S -gt α [0n+1]
bull So sweep through the table from 0 to n+1hellipndash Predictor New predicted states are created by states in current
chartndash Scanner New incomplete states are created by advancing
existing states as new constituents are discoveredndash Completer New complete states are created in the same way
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Earley
bull More specificallyhellip1 Predict all the states you can upfront2 Read a word
ndash Extend states based on matchesndash Add new predictionsndash Go to 2
3 Look at N+1 to see if you have a winner
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Earley and Left Recursion
bull So Earley solves the left-recursion problem without having to alter the grammar or artificially limit the searchndash Never place a state into the chart thatrsquos already therendash Copy states before advancing them
S -gt NP VPNP -gt NP PP
bull The first rule predictsS -gt NP VP [00] that addsNP -gt NP PP [00]stops there since adding any subsequent prediction would be fruitless
bull When a state gets advanced make a copy and leave the original alonendash Say we have
NP -gt NP PP [00]ndash We find an NP from 0 to 2 so we create NP -gt NP PP [02]ndash But we leave the original state as is
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example
Book that flight
We should findhellip an S from 0 to 3 that is a completed statehellip
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)
Slide 1
Example (contrsquod)