Albert Gatt LIN3022 Natural Language Processing Lecture 8.

Slides:



Advertisements
Similar presentations
School of something FACULTY OF OTHER School of Computing FACULTY OF ENGINEERING Parsing: computing the grammatical structure of English sentences COMP3310.
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.
Grammars, Languages and Parse Trees. Language Let V be an alphabet or vocabulary V* is set of all strings over V A language L is a subset of V*, i.e.,
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- 발표자 : 정영임 발표일 :
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.
PCFG Parsing, Evaluation, & Improvements Ling 571 Deep Processing Techniques for NLP January 24, 2011.
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
CS Basic Parsing with Context-Free Grammars.
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.
1/13 Parsing III Probabilistic Parsing and Conclusions.
Features and Unification
1/17 Probabilistic Parsing … and some other approaches.
Parsing — Part II (Ambiguity, Top-down parsing, Left-recursion Removal)
CS 4705 Lecture 7 Parsing with Context-Free Grammars.
CS 4705 Basic Parsing with Context-Free Grammars.
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.
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.
EECS 6083 Intro to Parsing Context Free Grammars
TEORIE E TECNICHE DEL RICONOSCIMENTO Linguistica computazionale in Python: -Analisi sintattica (parsing)
October 2008csa3180: Setence Parsing Algorithms 1 1 CSA350: NLP Algorithms Sentence Parsing I The Parsing Problem Parsing as Search Top Down/Bottom Up.
1 CPE 480 Natural Language Processing Lecture 5: Parser Asst. Prof. Nuttanart Facundes, Ph.D.
1 Statistical Parsing Chapter 14 October 2012 Lecture #9.
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)
Lesson 3 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
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.
Page 1 Probabilistic Parsing and Treebanks L545 Spring 2000.
Parsing Introduction Syntactic Analysis I. Parsing Introduction 2 The Role of the Parser The Syntactic Analyzer, or Parser, is the heart of the front.
Bernd Fischer RW713: Compiler and Software Language Engineering.
Albert Gatt Corpora and Statistical Methods Lecture 11.
For Wednesday Read chapter 23 Homework: –Chapter 22, exercises 1,4, 7, and 14.
Natural Language - General
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:
LING 001 Introduction to Linguistics Spring 2010 Syntactic parsing Part-Of-Speech tagging Apr. 5 Computational linguistics.
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.
CS 4705 Lecture 7 Parsing with Context-Free Grammars.
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.
October 2005CSA3180: Parsing Algorithms 21 CSA3050: NLP Algorithms Parsing Algorithms 2 Problems with DFTD Parser Earley Parsing Algorithm.
NLP. Introduction to NLP Time flies like an arrow –Many parses –Some (clearly) more likely than others –Need for a probabilistic ranking method.
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%)
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 -
10/31/00 1 Introduction to Cognitive Science Linguistics Component Topic: Formal Grammars: Generating and Parsing Lecturer: Dr Bodomo.
Basic Parsing with Context Free Grammars Chapter 13
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
Natural Language - General
Parsing and More Parsing
Lecture 7: Introduction to Parsing (Syntax Analysis)
David Kauchak CS159 – Spring 2019
Presentation transcript:

Albert Gatt LIN3022 Natural Language Processing Lecture 8

In this lecture We begin to look at the task of syntactic parsing Overview of grammar formalisms (especially CFGs) Overview of parsing algorithms

The task Example input sentence: Book that flight. What does a parser need to do? Recognise the sentence as a legal sentence of English. (i.e. That the sentence is allowed by the grammar) Identify the correct underlying structure for that sentence. More precisely, identify all the allowable structures for the sentence.

Why parsing is useful Several NLP applications use parsing as a first step. Grammar checking If a sentence typed by an author has no parse, then it is either ungrammatical or probably hard to read. Question answering: E.g. What laws have been passed during Obama’s presidency? Requires knowledge that: Subject is what laws (i.e. this is a question about legislation) Adjunct is during Obama’s presidency... Machine translation Many MT algorithms work by mapping from input to target language. Parsing the input makes it easier to consider syntactic differences between languages.

A simple context-free grammar Jurafsky & Martin 2009, p. 462

The parse Things to note The parse tree has one root node (S). Every path through the tree represents a sequence of rule applications. The tree has 3 leaf nodes. This is a constraint imposed by the input sentence.

Grammar vs parse A grammar specifies the space of possible structures in a language. Remember our discussion of FS models for morphology. The FSA defines the space of possible words in the language. But a grammar does not tell us how an input sentence is to be parsed. Therefore, we need to consider algorithms to search through the space of possibilities and return the right structure.

Part 1 Context-free grammars

Parsing with CFGs Many parsing algorithms use the CFG formalism. We therefore need to consider: The definition of CFGs Their scope.

CFG definition A CFG is a 4-tuple: (N, Σ,P,S): N = a set of non-terminal symbols (e.g. NP, VP) Σ = a set of terminals (e.g. words) N and Σ are disjoint (no element of N is also an element of Σ ) P = a set of productions of the form A  β where: A is a non-terminal (a member of N) β is any string of terminals and non-terminals S = a designated start symbol (usually, “sentence”)

A CFG example in more detail S  NP VP S  Aux NP VP NP  Det Nom NP  Proper-Noun Det  that | the | a … Some of these rules are “lexical” The grammar defines a space of possible structures (e.g. Two possible types of sentence) A parsing algorithm needs to search through that space for a structure which: Covers the whole of the input string. Starts with root node S.

Where does a CFG come from? CFGs can of course be written by hand. However: Wide-coverage grammars are very laborious to write. There is no guarantee that we have covered all the (realistic) rules of a language. For this reason, many parsers employ grammars which are automatically extracted from a treebank. A corpus of naturally occurring text; Each sentence in the corpus manually parsed. If the corpus is large enough, we have some guarantee that a broad range of phenomena will be covered.

The Penn Treebank Created at the University of Pennsylvania. Widely used for many parsing tasks. Manually parsed corpus with texts from: Brown corpus (general Americal English) Switchboard corpus (telephone conversations) Wall Street Journal (news, finance) ATIS (Air Traffic Information System) Quite neutral as regards the syntactic theory used. Parses conform to the CFG formalism.

Penn Treebank example Brown extractATIS extract Jurafsky & Martin 2009, p. 439

Some things to note Quite flat structures. Some grammatical function information marked (SBJ, PRD)

Marking up syntactic movement Marks object of “said” as preceding sentence.

Top-down parsing One way to think of parsing is as a goal-directed search: 1. Start from the root node S (the goal). 2. Recursively expand S until every part of the input is covered.

Bottom-up parsing Another way to think of parsing is as a bottom-up or data-directed search: 1. Start from the individual words. 2. Recursively find the rules that will cover increasingly large parts of the input until: all words are covered and S is reached.

Part 2 Top-down parsing

A top-down parser searches for a parse tree by trying to build from the root S down to the leaves. Basic procedure: 1. Assume that the input can be derived from S 2. Find all the possible expansions of S in the grammar (the set of possible “expectations”) 3. For each expansion, use the right hand side of the rule to create a new set of expectations Continue until at least one expansion matches the part-of-speech categories of the input words. 6. Reject all non-matching expansions.

Top-down: Book that flight 1. Assume that the input can be derived from S

Top-down: Book that flight 1. Assume that the input can be derived from S. 2. Find all the possible expansions of S in the grammar.

Top-down: Book that flight 1. Assume that the input can be derived from S. 2. Find all the possible expansions of S in the grammar. 3. For each expansion, use the right hand side of the rule to create a new set of expectations.

Top-down: Book that flight 1. Assume that the input can be derived from S. 2. Find all the possible expansions of S in the grammar. 3. For each expansion, use the right hand side of the rule to create a new set of expectations. 4. Reject all non-matching parses

Some important terminology We can think of this as a search through ever-deeper levels. Each level of the search is called a ply. First ply Second ply Third ply

Part 3 Bottom-up parsing

The earliest parsing algorithm proposed was bottom-up. Very common technique for parsing artificial languages (especially programming languages, which need to be parsed in order for a computer to “understand” a program and follow its instructions).

Bottom-up parsing The basic procedure: 1. Start from the words, and find terminal rules in the grammar that have each individual word as RHS. (e.g. Det  that) 2. Continue recursively applying grammar rules one at a time until the S node is reached. 3. At each ply, throw away any partial trees that cannot be further expanded.

Bottom-up: Book that flight 1. Start from the words

Bottom-up: Book that flight 1. Start from the words 2. find terminal rules in the grammar that have each individual word as RHS Ambiguity results in bifurcation of search space.

Bottom-up: Book that flight 1. Start from the words 2. find terminal rules in the grammar that have each individual word as RHS Ambiguity results in bifurcation of search space. 3. Recursively build structure by applying grammar rules whose RHS matches input.

Bottom-up: Book that flight 1. Start from the words 2. find terminal rules in the grammar that have each individual word as RHS Ambiguity results in bifurcation of search space. 3. Recursively build structure by applying grammar rules whose RHS matches input.

Bottom-up: Book that flight 1. Start from the words 2. find terminal rules in the grammar that have each individual word as RHS Ambiguity results in bifurcation of search space. 3. Recursively build structure by applying grammar rules whose RHS matches input. 4. Prune non-matching trees. 5. Continue until S is reached.

Top-down vs bottom-up Top-downBottom-up Never considers derivations that do not end up at root S. Wastes a lot of time with trees that are inconsistent with the input. Generates many subtrees that will never lead to an S. Only considers trees that cover some part of the input.

Part 4 The problem of ambiguity (again)

Syntactic ambiguity Broadly, a sentence is ambiguous if it has more than one parse. Local ambiguity: a sentence can be unambiguous (have only one correct parse), but manifest local ambiguity in one or more of its subtrees. Book that flight Unambiguous, but a local ambiguity arises with book (N or V) Global ambiguity: a sentence can have more than one correct parse.

Global ambiguity Ambiguity is pervasive, but we often don’t notice it, because we default to a “most likely” parse using: Semantic knowledge; Pragmatic and real-world knowledge; Statistical probabilities. Example (with apologies to Groucho Marx): I shot an elephant in my pyjamas.

Of elephants and pyjamas

Two common types of ambiguity Attachment ambiguity: A phrase can attach to more than one head. I [shot [the elephant] [in my pyjamas]] I [shot [the elephant in my pyjamas]] Coordination ambiguity: A coordinate phrase is ambiguous in relation to its modifiers. [old men] and [shoes] [old [men and shoes]] An example of PP attachment ambiguity (very common)

Syntactic disambiguation In the absence of statistical, semantic and pragmatic knowledge, it is difficult to perform disambiguation. On the other hand, returning all possible parses of a sentence can be very inefficient. Large grammar  bigger search space  more possibilities  more ambiguity No of possible parses grows exponentially with a large grammar

Beyond simple algorithms Next week, we’ll start looking at some solutions to these problems: Dynamic programming algorithms Algorithms that don’t search exhaustively through a space of possibilities, but resolve a problem by breaking it down into partial solutions. Using corpus-derived probabilities to identify the best parse.