Refresher on Dependency Syntax and the Nivre Algorithm

Similar documents
Dependency Parsing CMSC 723 / LING 723 / INST 725. Marine Carpuat. Fig credits: Joakim Nivre, Dan Jurafsky & James Martin

Dependency Parsing 2 CMSC 723 / LING 723 / INST 725. Marine Carpuat. Fig credits: Joakim Nivre, Dan Jurafsky & James Martin

CS224n: Natural Language Processing with Deep Learning 1 Lecture Notes: Part IV Dependency Parsing 2 Winter 2019

Dependency Parsing. Johan Aulin D03 Department of Computer Science Lund University, Sweden

Transition-Based Dependency Parsing with MaltParser

Transition-Based Dependency Parsing with Stack Long Short-Term Memory

Let s get parsing! Each component processes the Doc object, then passes it on. doc.is_parsed attribute checks whether a Doc object has been parsed

A Quick Guide to MaltParser Optimization

Basic Parsing with Context-Free Grammars. Some slides adapted from Karl Stratos and from Chris Manning

Agenda for today. Homework questions, issues? Non-projective dependencies Spanning tree algorithm for non-projective parsing

Introduction to Data-Driven Dependency Parsing

EDAN20 Language Technology Chapter 13: Dependency Parsing

CS395T Project 2: Shift-Reduce Parsing

CSE450 Translation of Programming Languages. Lecture 4: Syntax Analysis

Supplementary A. Built-in transition systems

The Application of Constraint Rules to Data-driven Parsing

Dependency grammar and dependency parsing

Dependency grammar and dependency parsing

Dependency grammar and dependency parsing

Transition-based dependency parsing

Assignment 4 CSE 517: Natural Language Processing

Homework 2: Parsing and Machine Learning

Transition-based Parsing with Neural Nets

School of Computing and Information Systems The University of Melbourne COMP90042 WEB SEARCH AND TEXT ANALYSIS (Semester 1, 2017)

Homework & NLTK. CS 181: Natural Language Processing Lecture 9: Context Free Grammars. Motivation. Formal Def of CFG. Uses of CFG.

A language is a subset of the set of all strings over some alphabet. string: a sequence of symbols alphabet: a set of symbols

ADTS, GRAMMARS, PARSING, TREE TRAVERSALS

Lecture 14: Annotation

Managing a Multilingual Treebank Project

Grammar Knowledge Transfer for Building RMRSs over Dependency Parses in Bulgarian

Final Project Discussion. Adam Meyers Montclair State University

CS 224N Assignment 2 Writeup

Syntactic Analysis. CS345H: Programming Languages. Lecture 3: Lexical Analysis. Outline. Lexical Analysis. What is a Token? Tokens

LING/C SC/PSYC 438/538. Lecture 3 Sandiway Fong

If you are going to form a group for A2, please do it before tomorrow (Friday) noon GRAMMARS & PARSING. Lecture 8 CS2110 Spring 2014

Parsing Techniques. CS152. Chris Pollett. Sep. 24, 2008.

The ATILF-LLF System for Parseme Shared Task: a Transition-based Verbal Multiword Expression Tagger

CS 4120 Introduction to Compilers

Chapter 4. Lexical and Syntax Analysis. Topics. Compilation. Language Implementation. Issues in Lexical and Syntax Analysis.

Learning Latent Linguistic Structure to Optimize End Tasks. David A. Smith with Jason Naradowsky and Xiaoye Tiger Wu

Topics in Parsing: Context and Markovization; Dependency Parsing. COMP-599 Oct 17, 2016

Dependency Parsing domain adaptation using transductive SVM

ANC2Go: A Web Application for Customized Corpus Creation

The CKY algorithm part 2: Probabilistic parsing

AT&T: The Tag&Parse Approach to Semantic Parsing of Robot Spatial Commands

A simple pattern-matching algorithm for recovering empty nodes and their antecedents

Dependency Parsing. Ganesh Bhosale Neelamadhav G Nilesh Bhosale Pranav Jawale under the guidance of

String Vector based KNN for Text Categorization

ADTS, GRAMMARS, PARSING, TREE TRAVERSALS

Collins and Eisner s algorithms

Incremental Integer Linear Programming for Non-projective Dependency Parsing

Topic 3: Syntax Analysis I

INF FALL NATURAL LANGUAGE PROCESSING. Jan Tore Lønning, Lecture 4, 10.9

Lecture Notes on Shift-Reduce Parsing

Privacy and Security in Online Social Networks Department of Computer Science and Engineering Indian Institute of Technology, Madras

ADTS, GRAMMARS, PARSING, TREE TRAVERSALS

Automatic Evaluation of Parser Robustness: Eliminating Manual Labor and Annotated Resources

A Transition-Based Dependency Parser Using a Dynamic Parsing Strategy

Syntax Analysis, V Bottom-up Parsing & The Magic of Handles Comp 412

Wednesday, August 31, Parsers

Tekniker för storskalig parsning: Dependensparsning 2

Meaning Banking and Beyond

COMPILER DESIGN. For COMPUTER SCIENCE

CHAPTER 5 SEARCH ENGINE USING SEMANTIC CONCEPTS

CSE 417 Dynamic Programming (pt 6) Parsing Algorithms

NLP Lab Session Week 9, October 28, 2015 Classification and Feature Sets in the NLTK, Part 1. Getting Started

Question Answering Using XML-Tagged Documents

Specifying Syntax. An English Grammar. Components of a Grammar. Language Specification. Types of Grammars. 1. Terminal symbols or terminals, Σ

A Dependency Parser for Tweets. Lingpeng Kong, Nathan Schneider, Swabha Swayamdipta, Archna Bhatia, Chris Dyer, and Noah A. Smith

Parsing partially bracketed input

Multiword deconstruction in AnCora dependencies and final release data

Transition-Based Parsing of the Chinese Treebank using a Global Discriminative Model

Non-Projective Dependency Parsing in Expected Linear Time

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING

Statistical parsing. Fei Xia Feb 27, 2009 CSE 590A

Stack- propaga+on: Improved Representa+on Learning for Syntax

Transition-based Dependency Parsing with Rich Non-local Features

L322 Syntax. Chapter 3: Structural Relations. Linguistics 322 D E F G H. Another representation is in the form of labelled brackets:

Hidden Markov Models. Natural Language Processing: Jordan Boyd-Graber. University of Colorado Boulder LECTURE 20. Adapted from material by Ray Mooney

LL(1) predictive parsing

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

The CKY Parsing Algorithm and PCFGs. COMP-550 Oct 12, 2017

NLP Chain. Giuseppe Castellucci Web Mining & Retrieval a.a. 2013/2014

NLP Final Project Fall 2015, Due Friday, December 18

Question Bank. 10CS63:Compiler Design

Online Graph Planarisation for Synchronous Parsing of Semantic and Syntactic Dependencies

Advanced Topics in Information Retrieval Natural Language Processing for IR & IR Evaluation. ATIR April 28, 2016

ADTS, GRAMMARS, PARSING, TREE TRAVERSALS. Regrades 10/6/15. Prelim 1. Prelim 1. Expression trees. Pointers to material

announcements CSE 311: Foundations of Computing review: regular expressions review: languages---sets of strings

Ortolang Tools : MarsaTag

Semantic Pattern Classification

Undirected Dependency Parsing

Log- linear models. Natural Language Processing: Lecture Kairit Sirts

Christoph Treude. Bimodal Software Documentation

Automatic Discovery of Feature Sets for Dependency Parsing

LL Parsing, LR Parsing, Complexity, and Automata

Ngram Search Engine with Patterns Combining Token, POS, Chunk and NE Information

University of Sheffield, NLP. Chunking Practical Exercise

GRAMMARS & PARSING. Lecture 7 CS2110 Fall 2013

ECE 468/573 Midterm 1 September 30, 2015

Transcription:

Refresher on Dependency yntax and Nivre Algorithm Richard Johansson 1 Introduction This document gives more details about some important topics that re discussed very quickly during lecture: dependency syntax and Nivre algorithm for automatic dependency parsing 2 Refresher on dependency syntax In a dependency representation of syntax, represent grammatical structure of sentence as a tree, where have links dependency arcs beten word tokens in sentence If have a dependency arc going from word H to word D, n say that H is head of D, and that D is dependent ofh Typically, if have a link fromh tod, n this means thath grammatically dominates D somehow, such as a verb being head of its subject, and a noun being head of its determiner To simplify algorithmic processing, add a special dummy root token before sentence We connect main word of sentence (typically a finite verb) to this dummy We may have a dependency label on each dependency arc These labels represent grammatical functions such as subject, object, adverbial, determiner, and so on Although will refer to se grammatical functions (such as saying that noun is subject of verb ), will not discuss how to assign labels in automatic parsing algorithm Here is an example of a dependency tree representing grammatical analysis of sentence In figure,<d> represents dummy root token Arrows are drawn from heads to dependents The links in this dependency tree can be interpreted as follows: is main verb of sentence, so it is a dependent of dummy root token is a temporal adverbial of is subject of is object of is determiner of We typically connect punctuation to main verb, so make period a dependent of ome important properties of a dependency tree: Every token has exactly one head, except dummy root token which has none Every token can be reached if start at dummy root and follow arcs down from head to dependent There are no cycles this is why may say that it s a tree

3 The Nivre algorithm for incremental dependency parsing As discussed in lectures, Nivre algorithm is incremental: it processes tokens in order y appear in sentence This means that can start parsing while input is still being produced, for instance in a spoken dialogue system or a T9 input system for mobile phones The algorithm that will study was defined by Nivre (2003), and is one of several incremental algorithms (Nivre, 2008) The algorithm is initialized by creating a stack and a queue, and all words in sentence (including dummy root) are inserted into queue If you haven t taken a course in data structures, here s a short introduction: stacks and queues are both lists of items to process, and difference beten m is order in which process items: A queue is a work list where items are processed in a first-in-first-out order, so item to be processed first item is one that was inserted first A stack is a work list where items are processed in a last-in-first-out order, so item that was most recently inserted top item is available to algorithm for processing The algorithm n processes tokens in stack and queue, and gradually adds dependencies beten tokens that appear This process goes on until queue is empty The four actions that can be performed on stack and queue can be summarized as follows, and are described in detail in next section HIFT: move a token from queue to stack; REDUCE: remove a token from stack; LEFT-ARC: top token of stack becomes dependent of first item of queue, and is removed from stack RIGHT-ARC: first item of queue becomes dependent of top token of stack, and is n moved from queue onto stack 31 Detailed description of parsing actions Now give detailed descriptions of four actions of algorithm In descriptions, assume that have a stack where top item is T, and a queue where first item is F Be careful to understand preconditions of each action, ie circumstances in which it is legal to carry out a particular action, and effects, ie how stack and queue are affected and if any dependencies are added by action For each action, re is a figure that exemplifies situation before and after have applied action In figure, stack is drawn with top item to right, and queue with first item to left HIFT must not be empty F is removed from F becomes first item of

REDUCE must not be empty T must have a head T is removed from LEFT-ARC must not be empty must not be empty T must not have a head T must not be dummy root token T is removed from An dependency arc is added, withf as head and T as dependent Typical cases: RIGHT-ARC T is a noun and F is a verb We make a LEFT-ARC to connect noun to verb as a subject T is an article such as, and F is a noun We make a LEFT-ARC to connect article to noun as its determiner must not be empty must not be empty F must not have a head F is removed from F becomes first item of An dependency arc is added, witht as head and F as dependent

Typical cases: T is a verb and F is a noun We make a RIGHT-ARC to connect noun to verb as an object T is a preposition and F is a noun We make a RIGHT-ARC to connect noun to preposition as a prepositional complement T is a noun and F is a verb We make a RIGHT-ARC to connect verb to noun as head of a relative clause 4 Building an automatic parser using Nivre algorithm Until now described how Nivre algorithm proceeds through sentence, gradually adding arcs until sentence ends and all arcs have been added The obvious followup question is: when parse a sentence using an automatic parser, how do know which action to carry out? The ansr is: train a statistical classifier, and when come to a new sentence, apply Nivre algorithm and ask classifier for advice at each step The classifier is a function F that takes a stack and a queue and returns action it thinks should be carried out How do n build a training set that can give to machine learning software such as your Naïve Bayes implemenation, NLTK, or cikit-learn? To address this, need to do following: First collect a set of sentences where some linguist has annotated grammatical structure manually We call such a collection a treebank For each sentence in treebank, go through sentence using Nivre algorithm and determine correct sequence of actions (see next section) Now can build a training set for our classifiers At each step of Nivre algorithm, extract training features describing stack and queue; in NLTK and cikit-learn, this will be an attribute-value dictionary add features and corresponding action to training set 41 Finding correct sequence of actions if know true tree Assume that are given a dependency parse treegand want to determine sequence of parsing actions needed to produce that tree, go through Nivre algorithm step by step, and at each step use following decision rules to select action Again, T means top item of stack, and F means first item of queue 1 If stack is empty, select HIFT 2 If G contains a dependency arc with head F and dependent T, n select LEFT-ARC 3 If G contains a dependency arc with head T and dependent F, n select RIGHT-ARC 4 If stack contains a token T such that T is head or dependent of F in G, n select REDUCE 5 Orwise, select HIFT

>D< >D< 42 Walkthrough of example sentence Now will determine complete sequence of steps required to parse sentence The tree want to build is this one: We initialize by putting all tokens, including dummy root token, into working queue We also create an empty stack ince stack is empty, don t have any choice but HIFT (case 1): There is no dependency arc beten dummy root and, so HIFT from queue onto stack (case 5): and also HIFT (case 5): In tree want to build, is a dependent (a subject) of, so now make a LEFT-ARC is dropped from stack (case 2):

>D< imilarly, is a dependent (a temporal adverbial) of, so now again make a LEFT-ARC is dropped from stack (case 2): is main verb in this sentence, so make a RIGHT-ARC from dummy root to, which is moved from onto (case 3): The gold-standard tree contains no dependency arc beten and, so HIFT token from onto (case 5): is determiner of, so make a LEFT-ARC and drop from (case 2): We want to have as object of, so make a RIGHT-ARC beten those words moves from onto (case 3):

Now, top T of stack is and first item F in queue is period ; se two words are not connected in gold-standard tree, but stack contains anor word that is head of, namely o need to REDUCE, and remove from stack (case 4): Now that have reduced, have prepared for RIGHT-ARC beten and period The period moves from onto (case 3): The input queue is now empty, so are done! The dependency arcs produced by algorithm correspond to those in given tree 43 Making a training set for action classifier Our action classifier needs to apply a feature extraction function to state of parser (ie stack and queue) before making a guess about which parsing action to carry out Assume that are using a feature extraction function that extracts PO tag oft and off, if our training corpus consists of example sentence, would generate following training set for training our action classifier: [ ( {"T_pos":"(none)", "F_pos":"<D>" }, "shift" ), ( {"T_pos":"<D>", "F_pos":"adverb" }, "shift" ), ( {"T_pos":"adverb", "F_pos":"pronoun" }, "shift" ), ( {"T_pos":"pronoun", "F_pos":"finite_verb" }, "left-arc" ), ( {"T_pos":"adverb", "F_pos":"finite_verb" }, "left-arc" ), ( {"T_pos":"<D>", "F_pos":"finite_verb" }, "right-arc" ), ( {"T_pos":"finite_verb", "F_pos":"article" }, "shift" ), ( {"T_pos":"article", "F_pos":"noun" }, "left-arc" ), ( {"T_pos":"finite_verb", "F_pos":"noun" }, "right-arc" ), ( {"T_pos":"noun", "F_pos":"punctuation" }, "reduce" ), ( {"T_pos":"finite_verb", "F_pos":"punctuation" }, "right-arc" ) ] Obviously need many more examples to be able to train a good action classifier, but this is general idea! References Joakim Nivre 2003 An efficient algorithm for projective dependency parsing In Proceedings of 8th International Workshop on Parsing Technologies (IWPT 03), pages 149 160, Nancy, France Joakim Nivre 2008 Algorithms for deterministic incremental dependency parsing Computational Linguistics, 34(4):513 553