Semantic Ambiguity CS 181: Natural Language Processing Some ambiguities arise at semantic level Lecture 17: Computational Semantics have same parse trees, but different meanings Kim Bruce Every student read a book. Pomona College They each picked their own. Spring 2008 Some liked it, while others did not. Disclaimer: Slide contents borrowed from many sources on web! What about other “Obvious” Semantics meaning? [[Every student read a book]] = [[Every student]] ([[read a book]]) Montague [1973]: Rewrite sentence: A book, every student read it. [[Every student]] = !Q.!x(student(x)"Q(x)) “It” creates a hole to be filled: [[read a book]] = !s:D. #y(book(y) $ read(s,y)) [[every student read it]] = !!!! !z:D.!x.(student(x) " read(x,z)) [[Every student]] ([[read a book]]) [[a book]] = !P.#y.(book(y) $ P(y)) with type = !x(student(x)"(!s:D. #y(book(y) $ read(s,y)))(x)) VPType % Form. = !x(student(x)"#y(book(y) $ read(x,y))) Putting it Together Other Solutions Cooper Storage: “Freeze” meanings for quantifiers, pull out when [[A book, every student read it]] needed. (See book for similar idea) = (!P.#y.(book(y) $ P(y))) !!! (!z:D.!x.(student(x) " read(x,z))) Results in saving multiple meanings. = #y.(book(y) $ (!z:D.!x.(student(x) " Doesn’t work with nested noun phrases !!!!!!!!! read(x,z)))(y))) “Jane read every book of a teacher.” = #y.(book(y) $!x.(student(x) " read(x,y))) Keller suggested an improvement Seems like a trick! !!! Hole semantics incorporates constraints Graphical representation representing constraints. Semantic Ambiguity More attempted solutions: Quasi-Logical Form, Underspecified Logical Form, Underspecified Discourse Representation Theory, Minimal Recursion Semantics, Ontological Promiscuity, Hole Semantics, the Logic in NLTK Constraint Language for Lambda Structures, and Normal Dominance Constraints Sentences w/N quantifiers have up to N! meanings. Desirable to return probability weightings Formulas Building formulas Examples: >>> lp.parse('(and p q)') >>> lp = nltk.sem.LogicParser() ApplicationExpression('(and p)', 'q') >>> lp.parse(r'(walk x)') Allows infix ApplicationExpression('walk', 'x') >>> lp.parse('(p and q)') >>> lp.parse(r'\x.(walk x)') ApplicationExpression('(and p)', 'q') LambdaExpression('x', '(walk x)') >>> e = lp.parse('(p and (not q))') >>> e ApplicationExpression('(and p)', '(not q)') Formatting Using Lambda Calculus Examples Examples: >>> e = lp.parse(r'(\x.((walk x) and (talk x)) john)') >>> print e >>> e (and p (not q)) ApplicationExpression('\x.(and (walk x) (talk x))', 'john') >>> print e.infixify() >>> e.simplify() (p and (not q)) ApplicationExpression('(and (walk john))', '(talk john)') Embedding FOL Characteristic Functions Build characteristic functions from dicts: >>> called = nltk.sem.CharFun( !!{'bob': nltk.sem.CharFun({'mary':True}), Examples: ... 'jane': nltk.sem.CharFun({'mary':True})}) >>> lp = nltk.sem.LogicParser(constants= !!!!!!!!! ['dog', 'walk', 'see']) >>> called['bob'] {'mary': True} >>> lp.parse(r'dog') >>> called['bob']['mary'] ConstantExpression('dog') True >>> lp.parse('x') >>> called['bob']['jane'] IndVariableExpression('x') Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 'jane' Building Characteristic Functions Building a Model Build from relations: Valuations interpret non-logical symbols: >>> val = >>> cd = set([('bob','mary'),('jane','sally')]) nltk.sem.Valuation({'JJ':'jane','Tiger':'bob','Mare':'mary', >>> cf = nltk.sem.CharFun() ..., 'boy':{'bob':True}, 'called':called}) >>> cf.read(cd) >>> val['JJ'] 'jane' >>> cf >>> val['called'] {'sally': {'jane': True}, 'mary': {'bob': True}} {'jane': {'mary': True}, 'bob': {'mary': True}} Building a Model Building a Model Assignments: domain of model >>> g = nltk.sem.Assignment(['jane','bob','mary','sally'],!!! Model: !!!!!!! {'x':'bob','y':'mary'}) m = nltk.sem.Model(set(['jane','bob','mary','sally']),val) >>> g m.evaluate('some x.((boy x) and (called x Mare))',g) {'y': 'mary', 'x': 'bob'} True >>> print g Searches over domain of model for satisfying assignment -- slow, as keeps going even after it finds it! g[mary/y][bob/x] Warning: Tracing evaluate w/existentials raises exception at runtime! >>> g.add('sally','z') {'y': 'mary', 'x': 'bob', 'z': 'sally'} Adding Semantic Features Before associated non-CFG rules to Unification productions: NP % Det Nominal Based <Det AGREEMENT> = < Nominal AGREEMENT> <NP AGREEMENT> = <Nominal AGREEMENT> Approaches Want to associate semantics in same way. Give up FOL for now to explore use of feature constraints Two Representations Example [[Jane walked]] IVerb % walked !!!!! = #e.Walked(e) $ Walker(e,jane) <IVerb SEM QUANT> = # <IVerb SEM FORMULA OP> = $ or <IVerb SEM FORMULA FORMULA1 PRED> = walked QUANT # <IVerb SEM FORMULA FORMULA1 ARG0> = VAR ! !!!!!!!!!!! <IVerb SEM VAR> OP AND <IVerb SEM FORMULA FORMULA2 PRED> = walker <IVerb SEM FORMULA FORMULA2 ARG0> = FORMULA1 PRED walked !!!!!!!!!!! <IVerb SEM VAR> [ARG0 ! <IVerb SEM FORMULA FORMULA2 ARG1> = FORMULA PRED walker !!!!!!!!!!! <IVerb ARG0> FORMULA2 ARG0 ! Draw picture! [ [ARG1 jane Example Put it all together ... VP % IVerb <VP SEM> = <IVerb SEM> S % NP VP <VP ARG0> = <IVerb ARG0> <S Sem> = <NP Sem> PropNoun % Jane <VP ARG0> = <NP VAR> <PropNoun SEM PRED> = Jane <NP SCOPE> = <VP SEM> <PropNoun VAR> = <PropNoun SEM PRED> NP % PropNoun Allows one to construct diagrams using unification as <NP SEM> = <PropNoun SEM> before. <NP SCOPE> = <PropNoun SCOPE> Can unify as parse as w/other features <NP VAR> = <PropNoun VAR> Back to Logic Handle declaratives, interrogatives, and Semantics for imperatives. Fragment of S % NP VP {DCL(NP.Sem(VP.sem))} S % VP {IMP(VP.sem(DummyYou))} English S % Aux NP VP {YNQ(NP.Sem(VP.sem))} DCL, IMP, YNQ are operators resulting in actions. Operators Wh-Questions Who ate the candy? DCL S % WhWord VP add to knowledge base {WHQ(WhWord.sem.var,VP.sem)} YNQ !z:NP. z(VP.Sem) is function taking a NP. determine if prop can be inferred from Meaning is set of f in NP making fcn true. knowledge base - meaning is correct answer What did John eat? IMP S % WhWord Aux NP VP speech act - discussed later on dialog {WHQ(!o:NP(NP.sem((!x:NP: VP.sem(x))(o))} or {WHQ(o,NP.sem,VP.sem(x))} Noun Phrases Adjective Phrases Try: Already seen NPType = VPType % Form Nominal % Adj Nominal {!x. Nominal.sem(x) $ IsA(x,Adj.sem)} Nominal % Noun Nominal Adj % red {!P:NounType.!x.P(x) $ IsA(x,red)} ! {!x. Nominal.sem(x) NN(Noun.sem, x)} $ Adj % small {!P:NounType.!x.P(x) $ IsA(x,small)} " summer vacation, head start, elephant gun, ... [[small mouse]] = !x. mouse(x) $ IsA(x,small) Note that an elephant gun is not an elephant! [[small elephant]] = !x. elephant(x) $ IsA(x,small) Others: former friend, fake gun, ... Genitive Noun Phrases Prepositional Phrases Mary’s bike, Mary’s friend, Ontario’s airport. Generalize from possessives: Meaning determined more by noun, not possessive! Mary’s bike & the bike of Mary NP % ComplexDet Nominal [[house on a hill]]: NounType = D % Form ComplexDet % NP’s {NP.sem} P % on {!P:NPType.!Q:NounType. !x:D. !!!!!!!! P(!y. Q(x) $ on(x,y))} {!Q:VPType. #x. Nominal.sem(x) $ PP % P NP {P.sem(NP.sem)} !!!!!GN(x, ComplexDet.sem) $ Q(x)} Nom % Nom PP {PP.sem(Nom.sem)} [[Mary’s bike]] = !Q:VPType. (#x. bike(x) $ !!!!!!!belongsTo(bike,Mary) $ Q(x)) Different from text! Semantics & Earley Parser Idioms Hard - don’t make literal sense. Just like other features Tip of the iceberg, Achilles’ heel, .. No extra problems! Generally not compositional. Must recognize and treat separately Summary of Semantics Principle of Compositionality key Syntax-driven semantic analysis Any Questions? Use !-expressions (and other cheats) Quantifiers require lambda lifting..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages6 Page
-
File Size-