Presentation is loading. Please wait.

Presentation is loading. Please wait.

Parsing with Context Free Grammars. Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top -

Similar presentations


Presentation on theme: "Parsing with Context Free Grammars. Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top -"— Presentation transcript:

1 Parsing with Context Free Grammars

2 Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top - Down Space (an example) Top - Down Space (an exercise) Conclusion (Top - Down Parse versus Bottom - up Parse)

3 Slide 1 Why should you care? Grammar checkers Question answering Information extraction Machine translation

4 Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top Down Space (an example) Top Down Space (an exercise) Conclusion (Top Down Parse versus Bottom up Parse)

5 Slide 1 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 doesn’t actually mean that the system can select the correct tree from among the possible trees

6 Slide 1 Parsing As with everything of interest, parsing involves a search that involves the making of choices. Parsing a string with a CFG: Finding a derivation of the string consistent with the grammar.The derivation gives us a PARSE TREE

7 Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top Down Space (an example) Top Down Space (an exercise) Conclusion (Top Down Parse versus Bottom up Parse)

8 Slide 1 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.

9 Slide 1 Top Down Space

10 Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Top Down Space (an example) Top Down Space (an exercise) Conclusion (Top Down Parse versus Bottom up Parse)

11 Slide 1 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.

12 Slide 1 Bottom-Up Space (an example)

13 Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top Down Space (an example) Top Down Space (an exercise) Conclusion (Top Down Parse versus Bottom up Parse)

14 Slide 1 Top Down Space Example (Does this flight …..)

15 Slide 1 Example … (cont’d)

16 Slide 1 Example (cont’d) flight

17 Slide 1 Example (cont’d) flight

18 Slide 1 TOP-DOWN, DEPTH-FIRST, LEFT-TO-RIGHT

19 Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top Down Space (an example) Top Down Space (an exercise) Conclusion (Top Down Parse versus Bottom up Parse)

20 Slide 1 Top Down Space (an exercise) Using Top Down Space draw the parse tree for the following sentence: 1- Book that flight. 2- John hit the ball.

21 Slide 1 Top Down Space (result parse tree no.1)

22 Slide 1 Top Down Space (result parse tree no.2)

23 Slide 1 Avoiding Repeated Work Parsing is hard, and slow. It’s 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

24 Slide 1 flight Step by step parsing…1

25 Slide 1 flight Parsing step …2

26 Slide 1 Step by step parsing…3

27 Slide 1 The parse tree. s

28 Slide 1 Top Down Space (an exercise) Using Top Down Space draw the parse tree for the following sentence: I shot an elephant in my pajamas.

29 Slide 1 Top Down Space (result parse tree ) Pro V NP Ishot poss Det anelephantmy P NP PP NP Nom inpajamas

30 Slide 1 Top Down Space (result parse tree)

31 Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top Down Space (an example) Top Down Space (an exercise) Conclusion (Top Down Parse versus Bottom up Parse)

32 Slide 1 TOP-DOWN AND BOTTOM-UP SEARCH STRATEGIES The search has to be guided by the INPUT and the GRAMMAR TOP-DOWN search: the parse tree has to be rooted in the start symbol S EXPECTATION-DRIVEN parsing BOTTOM-UP search: the parse tree must be an analysis of the input DATA-DRIVEN parsing

33 Slide 1 TOP-DOWN vs BOTTOM-UP TOP-DOWN: Only search among grammatical answers BUT: suggests hypotheses that may not be consistent with data Problem: left-recursion BOTTOM-UP: Only forms hypotheses consistent with data BUT: may suggest hypotheses that make no sense globally


Download ppt "Parsing with Context Free Grammars. Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top -"

Similar presentations


Ads by Google