Fundamentals of SNLP
Lecture 1
Syntax: Constituency Parsing
Krishnendu Ghosh
Two Views of Linguistic Structure
Constituency (Phrase Structure)
Constituency (Phrase Structure)
Distribution: a constituent behaves as a unit that can appear in different places:
John talked [to the children] [about drugs].
John talked [about drugs] [to the children].
*John talked drugs to the children about.
Substitution/expansion/pro-forms:
I sat [on the box/right on top of the box/there].
Coordination, regular internal structure, no intrusion, fragments, semantics, …
A Phrase Structure Grammar
S → NP VP
VP → V NP
VP → V NP PP
NP → NP NP
NP → NP PP
NP → N
NP → e
PP → P NP
people fish tanks
people fish with rods
N → people
N → fish
N → tanks
N → rods
V → people
V → fish
V → tanks
P → with
Phrase Structure Grammars
= Context-Free Grammars (CFGs)
Context-Free Grammar
G = (T, C, N, S, L, R)
Context-Free Grammar
Example 1:
Context-Free Grammar
Example 2. Let us consider this grammar: E-> E + E | E*E | id, We can create two parse tree from this grammar to obtain a string id + id * id.
Probabilistic Context-Free Grammar
G = (T, N, S, R, P)
A PCFG
S → NP VP 1.0
VP → V NP 0.6
VP → V NP PP 0.4
NP → NP NP 0.1
NP → NP PP 0.2
NP → N 0.7
PP → P NP 1.0
N → people 0.5
N → fish 0.2
N → tanks 0.2
N → rods 0.1
V → people 0.1
V → fish 0.6
V → tanks 0.3
P → with 1.0
Probability of Trees and Strings
P(t) – The probability of a tree t is the product of the probabilities of the rules used to generate it.
P(s) – The probability of the string s is the sum of the probabilities of the trees which have that string as their yield
P(s) = Σj P(s, t) where t is a parse of s
= Σj P(t)
Tree and String Probabilities
s = people fish tanks with rods
P(t1) = 1.0 × 0.7 × 0.4 × 0.5 × 0.6 × 0.7
× 1.0 × 0.2 × 1.0 × 0.7 × 0.1
= 0.0008232
P(t2) = 1.0 × 0.7 × 0.6 × 0.5 × 0.6 × 0.2
× 0.7 × 1.0 × 0.2 × 1.0 × 0.7 × 0.1
= 0.00024696
P(s) = P(t1) + P(t2)
= 0.0008232 + 0.00024696
= 0.00107016
Verb attachment
Noun attachment
Grammar Transforms
Restricting the grammar form for efficient parsing
Chomsky Normal Form
Chomsky Normal Form
Chomsky Normal Form
S → NP VP
VP → V NP
VP → V NP PP
NP → NP NP
NP → NP PP
NP → N
NP → e
PP → P NP
N → people
N → fish
N → tanks
N → rods
V → people
V → fish
V → tanks
P → with
Chomsky Normal Form
S → NP VP
S → VP
VP → V NP
VP → V
VP → V NP PP
VP → V PP
NP → NP NP
NP → NP
NP → NP PP
NP → PP
NP → N
PP → P NP
PP → P
N → people
N → fish
N → tanks
N → rods
V → people
V → fish
V → tanks
P → with
Eliminate e
Chomsky Normal Form
S → NP VP
VP → V NP
S → V NP
VP → V
S → V
VP → V NP PP
S → V NP PP
VP → V PP
S → V PP
NP → NP NP
NP → NP
NP → NP PP
NP → PP
NP → N
PP → P NP
PP → P
N → people
N → fish
N → tanks
N → rods
V → people
V → fish
V → tanks
P → with
Chomsky Normal Form
S → NP VP
VP → V NP
S → V NP
VP → V
VP → V NP PP
S → V NP PP
VP → V PP
S → V PP
NP → NP NP
NP → NP
NP → NP PP
NP → PP
NP → N
PP → P NP
PP → P
N → people
N → fish
N → tanks
N → rods
V → people
S → people
V → fish
S → fish
V → tanks
S → tanks
P → with
Chomsky Normal Form
S → NP VP
VP → V NP
S → V NP
VP → V NP PP
S → V NP PP
VP → V PP
S → V PP
NP → NP NP
NP → NP
NP → NP PP
NP → PP
NP → N
PP → P NP
PP → P
N → people
N → fish
N → tanks
N → rods
V → people
S → people
VP → people
V → fish
S → fish
VP → fish
V → tanks
S → tanks
VP → tanks
P → with
Chomsky Normal Form
S → NP VP
VP → V NP
S → V NP
VP → V NP PP
S → V NP PP
VP → V PP
S → V PP
NP → NP NP
NP → NP PP
NP → P NP
PP → P NP
NP → people
NP → fish
NP → tanks
NP → rods
V → people
S → people
VP → people
V → fish
S → fish
VP → fish
V → tanks
S → tanks
VP → tanks
P → with
PP → with
Chomsky Normal Form
S → NP VP
VP → V NP
S → V NP
VP → V @VP_V
@VP_V → NP PP
S → V @S_V
@S_V → NP PP
VP → V PP
S → V PP
NP → NP NP
NP → NP PP
NP → P NP
PP → P NP
NP → people
NP → fish
NP → tanks
NP → rods
V → people
S → people
VP → people
V → fish
S → fish
VP → fish
V → tanks
S → tanks
VP → tanks
P → with
PP → with
Before vs After Binarization
ROOT
S
NP
VP
N
people
V
NP
PP
P
NP
rods
with
tanks
fish
N
N
P
NP
rods
N
with
NP
N
people
tanks
fish
N
VP
V
NP
PP
@VP_V
ROOT
S
Constituency Parsing
fish people fish tanks
N
N
V
N
VP
NP
NP
S
Rule Prob θi
S → NP VP θ0
NP → NP NP θ1
…
N → fish θ42
N → people θ43
V → fish θ44
…
PCFG