Chatbots fall into two broad classes, the hand-crafted and the brute-force. Hand-crafted bots, like ALICE and SUZETTE, have the advantage of being able to create a consistent persona at the cost of having to hand author everything. Brute-force bots either harvest the internet or people’s chat, like Cleverbot. They have the advantage of it being easy to add new data at a cost of having that data be completely schizophrenic.
Historically, brute-force wins in AI every time. It won in chess, it is winning in Go, it is winning in language translation and search, and it wins in manufacturing. It wins because it overlooks nothing and costs less to produce. All it requires is powerful enough hardware, and time is in its favorite for that.
So we who tilt at windmills with our hand-crafted bots strive to improve the ease of adding rules. My focus in ChatScript for that is the table. Tables make it easy to add data. Take, for instance, the simple question of “what is your favorite xxx”. This kind of question showed up twice in last year’s qualifiers, first as food and then as color.
Writing patterns for “what is your favorite color” is easy. And if you put all the patterns that represent that meaning in a macro that takes the what as a argument, it becomes something like
?: ( ^WHATFAVORITE(color)) My favorite color is green.
But imagine doing some 400 favorites, in a variety of different topics. You have to scroll around to the right topic, type in that whole pattern stuff. Or you can be lazy, using a table. I create a topic of “favorite” and use a table to arrange the data. I can accommodates single and double word phrases. E.g.
Table: favorites (^topic ^modifier ^what ^result)
^createfact((^modifier ^topic ^what) favorite ^result )
DATA:
~books _ book “My favorite book is Time Enough for Love.”
~books Dr._Seuss book “I like The Cat in the Hat.”
Assuming you have patterns that detect the structure of the “what is your favorite ”, you can write them to detect one or two-word requests, and store the base request in _1 and the modifier (if there is one) in _0. If there is no modifier, just store the _ character. Then you can do a query like this:
query(direct_vo ? favorite _1 )
which retrieves all favorite facts about _1. You can then loop through the facts and see which, if any, match the modifier _0. Finding a match, you print out the result AND, you set the current topic to the topic associated with the fact. That way, conversation continues in a related subject area. So while the match was in the favorites topic, the continuation is in the topic appropriate to the answer.
You are allowed a shortcut in a table for a bunch of synonyms, like this:
~music [rock musical music] group “I like Kiss”.
Which generates separate facts for each modifier.
I improve on this notion by adding the why in the result, like “I like dogs because they are cute”, and then “^burst” the result so as to get the part before because and the part after. I randomly display the full sentence, or just the first part, hoping to tease the user into asking why. The rejoinder will then display the second part, if there is one.
I further improve on this sometimes by allowing concepts into the table.
~computers _ ~chatbotlist “My favorite robot is the computer on Star Trek. It was always so easy to fool.”
But this requires changing the query, because the base item will not be a word of the sentence. The query must see if the base item is ultimately a member of the concept. The query becomes query(direct_v<o ? favorite _1 ). This query looks for facts where the verb is given but the object can trace a path from left to right ( < means left to right), using membership. This sophisticated search will see if the word given is a member of what is given as the object. So if the actual object given is “chatbot”, it will check each favorite fact to see if chatbot is ultimately a member of the object. In this case ~chatbotlist is a list of synonyms for chatbot.
And while I haven’t bothered to code it yet, one could take this even further…
~books ~authors book xxxx
I could write script xxxx (where xxx is actually script and not a sentence) that would look up a specific author, find from facts of books that he wrote, and respond by randomly picking one of his books.
That is, having stuff in multiple tables allows you to interact knowledgeably with it. Unlike writing rules where the answer is stuck in a specific rule and you can’t do anything else with it.