Slides
Slides
Ann Copestake
Computer Laboratory
University of Cambridge
October 2007
Natural Language Processing
Lecture 1: Introduction
Overview of the course
Why NLP is hard.
Scope of NLP.
A sample application: sentiment classification
More NLP applications
NLP components.
Natural Language Processing
Lecture 1: Introduction
Overview of the course
Also note:
User query:
I Has my order number 4291 been shipped yet?
Database:
ORDER
Order number Date ordered Date shipped
4290 2/2/02 2/2/02
4291 2/2/02 2/2/02
4292 2/2/02
Ooooo. Scary.
The old adage of the simplest ideas being the best is
once again demonstrated in this, one of the most
entertaining films of the early 80’s, and almost
certainly Jon Landis’ best work to date. The script is
light and witty, the visuals are great and the
atmosphere is top class. Plus there are some great
freeze-frame moments to enjoy again and again. Not
forgetting, of course, the great transformation scene
which still impresses to this day.
In Summary: Top banana
Natural Language Processing
Lecture 1: Introduction
A sample application: sentiment classification
I Negation:
Ridley Scott has never directed a bad film.
More contrasts
Sample data
http://www.cl.cam.ac.uk/ aac10/sentiment/
(linked from http://www.cl.cam.ac.uk/ aac10/stuff.html)
See test data texts in:
http://www.cl.cam.ac.uk/ aac10/sentiment/test/
classified into positive/negative.
Natural Language Processing
Lecture 1: Introduction
A sample application: sentiment classification
IR, IE and QA
MT
KB
*
j
KB INTERFACE KB OUTPUT
6
?
PARSING TACTICAL GENERATION
6
?
MORPHOLOGY MORPHOLOGY GENERATION
6
?
INPUT PROCESSING OUTPUT PROCESSING
6
?
user input output
Natural Language Processing
Lecture 1: Introduction
NLP components.
General comments
Some terminology.
Inflectional morphology
Derivational morphology
j
KB INTERFACE KB OUTPUT
6
?
PARSING TACTICAL GENERATION
6
?
MORPHOLOGY MORPHOLOGY GENERATION
6
?
INPUT PROCESSING OUTPUT PROCESSING
6
?
user input output
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Using morphology.
Mongoose
Mongoose
Mongoose
e-insertion
e.g. boxˆs to boxes
s
ε → e/ x ˆ s
z
e-insertion
e.g. boxˆs to boxes
s
ε → e/ x ˆ s
z
e-insertion
e.g. boxˆs to boxes
s
ε → e/ x ˆ s
z
1 2 3 4 5 6
digit digit
Recursive FSA
comma-separated list of day/month pairs:
0,1,2,3 digit / 0,1 0,1,2
1 2 3 4 5 6
digit digit
,
I list of indefinite length
I e.g., 11/3, 5/6, 12/04
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Finite state techniques.
1 2 3
e:e s:s
other : other x:x e: ˆ s
z:z
ε → e/ x ˆ s
z
4
surface : underlying
s:s cakes↔cakeˆs
x:x
z:z boxes↔boxˆs
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Finite state techniques.
Analysing b o x e s
b:b
ε: ˆ
1 2 3
Input: b
4 Output: b
(Plus: . ˆ)
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Finite state techniques.
Analysing b o x e s
b:b
ε: ˆ
1 2 3
Input: b
4 Output: b
(Plus: . ˆ)
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Finite state techniques.
Analysing b o x e s
o:o
1 2 3
4 Input: b o
Output: b o
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Finite state techniques.
Analysing b o x e s
1 2 3
x:x
4 Input: b o x
Output: b o x
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Finite state techniques.
Analysing b o x e s
1 2 3
e:e
e: ˆ
Input: b o x e
4 Output: b o x ˆ
Output: b o x e
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Finite state techniques.
Analysing b o x e s
ε: ˆ
1 2 3
Input: b o x e
Output: b o x ˆ
Output: b o x e
4 Input: b o x e
Output: b o x e ˆ
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Finite state techniques.
Analysing b o x e s
s:s
1 2 3
s:s Input: b o x e s
Output: b o x ˆ s
Output: b o x e s
4 Input: b o x e s
Output: b o x e ˆ s
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
Finite state techniques.
Analysing b o x e s
e:e
other : other
ε: ˆ s:s
1 2 3
Using FSTs
mumble
1
mumble mumble
month day
2 day & 3
month
day month
4
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
More applications for finite state techniques.
0.1
1
0.1 0.2
0.5 0.1
2 0.3 3
0.9 0.8
4
Natural Language Processing
Lecture 2: Morphology and finite state techniques.
More applications for finite state techniques.
Next lecture
First of three lectures that concern syntax (i.e., how words fit
together). This lecture: ‘shallow’ syntax: word sequences and
POS tags. Next lectures: more detailed syntactic structures.
Natural Language Processing
Lecture 3: Prediction and part-of-speech tagging.
Corpora in NLP
Corpora
Changes in NLP research over the last 15-20 years are largely
due to increased availability of electronic corpora.
I corpus: text that has been collected for some purpose.
I balanced corpus: texts representing different genres
genre is a type of text (vs domain)
I tagged corpus: a corpus annotated with POS tags
I treebank: a corpus annotated with parse trees
I specialist corpora — e.g., collected to train or evaluate
particular applications
I Movie reviews for sentiment classification
I Data collected from simulation of a dialogue system
Natural Language Processing
Lecture 3: Prediction and part-of-speech tagging.
Word prediction
Prediction
Prediction
Prediction
Prediction
k =1
Calculating bigrams
hsi good morning hsi good afternoon hsi good afternoon hsi it
is very good hsi it is good hsi
Practical application
Assigning probabilities
P(T )P(W |T )
P(T |W ) =
P(W )
Example
Evaluation in general
I Training data and test data Test data must be kept unseen,
often 90% training and 10% test data.
I Baseline
I Ceiling Human performance on the task, where the ceiling
is the percentage agreement found between two
annotators (interannotator agreement)
I Error analysis Error rates are nearly always unevenly
distributed.
I Reproducibility
Natural Language Processing
Lecture 3: Prediction and part-of-speech tagging.
Evaluation in general, evaluation of POS tagging
Generative grammar
a formally specified grammar that can generate all and only the
acceptable sentences of a natural language
Internal structure:
can be bracketed
NP ->
Natural Language Processing
Lecture 4: Parsing and generation.
Simple context free grammars
lexicon
rules V -> can
V -> fish
S -> NP VP
NP -> fish
VP -> VP PP
NP -> rivers
VP -> V
NP -> pools
VP -> V NP
NP -> December
VP -> V VP
NP -> Scotland
NP -> NP PP
NP -> it
PP -> P NP
NP -> they
P -> in
Natural Language Processing
Lecture 4: Parsing and generation.
Simple context free grammars
(S (NP they)
(VP (VP (V fish))
(PP (P in) (NP (NP rivers)
(PP (P in) (NP December))))))
(S (NP they)
(VP (VP (VP (V fish))
(PP (P in) (NP (NP rivers))))
(PP (P in) (NP December))))
Natural Language Processing
Lecture 4: Parsing and generation.
Simple context free grammars
(S (NP they)
(VP (VP (V fish))
(PP (P in) (NP (NP rivers)
(PP (P in) (NP December))))))
(S (NP they)
(VP (VP (VP (V fish))
(PP (P in) (NP (NP rivers))))
(PP (P in) (NP December))))
Natural Language Processing
Lecture 4: Parsing and generation.
Simple context free grammars
Parse trees
S
NP VP
they V VP
can VP PP
V P NP
fish in December
(S (NP they)
(VP (V can)
(VP (VP (V fish))
(PP (P in)
(NP December)))))
Natural Language Processing
Lecture 4: Parsing and generation.
Random generation with a CFG
Expand cat S ()
possibilities = {S -> NP VP}, chosen = S -> NP VP
Expand cat NP ()
possibilities = {it, they, fish}
chosen = fish
sentence-record = (fish)
Expand cat VP (fish)
possibilities ={VP -> V, VP -> V VP, VP -> V NP}
chosen = VP -> V
Expand cat V (fish)
possibilities = {fish, can}
chosen = fish
sentence-record = (fish fish)
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Chart parsing
A dynamic programming algorithm (memoisation):
chart store partial results of parsing
edge representation of a rule application
Edge data structure:
[id,left_vtx, right_vtx,mother_category, dtrs]
Fragment of chart:
id l r ma dtrs
5 2 3 V (fish)
6 2 3 VP (5)
7 1 3 VP (3 6)
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse:
Initialize the chart
For each word word, let from be left vtx,
to right vtx and dtrs be (word)
For each category category
lexically associated with word
Add new edge from, to, category, dtrs
Output results for all spanning edges
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Inner function
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
word = they, categories = {NP}
Add new edge 0, 1, NP, (they)
Matching grammar rules: {VP→V NP, PP→P NP}
No matching edges corresponding to V or P
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
word = can, categories = {V}
Add new edge 1, 2, V, (can)
Matching grammar rules: {VP→V}
recurse on edges {(2)}
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Add new edge 1, 2, VP, (2)
Matching grammar rules: {S→NP VP, VP→V VP}
recurse on edges {(1,3)}
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Add new edge 0, 2, S, (1, 3)
No matching grammar rules for S
Matching grammar rules: {S→NP VP, VP→V VP}
No edges for V VP
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
word = fish, categories = {V, NP}
Add new edge 2, 3, V, (fish) NB: fish as V
Matching grammar rules: {VP→V}
recurse on edges {(5)}
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Add new edge 2, 3, VP, (5)
Matching grammar rules: {S →NP VP, VP →V VP}
No edges match NP
recurse on edges for V VP: {(2,6)}
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Add new edge 1, 3, VP, (2, 6)
Matching grammar rules: {S→NP VP, VP→V VP}
recurse on edges for NP VP: {(1,7)}
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Add new edge 0, 3, S, (1, 7)
No matching grammar rules for S
Matching grammar rules: {S→NP VP, VP →V VP}
No edges matching V
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Add new edge 2, 3, NP, (fish) NB: fish as NP
Matching grammar rules: {VP→V NP, PP→P NP}
recurse on edges for V NP {(2,9)}
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Add new edge 1, 3, VP, (2, 9)
Matching grammar rules: {S→NP VP, VP→V VP}
recurse on edges for NP VP: {(1, 10)}
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Parse construction
11:S
10:VP
8:S 9:NP
4:S 7:VP
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Add new edge 0, 3, S, (1, 10)
No matching grammar rules for S
Matching grammar rules: {S→NP VP, VP→V VP}
No edges corresponding to V VP
Matching grammar rules: {VP→V NP, PP→P NP}
No edges corresponding to P NP
Natural Language Processing
Lecture 4: Parsing and generation.
Simple chart parsing with CFGs
Packing
Packing example
1 0 1 NP {(they)}
2 1 2 V {(can)}
3 1 2 VP {(2)}
4 0 2 S {(1 3)}
5 2 3 V {(fish)}
6 2 3 VP {(5)}
7 1 3 VP {(2 6)}
8 0 3 S {(1 7)}
9 2 3 NP {(fish)}
Packing example
8:S 9:NP
4:S 7:VP+
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Both spanning results can now be extracted from edge 8.
Natural Language Processing
Lecture 4: Parsing and generation.
More advanced chart parsing
Packing example
10:VP
8:S 9:NP
4:S 7:VP+
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Both spanning results can now be extracted from edge 8.
Natural Language Processing
Lecture 4: Parsing and generation.
More advanced chart parsing
Packing example
8:S 9:NP
4:S 7:VP+
3:VP 6:VP
1:NP 2:V 5:V
they can fish
Both spanning results can now be extracted from edge 8.
Natural Language Processing
Lecture 4: Parsing and generation.
More advanced chart parsing
centre-embedding:
A → αAβ
generate grammars of the form an bn .
For instance:
However:
Subcategorization
Overgeneration:
Long-distance dependencies
1. which problem did you say you don’t understand?
2. who do you think Kim asked Sandy to hit?
3. which kids did you say were making all that noise?
‘gaps’ (underscores below)
1. which problem did you say you don’t understand _?
2. who do you think Kim asked Sandy to hit _?
3. which kids did you say _ were making all that noise?
In 3, the verb were shows plural agreement.
* what kid did you say _ were making all that noise?
The gap filler has to be plural.
I Informally: need a ‘gap’ slot which is to be filled by
something that itself has features.
Natural Language Processing
Lecture 5: Parsing with constraint-based grammars.
Feature structures (informally)
Feature structures
CASE [ ]
AGR sg
sg
j
Example 2:
HEAD- CAT -NP
HEAD CAT NP
AGR
AGR []
j
Reentrancy
: a
F
F a
a
G
G - a
F F 0 a
G G 0
a z
-
Reentrancy indicated by boxed integer in AVM diagram:
indicates path goes to the same node.
Natural Language Processing
Lecture 5: Parsing with constraint-based grammars.
Encoding agreement
Root structure: S
h i
CAT
CAT NP NP V
they it CAT likes CAT
AGR pl sg sg
AGR AGR
CAT NP V
fish like CAT
pl
AGR [ ] AGR
Natural Language Processing
Lecture 5: Parsing with constraint-based grammars.
Parsing with feature structures
Rules as FSs
Rules have features MOTHER , DTR 1, DTR 2 . . . DTRN.
CAT VP CAT V CAT NP
informally: → ,
AGR 1 AGR 1 AGR [ ]
MOTHER VP CAT
AGR 1
CAT V
actually: DTR 1
1
AGR
DTR 2 CAT NP
AGR [ ]
Natural Language Processing
Lecture 5: Parsing with constraint-based grammars.
Parsing with feature structures
CAT NP
FS for they:
AGR pl
Unification of this with the value of DTR 1 succeeds (but adds no
new information):
CAT S
MOTHER AGR 1 pl
DTR 1 CAT NP
AGR 1
CAT VP
DTR 2
AGR 1
Properties of FSs
Subsumption
Feature structures are ordered by information content — FS1
subsumes FS2 if FS2 carries extra information.
FS1 subsumes FS2 if and only if the following conditions hold:
Path values For every path P in FS1 there is a path P in FS2. If
P has a value t in FS1, then P also has value t in
FS2.
Path equivalences Every pair of paths P and Q which are
reentrant in FS1 (i.e., which lead to the same node
in the graph) are also reentrant in FS2.
Unification
The unification of two FSs FS1 and FS2 is the most general FS
which is subsumed by both FS1 and FS2, if it exists.
Natural Language Processing
Lecture 5: Parsing with constraint-based grammars.
Encoding subcategorisation
1 HEAD 1
HEAD
SUBJ 3 SUBJ 3
verb CAT
HEAD AGR pl
can (transitive verb): HEAD CAT noun
OBJ
OBJ filled
SUBJ HEAD CAT noun
Natural Language Processing
Lecture 5: Parsing with constraint-based grammars.
Encoding subcategorisation
1 HEAD 1
HEAD
SUBJ 3 SUBJ 3
v CAT
HEAD AGR pl
can (transitive verb): HEAD CAT n
OBJ
fld
OBJ
SUBJ HEAD CAT n
Natural Language Processing
Lecture 5: Parsing with constraint-based grammars.
Encoding subcategorisation
subject-verb rule:
HEAD 1 HEAD AGR 3 1
HEAD AGR 3
OBJ fld → 2 OBJ fld , OBJ fld
SUBJ fld SUBJ fld SUBJ 2
CAT n
HEAD AGR pl
Lexical entry for they:
OBJ fld
SUBJ fld
unify this with first dtr position:
CAT v CAT n
HEAD 1 HEAD AGR 3 HEAD 1
AGR 3 pl
→ 2 , OBJ fld
OBJ fld OBJ fld
2
SUBJ
SUBJ fld SUBJ fld
HEAD CAT v
Templates
and
PRED
pron
PRED
ARG 1
ARG 1 1
PRED and
PRED like_v
ARG 1
ARG 1 1
ARG 2
ARG 2 2
PRED fish_n
ARG 2
ARG 1 2
Noun entry
HEAD CAT
n
AGR []
OBJ fld
fish
SUBJ fld
INDEX 1
SEM PRED fish_n
ARG 1 1
Noun entry
HEAD CAT
n
AGR []
OBJ fld
fish
SUBJ fld
INDEX 1
SEM PRED fish_n
ARG 1 1
Verb entry
HEAD CAT v
AGR pl
CAT n
h i
HEAD
OBJ fld
OBJ
h i
INDEX 2
SEM
like
CAT n
h i
HEAD
SUBJ h
i
SEM INDEX 1
PRED like_v
ARG 1 1
SEM
ARG 2 2
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Compositional semantics in feature structures
Verb-object rule
HEAD 1
OBJ fld
HEAD 1
SUBJ 3 → OBJ 2 , 2 OBJ fld
PRED and
SUBJ 3 SEM 5
SEM ARG 1 4 SEM 4
ARG 2 5
I As last time: object of the verb (DTR2) ‘fills’ the OBJ slot
I New: semantics on the mother is the ‘and’ of the semantics
of the dtrs
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Logical forms
Meaning postulates
I e.g.,
bachelor0 (Kim)
unmarried0 (Kim)
Hyponymy: IS-A:
I (a sense of) dog is a hyponym of (a sense of) animal
I animal is a hypernym of dog
I hyponymy relationships form a taxonomy
I works best for concrete nouns
Meronomy: PART-OF e.g., arm is a meronym of body, steering
wheel is a meronym of car (piece vs part)
Synonymy e.g., aubergine/eggplant
Antonymy e.g., big/little
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Lexical semantics: semantic relations
WordNet
I large scale, open source resource for English
I hand-constructed
I wordnets being built for other languages
I organized into synsets: synonym sets (near-synonyms)
Overview of adj red:
1. (43) red, reddish, ruddy, blood-red, carmine,
cerise, cherry, cherry-red, crimson, ruby,
ruby-red, scarlet - (having any of numerous
bright or strong colors reminiscent of the color
of blood or cherries or tomatoes or rubies)
2. (8) red, reddish - ((used of hair or fur)
of a reddish brown color; "red deer";
reddish hair")
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Lexical semantics: semantic relations
Hyponymy in WordNet
Sense 6
big cat, cat
=> leopard, Panthera pardus
=> leopardess
=> panther
=> snow leopard, ounce, Panthera uncia
=> jaguar, panther, Panthera onca,
Felis onca
=> lion, king of beasts, Panthera leo
=> lioness
=> lionet
=> tiger, Panthera tigris
=> Bengal tiger
=> tigress
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Lexical semantics: semantic relations
Polysemy
WSD techniques
Initial state
? ?? ? ?
? ?
? ??
? ? ?
?? ?
? ? ?
?? ? ? ?
? ?
? ? ?
? ?
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Word sense disambiguation
Seeds
? ?? ? B
? B
? ?? manu.
? ? ?
?? life ?
A ? ?
?? A A ?
? A
? A ?
? ?
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Word sense disambiguation
Iterating:
? ?? ? B
B B
? ??
animal ? ? ?
company
AA B
A ? ?
?? A A ?
? A
? A ?
? ?
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Word sense disambiguation
Final:
A AA B B
B B
A BB
A B B
AA B
A B B
AA A A B
A A
A A B
A B
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Word sense disambiguation
Evaluation of WSD
I SENSEVAL competitions
I evaluate against WordNet
I baseline: pick most frequent sense — hard to beat (but
don’t always know most frequent sense)
I human ceiling varies with words
I MT task: more objective but sometimes doesn’t
correspond to polysemy in source language
Natural Language Processing
Lecture 6: Compositional and lexical semantics.
Word sense disambiguation
Lecture 7: Discourse.
Relationships between sentences.
Coherence
Anaphora (pronouns etc)
An algorithm for anaphora resolution
Natural Language Processing
Lecture 7: Discourse.
Lecture 7: Discourse.
Relationships between sentences.
Coherence
Anaphora (pronouns etc)
An algorithm for anaphora resolution
Natural Language Processing
Lecture 7: Discourse.
Relationships between sentences.
Rhetorical relations
Coherence
Can be OK in context:
Kim got into her car. Sandy likes apples, so Kim thought she’d
go to the farm shop and see if she could get some.
Natural Language Processing
Lecture 7: Discourse.
Coherence
Coherence in generation
Strategic generation: constructing the logical form. Tactical
generation: logical form to string.
Strategic generation needs to maintain coherence.
Better:
So far this has only been attempted for limited domains: e.g.
tutorial dialogues.
Natural Language Processing
Lecture 7: Discourse.
Coherence
Coherence in interpretation
1. Cue phrases.
2. Punctuation (also prosody) and text structure.
Max fell (John pushed him) and Kim laughed.
Max fell, John pushed him and Kim laughed.
3. Real world content:
Max fell. John pushed him as he lay on the ground.
4. Tense and aspect.
Max fell. John had pushed him.
Max was falling. John pushed him.
Hard problem, but ‘surfacy techniques’ (punctuation and cue
phrases) work to some extent.
Natural Language Processing
Lecture 7: Discourse.
Coherence
Referring expressions
Pronoun resolution
Pronoun resolution
Pronoun resolution
Pronoun resolution
Recency Kim has a fast car. Sandy has an even faster one.
Lee likes to drive it.
Grammatical role Subjects > objects > everything else: Fred
went to the Grafton Centre with Bill. He bought a
CD.
Repeated mention Entities that have been mentioned more
frequently are preferred.
Parallelism Entities which share the same role as the pronoun
in the same sort of sentence are preferred: Bill
went with Fred to the Grafton Centre. Kim went
with him to Lion Yard. Him=Fred
Coherence effects (mentioned above)
Natural Language Processing
Lecture 7: Discourse.
An algorithm for anaphora resolution
Weights
Global salience factors:
recency 100 (current sentence)
subject 80
existential 70 there is a cat
direct object 50
indirect object 40 give Sandy a present
oblique complement 40 put the cat on a mat
non-embedded noun 80
non-adverbial 50
(i.e., embedded -80 and adverbial -50 but no negative weights)
Per pronoun salience factors:
cataphora -175 pronoun before NP
same role 35 e.g., pronoun and NP both subject
Natural Language Processing
Lecture 7: Discourse.
An algorithm for anaphora resolution
Example
Possible antecedants:
N Niall Ferguson, him 435
S Stephen Moss 310
N has score 155 + 280 ((subject + non-embedded +
non-adverbial + recency)/2 + (direct object + non-embedded +
non-adverbial + recency))
S has score 310 (subject + non-embedded + non-adverbial +
recency) + same role per-pronoun 35
So we resolve he to N (wrongly . . . )
Natural Language Processing
Lecture 7: Discourse.
An algorithm for anaphora resolution
Example, continued
Evaluation
Lecture 8: Applications.
Spoken dialogue systems
Question Answering
Wrapping up
Natural Language Processing
Lecture 8: Applications.
Spoken dialogue systems
Approaches to SDS
DIALOGUE MANAGER
6
DB
*
slot filling
R
j j
string withrecorded
PARSING: turn-specific grammars
Y filled slots speech
grammar6
constraints constraints
?
R
TEXT-TO-
SPEECH RECOGNITION
SPEECH
6
R
user input speech output
Natural Language Processing
Lecture 8: Applications.
Spoken dialogue systems
PARSED CORPUS
*
j
query match response selection
6
?
PARSING output
6
MORPHOLOGY
6
INPUT PROCESSING
6
user input
Natural Language Processing
Lecture 8: Applications.
Question Answering
QA example 1
Example
What eats jellyfish?
Simplified semantics:
[ a:eat(e), ARG1(a,x), ARG2(a,y), jellyfish(y) ]
So won’t match on jellyfish eat fish.
Natural Language Processing
Lecture 8: Applications.
Question Answering
Example
Turtles eat jellyfish and they have special hooks in their throats
to help them swallow these slimy animals.
Natural Language Processing
Lecture 8: Applications.
Question Answering
Example
Turtles eat jellyfish and they have special hooks in their throats
to help them swallow these slimy animals.
Example
Sea turtles, ocean sunfish (Mola mola) and blue rockfish all are
able to eat large jellyfish, seemingly without being affected by
the nematocysts.
Natural Language Processing
Lecture 8: Applications.
Question Answering
Example
Sea turtles, ocean sunfish (Mola mola) and blue rockfish all are
able to eat large jellyfish, seemingly without being affected by
the nematocysts.
Example
Also, open ocean-dwelling snails called Janthina and even
some seabirds have been known to eat jellyfish.
Natural Language Processing
Lecture 8: Applications.
Question Answering
Example
Also, open ocean-dwelling snails called Janthina and even
some seabirds have been known to eat jellyfish.
[ a1:know(e), ARG2(a1,h1), qeq(h1,lb), lb:a:eat(e), ARG1(a,x),
ARG2(a,y), jellyfish(y) ]
Logically valid if know is taken as truth preserving.
∀P∀y [know(y , P) =⇒ P]
Axioms like this required for logically valid entailment: missing
axiom would cause failure to match.
Natural Language Processing
Lecture 8: Applications.
Question Answering
Example
Also, open ocean-dwelling snails called Janthina and even
some seabirds have been known to eat jellyfish.
[ a1:know(e), ARG2(a1,h1), qeq(h1,lb), lb:a:eat(e), ARG1(a,x),
ARG2(a,y), jellyfish(y) ]
Logically valid if know is taken as truth preserving.
∀P∀y [know(y , P) =⇒ P]
Axioms like this required for logically valid entailment: missing
axiom would cause failure to match.
Natural Language Processing
Lecture 8: Applications.
Question Answering
QA processing
spelling rule
plur_noun_orule :=
%suffix (!s !ss) (!ss !ssses) (ss sses)
(!ty !ties) (ch ches) (sh shes) (x xes) (z zes)
lex_rule_infl_affixed &
[ ND-AFF +,
SYNSEM mass_or_count_synsem &
[ LOCAL plur_noun ]].
Natural Language Processing
Lecture 8: Applications.
Question Answering
Semantics
What eats aardvarks?
<mrs>
<label vid=’1’/><var vid=’2’/>
<ep cfrom=’0’ cto=’4’><pred>THING_REL</pred><label vid=’3’/>
<fvpair><rargname>ARG0</rargname><var vid=’4’ sort=’x’>
<extrapair><path>PERS</path><value>3</value></extrapair>
<extrapair><path>NUM</path><value>SG</value></extrapair>
<extrapair><path>SF</path><value>PROP</value></extrapair></var></fvpair></ep>
<ep cfrom=’0’ cto=’4’><pred>WHICH_Q_REL</pred><label vid=’5’/>
<fvpair><rargname>ARG0</rargname><var vid=’4’ sort=’x’>
<extrapair><path>PERS</path><value>3</value></extrapair>
<extrapair><path>NUM</path><value>SG</value></extrapair>
<extrapair><path>SF</path><value>PROP</value></extrapair></var></fvpair>
<fvpair><rargname>RSTR</rargname><var vid=’6’ sort=’h’></var></fvpair>
<fvpair><rargname>BODY</rargname><var vid=’7’ sort=’h’></var></fvpair></ep>
<ep cfrom=’5’ cto=’9’><spred>_eat_v_1_rel</spred><label vid=’8’/>
<fvpair><rargname>ARG0</rargname><var vid=’2’ sort=’e’>
<extrapair><path>TENSE</path><value>PRES</value></extrapair>
<extrapair><path>MOOD</path><value>INDICATIVE</value></extrapair>
<extrapair><path>PROG</path><value>-</value></extrapair>
<extrapair><path>PERF</path><value>-</value></extrapair>
<extrapair><path>SF</path><value>QUES</value></extrapair></var></fvpair>
<fvpair><rargname>ARG1</rargname><var vid=’4’ sort=’x’>
<extrapair><path>PERS</path><value>3</value></extrapair>
<extrapair><path>NUM</path><value>SG</value></extrapair>
<extrapair><path>SF</path><value>PROP</value></extrapair></var></fvpair>
<fvpair><rargname>ARG2</rargname><var vid=’9’ sort=’x’>
<extrapair><path>PERS</path><value>3</value></extrapair>
Natural Language Processing
Lecture 8: Applications.
Question Answering
Themes: ambiguity
Themes: evaluation
Themes: evaluation
Conclusion