Left-Corner Grammar Transform and Incremental Parsing

advertisement
Left-Corner Grammar Transform
and
Incremental Parsing
Aria Haghighi
Grammar Transform
•
A CFG G
•
•
•
•
Nonterminals N
Terminals T
Productions (Rules) P
A grammar Transform
•
:G ! G’
Parsing Strategies
•
Bottom-Up
•
•
Top-Down
•
•
e.g. CKY
Inefficient and may not terminate
Left-Corner
•
Recognize Left-Child predict parent
Left-Corner’s Arch-Nemesis
•
Left recursion
•
•
X !* X 
Nontermination
•
Recognize X starting at position 1
•
Recognize X starting at position 1
Recognize X starting at position 1
Recognize X starting at position 1
…..
Old School
Left-Recursion Removal
•
Due to Hopcraft and Ullman
For
A ! 1 | … | m
A ! A 1 | … | A k
(i  A )
(i  )
Add
A ! 1 | 1 A’|…|m | m A’
A’ ! 1 | 1 A’ | …. | k | k A’
Problem with the old school
•
It’s a big school!!
•
•
Can have exponential
Blowup in number of productions
PCFG Estimation
•
Lots of sparse rules
Select Left-Corner Transform
•
•
Left-corner productions L
Add states D-X
Example Transform
Keeping it Small
•
Do we need each D-X ?
•
•
Only if D !L* X 
How do we choose L ?
•
•
Need all left recursive rules
Suffice to have rules where
first child is a non-terminal
Binarizing the Output
For Top-Down Rules: (td)
For Left-Corner Rules: (lc)
Grammar Sizes
Incremental Parsing
Incremental Parsing
•
Operate on flattened selective leftcorner algorithm
•
Partial Parses include left-chain
with heuristic filtering
•
Beam Search
Download