1. Seman&c
Analysis
in
Language
Technology
http://stp.lingfil.uu.se/~santinim/sais/2016/sais_2016.htm
Semantics and
Computational Semantics
Marina
San(ni
san$nim@stp.lingfil.uu.se
Department
of
Linguis(cs
and
Philology
Uppsala
University,
Uppsala,
Sweden
Spring
2016
Lecture 2: Computational Semantics
1
2. Acknowledgements
The
content
of
these
slides
is
mostly
based
on
the
following
chapter:
• Stone
M.
(In
Press)
Seman$cs
and
computa$onal
seman$cs
To
appear
in
Paul
Dekker
and
Maria
Aloni,
eds.,
Cambridge
Handbook
of
Formal
Seman(cs.
hJps://www.cs.rutgers.edu/~mdstone/pubs/compsem13.pdf
• Blackburn
P.
and
Bos
J.
(2003)
Computa$onal
Seman$cs
hJp://www.let.rug.nl/bos/pubs/BlackburnBos2003Theoria.pdf
Some
slides
are
borrowed
from
/
inspired
by:
• Manning
C.:
Computa(onal
Seman(cs,
CS224N
Stanford
University
hJp://web.stanford.edu/class/cs224n/handouts/Computa(onal
%20Seman(cs.pdf
• Dragomir
Radev:
Introduc(on
to
NLP,
Coursera
Lecture 2: Computational Semantics
2
5. Generally
speaking…
seman(cs
is
the
study
of
meaning
that
is
used
for
understanding
human
expressions
through
language
• Seman&cs
is
the
study
of
meaning:
accounts
for
links
between
words
and
the
world.
• Seman(cs
is
the
study
of
how
meaning
is
conveyed
through
signs
and
language.
– Denota(ons
are
the
literal
or
primary
meanings
of
words.
– Connota(ons
are
ideas
or
feelings
that
a
word
invokes
for
a
person
in
addi(on
to
its
literal
or
primary
meaning.
• Seman(cs
focuses
on
the
rela(on
between
signifiers
(like
words,
phrases,
signs,
and
symbols)
and
what
they
stand
for,
ie
their
denota(ons
(concepts)
and
connota(ons
(seman(c
analysis).
Lecture 2: Computational Semantics
5
6. Comput(er)-‐a(onal
Seman(cs
• Seman$cs
is
the
study
of
meaning
in
language.
• Computer
science
is
the
study
of
precise
descrip(ons
of
finite
processes;
• Thus,
computa(onal
seman(cs
embraces
any
project
that
approaches
the
phenomenon
of
meaning
by
way
of
tasks
that
can
be
performed
by
following
definite
sets
of
mechanical
instruc(ons.
Lecture 2: Computational Semantics
6
7. We
can
start
by
saying
that…
”The
aim
of
computa(onal
seman(cs
is
to
find
techniques
for
automa(cally
construc&ng
seman&c
representa&ons
for
expressions
of
human
language,
representa(ons
that
be
used
to
perform
inference.
”
Blackburn
and
Bos
(2003).
Inference
=
reasoning
Lecture 2: Computational Semantics
7
8. Why
do
we
need
”meaning”
in
Language
Technology?
• The
short
answer
is:
because
”intelligent”
applica(ons
must
”understand”
in
order
to
act.
Lecture 2: Computational Semantics
8
9. Ex
1:
Google
-‐
What
is
the
capital
of
Sweden?
• Answer:
Lecture 2: Computational Semantics
9
10. Ex
2:
Siri
-‐
Which
countries
does
the
Danube
river
flows
through?
Lecture 2: Computational Semantics
10
11. Ex
3:
Facebook
Graph
Search
Facebook
Graph
Search
was
a
seman$c
search
engine
that
was
introduced
by
Facebook
in
March
2013.
It
was
designed
to
give
answers
to
user
natural
language
queries
rather
than
a
list
of
links.”
Examples:
"Friends
who
Like
Star
Wars
and
Harry
Po@er”
"photos
of
my
friends
taken
at
Na&onal
Parks"
hJps://en.wikipedia.org/wiki/Facebook_Graph_Search
Lecture 2: Computational Semantics
11
12. Understanding
Meaning
If
an
agent
(eg.
a
robot)
hears
a
sentence
and
act
accordingly,
the
agent
is
said
to
understand
the
sentence:
Example:
Leave
the
book
on
the
table
Understanding
may
involve
inference:
Which
book?
Which
table?
So,
understanding
may
involve
some
kind
of
reasoning…
Lecture 2: Computational Semantics
12
13. NLP/LT
and
Seman(cs
• Not
all
LT-‐based
applica(ons
require
seman(cs.
–
Ex:
taggers,
parsers,
etc.
• Much
can
be
done
with
shallow
seman(cs.
– Ex:
word
sense
disambigua(on,
etc.
• For
more
complex
tasks
(more
”intelligent”
tasks”)
seman(c
reasoning
is
needed.
– Ex:
QAnswering,
Info
Extrac(on,
Ontology
Crea(on,
etc.
Lecture 2: Computational Semantics
13
14. Tradi(onally…
…reasoning
is
done
by
using
some
kind
of
logic…
A
tradi(onal
approach
is
to
use
FOL
(first
order
logic)
to
”formalize”
meaning
(see
Formal
Seman(cs
Theories).
…
before
start
studying
how
seman(cs
is
used
in
Language
Technology-‐based
applica(ons,
let’s
summarise
how
seman(cs
has
been
brought
into
computer
science
and
ar(ficial
intelligence.
Lecture 2: Computational Semantics
14
16. Proper(es
of
Meaning
in
Logic
• Verifiability
– Can
a
statement
be
verified
against
a
knowledge
base
(KB)
– Example:
does
my
cat
Mar(n
have
whiskers?
• Unambiguousness
– Give
me
the
book
– Which
book?
• Canonical
form
(standard/abstract
form
of
an
expression)
• Expressiveness
– Can
the
formalism
express
temporal
rela(ons,
beliefs,
…?
– Is
it
domain-‐independent?
• Inference
Lecture 2: Computational Semantics
16
17. Represen(ng
Meaning
• A
tradi(onal
approach
to
meaning
is
to
–
use
proposi(onal
logic
– predicate/first
order
logic
(FOL)
– use
theorem
proving
(inference)
to
determine
whether
a
statement
entails
another
Lecture 2: Computational Semantics
17
18. Proposi(onal
Logic
:
proposi(ons
are
represented
by
leJers
• In
proposi(onal
logic,
we
use
leJers
to
symbolize
en(re
proposi(ons.
• Proposi(ons
are
statements
of
the
form
"x
is
y"
where
x
is
a
subject
and
y
is
a
predicate.
• For
example,
"Socrates
is
a
Man"
is
a
proposi(on
and
might
be
represented
in
proposi(onal
logic
as
"S".
Lecture 2: Computational Semantics
18
19. True
and
False
• Proposi(onal
Logic
studies
proposi(ons,
whether
they
are
true
or
false.
• A
sentence
might
contain
several
proposi(ons
that
are
linked
together
by
logical
connec(ves.
• Logical
connec(ves
are
found
in
natural
languages.
In
English
for
example,
some
examples
are
"and"
(conjunc(on),
"or"
(disjunc(on),
"not”
(nega(on)
and
"if"
(but
only
when
used
to
denote
material
condi(onal).
• Ex
(wikipedia):
simple
inference
within
the
scope
of
proposi(onal
logic:
• Premise
1:
If
it's
raining
then
it's
cloudy.
• Premise
2:
It's
raining.
• Conclusion:
It's
cloudy.
Both
premises
and
the
conclusion
are
proposi(ons.
The
premises
are
taken
for
granted
and
then
with
the
applica(on
of
modus
ponens
(an
inference
rule)
the
conclusion
follows.
Lecture 2: Computational Semantics
19
20. Syntax
of
Proposi(onal
Logic
• The
simplest
type
of
logic
–
If
S
is
a
sentence,
¬S
is
a
sentence
(nega(on)
–
If
S1
and
S2
are
sentences,
S1
∧
S2
is
a
sentence
(conjunc(on)
–
If
S1
and
S2
are
sentences,
S1
∨
S2
is
a
sentence
(disjunc(on)
–
If
S1
and
S2
are
sentences,
S1
⇒
S2
is
a
sentence
(implica(on)
–
If
S1
and
S2
are
sentences,
S1
⇔
S2
is
a
sentence(bicondi(onal)
Lecture 2: Computational Semantics
20
21. Proposi(onal
Logic
and
Natural
Language
Operator
Precedence
¬
(highest)
=
nega(on
∧
=
conjunc(on
∨
=
disjunc(on
⇒
=
implica(on
⇔
(lowest)
=
bicondi(onal*
*A
bicondi(onal
statement
is
defined
to
be
true
whenever
both
parts
have
the
same
truth
value.
Logic
and
Language
A
=
Today
is
a
holiday.
B
=
We
are
going
to
the
park.
A
⇒
B
A
∧
¬
B
¬
A
⇒
B
¬
B
⇒
A
B
⇒
A
Lecture 2: Computational Semantics
21
23. Proposi(onal
Logic
and
Seman(cs
Transla$ng
propos$ons
to
Eng
Seman$cs
of
Proposi$onal
Logic
Lecture 2: Computational Semantics
23
24. Proposi(onal
logic
vs
FOL/Predicate
Logic
• Proposi(onal
logic
(also
called
senten(al
logic)
is
logic
that
includes
sentence
leJers
(A,B,C
…
)
and
logical
connec(ves,
but
not
quan(fiers.
The
seman(cs
of
proposi(onal
logic
uses
truth
assignments
to
the
leJers
to
determine
whether
a
compound
proposi(onal
sentence
is
true.
• Predicate
logic
is
usually
used
as
a
synonym
for
first-‐order
logic.
Syntac(cally,
first-‐order
logic
has
the
same
connec(ves
as
proposi(onal
logic,
but
it
also
has
variables
for
individual
objects,
quan(fiers,
symbols
for
func(ons,
and
symbols
for
rela(ons.
• Its
seman(cs
includes
a
domain
of
discourse
for
the
variables
and
quan(fiers
to
range
over,
along
with
interpreta(ons
of
the
rela(on
and
func(on
symbols.
Lecture 2: Computational Semantics
24
25. Predicate
Logic:
more
expressive
than
Proposi(onal
Logic
• In
predicate
logic,
we
symbolize
subject
and
predicate
separately.
• The
important
difference
is
that
you
can
use
predicate
logic
to
say
something
about
a
set
of
objects.
• By
introducing
the
universal
quan(fier
("∀"),
the
existen(al
quan(fier
("∃")
and
variables
("x",
"y"
or
"z"),
we
can
use
predicate
logic
to
represent
thing
like:
– "Everything
is
green"
as
"∀Gx”
”
– Something
is
blue"
as
"∃Bx”
Lecture 2: Computational Semantics
25
26. Used
to
represent
• Objects
–
Mar(n
the
cat
• Rela(ons
–
Mar(n
and
Moses
are
brothers
• Func(ons
–
Mar(n’s
age
Lecture 2: Computational Semantics
26
27. FOL
elements
(short
version)
• Constant
• Variables
• Predicates
• Boolean
connec(ves
• Quan(fiers
• Brackets
and
comma
to
group
the
symbols
together
• Ex:
A
woman
crosses
Sunset
Boulevard
Lecture 2: Computational Semantics
27
28. FOL
elements
(long
version)
Formula
→
AtomicFormula
or
Formula
Connec(ve
Formula
or
Quan(fier
Variable
Formula
or
¬
Formula
(Formula):
Lecture 2: Computational Semantics
28
29. FOL’s
most
important
feature:
quan(fiers
à
generaliza(on
Lecture 2: Computational Semantics
29
To ace a test =
to get a very
high score on a
test
31. Lambda
calculus
à
Variable
subs(tu(on
Useful
for
expressing
computa(on
by
way
of
variable
binding
and
subs(tu(on.
Variables
are
just
names
that
are
bound
as
arguments.
Lambda
calculus
is
important
in
programming
language
theory.
Example
–
inc(x)
=
λx
x+1
–
then
inc(4)
=
(λx
x+1)(4)
=
5
Example
–
add(x,y)
=
λx,λy(x+y)
–
then
add(3,4)
=
(λx,λy(x+y))(3)(4)=
(λy
3+y)(4)
=3+4
=
12
Lecture 2: Computational Semantics
31
33. Composi(onal
Seman(cs
• Add
seman(c
aJachments
to
syntac(c
rules
•
Composi(onal
seman(cs
– Parse
the
sentence
syntac(cally
– Associate
some
seman(cs
to
each
word
– Combine
the
seman(cs
of
words
and
non
terminals
recursively
– Un(l
the
root
of
the
sentence
Lecture 2: Computational Semantics
33
34. Example
• Input
– Javier
likes
pizza
• Output
– like(Javier,
pizza)
Lecture 2: Computational Semantics
34
Associate a
semantic
expression
with each
node
35. Seman(c
Parsing
• Conver(ng
natural
language
to
a
logical
form
– e.g.,
executable
code
for
a
specific
applica(on
–
Example:
• Airline
reserva(ons
• Geographical
query
systems
Lecture 2: Computational Semantics
35
36. What
about
”kick
the
bucket”?
• What
happens
when
the
meaning
of
single
words
does
not
lead
to
the
meaning
of
the
whole?
Lecture 2: Computational Semantics
36
38. Unifica(on
Grammar
• Unifica(on
grammar
is
a
formalism
that
derives
seman(c
representa(ons
by
accumula(ng
constraints
in
tandem
with
a
syntac(c
deriva(on.
• The
constraints
take
the
form
of
equa(ons
between
terms
which
may
contain
variables.
• The
formalism
gets
its
name
from
the
process,
unifica$on,
which
determines
values
for
variables
to
solve
the
equa(ons.
Lecture 2: Computational Semantics
38
39. Example:
”everybody
walks”
The
meaning
representa(on
of
∀x.walks(x)
is
assembled
as
the
solu(on
to
a
set
of
constraints
and
not
through
the
func(on–argument
maninupula(on
of
the
lambda
calculus.
Lecture 2: Computational Semantics
39
40. More
flexibility
• Lambda-‐calculus
techniques
expect
each
element
in
a
meaning
representa(on
to
be
specified
exactly
once.
• Unifica(on:
we
model
sentence
meaning
as
the
solu(on
to
a
set
of
equa(ons
à
we
might
find
elements
of
meaning
that
are
simultaneously
determined
by
mul(ple
equa(ons,
and
elements
of
meaning
that
are
lev
unconstrained
and
must
be
resolved
by
context.
• Constraint
techniques
offer
new
ways
to
analyze
idioms
and
mul(-‐
word
expressions.
Each
cons(tuent
can
not
only
specify
its
own
meaning
but
can
impose
a
constraint
on
the
meaning
of
the
whole.
Lecture 2: Computational Semantics
40
41. Limita(ons
• Composi(onal
seman(cs
(any
formalisms)
gives
us
representa(ons
that
capture
aspects
of
the
logical
structure
of
meaning.
• But:
what
specific
en((es
and
concepts
does
a
sentence
describe,
and
what
specific
claim
does
it
make
about
them?
Lecture 2: Computational Semantics
41
43. Basically…
• We
need
to
(e
together:
– Grammar
(grammar
and
composi(onal
meaning
is
not
enough)
– Speaker’s
kowledge
about
the
wolrd
– PaBerns
of
use
à
unique
insights
given
by
large
corpora
of
linguis$c
evidence
Lecture 2: Computational Semantics
43
44. In
this
course…
• We
review
research
about
different
aspects
of
word
meaning
that
are
needed
for
LT-‐based
applica(ons.
Lecture 2: Computational Semantics
44
45. How
is
*meaning*
handled
in
Seman(c-‐Based
LT-‐Applica(ons
• Seman(c
Role
Labelling/Predicate-‐Argument
Structure
(???)
• Sen(ment
Analysis
(???)
• Word
sense
disambigua(on
(???)
• Informa(on
extrac(on
(???)
• Ques(on
Answering
(???)
• Ontologies
(???)
Lecture 2: Computational Semantics
45
46. Reminder:
Glossary
Entries
• Which
concepts
are
the
most
salient
in
this
lecture?
• Start
crea(ng
your
Glossary
now…
Lecture 2: Computational Semantics
46