Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 13

Parsing

Parsing with CFGs refers to the task of assigning correct trees to


input strings.

Correct here means a tree that covers all and only the elements of the
input and has an S at the top.

It doesnt actually mean that the system can select the correct tree
from among the possible trees

As with everything of interest, parsing involves a search that involves


the making of choices

Slide 1

Some assumptions..
Assume

You have all the words already in some buffer


The input is/isnt pos tagged
All the words are known

Slide 1

Parsing
Top-Down Parsing

Since we are trying to find trees rooted with an S (Sentences) start


with the rules that give us an S.

Then work your way down from there to the words.


- Bottom-Up Parsing
Of course, we also want trees that cover the input words. So start with trees
that link up with the words in the right way.

Then work your way up from there.

Slide 1

Top Down Space

Slide 1

Bottom-Up Space

Slide 1

Top-Down VS. Bottom-Up


Top-down

Only searches for trees that can be answers


But suggests trees that are not consistent with the words
Guarantees that tree starts with S as root
Does not guarantee that tree will match input words

Only forms trees consistent with the words


Suggest trees that make no sense globally
Guarantees that tree matches input words
Does not guarantee that parse tree will lead to S as a root

Bottom-up

Combine the advantages of the two by doing a search constrained


from both sides (top and bottom)

Slide 1

Possible Problem: Left-Recursion


What happens in the following situation
S -> NP VP
S -> Aux NP VP
NP -> NP PP
NP -> Det Nominal

With the sentence starting with


Did the flight

Slide 1

Solution: Rule Ordering


S -> Aux NP VP
S -> NP VP
NP -> Det Nominal
NP -> NP PP
The key for the NP is that you want the recursive option after any base
case.

Slide 1

Avoiding Repeated Work


Parsing is hard, and slow. Its wasteful to redo stuff over and over and
over.
Consider an attempt to top-down parse the following as an NP
A flight from Indianapolis to Houston on TWA

Slide 1

flight

Slide 1

flight

flight

Slide 1

Slide 1

Slide 1

You might also like