Parsing With Context Free Grammars
-
Upload
ankur-mishra -
Category
Documents
-
view
244 -
download
0
Transcript of Parsing With Context Free Grammars
-
7/23/2019 Parsing With Context Free Grammars
1/13
Slide 1
Parsing
Parsing with CFGs refers to the task of assigning correct trees toinput strings.
Correct here means a tree that covers all and only the elements of theinputand has an S at the top.
It doesnt actually mean that the system can select the correct treefrom among the possible trees
s with everything of interest! parsing involves a search that involvesthe making of choices
-
7/23/2019 Parsing With Context Free Grammars
2/13
Slide 1
Some assumptions..
ssume"#ou have all the words already in some buffer $he input is%isnt pos taggedll the words are known
-
7/23/2019 Parsing With Context Free Grammars
3/13
Slide 1
Parsing
Top-Down Parsing
Since we are trying to find trees rooted with an S &Sentences' startwith the rules that give us an S.
$hen work your way down from there to the words.
( Bottom-Up Parsing
)f course! we also want trees that cover the input words. So start with trees
that link up with the words in the right way.
$hen work your way up from there.
-
7/23/2019 Parsing With Context Free Grammars
4/13
Slide 1
Top Down Space
-
7/23/2019 Parsing With Context Free Grammars
5/13
Slide 1
Bottom-Up Space
-
7/23/2019 Parsing With Context Free Grammars
6/13
Slide 1
Top-Down VS. Bottom-Up
$op(down )nly searches for trees that can be answers *ut suggests trees that are not consistent with the words Guarantees that tree starts with S as root +oes not guarantee that tree will match input words
*ottom(up
)nly forms trees consistent with the words
Suggest trees that make no sense globally Guarantees that tree matches input words +oes not guarantee that parse tree will lead to S as a root
Combine the advantages of the two by doing a search constrained
from both sides &top and bottom'
-
7/23/2019 Parsing With Context Free Grammars
7/13Slide 1
Possible Problem: Left-Recursion
,hat happens in the following situationS (- P /P
S (- u0 P /PP (- P PPP (- +et ominal"
,ith the sentence starting with+id the flight"
-
7/23/2019 Parsing With Context Free Grammars
8/13Slide 1
Solution: Rule Orering
S (- u0 P /PS (- P /PP (- +et ominalP (- P PP
$he key for the P is that you want the recursive option after any base
case.
-
7/23/2019 Parsing With Context Free Grammars
9/13Slide 1
!"oiing Repeate #or$
Parsing is hard! and slow. Its wasteful to redo stuff over and over andover.
Consider an attempt to top(down parse the following as an P
flight from Indianapolis to 1ouston on $,
-
7/23/2019 Parsing With Context Free Grammars
10/13
Slide 1
flight
-
7/23/2019 Parsing With Context Free Grammars
11/13
Slide 1
flight
flight
-
7/23/2019 Parsing With Context Free Grammars
12/13
Slide 1
-
7/23/2019 Parsing With Context Free Grammars
13/13
Slide 1