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.

Slides:



Advertisements
Similar presentations
March 1, 2009Dr. Muhammed Al_mulhem1 ICS482 Parsing Chapter 13 Muhammed Al-Mulhem March 1, 2009.
Advertisements

Basic Parsing with Context-Free Grammars CS 4705 Julia Hirschberg 1 Some slides adapted from Kathy McKeown and Dan Jurafsky.
Natural Language Processing - Parsing 1 - Language, Syntax, Parsing Problems in Parsing Ambiguity, Attachment / Binding Bottom vs. Top Down Parsing.
101 The Cocke-Kasami-Younger Algorithm An example of bottom-up parsing, for CFG in Chomsky normal form G :S  AB | BB A  CC | AB | a B  BB | CA | b C.
PARSING WITH CONTEXT-FREE GRAMMARS
Parsing with Context Free Grammars Reading: Chap 13, Jurafsky & Martin
GRAMMAR & PARSING (Syntactic Analysis) NLP- WEEK 4.
10. Lexicalized and Probabilistic Parsing -Speech and Language Processing- 발표자 : 정영임 발표일 :
March 1, 2009 Dr. Muhammed Al-Mulhem 1 ICS 482 Natural Language Processing Probabilistic Context Free Grammars (Chapter 14) Muhammed Al-Mulhem March 1,
CKY Parsing Ling 571 Deep Processing Techniques for NLP January 12, 2011.
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.
Albert Gatt LIN3022 Natural Language Processing Lecture 8.
6/12/2015Prof. Hilfinger CS164 Lecture 111 Bottom-Up Parsing Lecture (From slides by G. Necula & R. Bodik)
Parsing — Part II (Ambiguity, Top-down parsing, Left-recursion Removal)
Syntactic Parsing with CFGs CMSC 723: Computational Linguistics I ― Session #7 Jimmy Lin The iSchool University of Maryland Wednesday, October 14, 2009.
Prof. Fateman CS 164 Lecture 91 Bottom-Up Parsing Lecture 9.
Cs466(Prasad)L8Norm1 Normal Forms Chomsky Normal Form Griebach Normal Form.
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.
11 CS 388: Natural Language Processing: Syntactic Parsing Raymond J. Mooney University of Texas at Austin.
PARSING David Kauchak CS457 – Fall 2011 some slides adapted from Ray Mooney.
CS460/626 : Natural Language Processing/Speech, NLP and the Web (Lecture 29– CYK; Inside Probability; Parse Tree construction) Pushpak Bhattacharyya CSE.
Probabilistic Parsing Reading: Chap 14, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Paul Tarau, based on Rada.
1 Syntax Sudeshna Sarkar 25 Aug Sentence-Types Declaratives: A plane left S -> NP VP Imperatives: Leave! S -> VP Yes-No Questions: Did the plane.
1 CKY and Earley Algorithms Chapter 13 October 2012 Lecture #8.
LINGUISTICA GENERALE E COMPUTAZIONALE ANALISI SINTATTICA (PARSING)
11 Syntactic Parsing. Produce the correct syntactic parse tree for a sentence.
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.
PARSING David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
11 Chapter 14 Part 1 Statistical Parsing Based on slides by Ray Mooney.
Syntax and Semantics Structure of programming languages.
Lecture 1, 7/21/2005Natural Language Processing1 CS60057 Speech &Natural Language Processing Autumn 2007 Lecture August 2007.
1 Chart Parsing Allen ’ s Chapter 3 J & M ’ s Chapter 10.
Sentence Parsing Parsing 3 Dynamic Programming. Jan 2009 Speech and Language Processing - Jurafsky and Martin 2 Acknowledgement  Lecture based on  Jurafsky.
Basic Parsing Algorithms: Earley Parser and Left Corner Parsing
PARSING 2 David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
NLP. Introduction to NLP Motivation –A lot of the work is repeated –Caching intermediate results improves the complexity Dynamic programming –Building.
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.
Natural Language Processing Lecture 15—10/15/2015 Jim Martin.
GRAMMARS David Kauchak CS457 – Spring 2011 some slides adapted from Ray Mooney.
NLP. Introduction to NLP Time flies like an arrow –Many parses –Some (clearly) more likely than others –Need for a probabilistic ranking method.
Exercises on Chomsky Normal Form and CYK parsing
PARSING David Kauchak CS159 – Fall Admin Assignment 3 Quiz #1  High: 36  Average: 33 (92%)  Median: 33.5 (93%)
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 -
Introduction to Parsing
1 Statistical methods in NLP Diana Trandabat
CSC 594 Topics in AI – Natural Language Processing
Parsing Recommended Reading: Ch th Jurafsky & Martin 2nd edition
Programming Languages Translator
CS60057 Speech &Natural Language Processing
Heng Ji September 13, 2016 SYNATCTIC PARSING Heng Ji September 13, 2016.
Parsing Recommended Reading: Ch th Jurafsky & Martin 2nd edition
CSCI 5832 Natural Language Processing
CPSC 503 Computational Linguistics
CSCI 5832 Natural Language Processing
CS 388: Natural Language Processing: Syntactic Parsing
CSCI 5832 Natural Language Processing
CSCI 5832 Natural Language Processing
Parsing and More Parsing
Heng Ji January 17, 2019 SYNATCTIC PARSING Heng Ji January 17, 2019.
Parsing I: CFGs & the Earley Parser
David Kauchak CS159 – Spring 2019
NLP.
Presentation transcript:

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  Mention of Earley and chart parsing

7/2/2015 Speech and Language Processing - Jurafsky and Martin 3 Parsing  Parsing with CFGs refers to the task of assigning trees to input strings  Trees that covers all and only the elements of the input and has an S at the top  This chapter: find all possible trees  Next chapter (14): choose the most probable one

7/2/2015 Speech and Language Processing - Jurafsky and Martin 4 Parsing  parsing involves a search

7/2/2015 Speech and Language Processing - Jurafsky and Martin 5 Top-Down Search  We’re trying to find trees rooted with an S; start with the rules that give us an S.  Then we can work our way down from there to the words.

7/2/2015 Speech and Language Processing - Jurafsky and Martin 6 Top Down Space

7/2/2015 Speech and Language Processing - Jurafsky and Martin 7 Bottom-Up Parsing  We also want trees that cover the input words.  Start with trees that link up with the words  Then work your way up from there to larger and larger trees.

Bottom-Up Space 8

7/2/2015 Speech and Language Processing - Jurafsky and Martin 9 Top-Down and Bottom-Up  Top-down  Only searches for trees that can be S’s  But also suggests trees that are not consistent with any of the words  Bottom-up  Only forms trees consistent with the words  But suggests trees that make no sense globally

7/2/2015 Speech and Language Processing - Jurafsky and Martin 10 Control  Which node to try to expand next  Which grammar rule to use to expand a node  One approach: exhaustive search of the space of possibilities  Not feasible  Time is exponential in the number of non- terminals  LOTS of repeated work, as the same constituent is created over and over (shared sub-problems)

7/2/2015 Speech and Language Processing - Jurafsky and Martin 11 Dynamic Programming  DP search methods fill tables with partial results and thereby  Avoid doing avoidable repeated work  Solve exponential problems in polynomial time (well, no not really – we’ll return to this point)  Efficiently store ambiguous structures with shared sub-parts.  We’ll cover two approaches that roughly correspond to bottom-up and top-down approaches.  CKY  Earley – we will mention this, not cover it in detail

7/2/2015 Speech and Language Processing - Jurafsky and Martin 12 CKY Parsing  Consider the rule A  BC  If there is an A somewhere in the input then there must be a B followed by a C in the input.  If the A spans from i to j in the input then there must be some k st. i<k<j  Ie. The B splits from the C someplace.

7/2/2015 Speech and Language Processing - Jurafsky and Martin 13 Convert Grammar to CNF  What if your grammar isn’t binary?  As in the case of the TreeBank grammar?  Convert it to binary… any arbitrary CFG can be rewritten into Chomsky-Normal Form automatically.  The resulting grammar accepts (and rejects) the same set of strings as the original grammar.  But the resulting derivations (trees) are different.  We saw this in the last set of lecture notes

7/2/2015 Speech and Language Processing - Jurafsky and Martin 14 Convert Grammar to CNF  More specifically, we want our rules to be of the form A  B C Or A  w That is, rules can expand to either 2 non- terminals or to a single terminal.

7/2/2015 Speech and Language Processing - Jurafsky and Martin 15 Binarization Intuition  Introduce new intermediate non-terminals into the grammar that distribute rules with length > 2 over several rules.  So… S  A B C turns into S  X C and X  A B Where X is a symbol that doesn’t occur anywhere else in the the grammar.

Converting grammar to CNF 1.Copy all conforming rules to the new grammar unchanged 2.Convert terminals within rules to dummy non-terminals 3.Convert unit productions 4.Make all rules with NTs on the right binary In lecture: what these mean; apply to example on next two slides 7/2/

7/2/2015 Speech and Language Processing - Jurafsky and Martin 17 Sample L1 Grammar

7/2/2015 Speech and Language Processing - Jurafsky and Martin 18 CNF Conversion

7/2/2015 Speech and Language Processing - Jurafsky and Martin 19 CKY  Build a table so that an A spanning from i to j in the input is placed in cell [i,j] in the table.  E.g., a non-terminal spanning an entire string will sit in cell [0, n]  Hopefully an S

7/2/2015 Speech and Language Processing - Jurafsky and Martin 20 CKY  If  there is an A spanning i,j in the input  A  B C is a rule in the grammar  Then  There must be a B in [i,k] and a C in [k,j] for some i<k<j

7/2/2015 Speech and Language Processing - Jurafsky and Martin 21 CKY  The loops to fill the table a column at a time, from left to right, bottom to top.  When we’re filling a cell, the parts needed to fill it are already in the table  to the left and below

7/2/2015 Speech and Language Processing - Jurafsky and Martin 22 CKY Algorithm

7/2/2015 Speech and Language Processing - Jurafsky and Martin 23 Example Go through full example in lecture

7/2/2015 Speech and Language Processing - Jurafsky and Martin 24 CKY Parsing  Is that really a parser?  So, far it is only a recognizer  Success? an S in cell [0,N]  To turn it into a parser … see Lecture

7/2/2015 Speech and Language Processing - Jurafsky and Martin 25 CKY Notes  Since it’s bottom up, CKY populates the table with a lot of worthless constituents.  To avoid this we can switch to a top-down control strategy  Or we can add some kind of filtering that blocks constituents where they can not happen in a final analysis.

Dynamic Programming Parsing Methods  CKY (Cocke-Kasami-Younger) algorithm based on bottom-up parsing and requires first normalizing the grammar.  Earley parser is based on top-down parsing and does not require normalizing grammar but is more complex.  More generally, chart parsers retain completed phrases in a chart and can combine top-down and bottom-up search. 26

Conclusions  Syntax parse trees specify the syntactic structure of a sentence that helps determine its meaning.  John ate the spaghetti with meatballs with chopsticks.  How did John eat the spaghetti? What did John eat?  CFGs can be used to define the grammar of a natural language.  Dynamic programming algorithms allow computing a single parse tree in cubic time or all parse trees in exponential time. 27