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

computational linguistics ii parsing
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Computational Linguistics II: Parsing

Formal Languages: Context Free Languages III Frank Richter & Jan-Philipp S¨

  • hn

fr@sfs.uni-tuebingen.de, jp.soehn@uni-tuebingen.de

November 13th, 2006

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 1 / 15

slide-2
SLIDE 2

The Big Picture

Once Again: The Big Picture

hierarchy grammar machine

  • ther

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¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 2 / 15

slide-3
SLIDE 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 BjBk in

A → BiBjBk...

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 3 / 15

slide-4
SLIDE 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¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 4 / 15

slide-5
SLIDE 5

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF I

One type of rules allowed: A → aB1B2...Bk (k ≥ 0)

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 5 / 15

slide-6
SLIDE 6

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF I

One type of rules allowed: A → aB1B2...Bk (k ≥ 0)

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 6 / 15

slide-7
SLIDE 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¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 7 / 15

slide-8
SLIDE 8

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF III

Step 1: Rename it! A1 → A2A3 A2 → A3A1 | b A3 → A1A2 | a

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 8 / 15

slide-9
SLIDE 9

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF IV

Step 2: Ai → Ajα | i < j A1 → A2A3 A2 → A3A1 | b A3 → A1A2 | a A3 → A2A3A2 | a

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 9 / 15

slide-10
SLIDE 10

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF IV

Step 2: Ai → Ajα | i < j A1 → A2A3 A2 → A3A1 | b A3 → A1A2 | a A3 → A2A3A2 | a A3 → A3A1A3A2 | bA3A2 | a

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 10 / 15

slide-11
SLIDE 11

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF IV

Step 2: Ai → Ajα | i < j A1 → A2A3 A2 → A3A1 | b A3 → A1A2 | a A3 → A2A3A2 | a A3 → A3A1A3A2 | bA3A2 | a A3 → bA3A2B3 | aB3 | bA3A2 | a B3 → A1A3A2 | A1A3A2B3

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 11 / 15

slide-12
SLIDE 12

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF V

Step 3: Replace Ai → Ajα with Ai → βα for each Aj → β A1 → A2A3 A2 → A3A1 | b A3 → bA3A2B3 | aB3 | bA3A2 | a B3 → A1A3A2 | A1A3A2B3

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 12 / 15

slide-13
SLIDE 13

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF V

Step 3: Replace Ai → Ajα with Ai → βα for each Aj → β A1 → A2A3 A2 → bA3A2B3A1 | aB3A1 | bA3A2A1 | aA1 | b A3 → bA3A2B3 | aB3 | bA3A2 | a B3 → A1A3A2 | A1A3A2B3

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 13 / 15

slide-14
SLIDE 14

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF V

Step 3: Replace Ai → Ajα with Ai → βα for each Aj → β A1 → bA3A2B3A1A3 | aB3A1A3 | bA3A2A1A3 | aA1A3 | bA3 A2 → bA3A2B3A1 | aB3A1 | bA3A2A1 | aA1 | b A3 → bA3A2B3 | aB3 | bA3A2 | a B3 → A1A3A2 | A1A3A2B3

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 14 / 15

slide-15
SLIDE 15

A Format for Context-Free Languages Greibach Normal Form

The Greibach Normal Form: CFGs in GNF V

Step 3: Replace Ai → Ajα with Ai → βα for each Aj → β A1 → bA3A2B3A1A3 | aB3A1A3 | bA3A2A1A3 | aA1A3 | bA3 A2 → bA3A2B3A1 | aB3A1 | bA3A2A1 | aA1 | b A3 → bA3A2B3 | aB3 | bA3A2 | a B3 → bA3A2B3A1A3A3A2 | aB3A1A3A3A2 | bA3A2A1A3A3A2 | aA1A3A3A2 | bA3A3A2 | bA3A2B3A1A3A3A2B3 | aB3A1A3A3A2B3 | bA3A2A1A3A3A2B3 | aA1A3A3A2B3 | bA3A3A2B3

Richter/S¨

  • hn (WS 2006/07)

Computational Linguistics II: Parsing November 13th, 2006 15 / 15