Download presentation
Presentation is loading. Please wait.
Published byKristin Ray Modified over 8 years ago
1
November 2008NL Semantics V1 Advanced Topics in NLP Semantics V NL Access to Databases Semantics of Questions and Answers Simple Interpreters for Questions
2
November 2008NL Semantics V2 Access to Databases: 3 Approaches DB Query Language Form Interface Natural Language
3
November 2008NL Semantics V3 DB Query Language range of C is countries range of Cont is continents range of I is inclusions retrieve( Cont.name, count(C.name where C.name = I.inside and I.outside = Cont.name))
4
November 2008NL Semantics V4 Form Interface
5
November 2008NL Semantics V5 Natural Language How many countries are there in each continent?
6
November 2008NL Semantics V6 Issues Accessibility –Type of query language –What needs to be learned to make a query? –Data input vs. data output Flexibility –Can types of question be predicted? –Can types of question be easily changed? Expressivity –Limitations on kinds of information present –What types of query is possible
7
November 2008NL Semantics V7 Chat 80 Pereira and Warren (1983) General Architecture ENGLISH LOGICAL FORM PROLOG ANSWER Translation: what does the question mean Planning: how shall I answer it Execution: what is the answer?
8
November 2008NL Semantics V8 Different Types of Sentence Sentence TypeCommunicative Act Declarative SentenceAssertion Interrogative SentenceQuestion Imperative SentenceCommand
9
November 2008NL Semantics V9 Sentences and Assertions Assertions are usually expressed by declarative sentences. Our grammar/lexicon deals with very simple examples, e.g. John saw Fido More complex declarative sentences include All candidates for CSA4050 failed. Candidates who fail more than four credits shall not be allowed to take resits.
10
November 2008NL Semantics V10 Sentences and Questions Questions are usually expressed by interrogative sentences. Our simple grammar/lexicon does not yet deal with interrogative sentences. To handle them we must modify the grammar Issue: how do we recognise interrogative sentences?
11
November 2008NL Semantics V11 Execution of Communicative Acts Assertions add information to the database. The meaning of a declarative sentence involves execution an appropriate assert operation Questions query information in the database. The meaning of an interrogative sentence involves execution of an appropriate query operation Commands identify actions to be carried out. Representation of communicative act is in addition to representation of content.
12
November 2008NL Semantics V12 Assertions and Questions: Semantic Representation SentenceRepresentation of Semantic Content Representation of Communicative Act John sees Fido see(john,fido)a1(see(john,fido)) Does John see Fido see(john,fido)q1(see(john,fido))
13
November 2008NL Semantics V13 Basic Processing process(Sent,Result) :- s(SEM,Sent,[]), interpret(SEM,Result). In other words: to process the sentence: Parse it to produce semantic representation SEM Interpret SEM and give back RESULT Next we must define the interpret predicate
14
November 2008NL Semantics V14 Defining the Interpreter interpret(a1(LF),Ans) :- deal_with_a1_type(Ans). interpret(q1(LF),Ans) :- deal_with_q1_type(Ans). interpret(x(LF),Ans) :- deal_with_x_type(Ans). etc.
15
November 2008NL Semantics V15 Very Basic Intepretation interpret(a1(SEM,ok)) :- asserta(SEM). In the case of an assertion, just assert it. interpret(q1(SEM,yes)) :- call(SEM), !. interpret(q1(SEM,no)). If it’s a yes-no question, see if it’s true
16
November 2008NL Semantics V16 Dealing with Syntax We now have a primitive interpretation mechanism in place. It remains to modify the grammar/lexicon to handle the syntax of these very simple questions. To begin with, we will limit ourselves to yes/no questions
17
November 2008NL Semantics V17 Yes/No Questions: Grammar Rules for S % Declarative sentence s --> np, vp. John sees Fido % interrogative sentence s --> aux, np, vp. does John see Fido ?
18
November 2008NL Semantics V18 S Rule with Arguments :- [process]. s(a1(S)) --> np(VP^S), vp(VP). s(q1(S)) --> aux, np(VP^S), vp(VP).
19
November 2008NL Semantics V19 Complete Grammar s(a1(S)) --> np(NP), vp(VP), { reduce{NP,VP,S)}. s(q1(S)) --> aux, np(NP), vp(VP), { reduce{NP,VP,S)}. np(NP) --> n(NP). np(NP) --> d(D), n(N), {reduce(D,N,NP)}. vp(VP) --> v(VP). vp(Z^P) --> v(V2), np(NP), {reduce(V2,Z,V1), reduce(NP,V1,P)}. % lexicon aux --> [does]. aux --> [did]. v(X^walk(X)) --> [walk]. v(X^walk(X)) --> [walked]. v(X^Y^chased(X,Y)) --> [chase]. v(X^Y^chased(X,Y)) --> [chased]. n(X^cat(X)) --> [cat]. n(VP^S) --> [suzie], {reduce(VP,suzie,S)}. n(VP^S) --> [felix], {reduce(VP,felix,S)}. d(RL^SL^some(X,R,S)) --> [a], {reduce(RL,X,R),reduce(SL,X,S) }.
20
November 2008NL Semantics V20 Demo ?- process([does,john,see,fido],Ans). Ans=no ?- process([john,sees,fido],Ans). Ans=ok ?- process([does,john,sees,fido],Ans). Ans=yes
21
November 2008NL Semantics V21 Improving the Interpreter dbq :- readLine(L), dbq1(L), !, dbq. dbq1([halt]) :- nl, write(bye), !, fail. dbq1(Sent) :- process(Sent,A).
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.