Context-Free Grammars and Constituency Parsing
Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19
11 cards in “19.6 CKY parsing” · whole deck
19.6 CKY parsing
- Why is dynamic programming effective for parsing ambiguous sentences?Because rules are context-free, once a constituent has been found over a span it can be recorded and reused in any larger derivation, rather than reanalyzed. Such table-based methods are also called chart parsing.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, p. 435
- What grammar form does CKY require?Chomsky normal form (rules A → B C or A → w).
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, p. 435
- How is a general CFG converted to CNF?(1) Keep conforming rules; (2) replace terminals inside longer rules with dummy non-terminals (INF-VP → to VP becomes INF-VP → TO VP, TO → to); (3) eliminate unit productions (A → B) by rewriting with the non-unit rules they lead to; (4) binarize long rules with new non-terminals (S → Aux NP VP becomes S → X1 VP, X1 → Aux NP).
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, pp. 435–436
- What are unit productions, and what does eliminating them do to the grammar?Rules with a single non-terminal on the right (Nominal → Noun). Eliminating them flattens the grammar and promotes terminals to high levels, e.g. verbs become both VPs and Ss (S → book | include | prefer).
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, pp. 435–436
- What does cell \([i, j]\) of the CKY table contain, and what are fenceposts?The set of non-terminals for all constituents spanning positions \(i\) to \(j\). Indices point at the gaps between words (0 Book 1 the 2 flight 3 …), called fenceposts; the whole sentence is cell \([0, n]\).
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, p. 436
- How is a cell \([i, j]\) filled in CKY?Since every constituent has two daughters, for each split point \(k\) with \(i < k < j\), combine an entry B in \([i, k]\) (to the left, along row \(i\)) with an entry C in \([k, j]\) (below, along column \(j\)) whenever the grammar has A → B C, and add A.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, pp. 436–437
- In what order does CKY fill the table, and why?Column by column from left to right, each column from bottom to top, so the cells to the left and below that a cell depends on are already filled. This also mirrors processing words one at a time.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, pp. 437–438
- Fill in the CKY table for “Book the flight through Houston”.
Row = start position \(i\), column = end word; empty cells hold no constituent.Book the flight through Houston 0 S, VP, Verb, Nominal, Noun S, VP, X2 S, VP, X2 (3 parses) 1 Det NP NP 2 Nominal, Noun Nominal 3 Prep PP 4 NP, ProperNoun - Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, p. 438
- Why does cell [0, 5] for “Book the flight through Houston” contain several S entries?There are alternative parses: the PP through Houston modifies the flight, modifies the booking (VP → VP PP), or is the second argument of the original VP → Verb NP PP (now X2 PP).
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, p. 438
- Is the basic CKY algorithm a parser?No, a recognizer: it tells whether an S spans [0, n]. To parse, store with each non-terminal backpointers to the cells it came from and allow multiple copies of a non-terminal per cell; then the table contains all parses.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, p. 438
- What practical problem does CNF conversion cause, and how is it handled?Returned trees don’t match the original grammar. Binarization can be undone by deleting dummy non-terminals and promoting their daughters; unit productions are easier to handle by modifying CKY itself.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 19, §19.6, p. 439
Source
- Daniel Jurafsky and James H. Martin. Speech and Language Processing. 3rd edition (draft). https://web.stanford.edu/~jurafsky/slp3/