cky algorithm chomsky normal form
play

CKY Algorithm, Chomsky Normal Form Scott Farrar CLMA, University of - PowerPoint PPT Presentation

Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 CKY Algorithm, Chomsky Normal Form Scott Farrar CLMA, University of Washington January 13, 2010 Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form


  1. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 1 [1,2] 2 3 4 5 6 Notice how the spans (e.g, [1,2]) differ from the word indices (e.g, ‘chef’, 2). Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  2. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT [0,1] 1 [1,2] 2 [2,3] 3 [3,4] 4 [4,5] 5 [5,6] 6 [6,7] ‘the’ is labelled DT Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  3. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT [0,1] 1 NN [1,2] 2 [2,3] 3 [3,4] 4 [4,5] 5 [5,6] 6 [6,7] ‘chef’ is labelled NN Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  4. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] [0,1] 1 NN [1,2] 2 [2,3] 3 [3,4] 4 [4,5] 5 [5,6] 6 [6,7] Found an NP: [0,1], [1,2] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  5. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] [0,1] 1 NN [1,2] 2 VBZ [2,3] 3 [3,4] 4 [4,5] 5 [5,6] 6 [6,7] ‘eats’ is labelled VBZ Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  6. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] [0,1] 1 NN [1,2] 2 VBZ [2,3] 3 [3,4] 4 [4,5] 5 [5,6] 6 [6,7] Found an S: [0,2],[2,3] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  7. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] [0,1] 1 NN [1,2] 2 VBZ [2,3] 3 NNS [3,4] 4 [4,5] 5 [5,6] 6 [6,7] ‘fish’ is labelled NNS Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  8. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] [0,1] 1 NN [1,2] 2 VBZ [2,3] 3 NNS,VBP [3,4] 4 [4,5] 5 [5,6] 6 [6,7] ‘fish’ is labelled VBP Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  9. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] [0,1] 1 NN [1,2] 2 VBZ VP [2,4] [2,3] 3 NNS,VBP [3,4] 4 [4,5] 5 [5,6] 6 [6,7] Found a VP: [2,3], [3,4] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  10. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT S [0,3] NP [0,2] S [0,4] [0,1] 1 NN [1,2] 2 VBZ VP [2,4] [2,3] 3 NNS,VBP [3,4] 4 [4,5] 5 [5,6] 6 [6,7] Found an S: [0,2],[2,4] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  11. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] S [0,4] [0,1] 1 NN [1,2] 2 VBZ VP [2,4] [2,3] 3 NNS,VBP [3,4] 4 IN [4,5] 5 [5,6] 6 [6,7] ‘with’ is labelled IN Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  12. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] S [0,4] [0,1] 1 NN [1,2] 2 VBZ VP [2,4] [2,3] 3 NNS,VBP [3,4] 4 IN [4,5] 5 DT [5,6] 6 [6,7] ‘the’ is labelled DT Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  13. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] S [0,4] [0,1] 1 NN [1,2] 2 VBZ VP [2,4] [2,3] 3 NNS,VBP [3,4] 4 IN [4,5] 5 DT [5,6] 6 NNS [6,7] ‘chopsticks’ is labelled NNS Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  14. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] S [0,4] [0,1] 1 NN [1,2] 2 VBZ VP [2,4] [2,3] 3 NNS,VBP [3,4] 4 IN [4,5] 5 DT [5,6] NP [5,7] 6 NNS [6,7] Found an NP: [5,6], [6,7] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  15. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] S [0,4] [0,1] 1 NN [1,2] 2 VBZ VP [2,4] [2,3] 3 NNS,VBP [3,4] 4 IN [4,5] PP [4,7] 5 DT [5,6] NP [5,7] 6 NNS [6,7] Found a PP: [4,5],[5,7] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  16. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] S [0,4] [0,1] 1 NN [1,2] 2 VBZ VP [2,4] [2,3] 3 NNS,VBP VP [3,7] [3,4] 4 IN [4,5] PP [4,7] 5 DT [5,6] NP [5,7] 6 NNS [6,7] Found a VP: [3,4], [4,7] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  17. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] S [0,4] [0,1] 1 NN [1,2] 2 VP [2,4] VBZ VP [2,7] [2,3] 3 NNS,VBP VP [3,7] [3,4] 4 IN [4,5] PP [4,7] 5 DT [5,6] NP [5,7] 6 NNS [6,7] Found a VP: [2,3],[3,7] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  18. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT NP [0,2] S [0,3] S [0,4] [0,1] 1 NN [1,2] 2 VBZ VP 1 , VP 2 VP [2,4] [2,3] [2,7] 3 NNS,VBP VP [3,7] [3,4] 4 IN [4,5] PP [4,7] 5 DT [5,6] NP [5,7] 6 NNS [6,7] Found another VP: [2,4],[4,7] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  19. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT S [0,3] S [0,4] NP [0,2] S [0,7] [0,1] 1 NN [1,2] 2 VBZ VP [2,4] VP 1 , VP 2 [2,3] [2,7] 3 NNS,VBP VP [3,7] [3,4] 4 IN [4,5] PP [4,7] 5 DT [5,6] NP [5,7] 6 NNS [6,7] Found an S node: [0,2] [2,7] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  20. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT S [0,3] S [0,4] S 1 , S 2 NP [0,2] [0,1] [0,7] 1 NN [1,2] 2 VBZ VP [2,4] VP 1 , VP 2 [2,3] [2,7] 3 NNS,VBP VP [3,7] [3,4] 4 IN [4,5] PP [4,7] 5 DT [5,6] NP [5,7] 6 NNS [6,7] Found a second S node: also [0,2] [2,7] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  21. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 the chef eats fish with the chopsticks 0 1 2 3 4 5 6 7 0 DT S [0,3] S [0,4] S 1 , S 2 NP [0,2] [0,1] [0,7] 1 NN [1,2] 2 VBZ VP [2,4] VP 1 , VP 2 [2,3] [2,7] 3 NNS,VBP VP [3,7] [3,4] 4 IN [4,5] PP [4,7] 5 DT [5,6] NP [5,7] 6 NNS [6,7] Found a second S node: also [0,2] [2,7] Recognition algorithm returns True when a root node is found in [0,n] Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  22. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 The CKY Algorithm (recognition) function CKY-Parse ( words , grammar ) returns table for j ← 1 to length( words ) do : (loop over columns) table [j-1,j] ← { A | A → words [j] ∈ grammar } (add POS) for i ← j-2 downto 0 do : (loop over rows, backwards) for k ← i+1 to j-1 do : (loop over contents of cell) table [i,j] ← table [i,j] ∪ { A | A → B C ∈ grammar , B ∈ table [i,k] C ∈ table [k,j] } Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  23. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 CKY recognition vs. parsing Returning the full parse requires storing more in a cell than just a node label. We also require back-pointers to constituents of that node. We could also store whole trees, but less space efficient. For parsing, we must add an extra step to the algorithm: Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  24. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 CKY recognition vs. parsing Returning the full parse requires storing more in a cell than just a node label. We also require back-pointers to constituents of that node. We could also store whole trees, but less space efficient. For parsing, we must add an extra step to the algorithm: follow pointers and return the parse Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  25. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 The CKY Algorithm (parsing) function CKY-Parse ( words , grammar ) returns parses for j ← 1 to length( words ) do : (loop over columns) table [j-1,j] ← for all { A | A → words [j] ∈ grammar } (add all POS) for i ← j-2 downto 0 do : (loop over rows, backwards) for k ← i+1 to j-1 do : (loop over contents of cell) for all { A | A → B C } : (all productions) back [i,j,A] ← { k,B,C } (add back pointer) return buildtree( back [1, length( words ,S]), table [1,LENGTH( words ),S] (follow back pointer) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  26. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Issues with CKY Efficiency The CKY can be performed in cubic time: O ( n 3 ), where n=number of words in sentence. The complexity of the inner most loop is bounded by the square of the number of non-terminals. The more rules, the less efficient; but this increases at a constant rate L = r 2 where r is the number of non-terminals. Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  27. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Issues with CKY Grammar requirements The basic algoritm requires a binary grammar, in fact a grammar in Chomsky Normal Form. Basic algorithm can be extended to account for arbitrary CFGs. However, transforming a grammar into a CNF grammar is easier and more efficient than parsing with an arbitrary grammar. Later, we’ll look at the Earley Algorithm for parsing arbitrary CFGs. Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  28. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Binary tree Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  29. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Chomsky Normal Form grammar Definition CNF grammar: a context-free grammar where the RHS of each production rule is restricted to be either two non-terminals or one terminal, and no empty productions are allowed. There can be: no mixed rules ( NP → the NN ) no unit productions ( NP → NNP ), except for NN → dog no right hand sides of more than two non-terminals ( VP → VBZ NP PP ). Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  30. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Grammar equivalence Any CFG can be converted to a weakly equivalent grammar in CNF. Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  31. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Grammar equivalence Any CFG can be converted to a weakly equivalent grammar in CNF. Definition Weak equivalence: Two grammars are weakly equivalent if they generate the same set of strings (sentences). Transforming a grammar to CNF results in a new grammar that is weakly equivalent. Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  32. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Grammar equivalence Any CFG can be converted to a weakly equivalent grammar in CNF. Definition Weak equivalence: Two grammars are weakly equivalent if they generate the same set of strings (sentences). Transforming a grammar to CNF results in a new grammar that is weakly equivalent. Definition Strong equivalence: Two grammars are strongly equivalent if they generate the same set of strings AND the same structures over those strings. If only the variable names are diff. then the grammar are said to be isomorphic . Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  33. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Symbol naming conventions Use new symbols (binarization): X 1, X 2, . . . , Y 3 S → NP VP PUNC becomes: S → NP X 1, X 1 → VP PUNC Delete a symbol (unary collapsing): SBAR → S , S → NP VP becomes SBAR → NP VP Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  34. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 CNF conversion algorithm Removing unit-productions (unary collapsing): 1 while there is a unit-production A → B , Remove A → B . foreach B → u , add A → u . Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  35. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 CNF conversion algorithm Removing unit-productions (unary collapsing): 1 while there is a unit-production A → B , Remove A → B . foreach B → u , add A → u . Remove terminals from mixed rules 2 foreach production A → B 1 B 2 ... B k , containing a terminal x Add new non-terminal/production X 1 → x (unless it has already been added) Replace every B i = x with X 1 Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  36. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 CNF conversion algorithm Removing unit-productions (unary collapsing): 1 while there is a unit-production A → B , Remove A → B . foreach B → u , add A → u . Remove terminals from mixed rules 2 foreach production A → B 1 B 2 ... B k , containing a terminal x Add new non-terminal/production X 1 → x (unless it has already been added) Replace every B i = x with X 1 Remove rules with more than two nonterminals on the RHS 3 (binarization) foreach rule p of form A → B 1 B 2 ... B k replace p with A → B 1 X 1, X 1 → B 2 X 2, X 2 → B 3 X 3, ..., X ( k − 2) → B k − 1 B k ( Xi ’s are new variables.) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  37. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Binarization Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  38. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  39. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  40. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  41. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  42. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  43. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  44. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  45. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  46. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  47. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  48. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  49. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  50. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  51. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP (OK) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  52. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP (OK) VP → VBZ Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  53. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP (OK) VP → VBZ (unit production) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  54. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP (OK) VP → VBZ (unit production) VBZ → sleeps Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  55. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP (OK) VP → VBZ (unit production) VBZ → sleeps (OK) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  56. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP (OK) VP → VBZ (unit production) VBZ → sleeps (OK) VBZ → eats Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  57. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP (OK) VP → VBZ (unit production) VBZ → sleeps (OK) VBZ → eats (OK) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  58. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP (OK) VP → VBZ (unit production) VBZ → sleeps (OK) VBZ → eats (OK) DT → the Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  59. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 A sample CFG S → NP VP PUNC (non-binary) S → S and S (mixed) NP → DT NP (OK) NP → NN (unit production) NN → dog (OK) NN → cat (OK) VP → VBZ NP (OK) VP → VBZ (unit production) VBZ → sleeps (OK) VBZ → eats (OK) DT → the (OK) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  60. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  61. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— NP → NN Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  62. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— NP → NN NN → dog Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  63. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— NP → NN NN → dog NN → cat Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  64. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— NP → NN NN → dog NN → cat NP → dog (collapse rule) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  65. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— NP → NN NN → dog NN → cat NP → dog (collapse rule) NP → cat (collapse rule) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  66. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— NP → NN NN → dog NN → cat NP → dog (collapse rule) NP → cat (collapse rule) VP → VBZ Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  67. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— NP → NN NN → dog NN → cat NP → dog (collapse rule) NP → cat (collapse rule) VP → VBZ VBZ → sleeps Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  68. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— NP → NN NN → dog NN → cat NP → dog (collapse rule) NP → cat (collapse rule) VP → VBZ VBZ → sleeps VBZ → eats Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  69. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 1 Non-CNF grammar CNF grammar Action ——————– —————- ————— NP → NN NN → dog NN → cat NP → dog (collapse rule) NP → cat (collapse rule) VP → VBZ VBZ → sleeps VBZ → eats VP → sleeps (collapse rule) VP → eats (collapse rule) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  70. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 2 Non-CNF grammar CNF grammar Action ——————– —————- ————— Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  71. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 2 Non-CNF grammar CNF grammar Action ——————– —————- ————— S → S and S Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  72. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 2 Non-CNF grammar CNF grammar Action ——————– —————- ————— S → S and S Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  73. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 2 Non-CNF grammar CNF grammar Action ——————– —————- ————— S → S and S S → S X 1 (new symbol) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  74. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 2 Non-CNF grammar CNF grammar Action ——————– —————- ————— S → S and S S → S X 1 (new symbol) X 1 → X 2 S (new symbol) Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  75. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 2 Non-CNF grammar CNF grammar Action ——————– —————- ————— S → S and S S → S X 1 (new symbol) X 1 → X 2 S (new symbol) X 2 → and Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

  76. Brief review CKY algorithm Chomsky Normal Form (CNF) Homework2 Conversion of CFG to CNF: Step 3 Non-CNF grammar CNF grammar Action ——————– —————- ————— Scott Farrar CLMA, University of Washington CKY Algorithm, Chomsky Normal Form

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend