CS 460/IT 632 Natural Language Processing/Language Technology for the Web Lecture 6 (14/02/06) Prof. Pushpak Bhattacharyya IIT Bombay Top-Down and Bottom-Up Parsing
Example Grammar • • • S -> NP VP NP -> DT N NP -> N VP -> V ADV VP -> V Note : Order of rules important in some parsing algorithms. 14/02/06 Prof. Pushpak Bhattacharyya, IIT Bombay 2
Example Sentence People 1 laugh 2 3 These are positions Lexicon: People - N, V Laugh - N, V 14/02/06 This indicate that both Noun and Verb is possible for the word “People” Prof. Pushpak Bhattacharyya, IIT Bombay 3
Top-Down Parsing State Backup State Action -------------------------------------------------------------1. ((S)1) Symbol waiting expansion Position of input pointer 2. ((NP VP)1) 3 a. ((DT N VP)1) 3 b. ((N VP)1) 4. ((VP)2) 5 a. ((V ADV)2) 6. ((ADV)3) 5 b. ((V)2) 6. ((. )3) ((N VP) 1) ((V)2) - This will not be possible since DT does not match with the lexical category of “People” Consume “laugh” Termination Condition : All inputs over. No symbols remaining. Note: Input symbols can be pushed back. 14/02/06 Prof. Pushpak Bhattacharyya, IIT Bombay 4
Discussion for Top-Down Parsing • This kind of searching is goal driven. • Gives importance to textual precedence (rule precedence). • No regard for data, a priori (useless expansions made). 14/02/06 Prof. Pushpak Bhattacharyya, IIT Bombay 5
Bottom-Up Parsing Some conventions: N 12 Represents positions S 1? -> NP 12 ° VP 2? End position unknown 14/02/06 Work on the LHS done, while the work on RHS remaining Prof. Pushpak Bhattacharyya, IIT Bombay 6
Bottom-Up Parsing (pictorial representation) S -> NP 12 VP 23 ° People Laugh 1 2 N 12 V 12 NP 12 -> N 12 ° VP 12 -> V 12 ° S 1? -> NP 12 ° VP 2? 14/02/06 3 N 23 V 23 NP 23 -> N 23 ° VP 23 -> V 23 ° Prof. Pushpak Bhattacharyya, IIT Bombay 7
Problem with Top-Down • Left Recursion • Suppose you have A-> AB rule. Then we will have the expansion as follows: • ((A)K) -> ((ABB)K) ……. . 14/02/06 Prof. Pushpak Bhattacharyya, IIT Bombay 8