29 November 20151 Parsing Context-free grammars Part 2 ICS 482 Natural Language Processing Lecture 13: Parsing Context-free grammars Part 2 Husni Al-Muhtaseb.

Slides:



Advertisements
Similar presentations
12/18/20141 Machine Translation ICS 482 Natural Language Processing Lecture 29-2: Machine Translation Husni Al-Muhtaseb.
Advertisements

4/14/20151 REGULAR EXPRESSIONS AND AUTOMATA Lecture 3: REGULAR EXPRESSIONS AND AUTOMATA Husni Al-Muhtaseb.
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.
PARSING WITH CONTEXT-FREE GRAMMARS
5/12/20151 N-Gram: Part 1 ICS 482 Natural Language Processing Lecture 7: N-Gram: Part 1 Husni Al-Muhtaseb.
Parsing with Context Free Grammars Reading: Chap 13, Jurafsky & Martin
1 Lexicalized and Probabilistic Parsing – Part 1 ICS 482 Natural Language Processing Lecture 14: Lexicalized and Probabilistic Parsing – Part 1 Husni Al-Muhtaseb.
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.
Parsing context-free grammars Context-free grammars specify structure, not process. There are many different ways to parse input in accordance with a given.
Parsing with CFG Ling 571 Fei Xia Week 2: 10/4-10/6/05.
6/11/20151 Parsing Context-free grammars – Part 1 ICS 482 Natural Language Processing Lecture 12: Parsing Context-free grammars – Part 1 Husni Al-Muhtaseb.
Earley’s algorithm Earley’s algorithm employs the dynamic programming technique to address the weaknesses of general top-down parsing. Dynamic programming.
NLP Credits and Acknowledgment These slides were adapted from presentations of the Authors of the book SPEECH and LANGUAGE PROCESSING: An Introduction.
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.
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.
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.
Semantics: Representing Meaning ICS 482 Natural Language Processing
1 N-Gram – Part 2 ICS 482 Natural Language Processing Lecture 8: N-Gram – Part 2 Husni Al-Muhtaseb.
BİL711 Natural Language Processing
CS 4705 Parsing More Efficiently and Accurately. Review Top-Down vs. Bottom-Up Parsers Left-corner table provides more efficient look- ahead Left recursion.
1 CKY and Earley Algorithms Chapter 13 October 2012 Lecture #8.
10/13/20151 Representing Meaning Part 4 & Semantic Analysis ICS 482 Natural Language Processing Lecture 21: Representing Meaning Part 4 & Semantic Analysis.
LINGUISTICA GENERALE E COMPUTAZIONALE ANALISI SINTATTICA (PARSING)
Understanding Natural Language
10. Parsing with Context-free Grammars -Speech and Language Processing- 발표자 : 정영임 발표일 :
Chapter 13: Parsing with Context-Free Grammars Heshaam Faili University of Tehran.
11 Syntactic Parsing. Produce the correct syntactic parse tree for a sentence.
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.
5/31/20161 Lexical Semantic + Students Presentations ICS 482 Natural Language Processing Lecture 26: Lexical Semantic + Students Presentations Husni Al-Muhtaseb.
11 Chapter 14 Part 1 Statistical Parsing Based on slides by Ray Mooney.
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.
1 Parts of Speech Part 1 ICS 482 Natural Language Processing Lecture 9: Parts of Speech Part 1 Husni Al-Muhtaseb.
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.
Quick Speech Synthesis CMSC Natural Language Processing April 29, 2003.
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.
12/22/20151 Representing Meaning Part 2 ICS 482 Natural Language Processing Lecture 18: Representing Meaning Part 2 Husni Al-Muhtaseb.
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,
1/31/20161 Lexical Semantic 2 ICS 482 Natural Language Processing Lecture 29-1: Lexical Semantic 2 Husni Al-Muhtaseb.
Instructor: Nick Cercone CSEB - 1 Parsing and Context Free Grammars Parsers, Top Down, Bottom Up, Left Corner, Earley.
October 2005CSA3180: Parsing Algorithms 21 CSA3050: NLP Algorithms Parsing Algorithms 2 Problems with DFTD Parser Earley Parsing Algorithm.
3/7/20161 Representing Meaning Part 3 ICS 482 Natural Language Processing Lecture 20: Representing Meaning Part 3 Husni Al-Muhtaseb.
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 Recommended Reading: Ch th Jurafsky & Martin 2nd edition
Basic Parsing with Context Free Grammars Chapter 13
CPSC 503 Computational Linguistics
Grammars August 31, /16/2018.
CSCI 5832 Natural Language Processing
CKY Parser 0Book 1 the 2 flight 3 through 4 Houston5 11/16/2018
Natural Language - General
Parsing and More Parsing
Parsing I: CFGs & the Earley Parser
Information Extraction ICS 482 Natural Language Processing
David Kauchak CS159 – Spring 2019
Lecture 27: Husni Al-Muhtaseb
Context-free grammars ICS 482 Natural Language Processing
Presentation transcript:

29 November Parsing Context-free grammars Part 2 ICS 482 Natural Language Processing Lecture 13: Parsing Context-free grammars Part 2 Husni Al-Muhtaseb

29 November بسم الله الرحمن الرحيم ICS 482 Natural Language Processing Lecture 13: Parsing Context-free grammars Part 2 Husni Al-Muhtaseb

NLP Credits and Acknowledgment These slides were adapted from presentations of the Authors of the book SPEECH and LANGUAGE PROCESSING: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition and some modifications from presentations found in the WEB by several scholars including the following

NLP Credits and Acknowledgment If your name is missing please contact me muhtaseb At Kfupm. Edu. sa

NLP Credits and Acknowledgment Husni Al-Muhtaseb James Martin Jim Martin Dan Jurafsky Sandiway Fong Song young in Paula Matuszek Mary-Angela Papalaskari Dick Crouch Tracy Kin L. Venkata Subramaniam Martin Volk Bruce R. Maxim Jan Hajič Srinath Srinivasa Simeon Ntafos Paolo Pirjanian Ricardo Vilalta Tom Lenaerts Heshaam Feili Björn Gambäck Christian Korthals Thomas G. Dietterich Devika Subramanian Duminda Wijesekera Lee McCluskey David J. Kriegman Kathleen McKeown Michael J. Ciaraldi David Finkel Min-Yen Kan Andreas Geyer-Schulz Franz J. Kurfess Tim Finin Nadjet Bouayad Kathy McCoy Hans Uszkoreit Azadeh Maghsoodi Khurshid Ahmad Staffan Larsson Robert Wilensky Feiyu Xu Jakub Piskorski Rohini Srihari Mark Sanderson Andrew Elks Marc Davis Ray Larson Jimmy Lin Marti Hearst Andrew McCallum Nick Kushmerick Mark Craven Chia-Hui Chang Diana Maynard James Allan Martha Palmer julia hirschberg Elaine Rich Christof Monz Bonnie J. Dorr Nizar Habash Massimo Poesio David Goss-Grubbs Thomas K Harris John Hutchins Alexandros Potamianos Mike Rosner Latifa Al-Sulaiti Giorgio Satta Jerry R. Hobbs Christopher Manning Hinrich Schütze Alexander Gelbukh Gina-Anne Levow Guitao Gao Qing Ma Zeynep Altan

29 November 2015Husni Al-Muhtaseb6 Previous Lectures  Introduction and Phases of an NLP system  NLP Applications - Chatting with Alice  Finite State Automata & Regular Expressions & languages  Morphology: Inflectional & Derivational  Parsing and Finite State Transducers  Stemming & Porter Stemmer  Statistical NLP – Language Modeling  N Grams  Smoothing and NGram: Add-one & Witten-Bell  Parts of Speech and Arabic Parts of Speech  Syntax: Context Free Grammar (CFG)  Parsing Context Free Grammars: Top-Down, Bottom- Up, Top-down parsing with bottom-up filtering

29 November 2015Husni Al-Muhtaseb7 Today's Lecture  Parsing Context Free Grammars Dynamic  Earley’s Algorithm  Reminder: Next Time 25 Minutes Lecture  Tuesday 3 rd April 2007  Chapters 6, 8, 9, 10 and covered material  Sample quiz will be on the site by Monday afternoon

29 November 2015Husni Al-Muhtaseb8 Dynamic Programming  Create table of solutions to sub-problems (e.g. subtrees) as parse proceeds  Look up subtrees for each constituent rather than re- parsing  Since all parses implicitly stored, all available for later disambiguation  Method: Cocke-Younger-Kasami (CYK) (1960) Graham-Harrison-Ruzzo (GHR) (1980) Earley’s (1970) algorithm

29 November 2015Husni Al-Muhtaseb9 Earley’s Algorithm  Uses dynamic programming to do parallel top- down search  First, L2R pass fills out a chart with N+1 states (N: the number of words in the input) Think of chart entries as sitting between words in the input string keeping track of states of the parse at these positions For each word position, chart contains set of states representing all partial parse trees generated to date. E.g. chart[0] contains all partial parse trees generated at the beginning of the sentencechart[0]

29 November 2015Husni Al-Muhtaseb10  Chart entries represent three type of constituents: predicted constituents in-progress constituents completed constituents  Progress in parse represented by Dotted Rules Position of indicates type of constituent 0 Book 1 that 2 flight 3 S  VP, [0,0] (predicting VP) NP  Det Nominal, [1,2] (finding NP) VP  V NP, [0,3] (found VP) [x,y] tells us where the state begins (x) and where the dot lies (y) with respect to the input Earley’s Algorithm

29 November 2015Husni Al-Muhtaseb11 S  VP, [0,0] First 0 means S constituent begins at the start of the input Second 0 means the dot here too So, this is a top-down prediction NP  Det Nominal, [1,2] the NP begins at position 1 the dot is at position 2 so, Det has been successfully parsed Nominal predicted next 0 Book 1 that 2 flight 3

29 November 2015Husni Al-Muhtaseb12 VP  V NP, [0,3] Successful VP parse of entire input

29 November 2015Husni Al-Muhtaseb13 Successful Parse  Final answer found by looking at last entry in chart  If entry resembles S   [0,N] then input parsed successfully  But note that chart will also contain a record of all possible parses of input string, given the grammar -- not just the successful one(s)

29 November 2015Husni Al-Muhtaseb14 Parsing Procedure for the Earley’s Algorithm  Move through each set of states in order, applying one of three operators to each state: predictor: add predictions to the chart scanner: read input and add corresponding state to chart completer: move dot to right when new constituent found  Results (new states) added to current or next set of states in chart  No backtracking and no states removed: keep complete history of parse

29 November 2015Husni Al-Muhtaseb15 Predictor  Intuition: create new states represent top-down expectations  Applied when non-part-of-speech non-terminals are to the right of a dot S  VP [0,0] S  NP VPVP  Verb S  Aux NP VPDet  that | this | a S  VPNoun  book | flight | meal | money NP  Det NominalVerb  book | include | prefer NP  ProperNounAux  does Nominal  Noun NominalPrep  from | to | on Nominal  NounProperNoun  Houston | TWA VP  Verb NPPP  Prep NP  Adds new states to current chart One new state for each expansion of the non-terminal in the grammar VP  V [0,0] VP  V NP [0,0]

29 November 2015Husni Al-Muhtaseb16 Scanner  New states for predicted part of speech.  Applicable when part of speech is to the right of a dot VP  V NP [0,0] ‘Book…’  Looks at current word in input  If match, adds state(s) to next chart VP  V NP [0,1]

29 November 2015Husni Al-Muhtaseb17 Completer  Intuition: parser has discovered a constituent, so must find and advance states all that were waiting for this  Applied when dot has reached right end of rule NP  Det Nominal [1,3]  Find all states with dot at 1 and expecting an NP VP  V NP [0,1]  Adds new (completed) state(s) to current chart VP  V NP [0,3]

29 November 2015Husni Al-Muhtaseb18 CFG for Fragment of English S  NP VPVP  Verb S  Aux NP VPDet  that | this | a S  VPNoun  book | flight | meal | money NP  Det NominalVerb  book | include | prefer NP  ProperNounAux  does Nominal  Noun NominalPrep  from | to | on Nominal  NounProperNoun  Houston | TWA VP  Verb NPPP  Prep NP

29 November 2015Husni Al-Muhtaseb19 Book that flight (Chart [0])  Seed chart with top-down predictions for S from grammargrammar

29 November 2015Husni Al-Muhtaseb20  When dummy start state is processed, it’s passed to Predictor, which produces states representing every possible expansion of S, and adds these and every expansion of the left corners of these trees to bottom of Chart[0]PredictorChart[0]  When VP  Verb, [0,0] is reached, Scanner called, which consults first word of input, Book, and adds first state to Chart[1], VP  Book, [0,1]ScannerChart[1],  Note: When VP  Verb NP, [0,0] is reached in Chart[0], Scanner does not need to add VP  Book, [0,1] again to Chart[1]Chart[1]

29 November 2015Husni Al-Muhtaseb21 Chart[1] Verb  book  passed to Completer, which finds 2 states in Chart[0] whose left corner is Verb and adds them to Chart[1], moving dots to rightCompleterChart[0]

29 November 2015Husni Al-Muhtaseb22  When VP  Verb  is itself processed by the Completer, S  VP  is added to Chart[1] Chart[1]  Last 2 rules in Chart[1] are added by Predictor when VP  Verb  NP is processedChart[1] Predictor  And so on….

29 November 2015Husni Al-Muhtaseb23 Example  Book that flight  We should find… an S from 0 to 3 that is a completed state…

29 November 2015Husni Al-Muhtaseb24 Example: Book that flight

29 November 2015Husni Al-Muhtaseb25

29 November 2015Husni Al-Muhtaseb26 Example

29 November 2015Husni Al-Muhtaseb27 Example

29 November 2015Husni Al-Muhtaseb28 Earley Algorithm  The Earley algorithm has three main functions that do all the work. Predictor: Adds predictions into the chart. It is activated when the dot (in a state) is in the front of a non-terminal which is not a part of speech. Completer: Moves the dot to the right when new constituents are found. It is activated when the dot is at the end of a state. Scanner: Reads the input words and enters states representing those words into the chart. It is activated when the dot (in a state) is in the front of a non-terminal which is a part of speech.  The Early algorithm uses theses functions to maintain the chart.

29 November 2015Husni Al-Muhtaseb29 Predictor procedure PREDICTOR((A    B , [i,j])) for each (B   ) in GRAMMAR-RULES- FOR(B,grammar) do ENQUEUE((B   , [j,j]), chart[j]) end

29 November 2015Husni Al-Muhtaseb30 Completer procedure COMPLETER((B   , [j,k])) for each (A    B , [i,j]) in chart[j] do ENQUEUE((A   B  , [i,k]), chart[k]) end

29 November 2015Husni Al-Muhtaseb31 Scanner procedure SCANNER((A    B , [i,j])) if (B  PARTS-OF-SPEECH(word[j]) then ENQUEUE((B  word[j] , [j,j+1]), chart[j+1]) end

29 November 2015Husni Al-Muhtaseb32 Enqueue procedure ENQUEUE(state,chart-entry) if state is not already in chart-entry then Add state at the end of chart-entry) end

29 November 2015Husni Al-Muhtaseb33 Early Code function EARLY-PARSE(words,grammar) returns chart ENQUEUE((    S, [0,0], chart[0]) for i from 0 to LENGTH(words) do for each state in chart[i] do if INCOMPLETE?(state) and NEXT-CAT(state) is not a PS then PREDICTOR(state) elseif INCOMPLETE?(state) and NEXT-CAT(state) is a PS then SCANNER(state) else COMPLETER(state) end return(chart)

29 November 2015Husni Al-Muhtaseb34 Retrieving Parse Trees from A Chart  To retrieve parse trees from a chart, the representation of each state must be augmented with an additional field to store information about the completed states that generated its constituents.  To collect parse trees, we have to update COMPLETER such that it should add a pointer to the older state onto the list of previous-states of the new state.  Then, the parse tree can be created by retrieving these list of previous-states (starting from the completed state of S).

29 November 2015Husni Al-Muhtaseb35 Chart[0] - with Parse Tree Info S0    S [0,0] []Dummy start state S1S   NP VP [0,0] []Predictor S2NP   Det NOM [0,0] []Predictor S3NP   ProperNoun [0,0] []Predictor S4S   Aux NP VP [0,0] []Predictor S5S   VP [0,0] []Predictor S6VP   Verb [0,0] []Predictor S7VP   Verb NP [0,0] []Predictor

29 November 2015Husni Al-Muhtaseb36 Chart[1] - with Parse Tree Info S8Verb  book  [0,1] []Scanner S9VP  Verb  [0,1] [S8]Completer S10S  VP  [0,1] [S9]Completer S11VP  Verb  NP [0,1] [S8]Completer S12NP   Det NOM [1,1] []Predictor S13NP   ProperNoun [1,1] []Predictor

29 November 2015Husni Al-Muhtaseb37 Chart[2] - with Parse Tree Info S14Det  that  [1,2] []Scanner S15NP  Det  NOM [1,2] [S14]Completer S16NOM   Noun [2,2] []Predictor S17NOM   Noun NOM [2,2] []Predictor

29 November 2015Husni Al-Muhtaseb38 Chart[3] - with Parse Tree Info S18Noun  flight  [2,3] []Scanner S19NOM  Noun  [2,3] [S18]Completer S20NOM  Noun  NOM [2,3] [S18]Completer S21NP  Det NOM  [1,3] [S14,S19]Completer S22VP  Verb NP  [0,3] [S8,S21]Completer S23S  VP  [0,3] [S22]Completer S24NOM   Noun [3,3] []Predictor S25NOM   Noun NOM [3,3] []Predictor

29 November 2015Husni Al-Muhtaseb39 Global Ambiguity S  VerbS  Noun Chart[0] S0    S [0,0] []Dummy start state S1S   Verb [0,0] []Predictor S2S   Noun [0,0] []Predictor Chart[1] S3Verb  book  [0,1] []Scanner S4Noun  book  [0,1] []Scanner S5S  Verb  [0,1] [S3]Completer S6S  Noun  [0,1] [S4] Completer

29 November 2015Husni Al-Muhtaseb40 Error Handling  What happens when we look at the contents of the last table column and don't find a S   rule? Is it a total loss? No... Chart contains every constituent and combination of constituents possible for the input given the grammar  Also useful for partial parsing or shallow parsing used in information extraction

29 November 2015Husni Al-Muhtaseb41 Popup Quiz #1 (7 Minutes)  Given the following grammar and lexicon  S  NP VP,NP  N,VP  V NP,  N  me,N  Ahmad, V  saw  Assume the input is:  Ahmad saw me.  Show the charts content (states) along with the processors while applying Earley's algorithm to the above input sentence assuming the given grammar.

29 November 2015Husni Al-Muhtaseb42 Thank you  السلام عليكم ورحمة الله