Basic Parsing with Context- Free Grammars. Some slides adapted from Julia Hirschberg and Dan Jurafsky

Similar documents
Basic Parsing with Context-Free Grammars. Some slides adapted from Julia Hirschberg and Dan Jurafsky 1

Syntax Parsing 1. Grammars and parsing 2. Top-down and bottom-up parsing 3. Chart parsers 4. Bottom-up chart parsing 5. The Earley Algorithm

Grammars & Parsing, Part 1:

Parsing of part-of-speech tagged Assamese Texts

11/29/2010. Statistical Parsing. Statistical Parsing. Simple PCFG for ATIS English. Syntactic Disambiguation

CS 598 Natural Language Processing

Chapter 4: Valence & Agreement CSLI Publications

Natural Language Processing. George Konidaris

The Interface between Phrasal and Functional Constraints

Informatics 2A: Language Complexity and the. Inf2A: Chomsky Hierarchy

Context Free Grammars. Many slides from Michael Collins

ENGBG1 ENGBL1 Campus Linguistics. Meeting 2. Chapter 7 (Morphology) and chapter 9 (Syntax) Pia Sundqvist

Enhancing Unlexicalized Parsing Performance using a Wide Coverage Lexicon, Fuzzy Tag-set Mapping, and EM-HMM-based Lexical Probabilities

1/20 idea. We ll spend an extra hour on 1/21. based on assigned readings. so you ll be ready to discuss them in class

Parsing natural language

Towards a MWE-driven A* parsing with LTAGs [WG2,WG3]

Introduction to HPSG. Introduction. Historical Overview. The HPSG architecture. Signature. Linguistic Objects. Descriptions.

UNIVERSITY OF OSLO Department of Informatics. Dialog Act Recognition using Dependency Features. Master s thesis. Sindre Wetjen

LTAG-spinal and the Treebank

Parsing with Treebank Grammars: Empirical Bounds, Theoretical Models, and the Structure of the Penn Treebank

Developing a TT-MCTAG for German with an RCG-based Parser

"f TOPIC =T COMP COMP... OBJ

Proof Theory for Syntacticians

RANKING AND UNRANKING LEFT SZILARD LANGUAGES. Erkki Mäkinen DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A ER E P S I M S

Hyperedge Replacement and Nonprojective Dependency Structures

COMPUTATIONAL COMPLEXITY OF LEFT-ASSOCIATIVE GRAMMAR

Efficient Normal-Form Parsing for Combinatory Categorial Grammar

Inleiding Taalkunde. Docent: Paola Monachesi. Blok 4, 2001/ Syntax 2. 2 Phrases and constituent structure 2. 3 A minigrammar of Italian 3

Analysis of Probabilistic Parsing in NLP

Character Stream Parsing of Mixed-lingual Text

Compositional Semantics

Construction Grammar. University of Jena.

Chinese Language Parsing with Maximum-Entropy-Inspired Parser

BANGLA TO ENGLISH TEXT CONVERSION USING OPENNLP TOOLS

Ensemble Technique Utilization for Indonesian Dependency Parser

Modeling Attachment Decisions with a Probabilistic Parser: The Case of Head Final Structures

Accurate Unlexicalized Parsing for Modern Hebrew

Language Acquisition Fall 2010/Winter Lexical Categories. Afra Alishahi, Heiner Drenhaus

Case government vs Case agreement: modelling Modern Greek case attraction phenomena in LFG

Some Principles of Automated Natural Language Information Extraction

A Graph Based Authorship Identification Approach

The CYK -Approach to Serial and Parallel Parsing

Derivational: Inflectional: In a fit of rage the soldiers attacked them both that week, but lost the fight.

The presence of interpretable but ungrammatical sentences corresponds to mismatches between interpretive and productive parsing.

Ch VI- SENTENCE PATTERNS.

Theoretical Syntax Winter Answers to practice problems

Specifying a shallow grammatical for parsing purposes

Adapting Stochastic Output for Rule-Based Semantics

Approaches to control phenomena handout Obligatory control and morphological case: Icelandic and Basque

Chunk Parsing for Base Noun Phrases using Regular Expressions. Let s first let the variable s0 be the sentence tree of the first sentence.

Hans-Ulrich Block, Hans Haugeneder Siemens AG, MOnchen ZT ZTI INF W. Germany. (2) [S' [NP who][s does he try to find [NP e]]s IS' $=~

LNGT0101 Introduction to Linguistics

A Computational Evaluation of Case-Assignment Algorithms

Prediction of Maximal Projection for Semantic Role Labeling

Dear Teacher: Welcome to Reading Rods! Reading Rods offer many outstanding features! Read on to discover how to put Reading Rods to work today!

Linking Task: Identifying authors and book titles in verbose queries

Domain Adaptation for Parsing

Pre-Processing MRSes

Refining the Design of a Contracting Finite-State Dependency Parser

5 Star Writing Persuasive Essay

Machine Learning from Garden Path Sentences: The Application of Computational Linguistics

A Version Space Approach to Learning Context-free Grammars

NATURAL LANGUAGE PARSING AND REPRESENTATION IN XML EUGENIO JAROSIEWICZ

Words come in categories

Jack Jilly can play. 1. Can Jack play? 2. Can Jilly play? 3. Jack can play. 4. Jilly can play. 5. Play, Jack, play! 6. Play, Jilly, play!

Three New Probabilistic Models. Jason M. Eisner. CIS Department, University of Pennsylvania. 200 S. 33rd St., Philadelphia, PA , USA

A Minimalist Approach to Code-Switching. In the field of linguistics, the topic of bilingualism is a broad one. There are many

EdIt: A Broad-Coverage Grammar Checker Using Pattern Grammar

Phenomena of gender attraction in Polish *

The Smart/Empire TIPSTER IR System

2/15/13. POS Tagging Problem. Part-of-Speech Tagging. Example English Part-of-Speech Tagsets. More Details of the Problem. Typical Problem Cases

Part I. Figuring out how English works

The stages of event extraction

Som and Optimality Theory

An Efficient Implementation of a New POP Model

Basic Syntax. Doug Arnold We review some basic grammatical ideas and terminology, and look at some common constructions in English.

Control and Boundedness

Copyright and moral rights for this thesis are retained by the author

SEMAFOR: Frame Argument Resolution with Log-Linear Models

Argument structure and theta roles

On the Notion Determiner

GACE Computer Science Assessment Test at a Glance

Unit 8 Pronoun References

Language acquisition: acquiring some aspects of syntax.

Target Language Preposition Selection an Experiment with Transformation-Based Learning and Aligned Bilingual Data

The College Board Redesigned SAT Grade 12

Towards a Machine-Learning Architecture for Lexical Functional Grammar Parsing. Grzegorz Chrupa la

6.863J Natural Language Processing Lecture 12: Featured attraction. Instructor: Robert C. Berwick

CLASSIFICATION OF PROGRAM Critical Elements Analysis 1. High Priority Items Phonemic Awareness Instruction

Multilingual Document Clustering: an Heuristic Approach Based on Cognate Named Entities

Language properties and Grammar of Parallel and Series Parallel Languages

Seminar - Organic Computing

Good-Enough Representations in Language Comprehension

Interpretive (seeing) Interpersonal (speaking and short phrases)

THE ROLE OF DECISION TREES IN NATURAL LANGUAGE PROCESSING

Algebra 2- Semester 2 Review

Natural Language Analysis and Machine Translation in Pilot - ATC Communication. Boh Wasyliw* & Douglas Clarke $

THE VERB ARGUMENT BROWSER

The building blocks of HPSG grammars. Head-Driven Phrase Structure Grammar (HPSG) HPSG grammars from a linguistic perspective

Generating Test Cases From Use Cases

Transcription:

Basic Parsing with Context- Free Grammars Some slides adapted from Julia Hirschberg and Dan Jurafsky 1

To view past videos: http://globe.cvn.columbia.edu:8080/oncampus.ph p?c=133ae14752e27fde909fdbd64c06b337 Usually available only for 1 week. Right now, available for all previous lectures 2

3

4

5

Declarative formalisms like CFGs, FSAs define the legal strings of a language -- but only tell you this is a legal string of the language X Parsing algorithms specify how to recognize the strings of a language and assign each string one (or more) syntactic analyses 6

the small boy likes a girl Many possible CFGs for English, here is an example (fragment): S NP VP VP V NP NP Det N Adj NP N boy girl V sees likes Adj big small DetP a the *big the small girl sees a boy John likes a girl I like a girl I sleep The old dog the footsteps of the young

S NP VP S Aux NP VP S -> VP VP V VP -> V PP PP -> Prep NP NP Det Nom N old dog footsteps young flight NP PropN V dog include prefer book NP -> Pronoun Nom -> Adj Nom Aux does Nom N Prep from to on of Nom N Nom PropN Bush McCain Obama Nom Nom PP Det that this a the VP V NP Adj -> old green red

Parse Tree for The old dog the footsteps of the young for Prior CFG S NP VP DET NOM V NP N DET NOM The old dog the N footsteps PP of the young

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 10

Builds from the root S node to the leaves Expectation-based Common search strategy Top-down, left-to-right, backtracking Try first rule with LHS = S Next expand all constituents in these trees/rules Continue until leaves are POS Backtrack when candidate POS does not match input string 11

The old dog the footsteps of the young. Where does backtracking happen? What are the computational disadvantages? What are the advantages? 12

Parser begins with words of input and builds up trees, applying grammar rules whose RHS matches Det N V Det N Prep Det N The old dog the footsteps of the young. Det Adj N Det N Prep Det N The old dog the footsteps of the young. Parse continues until an S root node reached or no further node expansion possible 13

Det N V Det N Prep Det N The old dog the footsteps of the young. Det Adj N Det N Prep Det N 14

When does disambiguation occur? What are the computational advantages and disadvantages? 15

Top-Down parsers they never explore illegal parses (e.g. which can t form an S) -- but waste time on trees that can never match the input Bottom-Up parsers they never explore trees inconsistent with input -- but waste time exploring illegal parses (with no S root) For both: find a control strategy -- how explore search space efficiently? Pursuing all parses in parallel or backtrack or? Which rule to apply next? Which node to expand next? 16

Dynamic Programming Approaches Use a chart to represent partial results CKY Parsing Algorithm Bottom-up Grammar must be in Normal Form The parse tree might not be consistent with linguistic theory Early Parsing Algorithm Top-down Expectations about constituents are confirmed by input A POS tag for a word that is not predicted is never added Chart Parser 17

Allows arbitrary CFGs Fills a table in a single sweep over the input words Table is length N+1; N is number of words Table entries represent Completed constituents and their locations In-progress constituents Predicted constituents 18

The table-entries are called states and are represented with dotted-rules. S -> VP NP -> Det Nominal VP -> V NP A VP is predicted An NP is in progress A VP has been found 19

It would be nice to know where these things are in the input so S -> VP [0,0] NP -> Det Nominal [1,2] A VP is predicted at the start of the sentence An NP is in progress; the Det goes from 1 to 2 VP -> V NP [0,3] A VP has been found starting at 0 and ending at 3 20

21

As with most dynamic programming approaches, the answer is found by looking in the table in the right place. In this case, there should be an S state in the final column that spans from 0 to n+1 and is complete. If that s the case you re done. S > α [0,n+1] 22

March through chart left-to-right. At each step, apply 1 of 3 operators Predictor Create new states representing top-down expectations Scanner Match word predictions (rule with word after dot) to words Completer When a state is complete, see what rules were looking for that completed constituent 23

Given a state With a non-terminal to right of dot (not a partof-speech category) Create a new state for each expansion of the non-terminal Place these new states into same chart entry as generated state, beginning and ending where generating state ends. So predictor looking at S ->. VP [0,0] results in VP ->. Verb [0,0] VP ->. Verb NP [0,0] 24

Given a state With a non-terminal to right of dot that is a part-ofspeech category If the next word in the input matches this POS Create a new state with dot moved over the nonterminal So scanner looking at VP ->. Verb NP [0,0] If the next word, book, can be a verb, add new state: VP -> Verb. NP [0,1] Add this state to chart entry following current one Note: Earley algorithm uses top-down input to disambiguate POS! Only POS predicted by some state can get added to chart! 25

Applied to a state when its dot has reached right end of role. Parser has discovered a category over some span of input. Find and advance all previous states that were looking for this category copy state, move dot, insert in current chart entry Given: NP -> Det Nominal. [1,3] VP -> Verb. NP [0,1] Add VP -> Verb NP. [0,3] 26

Find an S state in the final column that spans from 0 to n+1 and is complete. If that s the case you re done. S > α [0,n+1] 27

More specifically 1. Predict all the states you can upfront 2. Read a word 1. Extend states based on matches 2. Add new predictions 3. Go to 2 3. Look at N+1 to see if you have a winner 28

Book that flight We should find an S from 0 to 3 that is a completed state 29

S NP VP S Aux NP VP VP V PP -> Prep NP NP Det Nom N old dog footsteps young NP PropN Nom -> Adj Nom Nom N V dog include prefer Aux does Prep from to on of Nom N Nom PropN Bush McCain Obama Nom Nom PP VP V NP Det that this a the Adj -> old green red

31

32

33

What kind of algorithms did we just describe Not parsers recognizers The presence of an S state with the right attributes in the right place indicates a successful recognition. But no parse tree no parser That s how we solve (not) an exponential problem in polynomial time 34

With the addition of a few pointers we have a parser Augment the Completer to point to where we came from. 35

S8 S9 S10 S11 S12 S13 S8 S9 S8

All the possible parses for an input are in the table We just need to read off all the backpointers from every complete S in the last column of the table Find all the S -> X. [0,N+1] Follow the structural traces from the Completer Of course, this won t be polynomial time, since there could be an exponential number of trees We can at least represent ambiguity efficiently 37

Depth-first search will never terminate if grammar is left recursive (e.g. NP --> NP PP) * * ( Α ααβ, α ε) 38

Solutions: Rewrite the grammar (automatically?) to a weakly equivalent one which is not left-recursive e.g. The man {on the hill with the telescope } NP NP PP (wanted: Nom plus a sequence of PPs) NP Nom PP NP Nom Nom Det N becomes NP Nom NP Nom Det N NP PP NP (wanted: a sequence of PPs) NP e Not so obvious what these rules mean

Harder to detect and eliminate non-immediate left recursion NP --> Nom PP Nom --> NP Fix depth of search explicitly Rule ordering: non-recursive rules first NP --> Det Nom NP --> NP PP 40

Multiple legal structures Attachment (e.g. I saw a man on a hill with a telescope) Coordination (e.g. younger cats and dogs) NP bracketing (e.g. Spanish language teachers) 41

NP vs. VP Attachment 42

Solution? Return all possible parses and disambiguate using other methods 43

Parsing is a search problem which may be implemented with many control strategies Top-Down or Bottom-Up approaches each have problems Combining the two solves some but not all issues Left recursion Syntactic ambiguity Next time: Making use of statistical information about syntactic constituents Read Ch 14 44