Syntactic and Dependency Parsing
Syntactic and Dependency Parsing
Department of Computer
Science
University of Illinois at
Chicago
Syntactic and
Ben-Gurion University’s NLP course
(https://www.cs.bgu.ac.il/~michaluz/seminar/CK
Y1.pdf ).
Dependency Parsing
What is The process of automatically recognizing
syntactic sentences and assigning syntactic
parsing?
(grammatical) structure to them.
• Lots of reasons!
• Grammar checking
• Sentences that can’t be parsed may be grammatically incorrect (or at least hard
to read)
• Semantic analysis
• Downstream applications
• Question answering
• Information extraction
S S
NP VP NP VP
PRP VP NP PRP VP PP
I VBP NP PP I VP NP PP NP
with chopsticks
S → NP VP
S → Aux NP VP
Nominal Nominal Nominal
S → VP
NP → Pronoun
Noun Det Noun Verb Det Noun
NP → Proper-Noun
NP → Det Nominal book that flight book that flight
Nominal → Noun
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb
VP → Verb NP
VP → Verb NP PP
VP → Verb PP
VP → VP PP
PP → Preposition NP
9/17/19 Natalie Parde - UIC CS 421 24
Bottom-Up Parsing: Example
Book that flight.
S → NP VP NP NP
S → Aux NP VP
Nominal Nominal VP Nominal Nominal
S → VP
NP → Pronoun
Noun Det Noun Verb Det Noun Verb Det Noun
NP → Proper-Noun
NP → Det Nominal book that flight book that flight book that flight
Nominal → Noun
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb
VP → Verb NP
VP → Verb NP PP
VP → Verb PP
VP → VP PP
PP → Preposition NP
9/17/19 Natalie Parde - UIC CS 421 25
Bottom-Up Parsing: Example
Book that flight.
S → NP VP VP
S → Aux NP VP
S → VP NP NP NP
NP → Pronoun
NP → Proper-Noun Nominal Nominal VP Nominal Nominal
NP → Det Nominal
Nominal → Noun Noun Det Noun Verb Det Noun Verb Det Noun
Nominal → Nominal Noun
Nominal → Nominal PP book that flight book that flight book that flight
VP → Verb
VP → Verb NP
VP → Verb NP PP
VP → Verb PP
VP → VP PP
PP → Preposition NP
9/17/19 Natalie Parde - UIC CS 421 26
Bottom-Up Parsing: Example
Book that flight.
S
S → NP VP VP
S → Aux NP VP
S → VP NP NP NP
NP → Pronoun
NP → Proper-Noun Nominal Nominal VP Nominal Nominal
NP → Det Nominal
Nominal → Noun Noun Det Noun Verb Det Noun Verb Det Noun
Nominal → Nominal Noun
Nominal → Nominal PP book that flight book that flight book that flight
VP → Verb
VP → Verb NP
VP → Verb NP PP
VP → Verb PP
VP → VP PP
PP → Preposition NP
9/17/19 Natalie Parde - UIC CS 421 27
Bottom-Up Parsing: Example
Book that flight.
S
S → NP VP VP
S → Aux NP VP
S → VP NP NP NP
NP → Pronoun
NP → Proper-Noun Nominal Nominal VP Nominal Nominal
NP → Det Nominal
Nominal → Noun Noun Det Noun Verb Det Noun Verb Det Noun
Nominal → Nominal Noun
Nominal → Nominal PP book that flight book that flight book that flight
VP → Verb
VP → Verb NP
VP → Verb NP PP
VP → Verb PP
VP → VP PP
PP → Preposition NP
9/17/19 Natalie Parde - UIC CS 421 28
Top-Down Parsing
• Pros:
• Never wastes time exploring trees that cannot result in a
sentence
• Never explores subtrees that cannot fit into a larger valid
(i.e., results in a sentence) tree
Top-Down • Cons:
• Spends considerable effort on trees that are not
vs. consistent with the input
Bottom-Up
Parsing Bottom-Up Parsing
• Pros:
• Never suggests trees that are inconsistent with the input
• Cons:
• Generates many trees and subtrees that cannot result in
a valid sentence (according to production rules specified
by the grammar)
Example S → NP VP S → NP VP
S → Aux NP VP S → X1 VP
• S → NP VP
• S → Aux NP VP X1 → Aux NP
• S → VP
• NP → Pronoun S → VP S → book | include | prefer
• NP → Proper-Noun
• NP → Det Nominal
S → Verb NP
• Nominal → Noun
S → X2 PP
• Nominal → Nominal Noun
• Nominal → Nominal PP X2 → Verb NP
• VP → Verb
• VP → Verb NP S → Verb PP
• VP → Verb NP PP
• VP → Verb PP S → VP PP
• VP → VP PP
• PP → Preposition NP
CKY
Algorithm:
Example S → NP VP
S → VP
NP → Pronoun
NP → Proper-Noun
NP → Det Nominal
Nominal → Noun
Nominal → Nominal Noun Det → that | this | a | the
Nominal → Nominal PP Noun → book | flight | meal | money
VP → Verb Verb → book | include | prefer
VP → Verb NP Pronoun → I | she | me
VP → Verb PP Proper-Noun → Chicago | Dallas
VP → VP PP Aux → does
PP → Preposition NP Preposition → from | to | on | near | through
Example
2
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas
Aux → does 3
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me
NP → Proper-Noun → Chicago | Dallas
4
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer
VP → Verb NP
5
VP → Verb PP
VP → VP PP
PP → Preposition NP
Example
2
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas
Aux → does 3
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me
NP → Proper-Noun → Chicago | Dallas
4
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer
VP → Verb NP
5
VP → Verb PP
VP → VP PP
PP → Preposition NP
Example
2 Det
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas
Aux → does 3
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me
NP → Proper-Noun → Chicago | Dallas
4
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer
VP → Verb NP 5
VP → Verb PP
VP → VP PP
PP → Preposition NP
Example
2 Det
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas
Aux → does 3 Noun
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me
NP → Proper-Noun → Chicago | Dallas
4
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer
VP → Verb NP
5
VP → Verb PP
VP → VP PP
PP → Preposition NP
Example
2 Det
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas
Aux → does 3 Noun
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep.
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer
VP → Verb NP
5
VP → Verb PP
VP → VP PP
PP → Preposition NP
Example
2 Det
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas
Aux → does 3 Noun
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me
NP → Proper-Noun → Chicago | Dallas
4 Prep.
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer
VP → Verb NP 5 PropN
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas
Aux → does 3 Noun
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep.
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer
VP → Verb NP
5 PropN
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep.
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer
VP → Verb NP
5 PropN
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep.
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep.
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep.
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep.
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep.
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep.
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3 Nominal
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3 Nominal
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP
Example
2 Det NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3 Nominal
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP
Example
2 Det NP NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3 Nominal
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP
Example
2 Det NP NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3 Nominal
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP S, VP
Example
2 Det NP NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3 Nominal
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP
Note that we can arrive at S in a NP
VP → Verb PP
VP → VP PP couple different ways! Each way is an
PP → Preposition NP
alternative parse.
9/17/19 Natalie Parde - UIC CS 421 66
CKY Algorithm
• The example we just saw functions as a recognizer …for it to succeed (i.e., find
a valid sentence according to this grammar), is simply needs to find an S in cell
[0,n]
• To return all possible parses, we need to make two changes to the algorithm:
• Pair each non-terminal with pointers to the table entries from which it was
derived
• Permit multiple versions of the same non-terminal to be entered into the table
• Then, we can choose an S from cell [0,n] and recursively retrieve its component
constituents from the table
Algorithm: 1
Verb, S,
Nominal,
VP
S, VP
S1, S2,
VP
Example
2 Det NP NP
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
Pronoun → I | she | me
Proper-Noun → Chicago | Dallas Noun,
Aux → does 3 Nominal
Nominal
Preposition → from | to | on | near | through
S → NP VP
S → VP → Verb → book | include | prefer
NP → Pronoun → I | she | me 4 Prep. PP
NP → Proper-Noun → Chicago | Dallas
NP → Det Nominal
Nominal → Noun → book | flight | meal | money
Nominal → Nominal Noun
Nominal → Nominal PP
VP → Verb → book | include | prefer PropN,
5
VP → Verb NP NP
VP → Verb PP
VP → VP PP
PP → Preposition NP
• Fill table in a single sweep over the input words, using a top-down
approach
• Table is length n+1, where n is equivalent to the number of words
• Table entries contain three types of information:
• A subtree corresponding to a single grammar rule
• Information about the progress made in completing the subtree
• The position of the subtree with respect to the input
• This is called Earley parsing
• VP → • Verb, [0,0]
• VP → • Verb NP, [0,0]
• VP → • Verb NP PP, [0,0]
• VP → • Verb PP, [0,0]
• VP → • VP PP, [0,0]
Earley Algorithm: 0
0
S1
S2
S → • NP VP
S → • VP
0, 0
0, 0
Predictor
Predictor
Example 0
0
S3
S4
NP → • Det Nominal
VP → • Verb
0, 0
0, 0
Predictor
Predictor
0 S5 VP → • Verb NP 0, 0 Predictor
S → NP VP
S → VP
NP → Det Nominal
Nominal → Noun
Nominal → Nominal Noun
VP → Verb
VP → Verb NP
Earley Algorithm: 0
0
S1
S2
S → • NP VP
S → • VP
0, 0
0, 0
Predictor
Predictor
Example 0
0
S3
S4
NP → • Det Nominal
VP → • Verb
0, 0
0, 0
Predictor
Predictor
0 S5 VP → • Verb NP 0, 0 Predictor
1 S6 Verb → book • 0, 1 Scanner
1 S7 VP → Verb • 0, 1 Completer
1 S8 VP → Verb • NP 0, 1 Completer
1 S9 S → VP • 0, 1 Completer
1 S10 NP → • Det Nominal 1, 1 Predictor
Det → that | this | a | the
Noun → book | flight | meal | money
Verb → book | include | prefer
S → NP VP
S → VP
NP → Det Nominal
Nominal → Noun
Nominal → Nominal Noun
VP → Verb
VP → Verb NP
Earley Algorithm: 0
0
S1
S2
S → • NP VP
S → • VP
0, 0
0, 0
Predictor
Predictor
Example 0
0
S3
S4
NP → • Det Nominal
VP → • Verb
0, 0
0, 0
Predictor
Predictor
0 S5 VP → • Verb NP 0, 0 Predictor
1 S6 Verb → book • 0, 1 Scanner
1 S7 VP → Verb • 0, 1 Completer
1 S8 VP → Verb • NP 0, 1 Completer
1 S9 S → VP • 0, 1 Completer
1 S10 NP → • Det Nominal 1, 1 Predictor
Det → that | this | a | the
2 S11 Det → that • 1, 2 Scanner
Noun → book | flight | meal | money
Verb → book | include | prefer 2 S12 NP → Det • Nominal 1, 2 Completer
2 S13 Nominal → • Noun 2, 2 Predictor
2 S14 Nominal → • Nominal Noun 2, 2 Predictor
S → NP VP
S → VP
NP → Det Nominal
Nominal → Noun
Nominal → Nominal Noun
VP → Verb
VP → Verb NP
Earley Algorithm: 0
0
S1
S2
S → • NP VP
S → • VP
0, 0
0, 0
Predictor
Predictor
Example 0
0
S3
S4
NP → • Det Nominal
VP → • Verb
0, 0
0, 0
Predictor
Predictor
0 S5 VP → • Verb NP 0, 0 Predictor
1 S6 Verb → book • 0, 1 Scanner
1 S7 VP → Verb • 0, 1 Completer
1 S8 VP → Verb • NP 0, 1 Completer
1 S9 S → VP • 0, 1 Completer
1 S10 NP → • Det Nominal 1, 1 Predictor
Det → that | this | a | the
2 S11 Det → that • 1, 2 Scanner
Noun → book | flight | meal | money
Verb → book | include | prefer 2 S12 NP → Det • Nominal 1, 2 Completer
2 S13 Nominal → • Noun 2, 2 Predictor
2 S14 Nominal → • Nominal Noun 2, 2 Predictor
S → NP VP
3 S15 Noun → flight • 2, 3 Scanner
S → VP
NP → Det Nominal 3 S16 Nominal → Noun • 2, 3 Completer
Nominal → Noun 3 S17 NP → Det Nominal • 1, 3 Completer
Nominal → Nominal Noun
3 S18 Nominal → Nominal • Noun 2, 3 Completer
VP → Verb
VP → Verb NP 3 S19 VP → Verb NP • 0, 3 Completer
3 S20 S → VP • 0, 3 Completer
Which 0
1
S5
S6
VP → • Verb NP
Verb → book •
0, 0
0, 1
Predictor
Scanner
states 1
1
S7
S8
VP → Verb •
VP → Verb • NP
0, 1
0, 1
Completer
Completer
participate 1
1
S9
S10
S → VP •
NP → • Det Nominal
0, 1
1, 1
Completer
Predictor
in the final
2 S11 Det → that • 1, 2 Scanner
2 S12 NP → Det • Nominal 1, 2 Completer
2 S13 Nominal → • Noun 2, 2 Predictor
parse? 2
3
S14
S15
Nominal → • Nominal Noun
Noun → flight •
2, 2
2, 3
Predictor
Scanner
3 S16 Nominal → Noun • 2, 3 Completer
3 S17 NP → Det Nominal • 1, 3 Completer
3 S18 Nominal → Nominal • Noun 2, 3 Completer
3 S19 VP → Verb NP • 0, 3 Completer
3 S20 S → VP • 0, 3 Completer
Which 0
1
S5
S6
VP → • Verb NP
Verb → book •
0, 0
0, 1
Predictor
Scanner
states 1
1
S7
S8
VP → Verb •
VP → Verb • NP
0, 1
0, 1
Completer
Completer
participate 1
1
S9
S10
S → VP •
NP → • Det Nominal
0, 1
1, 1
Completer
Predictor
in the final
2 S11 Det → that • 1, 2 Scanner
2 S12 NP → Det • Nominal 1, 2 Completer
2 S13 Nominal → • Noun 2, 2 Predictor
parse? 2
3
S14
S15
Nominal → • Nominal Noun
Noun → flight •
2, 2
2, 3
Predictor
Scanner
3 S16 Nominal → Noun • 2, 3 Completer (S15)
3 S17 NP → Det Nominal • 1, 3 Completer (S11, S15)
3 S18 Nominal → Nominal • Noun 2, 3 Completer
3 S19 VP → Verb NP • 0, 3 Completer (S6, S17)
3 S20 S → VP • 0, 3 Completer (S19)
dobj nmod
root
det
det
Pronoun Verb NP
dobj nmod
root
det
dobj nmod
root
det
Core Arguments nsubj csubj What she said about only choosing
of Clausal obj ccomp fantasy football players from northern
Predicates iobj xcomp teams makes sense.
Non-Core obl csubj(makes, said)
aux
Dependents of vocative advmod
advcl She copdissertation
said to read her second
Clausal expl discourse
for more tips. mark
Predicates dislocated
ccomp(said, read)
nmod
Dependents of det
appos acl amod
I consider her a genius. case
Nominals
nummod xcomp(consider, genius)
Core Arguments nsubj csubj He was upset when she read her
of Clausal obj ccomp dissertation to him.
Predicates iobj xcomp advcl(upset, read)
Non-Core obl
aux
Dependents of vocative advmod
advcl cop
Clausal expl discourse
mark
Predicates dislocated
nmod
Dependents of det
appos acl amod
Nominals case
nummod
Core
In-Class Arguments
of Clausal
nsubj
obj
csubj
ccomp
Exercise Predicates
iobj xcomp
• Assign universal
dependency relations to the
following sentences: Non-Core obl
• Time flies like an aux
Dependents vocative advmod
arrow. advcl cop
of Clausal expl discourse
• Fruit flies like a mark
banana. Predicates dislocated
https://www.google.com/searc nmod
h?q=timer Dependents det
appos acl amod
of Nominals case
nummod
Transition-based
Transition • Build a single tree in a left-to-right (assuming a left-to-right language)
sweep over the input sentence
Graph-based
Graph • Search through the space of possible trees for a given sentence, and try
to find the tree that maximizes some score
Oracle
based Benefits:
Parsing • Reasonably effective
• Simple to implement
Stack root
Relations
Relations
Relations
(book → me)
Relations (flight → morning)
(flight → the)
State is final
Stack root
(book → me)
(flight → morning)
Relations (flight → the)
(book → flight) book me the morning flight
(root → book)
4
4
8
12 flight
5 7
that
6
root book
4
4
8
12 flight
5 7
that
6
root book
F ← F ∪ bestInEdge
for each 𝑒 = 𝑢, 𝑣 ∈ 𝐸 do:
score’[e] ← score[e] - score[bestInEdge]
4
4
8
12 flight
5 7
that
6
root book
4
4
8
12 flight
5 7
that
6
root book
-4
-3
0
flight
0 8
-2 0
that
7
book -6
root
12
-7
-1
-4
-3
0
-2 that-
flight
book -6 -1
root
12
-7
-1
-4
-3
0
-2 that-
flight
book -6 -1
root
12
-7
-1
-4
-3
0
flight
0 8
-2 0
that
7
book -6
root
12
-7
-1
-4
-3
0
flight
0 8
-2 0
that
7
book -6
root
12
-7
-1
-4
-3
0
flight
0 8
-2 0
that
7
book -6
root
12
-7
-1