Instructor: Nick Cercone - 3050 CSEB - 1 Parsing and Context Free Grammars Parsers, Top Down, Bottom Up, Left Corner, Earley.

Slides:



Advertisements
Similar presentations
Basic Parsing with Context-Free Grammars CS 4705 Julia Hirschberg 1 Some slides adapted from Kathy McKeown and Dan Jurafsky.
Advertisements

Natural Language Processing - Parsing 1 - Language, Syntax, Parsing Problems in Parsing Ambiguity, Attachment / Binding Bottom vs. Top Down Parsing.
May 2006CLINT-LN Parsing1 Computational Linguistics Introduction Approaches to Parsing.
PARSING WITH CONTEXT-FREE GRAMMARS
Parsing with Context Free Grammars Reading: Chap 13, Jurafsky & Martin
March 1, 2009 Dr. Muhammed Al-Mulhem 1 ICS 482 Natural Language Processing Probabilistic Context Free Grammars (Chapter 14) Muhammed Al-Mulhem March 1,
Artificial Intelligence 2004 Natural Language Processing - Syntax and Parsing - Language, Syntax, Parsing Problems in Parsing Ambiguity, Attachment.
1 Earley Algorithm Chapter 13.4 October 2009 Lecture #9.
 Christel Kemke /08 COMP 4060 Natural Language Processing PARSING.
CS Basic Parsing with Context-Free Grammars.
Parsing context-free grammars Context-free grammars specify structure, not process. There are many different ways to parse input in accordance with a given.
Albert Gatt LIN3022 Natural Language Processing Lecture 8.
Parsing with CFG Ling 571 Fei Xia Week 2: 10/4-10/6/05.
Parsing with PCFG Ling 571 Fei Xia Week 3: 10/11-10/13/05.
Earley’s algorithm Earley’s algorithm employs the dynamic programming technique to address the weaknesses of general top-down parsing. Dynamic programming.
CMSC 723 / LING 645: Intro to Computational Linguistics November 10, 2004 Lecture 10 (Dorr): CFG’s (Finish Chapter 9) Parsing (Chapter 10) Prof. Bonnie.
Basic Parsing with Context- Free Grammars 1 Some slides adapted from Julia Hirschberg and Dan Jurafsky.
ISBN Chapter 4 Lexical and Syntax Analysis The Parsing Problem Recursive-Descent Parsing.
Syntax Analysis Mooly Sagiv html:// Textbook:Modern Compiler Design Chapter 2.2 (Partial) Hashlama 11:00-14:00.
CS 4705 Lecture 7 Parsing with Context-Free Grammars.
Syntactic Parsing with CFGs CMSC 723: Computational Linguistics I ― Session #7 Jimmy Lin The iSchool University of Maryland Wednesday, October 14, 2009.
CS 4705 Basic Parsing with Context-Free Grammars.
Fall 2004 Lecture Notes #5 EECS 595 / LING 541 / SI 661 Natural Language Processing.
Artificial Intelligence 2004 Natural Language Processing - Syntax and Parsing - Language Syntax Parsing.
Parsing SLP Chapter 13. 7/2/2015 Speech and Language Processing - Jurafsky and Martin 2 Outline  Parsing with CFGs  Bottom-up, top-down  CKY parsing.
Probabilistic Parsing Ling 571 Fei Xia Week 5: 10/25-10/27/05.
Basic Parsing with Context- Free Grammars 1 Some slides adapted from Julia Hirschberg and Dan Jurafsky.
Context-Free Grammar CSCI-GA.2590 – Lecture 3 Ralph Grishman NYU.
1 Basic Parsing with Context Free Grammars Chapter 13 September/October 2012 Lecture 6.
11 CS 388: Natural Language Processing: Syntactic Parsing Raymond J. Mooney University of Texas at Austin.
LIN LIN6932: Topics in Computational Linguistics Hana Filip.
1 Basic Parsing with Context- Free Grammars Slides adapted from Dan Jurafsky and Julia Hirschberg.
Intro to NLP - J. Eisner1 Earley’s Algorithm (1970) Nice combo of our parsing ideas so far:  no restrictions on the form of the grammar:  A.
CS 4705 Parsing More Efficiently and Accurately. Review Top-Down vs. Bottom-Up Parsers Left-corner table provides more efficient look- ahead Left recursion.
中文信息处理 Chinese NLP Lecture 9.
1 Chapter 5 LL (1) Grammars and Parsers. 2 Naming of parsing techniques The way to parse token sequence L: Leftmost R: Righmost Top-down  LL Bottom-up.
1 CKY and Earley Algorithms Chapter 13 October 2012 Lecture #8.
10/13/2015IT 3271 Tow kinds of predictive parsers: Bottom-Up: The syntax tree is built up from the leaves Example: LR(1) parser Top-Down The syntax tree.
LINGUISTICA GENERALE E COMPUTAZIONALE ANALISI SINTATTICA (PARSING)
10. Parsing with Context-free Grammars -Speech and Language Processing- 발표자 : 정영임 발표일 :
Chapter 13: Parsing with Context-Free Grammars Heshaam Faili University of Tehran.
May 2006CLINT-LN Parsing1 Computational Linguistics Introduction Parsing with Context Free Grammars.
October 2005csa3180: Parsing Algorithms 11 CSA350: NLP Algorithms Sentence Parsing I The Parsing Problem Parsing as Search Top Down/Bottom Up Parsing Strategies.
Parsing with Context Free Grammars CSC 9010 Natural Language Processing Paula Matuszek and Mary-Angela Papalaskari This slide set was adapted from: Jim.
Parsing I: Earley Parser CMSC Natural Language Processing May 1, 2003.
6/2/2016CPSC503 Winter CPSC 503 Computational Linguistics Lecture 9 Giuseppe Carenini.
Lecture 1, 7/21/2005Natural Language Processing1 CS60057 Speech &Natural Language Processing Autumn 2007 Lecture August 2007.
Sentence Parsing Parsing 3 Dynamic Programming. Jan 2009 Speech and Language Processing - Jurafsky and Martin 2 Acknowledgement  Lecture based on  Jurafsky.
Natural Language - General
Basic Parsing Algorithms: Earley Parser and Left Corner Parsing
PARSING 2 David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
Quick Speech Synthesis CMSC Natural Language Processing April 29, 2003.
CPSC 503 Computational Linguistics
CS 4705 Lecture 10 The Earley Algorithm. Review Top-Down vs. Bottom-Up Parsers –Both generate too many useless trees –Combine the two to avoid over-generation:
csa3050: Parsing Algorithms 11 CSA350: NLP Algorithms Parsing Algorithms 1 Top Down Bottom-Up Left Corner.
Computerlinguistik II / Sprachtechnologie Vorlesung im SS 2010 (M-GSW-10) Prof. Dr. Udo Hahn Lehrstuhl für Computerlinguistik Institut für Germanistische.
CS 4705 Lecture 7 Parsing with Context-Free Grammars.
Click to edit Master title style Instructor: Nick Cercone CSEB - CSE Introduction to Computational Linguistics Tuesdays,
October 2005CSA3180: Parsing Algorithms 21 CSA3050: NLP Algorithms Parsing Algorithms 2 Problems with DFTD Parser Earley Parsing Algorithm.
CS 330 Programming Languages 09 / 25 / 2007 Instructor: Michael Eckmann.
PARSING David Kauchak CS159 – Fall Admin Assignment 3 Quiz #1  High: 36  Average: 33 (92%)  Median: 33.5 (93%)
Formal grammars A formal grammar is a system for defining the syntax of a language by specifying sequences of symbols or sentences that are considered.
Speech and Language Processing SLP Chapter 13 Parsing.
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 -
Parsing Recommended Reading: Ch th Jurafsky & Martin 2nd edition
Basic Parsing with Context Free Grammars Chapter 13
CSCI 5832 Natural Language Processing
Natural Language - General
Parsing and More Parsing
Parsing I: CFGs & the Earley Parser
Presentation transcript:

Instructor: Nick Cercone CSEB - 1 Parsing and Context Free Grammars Parsers, Top Down, Bottom Up, Left Corner, Earley

Instructor: Nick Cercone CSEB - 2 Some Preliminaries What is Parsing? - Two kinds of parse trees: –Phrase structure –Dependency structure Accuracy: handle ambiguity well –Precision, recall, F-measure –Percent of sentences correctly parsed Robustness: handle “ungrammatical” sentences or sentences out of domain Resources needed: treebanks, grammars Efficiency: the speed Richness: trace, functional tags, etc.

Instructor: Nick Cercone CSEB - 3 Types of Parsers Use grammars? Grammar-based parsers: CFG, HPSG, … Parsers that do not use grammars explicitly: Ratnaparki’s parser (1997) Require treebanks? Supervised parsers Unsupervised parsers

Instructor: Nick Cercone CSEB - 4 Where grammars come from: Built by hand Extracted from treebanks Induced from text

Instructor: Nick Cercone CSEB - 5 Review of Grammars and languages GrammarLanguageAutomataRecognitionDependency Regular grammar Regular language Finite-state automata linearstrict local Context-free grammar Context-free language Pushdown automata polynomialnested Context- sensitive grammar Context- sensitive language Linear bounded automata NP- complete crossing Unstricted grammar Recursively enumerable languages Turing machines undecidablearbitrary

Instructor: Nick Cercone CSEB - 6 BNF Example a (context free) BNF grammar for a simple arithmetic expression. → | + | - → | x | / → | ↑ → | | ( ) → | [ ] → |,

Instructor: Nick Cercone CSEB - 7 BNF Example

Instructor: Nick Cercone CSEB - 8 BNF Example An equivalent (context free) BNF grammar for a simple arithmetic expression. | ↑ | x | + → | - | / → | | ( ) → | [ ] → |,

Instructor: Nick Cercone CSEB - 9 Parsing Algorithms Top-down Bottom-up Top-down with bottom-up filtering Earley algorithm CYK algorithm....

Instructor: Nick Cercone CSEB - 10 Parsing Algorithms - Top Down Start from the start symbol, and apply rules Top-down, depth-first, left-to-right parsing Never explore trees that do not result in S => goal-directed search Waste time on trees that do not match input sentence.

Instructor: Nick Cercone CSEB - 11 Parsing Algorithms - Bottom Up Use the input to guide => data-driven search Find rules whose right-hand sides match the current nodes. Waste time on trees that don’t result in S

Instructor: Nick Cercone CSEB - 12 Parsing Algorithms - Top-down parsing with bottom-up look-ahead filtering Use the input to guide Both top-down and bottom-up generate too many useless trees. Combine the two to reduce over-generation B is a left-corner of A if  see handout Left-corner table provides more efficient look-ahead Pre-compute all POS that can serve as the leftmost POS in the derivations of each non-terminal category

Instructor: Nick Cercone CSEB - 13 Dynamic Programming (DP) DP: –Dividable: The optimal solution of a sub-problem is part of the optimal solution of the whole problem. –Memorization: Solve small problems only once and remember the answers. Example: T(n) = T(n-1) + T(n-2)

Instructor: Nick Cercone CSEB - 14 Parsing with DP Three well-known CFG parsing algorithms: –Earley algorithm (1970) –Cocke-Younger-Kasami (CYK) (1960) –Graham-Harrison-Ruzzo (GHR) (1980)

Instructor: Nick Cercone CSEB - 15 Earley Algorithm Use DP to do top-down search A single left-to-right pass that fills out an array (called a chart) that has N+1 entries. An entry is a list of states: it represents all partial trees generated so far.

Instructor: Nick Cercone CSEB - 16 Earley Algorithm - A state A state contains: –A single dotted grammar rule: –[i, j]: i: where the state begins w.r.t. the input j: the position of dot w.r.t. the input In order to retrieve parse trees, we need to keep a list of pointers, which point to older states.

Instructor: Nick Cercone CSEB - 17 Earley Algorithm - Dotted rules 0 Book 1 that 2 flight 3 S --> VP, [0,0] –S begins position 0 –The dot is at position 0, too. –So, nothing has been covered so far. –We need cover VP next. NP --> Det Nom, [1,2] –the NP begins at position 1 –the dot is currently at position 2 –so, Det has been successfully covered. –We need to cover Nom next.

Instructor: Nick Cercone CSEB - 18 Earley Algorithm - Parsing procedure From left to right, for each entry chart[i]: apply one of three operators to each state: predictor: predict the expansion scanner: match input word with the POS after the dot. completer: advance previous created states.

Instructor: Nick Cercone CSEB - 19 Earley Algorithm - Predicator Why this operation: create new states to represent top- down expectations When to apply: the symbol after the dot is a non-POS. –Ex: S --> NP VP [i, j] What to do: Adds new states to current chart: One new state for each expansion of the non-terminal –Ex: VP  V [j, j] VP  V NP [j, j]

Instructor: Nick Cercone CSEB - 20 Earley Algorithm - Scanner Why: match the input word with the POS in a rule When: the symbol after the dot is a POS –Ex: VP --> V NP [ i, j ], word[ j ] = “book” What: if matches, adds state to next entry –Ex: V  book [ j, j+1 ]

Instructor: Nick Cercone CSEB - 21 Earley Algorithm - Completer Why: parser has discovered a constituent, so we must find and advance states that were waiting for this When: dot has reached right end of rule –Ex: NP --> Det Nom [ i, j ] What: Find every state w/ dot at i and expecting an NP, e.g., VP --> V NP [ h, i ] –Adds new states to current entry VP  V NP [ h, j ]

Instructor: Nick Cercone CSEB - 22 Earley Algorithm - Retrieving Parse Trees Augment the Completer to add pointers to older states from which it advances To retrieve parse trees, do a recursive retrieval from a complete S in the final chart entry.

Instructor: Nick Cercone CSEB - 23 Earley Algorithm - Example Book that flight Rules: (1) S  NP VP (9) N  book/cards/flight (2) S  VP (10) Det  that (3) VP  V NP (11) P  with (4) VP  VP PP (12) V  book (5) NP  NP PP (6) NP  N (7) NP  Det N (8) PP  P NP

Instructor: Nick Cercone CSEB - 24 Earley Algorithm - Example Chart [0], word[0]=book S0: Start .S [0,0] init pred S1: S .NP VP [0,0] S0 pred S2: S .VP [0,0] S0 pred S3: NP .NP PP [0,0] S1 pred S4: NP .Det N [0,0] S1 pred S5: NP .N [0,0] S1 pred S6: VP .V NP [0,0] S2 pred S7: VP .VP PP [0,0] S2 pred

Instructor: Nick Cercone CSEB - 25 Earley Algorithm - Example Chart[1], word[1]=that S8: N  book. [0,1] S5 scan S9: V  book. [0,1] S6 scan S10: NP  N. [0, 1] S8 comp [S8] S11: VP  V. NP [0,1] S9 comp [S9] S12: S  NP. VP [0,1] S10 comp [S10] S13: NP  NP. PP [0,1] S10 comp [S10] S14: NP .NP PP [1,1] S11 pred S15: NP .Det N [1,1] S11 pred S16: NP .N [1,1] S11 pred S17: VP .V NP [1,1] S12 pred S18: VP .VP PP [1,1] S12 pred S19: PP .P NP [1,1] S13 pred

Instructor: Nick Cercone CSEB - 26 Earley Algorithm - Example Chart[2] word[2]=flight S20: Det  that. [1,2] S15 scan S21: NP  Det. N [1,2] S20 comp [S20] Chart[3] S22: N  flight. [2,3] S21 scan S23: NP  Det N. [1,3] S22 comp [S20,S22] S24: VP  V NP. [0,3] S23 comp [S9,S23] S25: NP  NP. PP [1,3] S23 comp [S23] S26: S  VP. [0,3] S24 comp [S24] S27: VP  VP. PP [0,3] S24 comp [S24] S28: PP .P NP [3,3] S25 pred S29: start  S. [0,3] S26 comp [S26]

Instructor: Nick Cercone CSEB - 27 Earley Algorithm - Retrieving parse trees Start from chart[3], look for start  S. [0,3] S26 S24 S9, S23 S20, S22

Instructor: Nick Cercone CSEB - 28 Earley Algorithm - Summary of Earley algorithm Top-down search with DP A single left-to-right pass that fills out a chart Complexity: A: number of entries: O(N) B: number of states within an entry: O(|G| x N) C: time to process a state: O(|G| x N)  O(|G| 2 x N 3 )

Instructor: Nick Cercone CSEB - 29 Other Concluding Remarks MISSING LINK Man's a kind of Missing Link, fondly thinking he can think..