Transcript
Page 1: Semantics and Computational Semantics

Seman&c  Analysis  in  Language  Technology  http://stp.lingfil.uu.se/~santinim/sais/2016/sais_2016.htm

Semantics and

Computational Semantics

Marina  San(ni  [email protected]  

 Department  of  Linguis(cs  and  Philology  Uppsala  University,  Uppsala,  Sweden  

 Spring  2016  

   

Lecture  2:  Computational  Semantics 1

Page 2: Semantics and Computational Semantics

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

Page 3: Semantics and Computational Semantics

Outline  

•  Representa(on  and  Seman(cs  •  Computa(on  and  Composi(onal  Seman(cs  – Logic  – Unifica(on  

•  Conclusions  

Lecture  2:  Computational  Semantics 3

Page 4: Semantics and Computational Semantics

What  is  Seman(cs?  

Lecture  2:  Computational  Semantics 4

Page 5: Semantics and Computational Semantics

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

Page 6: Semantics and Computational Semantics

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

Page 7: Semantics and Computational Semantics

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

Page 8: Semantics and Computational Semantics

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

Page 9: Semantics and Computational Semantics

Ex  1:  Google  -­‐  What  is  the  capital  of  Sweden?  

•  Answer:  

Lecture  2:  Computational  Semantics 9

Page 10: Semantics and Computational Semantics

Ex  2:  Siri  -­‐  Which  countries  does  the  Danube  river  flows  through?  

Lecture  2:  Computational  Semantics 10

Page 11: Semantics and Computational Semantics

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

Page 12: Semantics and Computational Semantics

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

Page 13: Semantics and Computational Semantics

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

Page 14: Semantics and Computational Semantics

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

Page 15: Semantics and Computational Semantics

REPRESENTATION  AND  SEMANTICS  

Lecture  2:  Computational  Semantics 15

Page 16: Semantics and Computational Semantics

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

Page 17: Semantics and Computational Semantics

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

Page 18: Semantics and Computational Semantics

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

Page 19: Semantics and Computational Semantics

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

Page 20: Semantics and Computational Semantics

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

Page 21: Semantics and Computational Semantics

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

Page 22: Semantics and Computational Semantics

Truth  table  

Lecture  2:  Computational  Semantics 22

Page 23: Semantics and Computational Semantics

Proposi(onal  Logic  and  Seman(cs  

Transla$ng  propos$ons  to  Eng   Seman$cs  of  Proposi$onal  Logic  

Lecture  2:  Computational  Semantics 23

Page 24: Semantics and Computational Semantics

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

Page 25: Semantics and Computational Semantics

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

Page 26: Semantics and Computational Semantics

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

Page 27: Semantics and Computational Semantics

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

Page 28: Semantics and Computational Semantics

FOL  elements  (long  version)  

Formula  →  AtomicFormula  or  Formula  Connec(ve  Formula  or  Quan(fier  Variable  Formula  or  ¬  Formula    (Formula):    

Lecture  2:  Computational  Semantics 28

Page 29: Semantics and Computational Semantics

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

Page 30: Semantics and Computational Semantics

Proper(es  of  Predicate  Logic  

•  Pros  – Composi(onal  – Declara(ve  

•  Cons  – Limited  expressive  power  – Represents  facts  

Lecture  2:  Computational  Semantics 30

Page 31: Semantics and Computational Semantics

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

Page 32: Semantics and Computational Semantics

Stages  of  Seman(c  Parsing  

•  Input  – Sentence  

•   Syntac(c  Analysis  –   Syntac(c  structure  

•  Seman(c  Analysis  – Seman(c  representa(on  

Lecture  2:  Computational  Semantics 32

Page 33: Semantics and Computational Semantics

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

Page 34: Semantics and Computational Semantics

Example   •  Input  –  Javier  likes  pizza  

•  Output  –  like(Javier,  pizza)  

Lecture  2:  Computational  Semantics 34

Associate  a  semantic  expression  with  each  node

Page 35: Semantics and Computational Semantics

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

Page 36: Semantics and Computational Semantics

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

Page 37: Semantics and Computational Semantics

COMPUTATION  AND  COMPOSITIONAL  SEMANTICS  

Lecture  2:  Computational  Semantics 37

Page 38: Semantics and Computational Semantics

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

Page 39: Semantics and Computational Semantics

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

Page 40: Semantics and Computational Semantics

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

Page 41: Semantics and Computational Semantics

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

Page 42: Semantics and Computational Semantics

CONCLUSIONS  

Lecture  2:  Computational  Semantics 42

Page 43: Semantics and Computational Semantics

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

Page 44: Semantics and Computational Semantics

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

Page 45: Semantics and Computational Semantics

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

Page 46: Semantics and Computational Semantics

Reminder:  Glossary  Entries  

•  Which  concepts  are  the  most  salient  in  this  lecture?  

•  Start  crea(ng  your  Glossary  now…  

Lecture  2:  Computational  Semantics 46

Page 47: Semantics and Computational Semantics

The  End      

Lecture  2:  Computational  Semantics 47


Top Related