CS460/IT632 Natural Language Processing/Language Technology for the Web Lecture 6 (14/02/06) Prof. Pushpak Bhattacharyya IIT Bombay Top-Down and Bottom-Up Parsing.

Download Report

Transcript CS460/IT632 Natural Language Processing/Language Technology for the Web Lecture 6 (14/02/06) Prof. Pushpak Bhattacharyya IIT Bombay Top-Down and Bottom-Up Parsing.

CS460/IT632 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

1 People 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) This will not be possible since DT does not match with the lexical category of “People” 3a. ((DT N VP)1) ((N VP) 1) 3b. ((N VP)1) 4. ((VP)2) 5a. ((V ADV)2) ((V)2) 6. ((ADV)3) ((V)2) Consume “laugh” 5b. ((V)2) 6. ((.)3) Consume “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 Work on the LHS done, while the work on RHS remaining 14/02/06 Prof. Pushpak Bhattacharyya, IIT Bombay 6

Bottom-Up Parsing (pictorial representation)

People Laugh S -> NP 12 VP 23 ° 1 2 3 14/02/06 N 12 N 23 S NP V 12 12 -> N 12 ° NP 23 V 23 -> N 23 ° VP 1?

12 -> V 12 ° -> NP 12 ° VP 2? 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) -> ((AB)K) -> ((ABB)K) ……..

14/02/06 Prof. Pushpak Bhattacharyya, IIT Bombay 8