computational linguistics ii parsing
play

Computational Linguistics II: Parsing Formal Languages: Context Free - PowerPoint PPT Presentation

Computational Linguistics II: Parsing Formal Languages: Context Free Languages III Frank Richter & Jan-Philipp S ohn fr@sfs.uni-tuebingen.de, jp.soehn@uni-tuebingen.de November 13th, 2006 Richter/S ohn (WS 2006/07) Computational


  1. Computational Linguistics II: Parsing Formal Languages: Context Free Languages III Frank Richter & Jan-Philipp S¨ ohn fr@sfs.uni-tuebingen.de, jp.soehn@uni-tuebingen.de November 13th, 2006 Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 1 / 15

  2. The Big Picture Once Again: The Big Picture hierarchy grammar machine other type 3 reg. grammar DFA reg. expressions NFA det. cf. LR(k) grammar DPDA type 2 CFG PDA type 1 CSG LBA type 0 unrestricted Turing grammar machine DFA: Deterministic finite state automaton (D)PDA: (Deterministic) Pushdown automaton CFG: Context-free grammar CSG: Context-sensitive grammar LBA: Linear bounded automaton Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 2 / 15

  3. A Format for Context-Free Languages Chomsky Normal Form The Chomsky Normal Form: CFGs in CNF Two types of rules allowed: A → BC A → a How to do a transformation: 1 Add new variable for each terminal symbol. 2 Recursively add one new variable for each pair of variables B j B k in A → B i B j B k ... Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 3 / 15

  4. A Format for Context-Free Languages Chomsky Normal Form The Chomsky Normal Form: CFGs in CNF Transform the following Grammar into CNF: S → AB A → aAb A → ab B → cB B → c Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 4 / 15

  5. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF I One type of rules allowed: A → aB 1 B 2 ...B k ( k ≥ 0) Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 5 / 15

  6. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF I One type of rules allowed: A → aB 1 B 2 ...B k ( k ≥ 0) Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 6 / 15

  7. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF II We transform the following grammar into GNF: S → AB A → BS | b B → SA | a Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 7 / 15

  8. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF III Step 1: Rename it! A 1 → A 2 A 3 A 2 → A 3 A 1 | b A 3 → A 1 A 2 | a Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 8 / 15

  9. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF IV Step 2: A i → A j α | i < j A 1 → A 2 A 3 A 2 → A 3 A 1 | b A 3 → A 1 A 2 | a A 3 → A 2 A 3 A 2 | a Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 9 / 15

  10. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF IV Step 2: A i → A j α | i < j A 1 → A 2 A 3 A 2 → A 3 A 1 | b A 3 → A 1 A 2 | a A 3 → A 2 A 3 A 2 | a A 3 → A 3 A 1 A 3 A 2 | bA 3 A 2 | a Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 10 / 15

  11. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF IV Step 2: A i → A j α | i < j A 1 → A 2 A 3 A 2 → A 3 A 1 | b A 3 → A 1 A 2 | a A 3 → A 2 A 3 A 2 | a A 3 → A 3 A 1 A 3 A 2 | bA 3 A 2 | a A 3 → bA 3 A 2 B 3 | aB 3 | bA 3 A 2 | a B 3 → A 1 A 3 A 2 | A 1 A 3 A 2 B 3 Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 11 / 15

  12. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF V Step 3: Replace A i → A j α with A i → βα for each A j → β A 1 → A 2 A 3 A 2 → A 3 A 1 | b A 3 → bA 3 A 2 B 3 | aB 3 | bA 3 A 2 | a B 3 → A 1 A 3 A 2 | A 1 A 3 A 2 B 3 Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 12 / 15

  13. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF V Step 3: Replace A i → A j α with A i → βα for each A j → β A 1 → A 2 A 3 A 2 → bA 3 A 2 B 3 A 1 | aB 3 A 1 | bA 3 A 2 A 1 | aA 1 | b A 3 → bA 3 A 2 B 3 | aB 3 | bA 3 A 2 | a B 3 → A 1 A 3 A 2 | A 1 A 3 A 2 B 3 Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 13 / 15

  14. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF V Step 3: Replace A i → A j α with A i → βα for each A j → β A 1 → bA 3 A 2 B 3 A 1 A 3 | aB 3 A 1 A 3 | bA 3 A 2 A 1 A 3 | aA 1 A 3 | bA 3 A 2 → bA 3 A 2 B 3 A 1 | aB 3 A 1 | bA 3 A 2 A 1 | aA 1 | b A 3 → bA 3 A 2 B 3 | aB 3 | bA 3 A 2 | a B 3 → A 1 A 3 A 2 | A 1 A 3 A 2 B 3 Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 14 / 15

  15. A Format for Context-Free Languages Greibach Normal Form The Greibach Normal Form: CFGs in GNF V Step 3: Replace A i → A j α with A i → βα for each A j → β A 1 → bA 3 A 2 B 3 A 1 A 3 | aB 3 A 1 A 3 | bA 3 A 2 A 1 A 3 | aA 1 A 3 | bA 3 A 2 → bA 3 A 2 B 3 A 1 | aB 3 A 1 | bA 3 A 2 A 1 | aA 1 | b A 3 → bA 3 A 2 B 3 | aB 3 | bA 3 A 2 | a B 3 → bA 3 A 2 B 3 A 1 A 3 A 3 A 2 | aB 3 A 1 A 3 A 3 A 2 | bA 3 A 2 A 1 A 3 A 3 A 2 | aA 1 A 3 A 3 A 2 | bA 3 A 3 A 2 | bA 3 A 2 B 3 A 1 A 3 A 3 A 2 B 3 | aB 3 A 1 A 3 A 3 A 2 B 3 | bA 3 A 2 A 1 A 3 A 3 A 2 B 3 | aA 1 A 3 A 3 A 2 B 3 | bA 3 A 3 A 2 B 3 Richter/S¨ ohn (WS 2006/07) Computational Linguistics II: Parsing November 13th, 2006 15 / 15

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