CS 4705 Lecture 7 Parsing with Context-Free Grammars.

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
GRAMMAR & PARSING (Syntactic Analysis) NLP- WEEK 4.
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.
1 Earley Algorithm Chapter 13.4 October 2009 Lecture #9.
 Christel Kemke /08 COMP 4060 Natural Language Processing PARSING.
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
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.
CMSC 723 / LING 645: Intro to Computational Linguistics November 10, 2004 Lecture 10 (Dorr): CFG’s (Finish Chapter 9) Parsing (Chapter 10) Prof. Bonnie.
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.
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.
CPSC 503 Computational Linguistics
Syntax Construction of phrases and sentences from morphemes and words. Usually the word syntax refers to the way words are arranged together. Syntactic.
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 CPE 480 Natural Language Processing Lecture 5: Parser Asst. Prof. Nuttanart Facundes, Ph.D.
CS 4705 Parsing More Efficiently and Accurately. Review Top-Down vs. Bottom-Up Parsers Left-corner table provides more efficient look- ahead Left recursion.
For Friday Finish chapter 23 Homework: –Chapter 22, exercise 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.
LINGUISTICA GENERALE E COMPUTAZIONALE ANALISI SINTATTICA (PARSING)
10. Parsing with Context-free Grammars -Speech and Language Processing- 발표자 : 정영임 발표일 :
Fall 2004 Lecture Notes #4 EECS 595 / LING 541 / SI 661 Natural 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.
PARSING David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
6/2/2016CPSC503 Winter CPSC 503 Computational Linguistics Lecture 9 Giuseppe Carenini.
For Wednesday Read chapter 23 Homework: –Chapter 22, exercises 1,4, 7, and 14.
CPE 480 Natural Language Processing Lecture 4: Syntax Adapted from Owen Rambow’s slides for CSc Fall 2006.
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,
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.
1 Context Free Grammars October Syntactic Grammaticality Doesn’t depend on Having heard the sentence before The sentence being true –I saw a unicorn.
NLP. Introduction to NLP Motivation –A lot of the work is repeated –Caching intermediate results improves the complexity Dynamic programming –Building.
November 2004csa3050: Sentence Parsing II1 CSA350: NLP Algorithms Sentence Parsing 2 Top Down Bottom-Up Left Corner BUP Implementation in Prolog.
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.
Natural Language Processing Lecture 15—10/15/2015 Jim Martin.
CPSC 422, Lecture 27Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27 Nov, 16, 2015.
Instructor: Nick Cercone CSEB - 1 Parsing and Context Free Grammars Parsers, Top Down, Bottom Up, Left Corner, Earley.
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 =
November 2004csa3050: Parsing Algorithms 11 CSA350: NLP Algorithms Parsing Algorithms 1 Top Down Bottom-Up Left Corner.
PARSING David Kauchak CS159 – Fall Admin Assignment 3 Quiz #1  High: 36  Average: 33 (92%)  Median: 33.5 (93%)
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 -
Basic Parsing with Context Free Grammars Chapter 13
CPSC 503 Computational Linguistics
Natural Language - General
Parsing and More Parsing
CSA2050 Introduction to Computational Linguistics
David Kauchak CS159 – Spring 2019
Artificial Intelligence 2004 Speech & Natural Language Processing
Presentation transcript:

CS 4705 Lecture 7 Parsing with Context-Free Grammars

Linguistic Representations Sounds –Phonemes, Words, Intonational phrases Words –Classes: groups of words which behave similarly –Function/Content –P.O.S.: Nouns, Verbs, Adjectives, Prepositions Constituents: –Groupings of words into larger units which behavior similarly and have a particular p.o.s. as their head –Phrases: NP headed by Noun... VP, PP,... Discourses

Analyzing Language in Terms of these Representations Morphological parsing: –analyze words into morphemes and affixes –rule-based, FSAs, FSTs Phonological parsing: –analyze sounds into words and phrases POS Tagging Syntactic parsing: –identify component parts and how related –to see if a sentence is grammatical –to assign a semantic structure

Syntactic Parsing Declarative formalisms like CFGs define the legal strings of a language but don’t specify how to recognize or assign structure to them Parsing algorithms specify how to recognize the strings of a language and assign each string one or more syntactic structures Parse trees useful for grammar checking, semantic analysis, MT, QA, information extraction, speech recognition…and almost every task in NLP

Parsing as a Search Problem Searching FSAs –Finding the right path through the automaton –Search space defined by structure of FSA Searching CFGs –Finding the right parse tree among all possible parse trees –Search space defined by the grammar Constraints provided by the input sentence and the automaton or grammar

CFG for Fragment of English S  NP VPVP  V S  Aux NP VPDet  that | this | a S  VPN  book | flight | meal | money NP  Det NomV  book | include | prefer NP  PropNAux  does Nom  N NomPrep  from | to | on Nom  NPropN  Houston | TWA Nom  Nom PP VP  V NP TopDBotUpE.g. LC’s

S VP NP Nom VDet N Bookthatflight Parse Tree for ‘Book that flight’ for Prior CFGPrior CFG

Top-Down Parser Builds from the root S node to the leaves Assuming we build all trees in parallel: –Find all trees with root S (or all rules w/lhs S)all trees with root S all rules w/lhs S –Next expand all constituents in these trees/rules –Continue until leaves are pos –Candidate trees failing to match pos of input string are rejected (e.g. Book that flight can only match subtree 5)

Top-Down Search Space for CFG (expanding only leftmost leaves)Search SpaceCFG SSS NPVPAuxNPVPVP S S S SSS NP VPNP VP Aux NP VPAux NP VPVP VP Det NomPropNDet NomPropN V NPV Det Nom N

Bottom-Up Parsing Parser begins with words of input and builds up trees, applying grammar rules w/rhs matchgrammar rules –Book that flight NDetNVDetN BookthatflightBookthatflight –‘Book’ ambiguous –Parse continues until an S root node reached or no further node expansion possible

Two Candidates: One Successful ParseOne Successful Parse S VP VPNPNPNom VDetNVDetN BookthatflightBookthatflight

Comparing Top-Down and Bottom-Up Top-Down parsers never explore illegal parses (e.g. can’t form an S) -- but waste time on trees that can never match the inputTop-Down parsers Bottom-Up parsers never explore trees inconsistent with input -- but waste time exploring illegal parses (no S root)Bottom-Up parsers For both: how to explore the search space? –Pursuing all parses in parallel or …? –Which rule to apply next? –Which node to expand next?

A Top-Down Parsing Strategy Depth-first search: –Agenda of search states: expand search space incrementally, exploring most recently generated state (tree) each time incrementally –When you reach a state (tree) inconsistent with input, backtrack to most recent unexplored state (tree) Which node to expand? –Leftmost or rightmost Which grammar rule to use? –Order in the grammar

Top-Down, Depth-First, Left-Right Strategy Initialize agenda with ‘S’ tree and ptr to first word and make this current search state (cur) Loop until successful parse or empty agenda –Apply all applicable grammar rules to leftmost unexpanded node of curgrammar rules If this node is a POS category and matches that of the current input, push this onto agenda O.w. push new trees onto agenda –Pop new cur from agenda Does this flight include a meal?

Fig 10.7 CFG

Augmenting Top-Down Parsing with Bottom- Up Filtering We saw: Top-Down, depth-first, L2R parsing –Expands non-terminals along the tree’s left edge down to leftmost leaf of tree –Moves on to expand down to next leftmost leaf… –In a successful parse, current input word will be first word in derivation of node parser currently processing –So….lookahead to left-corner of the tree in B is a left-corner of A if A =*=> B Build table with left-corners of all non-terminals in grammar and consult before applying rule

Left Corners

Left-Corner Table for CFGCFG

Summing Up Parsing is a search problem which may be implemented with many search strategies –Top-Down or Bottom-Up approaches each have problems –Combining the two solves some Next time: Read Ch For fun: Work on your homework….