Chart Parsing and Augmenting Grammars CSE-391: Artificial Intelligence University of Pennsylvania Matt Huenerfauth March 2005.

Slides:



Advertisements
Similar presentations
Augmented Transition Networks
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.
May 2006CLINT-LN Parsing1 Computational Linguistics Introduction Approaches to Parsing.
Parsing I Context-free grammars and issues for parsers.
Parsing with Context Free Grammars Reading: Chap 13, Jurafsky & Martin
For Monday Read Chapter 23, sections 3-4 Homework –Chapter 23, exercises 1, 6, 14, 19 –Do them in order. Do NOT read ahead.
Artificial Intelligence 2004 Natural Language Processing - Syntax and Parsing - Language, Syntax, Parsing Problems in Parsing Ambiguity, Attachment.
 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.
Context-Free Parsing. 2/37 Basic issues Top-down vs. bottom-up Handling ambiguity –Lexical ambiguity –Structural ambiguity Breadth first vs. depth first.
Amirkabir University of Technology Computer Engineering Faculty AILAB Efficient Parsing Ahmad Abdollahzadeh Barfouroush Aban 1381 Natural Language Processing.
Earley’s algorithm Earley’s algorithm employs the dynamic programming technique to address the weaknesses of general top-down parsing. Dynamic programming.
Amirkabir University of Technology Computer Engineering Faculty AILAB Parsing Ahmad Abdollahzadeh Barfouroush Aban 1381 Natural Language Processing Course,
Syntactic Parsing with CFGs CMSC 723: Computational Linguistics I ― Session #7 Jimmy Lin The iSchool University of Maryland Wednesday, October 14, 2009.
CS 330 Programming Languages 09 / 23 / 2008 Instructor: Michael Eckmann.
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.
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.
THE PARTS OF SYNTAX Don’t worry, it’s just a phrase ELL113 Week 4.
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.
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.
For Friday Finish chapter 23 Homework: –Chapter 22, exercise 9.
CS : Speech, Natural Language Processing and the Web/Topics in Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 12: Deeper.
1 Natural Language Processing Lecture 11 Efficient Parsing Reading: James Allen NLU (Chapter 6)
10. Parsing with Context-free Grammars -Speech and Language Processing- 발표자 : 정영임 발표일 :
Adverbs and Prepositions
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.
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.
1 Chart Parsing Allen ’ s Chapter 3 J & M ’ s Chapter 10.
CSE573 Autumn /27/98 Natural Language Processing Administrative –New version of PS4 on the Web different interface to the Truckworld more extra.
Parsing with Context-Free Grammars References: 1.Natural Language Understanding, chapter 3 (3.1~3.4, 3.6) 2.Speech and Language Processing, chapters 9,
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.
CSE573 Autumn /23/98 Natural Language Processing Administrative –PS3 due today –PS4 out Wednesday, due Friday 3/13 (last day of class) special.
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.
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.
CS 4705 Lecture 7 Parsing with Context-Free Grammars.
◦ Process of describing the structure of phrases and sentences Chapter 8 - Phrases and sentences: grammar1.
GRAMMARS David Kauchak CS457 – Spring 2011 some slides adapted from Ray Mooney.
Instructor: Nick Cercone CSEB - 1 Parsing and Context Free Grammars Parsers, Top Down, Bottom Up, Left Corner, Earley.
CS 330 Programming Languages 09 / 25 / 2007 Instructor: Michael Eckmann.
NATURAL LANGUAGE PROCESSING
CS : Language Technology for the Web/Natural Language Processing Pushpak Bhattacharyya CSE Dept., IIT Bombay Parsing Algos.
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.
Week 3. Clauses and Trees English Syntax. Trees and constituency A sentence has a hierarchical structure Constituents can have constituents of their own.
Parsing Recommended Reading: Ch th Jurafsky & Martin 2nd edition
Beginning Syntax Linda Thomas
Basic Parsing with Context Free Grammars Chapter 13
CS : Speech, NLP and the Web/Topics in AI
CSCI 5832 Natural Language Processing
Natural Language - General
Earley’s Algorithm (1970) Nice combo of our parsing ideas so far:
Parsing and More Parsing
CSA2050 Introduction to Computational Linguistics
David Kauchak CS159 – Spring 2019
Presentation transcript:

Chart Parsing and Augmenting Grammars CSE-391: Artificial Intelligence University of Pennsylvania Matt Huenerfauth March 2005

Homework 6 Due Friday, April 1, (Two weeks.) You will write/modify some grammar rules. You will enact some parsing algorithms by hand. You will use the chart-parsing Python code from the textbook (we’ll learn about chart parsing today).

Last time: Our grammar S  NP VPVP  V VP  V NP NP  pronoun NP  nounV  verb NP  det adj nounV  aux verb NP  det noun NON-TERMINAL vs. terminal…

Last time: Two Parsing Approaches Top Down Parsing –Start with the top-level rule for S. –Blindly try all possible rules to build the sub pieces of the original S rule. Recurse. –When you back up, forget structures you built. Bottom Up Parsing –Start by considering the part of speech of all the words. Build all the possible ‘local’ pieces of structure, and slowly build larger pieces.

Last time: Top-down parse [The, old, can, can, hold, the, water] S → NP VP Consider NP… NP → pronoun? pronoun? fail NP → noun? noun? fail NP → det adj noun? det? the adj? old noun? Can Succeed. What about the VP?

Last time: Top-down parse [can, hold, the, water] Consider VP… V → verb? verb? fail V → aux verb? aux? can verb? hold succeed fail [the, water]

Bottom Up Parsing To illustrate bottom-up parsing, we will draw a chart diagram. For a sentence with k words, we will start with k+1 nodes in the diagram. We put edges between adjacent nodes labeled with input words & part of speech. theoldcan holdthewater detadj noun aux verb noun verb noun det noun verb

Drawing an edge… As we apply grammar rules to build a parse, we draw more edges: –An edge has a starting and a stopping point. This represents what input words it covers. –An edge has a label. In the bottom-up algorithm, it looks like this: VP  V NP –This means we just found a V and a NP, and we have combined them to build VP. –We’ll see an example of this on the next slide.

Bottom Up Parsing theoldcan holdthewater detadj noun aux verb noun verb noun det noun verb NP  det noun VP  V NP V  aux verb NP  det nounNP  det adj noun VP  V NP VP  VP NP S  NP VP NP  noun V  verb NP  noun V  verb NP  noun V  verb NP  noun V  verb

Bottom Up Parsing theoldcan holdthewater detadj noun aux verb noun verb noun det noun verb V  aux verbNP  det nounNP  det adj noun VP  VP NP S  NP VP

Three Parsing Algorithms Top Down Parsing –Tries lots of rules, does a lot of backtracking. –Has to re-build structures that it forgets about. –Feels a lot like uninformed search. Bottom Up Parsing –Starts with the small pieces of structure, but it builds everything it can. Don’t need all of it. –Most of it not used in the final complete parse. Top-Down Chart Parsing

(Top Down) Chart Parsing Advantages: –Only build those pieces of structure that we actually need to parse the entire sentence. –Remember pieces of structure that we build in a chart so that if we have to backtrack, we don’t have to build those sub-structures all over again.

Add one more rule… The first thing we do is add one more rule to our grammar. Our goal will be to produce a parse of the whole sentence that produces an S’: S’  S So, this will be the first rule we’ll try to process with the algorithm…

A New Kind of Edge Instead of just drawing edges in our chart diagram for complete structures that we find, now we’ll also add edges that represent incomplete structures that we want to find… For example, an edge labeled: VP  V NP could be used to represent a point in the algorithm where we really want to build a VP, and we have already found a V but have not yet found a NP to complete it. Why would we want such a thing? We’ll see… thecan fall detaux verb noun verb noun

How to Start thecan fall detaux verb noun verb noun S’  S Our goal is to build an edge covering the whole sentence labeled S’. So, we first add an edge that covers no words at the start of the sentence. Since we haven’t found any S yet in order to fulfill the S’ rule, then we have to put the dot in front of the S. So, now our mission is to find an S in this sentence so that we can produce an S’. In other words, when we add edges to the chart that contain dots, then we know we are looking for the thing to the right of the dot.

The Algorithm When we add an edge to the diagram, we give it a blue label. After we “process” the edge, then the label turns black. We will process edges in the order they are added to the diagram. Process edges like a “queue” (breadth-first feel). Could also use “stack” but this is less traditional. We really want all parses, not just one. How to we “process” an edge? It depends on where the dot is. –Before a NON-TERMINAL? –Before a terminal? –At the end?

PREDICT future rules… If the dot is before a NON-TERMINAL. We look up all the rules in the grammar that can produce that NON-TERMINAL. –We add all of these rules to the diagram as edges which cover no words. –We put a dot in front of the first item after the arrow. –Remember: All new edges have blue labels.

Dot before NON-TERMINAL: “Predict” thecan fall detaux verb noun verb noun S’  S (1)

thecan fall detaux verb noun verb noun S’  S S  NP VP Dot before NON-TERMINAL: “Predict” (1) (2)

thecan fall detaux verb noun verb noun S’  S S  NP VP Dot before NON-TERMINAL: “Predict” (1) (2)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before NON-TERMINAL: “Predict” (1) (2) (3) (4) (5) (6)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before NON-TERMINAL: “Predict” (1) (2) (3) (4) (5) (6)

SCAN input words… When the dot is before a terminal… Check the next word of input to see if any of its parts of speech matches the terminal symbol. If there is a match, then we: spread the rule to the right and we move the dot to the right as well.

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” (1) (2) (3) (4) (5) (6)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” (1) (2) (3) (4) (5) (6)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” (1) (2) (3) (4) (5) (6)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” NP  det noun (1) (2) (3) (4) (5) (6) (7)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” NP  det noun (1) (2) (3) (4) (5) (6) (7)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” NP  det noun NP  det adj noun (1) (2) (3) (4) (5) (6) (7) (8)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” NP  det noun NP  det adj noun (1) (2) (3) (4) (5) (6) (7) (8)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” NP  det noun NP  det adj noun NP  det noun (1) (2) (3) (4) (5) (6) (7) (8) (9)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” NP  det noun NP  det adj noun NP  det noun (1) (2) (3) (4) (5) (6) (7) (8) (9)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot before terminal: “Scan” NP  det noun NP  det adj noun NP  det noun (1) (2) (3) (4) (5) (6) (7) (8) (9)

Edge Extension When the dot is at the end of the label… Assume current edge is labeled: X  … –Look at all of the edges that ended where the current edge began. –If any of these preceding edges have a label of the form: …  … X … –Then spread this preceding edge across the width of the current edge, and label it: …  … X … (move the dot to the right)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot at end: “Edge Extension” NP  det noun NP  det adj noun NP  det noun (1) (2) (3) (4) (5) (6) (7) (8) (9)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot at end: “Edge Extension” NP  det noun NP  det adj noun NP  det noun (1) (2) (3) (4) (5) (6) (7) (8) (9)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot at end: “Edge Extension” NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot at end: “Edge Extension” NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun Dot at end: “Edge Extension” NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Remember… Process one edge at a time in the order they were added to the diagram. (queue) If the dot is just before: –a NON-TERMINAL: Then “predict.” (grab rules from the grammar) –a terminal: Then “scan.” (compare to POS of next word) –the end of the label: Then “edge extend.” (check preceding edges) Don’t add an edge with same exact label and same exact span as a previous one.

thecan fall detaux verb noun verb noun NP  det noun NP  det adj noun NP  det noun S  NP VP (7) (8) (9) (10) S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun (1) (2) (3) (4) (5) (6)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP (11) (12)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP (11) (12)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb (15)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb (15)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb (15) (16)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb (15) (16)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb (15) (16)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19) S  NP VP (20)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19) S  NP VP (20)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19) S  NP VP (20) NP  pro NP  noun NP  det noun NP  det adj noun (21) (22) (23) (24)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19) S  NP VP (20) NP  pro NP  noun NP  det noun NP  det adj noun (21) (22) (23) (24)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19) S  NP VP (20) NP  pro NP  noun NP  det noun NP  det adj noun (21) (22) (23) (24)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19) S  NP VP (20) NP  pro NP  noun NP  det noun NP  det adj noun (21) (22) (23) (24) VP  V VP  V NP (25) (26)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19) S  NP VP (20) NP  pro NP  noun NP  det noun NP  det adj noun (21) (22) (23) (24) VP  V VP  V NP (25) (26)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19) S  NP VP (20) NP  pro NP  noun NP  det noun NP  det adj noun (21) (22) (23) (24) VP  V VP  V NP (25) (26)

thecan fall detaux verb noun verb noun S’  S S  NP VP NP  pro NP  noun NP  det noun NP  det adj noun NP  det noun NP  det adj noun NP  det noun S  NP VP (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) VP  V VP  V NP V  verb V  aux verb (11) (12) (13) (14) V  verb V  aux verb VP  V VP  V NP (15) (16) (17) (18) V  aux verb (19) S  NP VP (20) NP  pro NP  noun NP  det noun NP  det adj noun (21) (22) (23) (24) VP  V VP  V NP (25) (26) We’ll stop here for now, but you would continue until you found a S’ edge that covered all the words.

Hybrid Approach This use of dots helps us understand what we are looking for – it gives this parsing algorithm its top-down feel. –In other words, we are guided to look for only those syntactic structures that will help build a parse for the whole sentence. The use of a chart diagram gives this algorithm a bottom-up feel (we used a diagram in the bottom-up algorithm).

Augmenting a Grammar

How Do You Modify a Grammar What if we want to extend a grammar to include a new linguistic structure? S  NP VPVP  V VP  V NP NP  pronoun NP  nounV  verb NP  det adj nounV  aux verb NP  det noun

Adding Adverbs How would we augment this grammar to add adverbs and adverb phrases? We’d like to allow sentences like: The can can fall quickly. The can can fall quickly and quietly. The can can quickly fall. Quickly the can can fall.

Adding Adverbs How would we augment this grammar to add adverbs and adverb phrases? We’d like to allow sentences like: The can can fall quickly. The can can fall quickly and quietly. The can can quickly fall. Quickly the can can fall.

Modify the lexicon… Let’s add the new words we need… –Quickly, quietly, and. What part of speech are they? –Adverb: quickly –Adverb: quietly –Conjunction: and

Modify Grammar (1) We’d like to allow single adverbs and adverbs combined with ‘and’ to occur in sentences… –So we add a new kind of NON-TERMINAL to the grammar: an adverb phrase. ADVP ADVP  adv ADVP  adv conj adv –This defines the internal structure of an adverb phrase.

Modify Grammar (2) Now that we have specified the internal structure of an adverb phrase, we should add rules to specify how to position adverb phrases within entire sentences. Where do we want to allow adverb phrases to go? –Start of sentence. –End of sentence. –Between aux and verb.

Beginning / End of Sentences Modify the rules for a sentence… S  NP VP S  ADVP NP VP S  NP VP ADVP But how to we position adverb phrases between aux’s and verb’s ?

Beginning / End of Sentences Modify the rules for a sentence… S  NP VP S  ADVP NP VP S  NP VP ADVP But how to we position adverb phrases between aux’s and verb’s ?

Between AUX and VERB We have to edit a different rule to allow adverbs between Auxiliaries and Verbs. V  verb V  aux verb V  aux ADVP verb In between aux and verb…

Our New Grammar S  NP VPVP  V S  ADVP NP VPVP  V NP S  NP VP ADVP V  verb NP  pronoun V  aux verb NP  noun V  aux ADVP verb NP  det adj noun NP  det nounADVP  adv ADVP  adv conj adv

Our New Lexicon Same entries as before, plus… adv(quickly) adv(quietly) conj(and)

Making Changes in Python import nlp.* En = Grammar('En', Rules( S = 'NP VP | ADVP NP VP | NP VP ADVP', NP = 'Pronoun | Noun | Det Noun | Det Adj Noun', VP = 'V | V NP', ADVP = “adv | adv conj adv”, V = 'Verb | Aux Verb | Aux ADVP Verb‘), Lexicon( Noun = "old | can | fall | hold | water", Aux = "can", Verb = "can | hold | fall | water", Adj = "old", Adv = "quickly | happily", Conj = "and", Pronoun = "me | you | I | it", Det = "the | a | an" )) Ec = Chart(En)