Lecture08 Dependency Parsing
Lecture08 Dependency Parsing
Processing
Lecture 8: Dependency Parsing
9/27/24
COMS W4705
Daniel Bauer
Dependency Structure dobj
det
det nsubj
girl likes
dependent head
PC
OBJ
ATT SBJ ATT ATT ATT
set of nodes Vs= {root, Economic, news, had, little, e ect, on, nancial, markets, . }
set of edges/ A = {(root, PRED, had), (had, SBJ, news), (had, OBJ, e ect),(had, PU, .),
arcs (news,ATT,Economic),(e ect,ATT,little),(e ect,ATT,on), (on,PC,markets),
(markets, ATT, nancial)}
fi
ff
ff
ff
ff
fi
ff
fi
Another Example
had
news e ect .
Economic little on
markets
nancial
A = {(root, PRED, had), (had, SBJ, news), (had, OBJ, e ect),(had, PU, .),
(news,ATT,Economic),(e ect,ATT,little),(e ect,ATT,on), (on,PC,markets),
(markets, ATT, nancial)}
fi
ff
fi
ff
ff
ff
ff
fi
ff
fi
Different Dependency
Representations
• How to deal with prepositions?
nmod
pobj
case
nmod amod amod
Source: http://universaldependencies.org/u/dep/
ff
Dependency Trees
• Dependency structure is typically assumed to be a tree.
hearing scheduled
A on
today
issue
the
hearing
scheduled
A on
today
issue
the
hearing scheduled
A on
today
issue
the
• bi-lexical a nities
• Intervening words
• subcategorization/valency of heads.
fi
ff
ffi
ff
Subcategorization/Valency
• Verbs may take a di erent number of arguments of di erent
syntactic types in di erent positions (applies to other types
of words as well).
• ...
ff
ff
ff
Dependency Parsing
• As with other NLP problems, we can think of dependency
parsing as a kind of search problem:
• Data-based
• σ - is a stack of words wi ∈ Vs
• β - is a bu er of words wi ∈ Vs
news
σ:
root β: [had, little, e ect, on, nancial, markets,.]
t0 t1 t2 tn-1
c0: ([w0]σ, [w1, w2, ... ,wm]β, {}A) c1 c2 ... cn-1 ([σ, [ ]β, A)
cT:
ATT
A:
Economic news
news
σ:
root β: [had[little,
,little, e ect, on, nancial, markets,.]
ff
ff
fi
fi
ff
Transition-Based Parsing -
Transitions
• Arc-leftr
Build an edge from the next word on the bu er to the top
word on the stack.
(σ | wi, wj | β, A) => (σ, wj | β, A ∪ {wj, r, wi})
Not allowed if i=0 (root may not have a parent)
ATT
A:
Economic news
Econonomic
σ:
root β: [news, little, e ect, on, nancial, markets,.]
OBJ
ATT SBJ ATT
A:
Economic news had little e ect
had
σ:
root β: ect, on, nancial, markets,.]
[e [had,
note: wi is moved from the top of the stack back to the bu er!
ff
ff
fi
fi
ff
ff
Transition-Based Parsing -
Some Observations
• Does the transition system contain dead ends? (states from which a
terminal state cannot be reached)? No!
PC
OBJ
ATT SBJ ATT ATT ATT
G = (Vs, A)
Vs= {root, Economic, news, had, little, e ect, on, nancial, markets, . }
A = {(root, PRED, had), (had, SBJ, news), (had, OBJ, e ect),(had, PU, .),
(news,ATT,Economic),(e ect,ATT,little),(e ect,ATT,on), (on,PC,markets),
(markets, ATT, nancial)}
fi
ff
ff
ff
ff
fi
ff
fi
Transition-Based Parsing -
Oracle Example
initial state
next transition: shift
A:
A:
Economic
σ: root β: [ news, had, little, e ect, on, nancial, markets,.]
ff
fi
Transition-Based Parsing -
Oracle Example
next transition: shift
A:
ATT
Economic news
A:
ATT
Economic news
news
σ: root β: [ had, little, e ect, on, nancial, markets,.]
ff
fi
Transition-Based Parsing -
Oracle Example
next transition: shift
A:
ATT SBJ
A:
ATT SBJ
had
σ: root β: [ little, e ect, on, nancial, markets,.]
ff
fi
Transition-Based Parsing -
Oracle Example
next transition: Left-ArcSBJ
A:
ATT SBJ
little
had
σ: root β: [ e ect, on, nancial, markets,.]
ff
fi
Transition-Based Parsing -
Oracle Example
next transition: shift
A:
had
σ: root β: [ e ect, on, nancial, markets,.]
ff
ff
fi
Transition-Based Parsing -
Oracle Example
next transition: shift
A:
e ect
had
σ: root β: [ on, nancial, markets,.]
ff
ff
fi
Transition-Based Parsing -
Oracle Example
next transition: shift
A:
on
e ect
had
σ: root β: [ nancial, markets,.]
ff
ff
fi
Transition-Based Parsing -
Oracle Example
next transition: Left-ArcATT
A:
nancial
on
e ect
had
σ: root β: [ markets,.]
fi
ff
ff
Transition-Based Parsing -
Oracle Example
next transition: Right-ArcPC
A:
on
e ect
had
σ: root β: [ markets,.]
fi
ff
ff
Transition-Based Parsing -
Oracle Example
next transition: Right-ArcATT
A:
PC
ATT SBJ ATT ATT
e ect
had
σ: root β: [on, .]
fi
ff
ff
Transition-Based Parsing -
Oracle Example
next transition: Right-ArcOBJ
A:
PC
ATT SBJ ATT ATT ATT
had
σ: root β: [e ect,.]
fi
ff
ff
Transition-Based Parsing -
Oracle Example
next transition: shift
A:
PC
OBJ
ATT SBJ ATT ATT ATT
σ: root β: [had,.]
fi
ff
Transition-Based Parsing -
Oracle Example
next transition: Right-ArcPU
A:
PC
OBJ
ATT SBJ ATT ATT ATT
had
σ: root β: [.]
fi
ff
Transition-Based Parsing -
Oracle Example
next transition: Right-ArcPRED PU
A:
PC
OBJ
ATT SBJ ATT ATT ATT
σ: root β: [had]
fi
ff
Transition-Based Parsing -
Oracle Example
next transition: shift PU
PRED
A:
PC
OBJ
ATT SBJ ATT ATT ATT
σ: β: [root]
fi
ff
Transition-Based Parsing -
Oracle Example
terminal PU
PRED
A:
PC
OBJ
ATT SBJ ATT ATT ATT
σ: root β: []
fi
ff
Properties of the transition
system
• The time required to parse w1,..., wm with an oracle is O(m).
Why?
• Could use perceptron, log linear model, SVM, Neural Network, ...
• If the classi er takes O(1), the runtime for parsing is still O(m) for m
words.
• Questions:
• Problem: We have not actually seen the transition sequence, only the
dependency trees!
• Reduce
Remove a completed node from the stack.
(σ | wi , β, A) => (σ, β , A)
Precondition: there is some (*, *, wi) in A.
ff
ff
ff
Arc-Eager Example
next transition: RightArcpred Can immediately attach had to root.
A:
ATT SBJ
PRED
A:
ATT SBJ
had
σ: root β: [ little, e ect, on, nancial, markets,.]
ff
fi
Arc-Eager Example
next transition: RightArcObj
PRED
A:
had
σ: root β: [e ect, on, nancial, markets,.]
ff
ff
fi
Arc-Eager Example
next transition: RightArcATT
PRED
A:
OBJ
ATT SBJ ATT
e ect
had
σ: root β: [on, nancial, markets,.]
ff
ff
fi
Arc-Eager Example
next transition: shift
PRED
A:
OBJ
ATT SBJ ATT ATT
on
e ect
little
had
σ: root β: [ nancial, markets,.]
fi
ff
ff
Arc-Eager Example
next transition: LeftArcATT
PRED
A:
OBJ
ATT SBJ ATT ATT
nancial
on
e ect
little
had
σ: root β: [markets,.]
fi
ff
ff
Arc-Eager Example
next transition: RightArcPC
PRED
A:
OBJ
ATT SBJ ATT ATT ATT
on
e ect
little
had
σ: root β: [markets,.]
fi
ff
ff
Arc-Eager Example
next transition: Reduce
PRED
A:
PC
OBJ
ATT SBJ ATT ATT ATT
markets
on
e ect
little
had
σ: root β: [.]
fi
ff
ff
Arc-Eager Example
next transition: Reduce
PRED
A:
PC
OBJ
ATT SBJ ATT ATT ATT
on
e ect
little
had
σ: root β: [.]
fi
ff
ff
Arc-Eager Example
next transition: Reduce
PRED
A:
PC
OBJ
ATT SBJ ATT ATT ATT
e ect
little
had
σ: root β: [.]
fi
ff
ff
Arc-Eager Example
next transition: Reduce
PRED
A:
PC
OBJ
ATT SBJ ATT ATT ATT
little
had
σ: root β: [.]
fi
ff
Arc-Eager Example
next transition: Reduce
PRED
A:
PC
OBJ
ATT SBJ ATT ATT ATT
had
σ: root β: [.]
fi
ff
Graph-Based Approach
• Transition Based Parsing with arc-standard or arc-eager can only
produce projective dependency structures? Why?
• Basic idea:
saw saw
30 30 30 30
20 0 20 0
11 11
total score: 70
Computing the MST
• For undirected graphs, there are two common algorithms: