I'm learning prolog and I've been stuck on a problem. I'm making a question and and answer system.
For example, When I type, "The color of the car is blue." The program will say "OK" and add that new rule, so when asked, "What is the color of the car?" It'll respond with blue.
If I say "the color of the car is green," it'll reply with "Its not."
But whenever I type "The color of the car is blue" it returns true, false for the question version. Can someone direct on where to go further? I don't know how to get the program to say "its blue" or anything
input :-
read_line_to_codes(user_input, Input),
string_to_atom(Input,Atoms),
atomic_list_concat(Alist, ' ', Atoms),
phrase(sentence(S), Alist),
process(S).
statement(Statement) --> np(Description), np(N), ap(A),
{ Statement =.. [Description, N, A]}.
query(Fact) --> qStart, np(A), np(N),
{ Fact =.. [A, N, X]}.
np(Noun) --> det, [Noun], prep.
np(Noun) --> det, [Noun].
ap(Adj) --> verb, [Adj].
qStart --> adjective, verb.
vp --> det, verb.
adjective --> [what].
det --> [the].
prep --> [of].
verb -->[is].
%% Combine grammar rules into one sentence
sentence(statement(S)) --> statement(S).
sentence(query(Q)) --> query(Q).
process(statement(S)) :- asserta(S).
process(query(Q)) :- Q.