-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanswer.pl
31 lines (25 loc) · 1013 Bytes
/
answer.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
:- module(answer,[answer/3]).
:- op(100,xfx,'=..').
/* Rules to define the compositions of an answer given the question's parse tree */
answer(Number,ParseTree,Reply) :-
ParseTree = question(noun(N),verb(V)),
Command =.. [V,N,A], % Produce a predicate to call from the components of the parse tree
call(Command),
append([],[N,V,A],Reply). % Construct the list of words representing the full-worded answer to the question
answer(Number,ParseTree,Reply) :-
ParseTree = question(noun_phrase(determiner(D),noun(N)),verb(V)),
Command =.. [V,N,A],
call(Command),
append([],[D,N,V,D,A],Reply).
answer(Number,ParseTree,Reply) :-
ParseTree = question(noun(N),descriptor(Dc)),
Command =.. [Dc,N,A],
call(Command),
isos(Number,I),
append([],[N,I,A],Reply).
answer(Number,ParseTree,Reply) :-
ParseTree = question(noun_phrase(determiner(D),noun(N)),descriptor(Dc)),
Command =.. [Dc,N,A],
call(Command),
isos(Number,I),
append([],[D,N,I,A],Reply).