Dependency Parsing Guest lecture in Computational Linguistics course - - PowerPoint PPT Presentation

dependency parsing
SMART_READER_LITE
LIVE PREVIEW

Dependency Parsing Guest lecture in Computational Linguistics course - - PowerPoint PPT Presentation

Dependency Parsing Guest lecture in Computational Linguistics course Barbara Plank bplank.github.io 11-10-2018 Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 1 / 77 Why Parsing? Barbara Plank bplank.github.io Dependency


slide-1
SLIDE 1

Dependency Parsing

Guest lecture in Computational Linguistics course Barbara Plank bplank.github.io 11-10-2018

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 1 / 77

slide-2
SLIDE 2

Why Parsing?

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 2 / 77

slide-3
SLIDE 3

Why Parsing?

For Whom?

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 3 / 77

slide-4
SLIDE 4

For Whom?

Researchers working on syntax or related topics within other traditions Researchers and application developers interested in using parsers as components in larger systems

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 4 / 77

slide-5
SLIDE 5

Two views of grammatical structure

So far (a.o.): Constituency structure (a.k.a. phrase structure - CFGs) Today: Dependency structure

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 5 / 77

slide-6
SLIDE 6

Today

1

Introduction

2

Transition-based parsing

3

Evaluation

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 6 / 77

slide-7
SLIDE 7

Outline

1

Introduction Introduction to UD

2

Transition-based parsing

3

Evaluation

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 7 / 77

slide-8
SLIDE 8

The notion of dependency

In a dependency grammar, syntactic structures consist of words that are linked pairwise by relations called dependencies. The following slides are based on a tutorial by J.Nivre et al: http: //universaldependencies.org/eacl17tutorial/intro.pdf

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 8 / 77

slide-9
SLIDE 9

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 9 / 77

slide-10
SLIDE 10

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 10 / 77

slide-11
SLIDE 11

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 11 / 77

slide-12
SLIDE 12

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 12 / 77

slide-13
SLIDE 13

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 13 / 77

slide-14
SLIDE 14

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 14 / 77

slide-15
SLIDE 15

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 15 / 77

slide-16
SLIDE 16

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 16 / 77

slide-17
SLIDE 17

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 17 / 77

slide-18
SLIDE 18

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 18 / 77

slide-19
SLIDE 19

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 19 / 77

slide-20
SLIDE 20

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 20 / 77

slide-21
SLIDE 21

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 21 / 77

slide-22
SLIDE 22

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 22 / 77

slide-23
SLIDE 23

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 23 / 77

slide-24
SLIDE 24

Introduction to UD

Introduction

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 24 / 77

slide-25
SLIDE 25

Naming nodes in a dependency

rel(head,dep) head vs dependent governor vs modifier regent vs subordinate parent vs child In the convention we use, dependency edges go from head to dependent: nsubj(runs,He). He runs

nsubj

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 25 / 77

slide-26
SLIDE 26

Example

“They ate the pizza with anchovies”

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 26 / 77

slide-27
SLIDE 27

Example

“They ate the pizza with anchovies”

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 26 / 77

slide-28
SLIDE 28

Dependency Trees: Universal dependencies

“They ate the pizza with anchovies” They ate the pizza with anchovies

nsubj dobj det nmod case

They ate the pizza with anchovies

nsubj dobj det nmod case

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 27 / 77

slide-29
SLIDE 29

Outline

1

Introduction

2

Transition-based parsing Choosing the Right Actions Representing configurations using feature templates

3

Evaluation

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 28 / 77

slide-30
SLIDE 30

What is Transition-based Parsing?

One of the two leading approaches for dependency parsing

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 29 / 77

slide-31
SLIDE 31

What is Transition-based Parsing?

One of the two leading approaches for dependency parsing

Approach 1: Transition-based parsing: local decisions Approach 2: Graph-based parsing: global decision (find globally best tree; computationally more expensive; we will not cover this)

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 29 / 77

slide-32
SLIDE 32

Why Transition-based Parsing?

left to right: similar to how the human brain does it in recent years: state-of-the-art accuracy very fast simple flexible: also suitable for producing phrase-structure trees, CCG derivations, semantic representations... (see next lectures)

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 30 / 77

slide-33
SLIDE 33

Transition-based Parsing: How? Intuition:

Read sentence word by word, left to right Build up the dependency tree one word at a time:

after each word, look at the current parser configuration select a parser operation from a set of operations consulting a machine-learned classifier

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 31 / 77

slide-34
SLIDE 34

What is a parser configuration?

Configuration: Buffer B (words left, at the start entire sentence) Stack S (last in, first out) Relations R (dependency edges predicted so far, a partial parse)

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 32 / 77

slide-35
SLIDE 35

Transition-based parsing

Configuration:

Buffer B (words left, at the start entire sentence) Stack S (last in, first out) Relations R (dependency edges predicted so far, a partial parse)

Configuration C = S, B, R

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 33 / 77

slide-36
SLIDE 36

Transition-based parsing

Configuration:

Buffer B (words left, at the start entire sentence) Stack S (last in, first out) Relations R (dependency edges predicted so far, a partial parse)

Configuration C = S, B, R Initial configuration: empty stack, all words on buffer, empty R Final configuration: stack, empty buffer, all edges are in R

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 33 / 77

slide-37
SLIDE 37

Transition-based parsing

Configuration:

Buffer B (words left, at the start entire sentence) Stack S (last in, first out) Relations R (dependency edges predicted so far, a partial parse)

Configuration C = S, B, R Initial configuration: empty stack, all words on buffer, empty R Final configuration: stack, empty buffer, all edges are in R Parser does a search through the space of possible configurations

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 33 / 77

slide-38
SLIDE 38

Basic actions (simplified)

The parser has 3 basic operations (other variants possible):

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 34 / 77

slide-39
SLIDE 39

Basic actions (simplified)

The parser has 3 basic operations (other variants possible):

Shift: Move a word from the buffer to the stack Left: Create an edge to the left Right: Create an edge to the right

(This transition system with 3 operations is called arc-standard)

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 34 / 77

slide-40
SLIDE 40

Basic actions (details)

The parser has 3 basic operations (other variants possible):

Shift: Move a word from the buffer to the stack (S, i|j|B, A) → (S|i, j|B, A) Left: Create an edge to the left (S|i|j, B, A) → (S|j, B, A ∪ j → i) [create an edge from j to i, where j is the first and i the second node from the top of the stack; in addition removes i from stack)] Right: Create an edge to the right (S|i|j, B, A) → (S|i, B, A ∪ i → j) [create an edge from i to j, where i is the second and j the first node on top of the stack; pops j from the stack]

Details in http: //stp.lingfil.uu.se/~nivre/master/transition.pdf

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 35 / 77

slide-41
SLIDE 41

Transition-based Dependency Parsing

buffer = [’They’, ’ate’, ’the’, ’pizza’, ’with’, anchovies’] stack = []

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 36 / 77

slide-42
SLIDE 42

Transition-based Dependency Parsing

buffer = [’They’, ’ate’, ’the’, ’pizza’, ’with’, anchovies’] stack = [] while len(buffer) > 0 or len(stack) > 1: action = choose_action(buffer, stack) if action == ’SHIFT’: stack.append(i) elif action == ’LEFT’: parse.add(stack[-2], stack.pop()) elif action == ’RIGHT’: parse.add(i, stack.pop())

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 36 / 77

slide-43
SLIDE 43

Example

Stack: [] Buffer: [They, ate, the, pizza, with, anchovies] R: []

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 37 / 77

slide-44
SLIDE 44

Example

Stack: [They] Buffer: [ate, the, pizza, with, anchovies] R: [] SHIFT,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 38 / 77

slide-45
SLIDE 45

Example

Stack: [They, ate] Buffer: [the, pizza, with, anchovies] R: [] SHIFT,SHIFT

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 39 / 77

slide-46
SLIDE 46

Example

Stack: [ate] Buffer: [the, pizza, with, anchovies] R: [ate → They] SHIFT,SHIFT,Left,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 40 / 77

slide-47
SLIDE 47

Example

Stack: [ate, the] Buffer: [pizza, with, anchovies] R: [ate → They] SHIFT,SHIFT,Left,SHIFT,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 41 / 77

slide-48
SLIDE 48

Example

Stack: [ate, the, pizza] Buffer: [with, anchovies] R: [ate → They] SHIFT,SHIFT,Left,SHIFT,SHIFT,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 42 / 77

slide-49
SLIDE 49

Example

Stack: [ate, pizza] Buffer: [with, anchovies] R: [ate → They, pizza → the] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 43 / 77

slide-50
SLIDE 50

Example

Stack: [ate, pizza, with] Buffer: [anchovies] R: [ate → They, pizza → the] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,SHIFT,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 44 / 77

slide-51
SLIDE 51

Example

Stack: [ate, pizza, with,anchovies] Buffer: [] R: [ate → They, pizza → the] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,SHIFT,SHIFT,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 45 / 77

slide-52
SLIDE 52

Example

Stack: [ate, pizza,anchovies] Buffer: [] R: [ate → They, pizza → the, anchovies → with] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,SHIFT,SHIFT,Left

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 46 / 77

slide-53
SLIDE 53

Example

Stack: [ate, pizza] Buffer: [] R: [ate → They, pizza → the, anchovies → with, pizza → anchovies] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,SHIFT,SHIFT,Left, Right

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 47 / 77

slide-54
SLIDE 54

Example

Stack: [ate] Buffer: [] R: [ate → They, pizza → the, anchovies → with, pizza → anchovies, ate → pizza] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,SHIFT,SHIFT,Left, Right,Right

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 48 / 77

slide-55
SLIDE 55

Example

Stack: [] Buffer: [] R: [ate → They, pizza → the, anchovies → with, pizza → anchovies, ate → pizza, ROOT→ ate ] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,SHIFT,SHIFT,Left, Right,Right,Right

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 49 / 77

slide-56
SLIDE 56

Example

Stack: [] Buffer: [] R: [ate → They, pizza → the, anchovies → with, pizza → anchovies, ate → pizza, ROOT→ ate ] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,SHIFT,SHIFT,Left, Right,Right,Right R encodes our dependency tree: They ate the pizza with anchovies

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 49 / 77

slide-57
SLIDE 57

How would we get the other parse tree?

They ate the pizza with anchovies They ate the pizza with anchovies

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 50 / 77

slide-58
SLIDE 58

How would we get the other parse tree?

They ate the pizza with anchovies They ate the pizza with anchovies Insight: each sequence of operations derives a dependency tree

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 50 / 77

slide-59
SLIDE 59

Back to our example - alternative

Stack: [ate, pizza] Buffer: [with, anchovies] R: [ate → They, pizza → the] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 51 / 77

slide-60
SLIDE 60

Back to our example - alternative

Stack: [ate] Buffer: [with, anchovies] R: [ate → They, pizza → the, ate → pizza] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,Right,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 52 / 77

slide-61
SLIDE 61

Back to our example - alternative

Stack: [ate,with] Buffer: [anchovies] R: [ate → They, pizza → the, ate → pizza] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,Right,SHIFT,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 53 / 77

slide-62
SLIDE 62

Back to our example - alternative

Stack: [ate,with,anchovies] Buffer: [] R: [ate → They, pizza → the, ate → pizza] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,Right,SHIFT, SHIFT,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 54 / 77

slide-63
SLIDE 63

Back to our example - alternative

Stack: [ate,anchovies] Buffer: [] R: [ate → They, pizza → the, ate → pizza, anchovies → with] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,Right,SHIFT, SHIFT, Left,

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 55 / 77

slide-64
SLIDE 64

Back to our example - alternative

Stack: [ate] Buffer: [] R: [ate → They, pizza → the, ate → pizza, anchovies → with, ate → anchovies] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,Right,SHIFT, SHIFT, Left,Right

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 56 / 77

slide-65
SLIDE 65

Back to our example - alternative

Stack: [] Buffer: [] R: [ate → They, pizza → the, ate → pizza, anchovies → with, ate → anchovies, ROOT → ate] SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,Right,SHIFT, SHIFT, Left,Right,Right

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 57 / 77

slide-66
SLIDE 66

Back to our example - alternative

SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,Right,SHIFT, SHIFT, Left,Right,Right They ate the pizza with anchovies

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 58 / 77

slide-67
SLIDE 67

Back to our example - alternative

SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,Right,SHIFT, SHIFT, Left,Right,Right They ate the pizza with anchovies SHIFT,SHIFT,Left,SHIFT,SHIFT,Left,SHIFT,SHIFT,Left, Right,Right,Right They ate the pizza with anchovies

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 58 / 77

slide-68
SLIDE 68

Which Action to Choose?

def choose_action(stack, buffer): # ??? Thanks to Kilian Evang for the basis of the following slides.

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 59 / 77

slide-69
SLIDE 69

Which Action to Choose?

stack: buffer: They ate the pizza with anchovies

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 60 / 77

slide-70
SLIDE 70

Which Action to Choose?

stack: buffer: They ate the pizza with anchovies Next action should be LEFT. But how does the parser know that?

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 60 / 77

slide-71
SLIDE 71

Look at Contextual Clues

E.g. word unigram features

stack: buffer: They ate the pizza with anchovies

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 61 / 77

slide-72
SLIDE 72

Look at Contextual Clues

E.g. word unigram features

stack: buffer: They ate the pizza with anchovies

Describe configuration in terms of features

’s_w0=pizza’ # word on top of stack

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 61 / 77

slide-73
SLIDE 73

Look at Contextual Clues

E.g. word unigram features

stack: buffer: They ate the pizza with anchovies

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 62 / 77

slide-74
SLIDE 74

Look at Contextual Clues

E.g. word unigram features

stack: buffer: They ate the pizza with anchovies

Describe configuration in terms of features

’s_w0=pizza’ # word on top of stack ’s_p0=NOUN’ # pos tag on top of stack ’b_w0=with’ # first word on buffer

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 62 / 77

slide-75
SLIDE 75

Look at Contextual Clues - they get weights

E.g. part-of-speech bigram features

stack: buffer: They ate the pizza with anchovies

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 63 / 77

slide-76
SLIDE 76

Look at Contextual Clues - they get weights

E.g. part-of-speech bigram features

stack: buffer: They ate the pizza with anchovies

Look up “weights” for each possible action

weight[’s_p1=DET;s_p0=NOUN’][’SHIFT’] = -3 weight[’s_p1=DET;s_p0=NOUN’][’LEFT’] = 10 weight[’s_p1=DET;s_p0=NOUN][’RIGHT’] = -5

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 63 / 77

slide-77
SLIDE 77

Look at Contextual Clues - they get weights

E.g. word unigram features

stack: buffer: They ate the pizza with anchovies

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 64 / 77

slide-78
SLIDE 78

Look at Contextual Clues - they get weights

E.g. word unigram features

stack: buffer: They ate the pizza with anchovies

Look up “weights” for each possible action

weight[’s_w1=the’][’SHIFT’] = 5 weight[’s_w1=the’][’LEFT’] = 5 weight[’s_w1=the’][’RIGHT’] = -5

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 64 / 77

slide-79
SLIDE 79

In Practice: Many More Features

stack: buffer: They ate the pizza with anchovies Sum up the weights for each possible action, choose the action with the highest total.

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 65 / 77

slide-80
SLIDE 80

Where Do the Weights Come from?

need training data = sentences where correct actions are known training = automatically find weights that lead to good parses e.g. perceptron training

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 66 / 77

slide-81
SLIDE 81

Perceptron Training

start with all weights = 0 parse the training data whenever the parser chooses the wrong action,

subtract 1 from the context weights for this action add 1 to the context weights for the correct action

  • ver time, parser makes fewer mistakes

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 67 / 77

slide-82
SLIDE 82

Perceptron Training: Example

stack: buffer: They ate the pizza with anchovies E.g. LEFT is correct, parser chooses SHIFT.

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 68 / 77

slide-83
SLIDE 83

Perceptron Training: Example

stack: buffer: They ate the pizza with anchovies E.g. LEFT is correct, parser chooses SHIFT. Update: weight[’s_w1=the’][’SHIFT’] -= 1 weight[’s_w1=the’][’LEFT’] += 1 weight[’s_p1=DET;s_p0=NOUN’][’SHIFT’] -= 1 weight[’s_p1=DET;s_p0=NOUN’][’LEFT’] += 1

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 68 / 77

slide-84
SLIDE 84

Choosing the Right Actions

Transition-based parsing

1

Introduction Introduction to UD

2

Transition-based parsing Choosing the Right Actions Representing configurations using feature templates

3

Evaluation

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 69 / 77

slide-85
SLIDE 85

Summary

goal: automatically find syntactic structure process sentences one word at a time at each step, choose the right action train parser using training data, features, perceptron training simple and works well in practice

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 70 / 77

slide-86
SLIDE 86

Features - Example configuration:

United canceled the morning flights to Houston Stack: [root, canceled, flights] Buffer: [to, Houston] R: [canceled → United, flights → morning, flights → the]

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 71 / 77

slide-87
SLIDE 87

Features - Example configuration:

United canceled the morning flights to Houston Stack: [root, canceled, flights] Buffer: [to, Houston] R: [canceled → United, flights → morning, flights → the] Partial structure so far: United canceled the morning flights to Houston

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 71 / 77

slide-88
SLIDE 88

Features - Example configuration:

United canceled the morning flights to Houston Stack: [root, canceled, flights] Buffer: [to, Houston] R: [canceled → United, flights → morning, flights → the] Partial structure so far: United canceled the morning flights to Houston What is the next action? How can we represent this parser state/configuration as features?

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 71 / 77

slide-89
SLIDE 89

Features - Get the basic elements:

(information from stack, buffer or R) Stack: [root, canceled, flights] Buffer: [to, Houston] R: [canceled → United, flights → morning, flights → the] s_w0: flights s_p0: NOUN s_w1: canceled s_p1: VERB b_w0: to #buffer context of top on stack: child1: the, child2: morning valence of top of stack: 2

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 72 / 77

slide-90
SLIDE 90

Features - add features:

Stack: [root, canceled, flights] Buffer: [to, Houston] R: [canceled → United, flights → morning, flights → the] Add features (a unique string = unique feature):

# unigram features.append((’s_w0=flights’,1)) features.append((’s_w1=canceled’,1)) # feature combinations features.append((’s_w0=flights,s_p0=NOUN’, 1)) features.append((’s_w1=canceled,s_p1=VERB’, 1)) # add more!

Note1: always add features with value 1! Note2: in the code you will do this with a format statement, because the feature depends on the current configuration

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 73 / 77

slide-91
SLIDE 91

Outline

1

Introduction

2

Transition-based parsing

3

Evaluation

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 74 / 77

slide-92
SLIDE 92

Evaluation

Which proportion of edges is predicted correctly? Label accuracy (LA): nodes with correct incoming edge/total number of nodes Unlabeled attachment score (UAS): nodes with correct parent/total nodes Labeled attachment score (LAS): nodes with correct parent and edge label / total nodes

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 75 / 77

slide-93
SLIDE 93

Evaluation

gold: Book me the flight to Houston

root

  • bj

det iobj nmod case

system: Book me the flight to Houston

root det nmod nsubj nmod case

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 76 / 77

slide-94
SLIDE 94

Evaluation

gold: Book me the flight to Houston

root

  • bj

det iobj nmod case

system: Book me the flight to Houston

root det nmod nsubj nmod case

LAS (labeled): 4/6 UAS (unlabeled): 5/6

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 76 / 77

slide-95
SLIDE 95

Reference

https://web.stanford.edu/~jurafsky/slp3/13.pdf

Barbara Plank bplank.github.io Dependency Parsing 11-10-2018 77 / 77