Search This Blog

Thursday 7 July 2016

The First One on Chatbots

Chatbot is a computer program that talks like a human to the user usually via a chat-room/messenger interface. It is daunting task for a computer to understand what a user is saying and respond to him/her in a sensible manner, since our languages are complex and we do not follow strict grammar in a casual conversation. But there are some shortcuts through which it can fool the user into believing that the responder on the other side is human and not a robot.

Sane and even some insane humans have enough intelligence infrastructure in their brain, to understand what other humans are saying(assuming they speak the same language) and respond to them with appropriate response. But how can a computer do that? It is obvious that the AI scientists are trying to mimic/embody the human or human like intelligence in computer for a while and with varying measures of success. How can then chatbots can accomplish its goal - talk like a human? Well, as mentioned above, there are tricks and shortcuts with we can "program" chatbots to be intelligent enough.

There are various ways devised and discovered from our experience with the field of artificial intelligence to embody intelligence into chatbots. The very old one(to my knowledge) is pattern-matching with some level of context management and that is what we going to look into. For instance,

Kayalvizhi: What is your name?
Edinburgh: My name is Edinburgh.
Edinburgh: What is your name?
Kayalvizhi: My name is Kayalvizhi.

I admit that is a lame example, but it illustrates the point. Our usual conversations tend to be in a pattern. Usually the human languages have lot more words than how many are used in day-to-day life. With this fact on hand we can employ pattern matching to construct a meaningful message to user. Let's see how we can build a bot for the above conversation in RiveScript.

RiveScript

[From Rivescript website] RiveScript is a simple scripting language for chatbots with a friendly, easy to learn syntax. RiveScript exposes a simple plain text scripting language that's easy to learn and begin writing in quickly. RiveScript has a handful of simple rules that can be combined in powerful ways to build an impressive chatbot personality. Write triggers in a simplified regular expression format to match complex sets of word patterns in one go. RiveScript takes a "Unix-like" approach to its development: the core library is small and self-contained and it does one thing very well—takes human input and gives an intelligent response. This flexibility enables RiveScript to be used how you need it to.

Basically RiveScripts consists of triggers and responses and something called topic.

Triggers are messages typed into, by the user. The chatbot read the messages, and it matches with the list triggers(already programmed) and finds a best match and then responds with the response string from the matched trigger.

one.rive   -- our first script.
+ my name is edinburgh
-  that is nice name

When ever you say that "my name is edinburgh" the bot will reply "that is a nice name." This is a very dumb bot, and it understands only one sentence - "my name is edinburgh".

Lets modify it a little bit, so that anyone can talk to our bot.
two.rive
+ my name is *
-  hi, there, how are you?

Conversation 2
Kuzhali: my name is kuzhali
Bot       : hi there, how are you?

Cheran:  my name is cheran
Bot      :  hi there, how are you?

Mark   :  my name is mark
Bot      :  hi there, how are you?

Toyota :  my name is toyota
Bot      :  hi there, how are you?

No comments:

Post a Comment