october 2004csa4050 advanced techniques in nlp 1 csa4050: advanced topics in nlp semantics 6...

20
October 2004 CSA4050 Advanced Techniqu es in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

Upload: conrad-booker

Post on 30-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

1

CSA4050: Advanced Topics in NLP

Semantics 6

Semantics of Questions and Assertions involving Quantification

Page 2: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

2

Classification of Questions

Yes/No Content Answer

Without Quantification

Did Suzie walk?

Did Suzie kick Felix?

Who walked?

Who kicked Felix?

Who did Suzie kick?

With Quantification

Did all the cats sleep?

Did a cat sleep?

Did someone kick Felix?

Which cats slept?

How many children slept?

Page 3: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

3

Classification of Assertions

Without Quantification Suzie walked

Suzie kicked Felix

With Quantification Suzie kicked a cat.

Every woman kicked Felix.

A woman kicked the cat.

The cat is a mammal

Page 4: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

4

Issues

• Handling questions ≠ Handling assertions

• Semantic issues:– What LF?– How to process LF

• Syntactic issues– how to parse sentences– how to build LF

Page 5: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

5

Semantics of Question TypeDid all the cats sleep?

• how to represent meaningq1(all(X,cat(X),sleep(X))

• how to process meaningprovide definition for all(X,R,S)

• intuitively, this succeeds if for every X where R succeeds, S also succeeds

• it fails if there is a single counterexample i.e. cat(X) succeeds and sleep(X) fails.

Page 6: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

6

Defining all

all(_,R,S) :-\+(R,\+S).

NB• \+ (G) succeeds if G fails.• Goal1,Goal2 succeeds if Goal1, then

Goal2 succeed• What happens if R fails?

Page 7: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

7

Semantics of Question TypeDid a cat sleep?

• how to represent meaningq1(some(X,cat(X),sleep(X))

• how to process meaningprovide definition for some(X,R,S)

• intuitively, this succeeds if there is an X which satisfies R and S.

• it fails if there is no such X. Only one example need be established.

Page 8: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

8

Defining some

some(_,R,S) :-

R, S.

NB

• Can this be made more efficient?

Page 9: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

9

Getting a List of SolutionsWhich cats sleep?

• The built in predicatesetof(X,Goal,L)binds L to a list of X that satisfy Goal

• So for example with a database containingcat(majlo). sleep(majlo). cat(felix). sleep(felix). cat(cobweb).

• ?- setof(X,(cat(X),sleep(X)),L).L = [majlo,felix]

Page 10: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

10

How many cats slept?

• "How many" questions require a numerical answer that is obtained by counting the number of solutions.

• This can be acheived as follows using setof in conjunction with the built-in length predicate.

howmany(X,Goal,N) :-

setof(X,Goal,L),

length(L,N).

Page 11: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

11

Assertions with QuantificationUniversal Statements

• Universal statements are those whose LF involves all(<var>,R,S).

• This translates into the Prolog clauseS :- R

• Example– English = Every cat sleeps– LF = all(X,cat(X),sleep(X)).– Prolog = sleep(X) :- cat(X)

Page 12: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

12

Restrictions on Translationinto Prolog

• Prolog uses the Horn Clause subset of FOL.

• A rule of the forma(X) :- a1(X), ..., an(X)corresponds to the FOL statementx (a1(x) & ... & an(x) a(x))

• Outermost quantifier must be universally quantifed

• Conclusion must be a single predicate

Page 13: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

13

Assertions with Quantification:Simple existential statements

• With simple assertions like Suzie chased Felixwe simply assert the corresponding LF chased(suzie,felix) into the database.

• This will not work with sentences likeSuzie chased a catwhose LF is some(X,cat(X),chase(suzie,X))

Page 14: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

14

Establishing the truthof quantified sentences

• In order to find out what has to be asserted, let’s see what happens with corresponding query, given that some(_,R,S) :- R, S.

• Clearly, the query?- some(X,cat(X),chase(suzie,X)).will cause subgoals cat(X), chase(suzie,X) to be tried.

• These will fail

Page 15: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

15

Anonymous Names

• cat(X) and chased(suzie,felix) will succeed if we have, e.g. cat(felix), chased(suzie,felix) in the database.

• But when we assert some(X,cat(X),chased(suzie,X))no such name is mentioned, so we have to invent an anonymous name.

• The simplest names are integers:cat(100). chased(suzie,100).

Page 16: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

16

Discourse Referents

• Such names are more properly called discourse referents. Discourse referents are entities that are referred to by different parts of a discourse.

• Some parts introduce new DRs. Others refer back to already established DRs.

• Discourse Representation Theory

• A baby cried. He was hungry

Page 17: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

17

Interpreting Wh Questions

• Semantically, issue is quite simple• We want the semantic interpretation of the

question to query the database and bind the result to a variable.

• Let SEM be the semantic interpretation of "who sees fido“. We want the following behaviour

?- interpret(SEM,Ans)Ans = [john,mary]

• What does SEM have to look like?

Page 18: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

18

Representing Meaning

Question Semantic Representation

Who sees Fido? q2(X,setof(Y,see(Y,fido),X))

Who did John see? q2(X,setof(Y,see(john,Y),X))

Page 19: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

19

How Internal BindingsYield the Answer

interpret(q2(X, ....X....),X)

• The first occurrence of X identifies what the unknown is called.

• The second occurrence identifies where the unknown information is situated in the second arg. position of q2).

• The last occurrence will become bound to the answer.

Page 20: October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification

October 2004 CSA4050 Advanced Techniques in NLP

20

Syntax of Wh Questions

• How do we build the right semantic representation from the question?

• Need to look carefully at the syntactic structure of the questions.

• In particular, need to look at the way sentences have been derived.

• Hypothesis: the word who can substitute any noun phrase.