22
November 2009 HLT: Sentence Parsing 1 HLT Sentence Parsing Algorithms 2 Problems with Depth First Top Down Parsing

HLT

Embed Size (px)

DESCRIPTION

HLT. Sentence Parsing Algorithms 2 Problems with Depth First Top Down Parsing. Left Recursion Handling Ambiguity Inefficiency. Problems with DFTD Parser. Left Recursion. A grammar is left recursive if it contains at least one non-terminal A for which A  * A and   *  - PowerPoint PPT Presentation

Citation preview

Page 1: HLT

November 2009 HLT: Sentence Parsing 1

HLT

Sentence Parsing Algorithms 2

Problems with

Depth First Top Down Parsing

Page 2: HLT

November 2009 HLT: Sentence Parsing 2

Problems withDFTD Parser

• Left Recursion• Handling Ambiguity• Inefficiency

Page 3: HLT

November 2009 HLT: Sentence Parsing 3

Left Recursion

• A grammar is left recursive if it contains at least one non-terminal A for whichA * A and *

(n.b. * is the transitive closure of )• Intuitive idea: derivation of that category

includes itself along its leftmost branch.

NP NP PP NP NP and NP

NP DetP Nominal DetP NP ' s

Page 4: HLT

November 2009 HLT: Sentence Parsing 4

Left RecursionLeft recursion can lead to an infinite loop

[nltk demo

Page 5: HLT

November 2009 HLT: Sentence Parsing 5

Dealing with Left Recursion

• Use different parsing strategy• Reformulate the grammar to

eliminate LRA A |

is rewritten asA A' A' A' |

Page 6: HLT

November 2009 HLT: Sentence Parsing 6

Rewriting the Grammar

NP → NP ‘and’ NP

NP → D N | D N PP

Page 7: HLT

November 2009 HLT: Sentence Parsing 7

Rewriting the Grammar

NP → NP ‘and’ NP

β

NP → D N | D N PP

α

Page 8: HLT

November 2009 HLT: Sentence Parsing 8

Rewriting the Grammar

NP → NP ‘and’ NP

β

NP → D N | D N PP

α

New Grammar

NP → α NP1

NP1 → β NP1 | ε

Page 9: HLT

November 2009 HLT: Sentence Parsing 9

Rewriting the Grammar

NP → NP ‘and’ NP

β

NP → D N | D N PP

α

New Grammar

NP → α NP1

NP1 → β NP1 | εα → D N | D N PP

β → ‘and’ NP

Page 10: HLT

November 2009 HLT: Sentence Parsing 10

New Parse Tree

D N

the cat

α

NP

NP1

ε

Page 11: HLT

November 2009 HLT: Sentence Parsing 11

Rewriting the Grammar

• Different parse tree

• Unnatural parse tree?

Page 12: HLT

November 2009 HLT: Sentence Parsing 12

Left Corner Parsing

• Two kinds of symbol on the stack: “predicted” and “announced”.

• The basic idea behind LC parsing is is that when the leftmost child of a production is completed, the parent of the category is “announced”, and the remaining right hand categories are “predicted”.

• When a predicted symbol and an announced symbol of the same category are on top of the stack, we can match them and remove them from the stack

Page 13: HLT

November 2009 HLT: Sentence Parsing 13

Problems withDFTD Parser

• Left Recursion• Handling Ambiguity• Inefficiency

Page 14: HLT

November 2009 HLT: Sentence Parsing 14

Handling Ambiguity

• Coordination Ambiguity: different scope of conjunction:Hot curry and ice taste nice with riceHot curry and rice taste nice with ice

• Attachment Ambiguity: a constituent can be added to the parse tree in different places:I shot an elephant in my trousers

• VP → VP PPNP → NP PP

Page 15: HLT

November 2009 HLT: Sentence Parsing 15

Real sentences are full of attachment ambiguitiesPresident Kennedy today pushed aside other White House business to devote all his time and attention to working on the Berlin crisis address he will deliver tomorrow night to the American people over nationwide television and radio

Page 16: HLT

November 2009 HLT: Sentence Parsing 16

Prepositional Phrase Ambiguity

No of PPs # parses

2 2

3 5

4 14

5 132

6 469

7 1430

8 4867

he will deliver- to the American people- over nationwide TV- in New York- during September- for very good reasons

Page 17: HLT

November 2009 HLT: Sentence Parsing 17

Growth of Number of Ambiguities

The nth Catalan number counts the ways of dissecting a polygon with n+2 sides into triangles by drawing nonintersecting diagonals. No of PPs # parses

2 2

3 5

4 14

5 132

6 469

7 1430

8 4867

Page 18: HLT

November 2009 HLT: Sentence Parsing 18

Handling Ambiguities

• Statistical disambiguation– which is the most probable interpretation?

• Semantic knowledge– which is the most sensible interpretation?– Subatomic particles such as positively charged

protons and electrons

Page 19: HLT

November 2009 HLT: Sentence Parsing 19

Problems withDFTD Parser

• Left Recursion• Handling Ambiguity• Inefficiency

Page 20: HLT

November 2009 HLT: Sentence Parsing 20

Repeated Parsing of Subtrees

• Local versus global ambiguity.– NP → Det Noun– NP → NP PP

• Because of the top down depth first, left to right policy, the parser builds trees that fail because they do not cover all of the input.

• Successive parses cover larger segments of the input, but these include structures that have already been built before.

Page 21: HLT

November 2009 HLT: Sentence Parsing 21

Repeated Parsing ofSubtrees

a flight 4

from Indianapolis 3

to Houston 2

on TWA 1

A flight from Indianapolis 3

A flight from Indianapolis to Houston

2

A flight from Indianapolis to Houston on TWA

1

NP Nom

Det Noun

a flight

NP

NP PP Nom

Det Noun P Noun

a flight from Indianapolis

Page 22: HLT

November 2009 HLT: Sentence Parsing 22

Repeated Parsing ofSubtrees

a flight 4

from Indianapolis 3

to Houston 2

on TWA 1

A flight from Indianapolis 3

A flight from Indianapolis to Houston

2

A flight from Indianapolis to Houston on TWA

1