Search code examples
prologchatbot

Chatbot in Prolog


I've been trying to create a chatbot (as an assignment) in prolog, so far I have made a database in a .pl file and I have listed a lot of possible conversations. I know that prolog works like this for example if we have

Chatbot(good) 

and we type

?-Chatbot(good). 

it will respond

yes or ture.

Now I don't know how to use my database so that the program can work exactly as a chatbot for example without the need to write in appropriate syntax:

Hello (typed by the user)

Hi there, (typed by the program automatically)

My database is like this:

answer( question, [
[Yes, I am here]]).

question ([are you there?]) 

Solution

  • The prototype chatbot I'm aware of is ELIZA by Weizenbaum 1966.

    Implementing it in Prolog is rather easy, as shown in The Art of Prolog by Sterling & Shapiro.

    Googling for 'ELIZA Prolog', the first link gives you a fairly complex implementation, and you could adapt/reuse the engine with your database. But this way you will lose all the fun. I suggest you read the book and take the time to implement your own.

    edit

    Just in case you haven't still seen it, SWISH offers a clean, barebone ELIZA implementation among its examples.