dumb fake NLP stuff

This commit is contained in:
Diogo Cordeiro 2018-12-07 16:11:11 +00:00
parent 07f341b5fa
commit 7fd64223fc

View File

@ -33,7 +33,6 @@
*/ */
:- use_module(library(clpr)). :- use_module(library(clpr)).
/******************************* /*******************************
* USER INTERFACE * * USER INTERFACE *
*******************************/ *******************************/
@ -153,6 +152,78 @@ is_number_in_predicate(C, F) :-
write(C), write(C),
fail. fail.
/*******************************
* NLP *
*******************************/
polyplay :-
write("> "),
read(R),
(
R = bye,
write("See ya")
;
(
nlp_understand(R, P, I),
writeln("That's trivial:"),
nlp_compute(P, I)
;
writeln("I didn't understand what you want.")
),
polyplay
).
nlp_understand(R,P,I) :-
(
R = simplify_x_squared,
P = simplify,
I = x^2
;
fail
).
nlp_compute(simplify, P) :-
simplify_polynomial(P, O),
writeln(O).
nlp_compute(_,_) :-
fail.
parse_digit(zero, 0).
parse_digit(one, 1).
parse_digit(two, 2).
parse_digit(three, 3).
parse_digit(four, 4).
parse_digit(five, 5).
parse_digit(six, 6).
parse_digit(seven, 7).
parse_digit(eight, 8).
parse_digit(nine, 9).
parse_digit(ten, 10).
parse_digit(eleven, 11).
parse_digit(twelve, 12).
parse_digit(thirteen, 13).
parse_digit(fourteen, 14).
parse_digit(fifteen, 15).
parse_digit(sixteen, 16).
parse_digit(seventeen, 17).
parse_digit(eighteen, 18).
parse_digit(nineteen, 19).
parse_digit(twenty, 20).
parse_digit(thirty, 30).
parse_digit(forty, 40).
parse_digit(fifty, 50).
parse_digit(sixty, 60).
parse_digit(seventy, 70).
parse_digit(eighty, 80).
parse_digit(ninety, 90).
parse_number([],0).
parse_number([N|L], X) :-
parse_digit(N, X1),
parse_number(L, X2),
X is X1 + X2.
/******************************* /*******************************
* BACKEND * * BACKEND *
*******************************/ *******************************/