11 CS 388: Natural Language Processing: Syntactic Parsing Raymond J. Mooney University of Texas at Austin.

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

Probabilistic and Lexicalized Parsing CS Probabilistic CFGs: PCFGs Weighted CFGs –Attach weights to rules of CFG –Compute weights of derivations.
Syntactic analysis using Context Free Grammars. Analysis of language Morphological analysis – Chairs, Part Of Speech (POS) tagging – The/DT man/NN left/VBD.
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
GRAMMAR & PARSING (Syntactic Analysis) NLP- WEEK 4.
Introduction and Jurafsky Model Resource: A Probabilistic Model of Lexical and Syntactic Access and Disambiguation, Jurafsky 1996.
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.
PCFG Parsing, Evaluation, & Improvements Ling 571 Deep Processing Techniques for NLP January 24, 2011.
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.
Syntactic Parsing with CFGs CMSC 723: Computational Linguistics I ― Session #7 Jimmy Lin The iSchool University of Maryland Wednesday, October 14, 2009.
1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake.
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.
Syllabus Text Books Classes Reading Material Assignments Grades Links Forum Text Books עיבוד שפות טבעיות - שיעור תשע Bottom Up Parsing עידו דגן.
Basic Parsing with Context- Free Grammars 1 Some slides adapted from Julia Hirschberg and Dan Jurafsky.
1 Basic Parsing with Context Free Grammars Chapter 13 September/October 2012 Lecture 6.
Context Free Grammars Reading: Chap 12-13, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Paul Tarau, based on Rada.
PARSING David Kauchak CS457 – Fall 2011 some slides adapted from Ray Mooney.
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 CPE 480 Natural Language Processing Lecture 5: Parser Asst. Prof. Nuttanart Facundes, Ph.D.
1 Statistical Parsing Chapter 14 October 2012 Lecture #9.
GRAMMARS David Kauchak CS159 – Fall 2014 some slides adapted from Ray Mooney.
Chapter 10. Parsing with CFGs From: Chapter 10 of An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition, by.
10. Parsing with Context-free Grammars -Speech and Language Processing- 발표자 : 정영임 발표일 :
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.
Context Free Grammars Reading: Chap 9, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Rada Mihalcea.
11 Chapter 14 Part 1 Statistical Parsing Based on slides by Ray Mooney.
Lecture 1, 7/21/2005Natural Language Processing1 CS60057 Speech &Natural Language Processing Autumn 2007 Lecture August 2007.
For Wednesday Read chapter 23 Homework: –Chapter 22, exercises 1,4, 7, and 14.
Rules, Movement, Ambiguity
CSA2050 Introduction to Computational Linguistics Parsing I.
NLP. Introduction to NLP Background –Developed by Jay Earley in 1970 –No need to convert the grammar to CNF –Left to right Complexity –Faster than O(n.
Sentence Parsing Parsing 3 Dynamic Programming. Jan 2009 Speech and Language Processing - Jurafsky and Martin 2 Acknowledgement  Lecture based on  Jurafsky.
Natural Language - General
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.
GRAMMARS David Kauchak CS457 – Spring 2011 some slides adapted from Ray Mooney.
NLP. Introduction to NLP #include int main() { int n, reverse = 0; printf("Enter a number to reverse\n"); scanf("%d",&n); while (n != 0) { reverse =
PARSING David Kauchak CS159 – Fall Admin Assignment 3 Quiz #1  High: 36  Average: 33 (92%)  Median: 33.5 (93%)
Syntactic Parsing: Part I Niranjan Balasubramanian Stony Brook University March 8 th and Mar 22 nd, 2016 Many slides adapted from: Ray Mooney, Michael.
Speech and Language Processing SLP Chapter 13 Parsing.
Natural Language Processing Vasile Rus
CSC 594 Topics in AI – Natural Language Processing
Parsing Recommended Reading: Ch th Jurafsky & Martin 2nd edition
Basic Parsing with Context Free Grammars Chapter 13
CKY Parser 0Book 1 the 2 flight 3 through 4 Houston5 6/19/2018
Probabilistic CKY Parser
CS 388: Natural Language Processing: Statistical Parsing
CSCI 5832 Natural Language Processing
CKY Parser 0Book 1 the 2 flight 3 through 4 Houston5 11/16/2018
CS 388: Natural Language Processing: Syntactic Parsing
Natural Language - General
Parsing and More Parsing
David Kauchak CS159 – Spring 2019
David Kauchak CS159 – Spring 2019
Presentation transcript:

11 CS 388: Natural Language Processing: Syntactic Parsing Raymond J. Mooney University of Texas at Austin

Phrase Chunking Find all non-recursive noun phrases (NPs) and verb phrases (VPs) in a sentence. –[NP I] [VP ate] [NP the spaghetti] [PP with] [NP meatballs]. –[NP He ] [VP reckons ] [NP the current account deficit ] [VP will narrow ] [PP to ] [NP only # 1.8 billion ] [PP in ] [NP September ]

Phrase Chunking as Sequence Labeling Tag individual words with one of 3 tags –B (Begin) word starts new target phrase –I (Inside) word is part of target phrase but not the first word –O (Other) word is not part of target phrase Sample for NP chunking –He reckons the current account deficit will narrow to only # 1.8 billion in September. 3 Begin Inside Other

Evaluating Chunking Per token accuracy does not evaluate finding correct full chunks. Instead use: 4 Take harmonic mean to produce a single evaluation metric called F measure.

Current Chunking Results Best system for NP chunking: F 1 =96% Typical results for finding range of chunk types (CONLL 2000 shared task: NP, VP, PP, ADV, SBAR, ADJP) is F 1 =92−94% 5

Syntactic Parsing Produce the correct syntactic parse tree for a sentence.

Context Free Grammars (CFG) N a set of non-terminal symbols (or variables)  a set of terminal symbols (disjoint from N) R a set of productions or rules of the form A→ , where A is a non-terminal and  is a string of symbols from (  N)* S, a designated non-terminal called the start symbol

Simple CFG for ATIS English S → NP VP S → Aux NP VP S → VP NP → Pronoun NP → Proper-Noun NP → Det Nominal Nominal → Noun Nominal → Nominal Noun Nominal → Nominal PP VP → Verb VP → Verb NP VP → VP PP PP → Prep NP Det → the | a | that | this Noun → book | flight | meal | money Verb → book | include | prefer Pronoun → I | he | she | me Proper-Noun → Houston | NWA Aux → does Prep → from | to | on | near | through Grammar Lexicon

Sentence Generation Sentences are generated by recursively rewriting the start symbol using the productions until only terminals symbols remain. S VP Verb NP Det Nominal Nominal PP book Prep NP through Houston Proper-Noun the flight Noun Derivation or Parse Tree

Parsing Given a string of terminals and a CFG, determine if the string can be generated by the CFG. –Also return a parse tree for the string –Also return all possible parse trees for the string Must search space of derivations for one that derives the given string. –Top-Down Parsing: Start searching space of derivations for the start symbol. –Bottom-up Parsing: Start search space of reverse deivations from the terminal symbols in the string.

Parsing Example S VP Verb NP book Det Nominal that Noun flight book that flight

Top Down Parsing S NP VP Pronoun

Top Down Parsing S NP VP Pronoun book X

Top Down Parsing S NP VP ProperNoun

Top Down Parsing S NP VP ProperNoun book X

Top Down Parsing S NP VP Det Nominal

Top Down Parsing S NP VP Det Nominal book X

Top Down Parsing S Aux NP VP

Top Down Parsing S Aux NP VP book X

Top Down Parsing S VP

Top Down Parsing S VP Verb

Top Down Parsing S VP Verb book

Top Down Parsing S VP Verb book X that

Top Down Parsing S VP Verb NP

Top Down Parsing S VP Verb NP book

Top Down Parsing S VP Verb NP book Pronoun

Top Down Parsing S VP Verb NP book Pronoun X that

Top Down Parsing S VP Verb NP book ProperNoun

Top Down Parsing S VP Verb NP book ProperNoun X that

Top Down Parsing S VP Verb NP book Det Nominal

Top Down Parsing S VP Verb NP book Det Nominal that

Top Down Parsing S VP Verb NP book Det Nominal that Noun

Top Down Parsing S VP Verb NP book Det Nominal that Noun flight

Bottom Up Parsing 34 book that flight

Bottom Up Parsing 35 book that flight Noun

Bottom Up Parsing 36 book that flight Noun Nominal

Bottom Up Parsing 37 book that flight Noun Nominal Noun Nominal

Bottom Up Parsing 38 book that flight Noun Nominal Noun Nominal X

Bottom Up Parsing 39 book that flight Noun Nominal PP Nominal

Bottom Up Parsing 40 book that flight Noun Det Nominal PP Nominal

Bottom Up Parsing 41 book that flight Noun Det NP Nominal Nominal PP Nominal

Bottom Up Parsing 42 book that Noun Det NP Nominal flight Noun Nominal PP Nominal

Bottom Up Parsing 43 book that Noun Det NP Nominal flight Noun Nominal PP Nominal

Bottom Up Parsing 44 book that Noun Det NP Nominal flight Noun S VP Nominal PP Nominal

Bottom Up Parsing 45 book that Noun Det NP Nominal flight Noun S VP X Nominal PP Nominal

Bottom Up Parsing 46 book that Noun Det NP Nominal flight Noun Nominal PP Nominal X

Bottom Up Parsing 47 book that Verb Det NP Nominal flight Noun

Bottom Up Parsing 48 book that Verb VP Det NP Nominal flight Noun

Det Bottom Up Parsing 49 book that Verb VP S NP Nominal flight Noun

Det Bottom Up Parsing 50 book that Verb VP S X NP Nominal flight Noun

Bottom Up Parsing 51 book that Verb VP PP Det NP Nominal flight Noun

Bottom Up Parsing 52 book that Verb VP PP Det NP Nominal flight Noun X

Bottom Up Parsing 53 book that Verb VP Det NP Nominal flight Noun NP

Bottom Up Parsing 54 book that Verb VP Det NP Nominal flight Noun

Bottom Up Parsing 55 book that Verb VP Det NP Nominal flight Noun S

Top Down vs. Bottom Up Top down never explores options that will not lead to a full parse, but can explore many options that never connect to the actual sentence. Bottom up never explores options that do not connect to the actual sentence but can explore options that can never lead to a full parse. Relative amounts of wasted search depend on how much the grammar branches in each direction. 56

Dynamic Programming Parsing To avoid extensive repeated work, must cache intermediate results, i.e. completed phrases. Caching (memoizing) critical to obtaining a polynomial time parsing (recognition) algorithm for CFGs. Dynamic programming algorithms based on both top-down and bottom-up search can achieve O(n 3 ) recognition time where n is the length of the input string. 57

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. 58

CKY First grammar must be converted to Chomsky normal form (CNF) in which productions must have either exactly 2 non- terminal symbols on the RHS or 1 terminal symbol (lexicon rules). Parse bottom-up storing phrases formed from all substrings in a triangular table (chart). 59

ATIS English Grammar Conversion S → NP VP S → Aux NP VP S → VP NP → Pronoun NP → Proper-Noun NP → Det Nominal Nominal → Noun Nominal → Nominal Noun Nominal → Nominal PP VP → Verb VP → Verb NP VP → VP PP PP → Prep NP Original Grammar Chomsky Normal Form S → NP VP S → X1 VP X1 → Aux NP S → book | include | prefer S → Verb NP S → VP PP NP → I | he | she | me NP → Houston | NWA NP → Det Nominal Nominal → book | flight | meal | money Nominal → Nominal Noun Nominal → Nominal PP VP → book | include | prefer VP → Verb NP VP → VP PP PP → Prep NP

CKY Parser 61 Book the flight through Houston i= j= Cell[i,j] contains all constituents (non-terminals) covering words i +1 through j

CKY Parser 62 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP

CKY Parser 63 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP

CKY Parser 64 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S

CKY Parser 65 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S

CKY Parser 66 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None

CKY Parser 67 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None NP ProperNoun PP

CKY Parser 68 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None NP ProperNoun PP Nominal

CKY Parser 69 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None NP ProperNoun PP Nominal NP

CKY Parser 70 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None NP ProperNoun PP Nominal NP VP

CKY Parser 71 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None NP ProperNoun PP Nominal NP S VP

CKY Parser 72 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None NP ProperNoun PP Nominal NP VP S

CKY Parser 73 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None NP ProperNoun PP Nominal NP VP S S

CKY Parser 74 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None NP ProperNoun PP Nominal NP VP S S Parse Tree #1

CKY Parser 75 Book the flight through Houston S, VP, Verb, Nominal, Noun Det Nominal, Noun None NP VP S Prep None NP ProperNoun PP Nominal NP VP S S Parse Tree #2

Complexity of CKY (recognition) There are (n(n+1)/2) = O(n 2 ) cells Filling each cell requires looking at every possible split point between the two non- terminals needed to introduce a new phrase. There are O(n) possible split points. Total time complexity is O(n 3 ) 76

Complexity of CKY (all parses) Previous analysis assumes the number of phrase labels in each cell is fixed by the size of the grammar. If compute all derivations for each non- terminal, the number of cell entries can expand combinatorially. Since the number of parses can be exponential, so is the complexity of finding all parse trees. 77

Effect of CNF on Parse Trees Parse trees are for CNF grammar not the original grammar. A post-process can repair the parse tree to return a parse tree for the original grammar. 78

Syntactic Ambiguity Just produces all possible parse trees. Does not address the important issue of ambiguity resolution. 79

Issues with CFGs Addressing some grammatical constraints requires complex CFGs that do no compactly encode the given regularities. Some aspects of natural language syntax may not be captured at all by CFGs and require context-sensitivity (productions with more than one symbol on the LHS). 80

Agreement Subjects must agree with their verbs on person and number. –I am cold. You are cold. He is cold. –* I are cold * You is cold. *He am cold. Requires separate productions for each combination. –S → NP1stPersonSing VP1stPersonSing –S → NP2ndPersonSing VP2ndPersonSing –NP1stPersonSing → … –VP1stPersonSing → … –NP2ndPersonSing → … –VP2ndPersonSing → … 81

Other Agreement Issues Pronouns have case (e.g. nominative, accusative) that must agree with their syntactic position. –I gave him the book. * I gave he the book. –He gave me the book. * Him gave me the book. Many languages have gender agreement. –Los Angeles * Las Angeles –Las Vegas * Los Vegas 82

Subcategorization Specific verbs take some types of arguments but not others. –Transitive verb: “found” requires a direct object John found the ring. * John found. –Intransitive verb: “disappeared” cannot take one John disappeared. * John disappeared the ring. –“gave” takes both a direct and indirect object John gave Mary the ring. * John gave Mary. * John gave the ring. –“want” takes an NP, or non-finite VP or S John wants a car. John wants to buy a car. John wants Mary to take the ring. * John wants. Subcategorization frames specify the range of argument types that a given verb can take. 83

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. 84