Title: Advanced Topics in NLP
1Advanced Topics in NLP
- Semantics V
- NL Access to Databases
- Semantics of Questions and Answers
- Simple Interpreters for Questions
2Access to Databases3 Approaches
- Natural Language
- DB Query Language
- Form Interface
3Natural Language
- How many countries are there in each continent?
- What is their average population?
4DB 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))
5Form Interface
6Issues
- 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
7Chat 80 Pereira and Warren (1983)General
Architecture
Translation what does the question mean
Planning how shall I answer it
Execution what is the answer?
8Different Types of Sentence
Sentence Type Communicative Act
Declarative Sentence Assertion
Interrogative Sentence Question
Imperative Sentence Command
9Sentences 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 includeAll
candidates for CSA4050 failed.Candidates who
fail more than four credits shall not be allowed
to take resits.
10Sentences 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 Execution ofCommunicative 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.
12Assertions and Questions Semantic Representation
Sentence Representation 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))
13Basic 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
14Defining the Interpreter
- interpret(a1(X),A) -
- a1(X,A).
- interpret(q1(Q),A) -
- q1(Q,A).
15Very Basic Intepretation
- a1(SEM,ok) - asserta(SEM).
- In the case of an assertion, just assert it.
- N.B. no check for previous assertion.
- q1(SEM,yes) - call(SEM), !.
- q1(SEM,no).
- If its a yes-no question, see if its true
16Dealing 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
17Yes/No QuestionsGrammar Rules for S
- Declarative sentence
- s --gt np, vp.
- John sees Fido
- interrogative sentence
- s --gt aux, np, vp.
- does John see Fido ?
18S Rule with Arguments
- - process.
- s(a1(S)) --gt
- np(NP), vp(NP),
- reduce(VP,NP,S).
- s(q1(S)) --gt
- aux, np(NP), vp(VP),
- reduce(VP,NP,S).
19Demo
- ?- process(does,john,see,fido,A).
- Ano
- ?- process(john,sees,fido,A).
- Aok
- ?- process(does,john,sees,fido,A).
- Ayes
20Improving the Interpreter
- dbq -
- readLine(L),
- dbq1(L),
- !,
- dbq.
- dbq.
- dbq1(halt) - nl, write(bye), !, fail.
- dbq1(Sent) - process(Sent,A).