Towards genericizing syntactic relations
------------------------------------------------------

A post on a chatbot site contained this dialog:

    Human: My car is red
    Bot: ok.
    Human: What color is my car?
    Bot: red
    Human: Johnny said he likes pizza.
    Bot: ok.
    Human: What did Johnny say?
    Bot: he likes pizza.
There are two problems here. The first is that "My car is red" has no explicit mention of color. I can handle this in logicagent by explicitly defining red as a color:
F:\controlbot\controller\logicagent>ruby logicbot.rb
Hello
I have loaded F:/controlbot/controller/logicagent/logicagent-api.yaml.
F:/controlbot/controller/logicagent/graph.yaml loaded.

> reset graph [start with a blank slate]
> my car is red
> red is a color [colors could be read in from a file at startup]
> what color is my car?
I think you said your car is red.
---

Another way I can handle this color question is with an if-then rule. For now, the rules are expressed in Ruby; the idea is to eventually allow natural language expression of if-then rules (in this case, something like: "if you get a question like 'what color is ___' then use the answer for 'what is ___'").

> reset graph [forget everything]
> logicbot: if input =~ /what color is (.*)/ then response = self.send("what is #{$1}") end
> my car is red
> what color is my car?
your car is red
---

The second problem in the first dialog is the verb "say", which the logic agent hasn't seen before. How can I teach it new relations? First, I defined the "say" relation in terms of another transitive verb that it knows about. After doing that, it can handle the "say" dialog:

> Johnny said he likes pizza.
> What did Johnny say?
Johnny said he likes pizza
---

Now what if I want the agent to handle other relations? Say "bit":

> Johnny bit his tongue.
Default response. [The program doesn't understand the input]

> (.*) (bit) (.*) is like (.*) (said) (.*) [teach the bot that "bit" is like "say"]
> Johnny bit his tongue.
Okay, Johnny bit his tongue. [The bot now understands, and stores the relation]

> What did Johnny bite?
Default response. [Doesn't understand the question]

> what did (.*) (bite) is like what did (.*) (say) [Tell the bot that the syntax of the new question is like another one it knows how to answer]
> bit is the past tense of bite [Teach the bot the irregular past tense of bite]
> What did Johnny bite?
Johnny bit his tongue
---

So I can tell the bot at runtime that a new relation follows the same pattern as a relation it already knows. I also can explicitly teach it irregular verb forms ("the past tense of bite is bit"). Another way to handle verb forms would be to look them up in a table...

The goal is to teach the bot at runtime how to handle new relations; I'm making progress :) Next I should be able to automate the explicit regular-expressions included in the teaching, so that for example I could simply say: "bite is like say" and the bot itself would supply the two rules I had to tell it:"(.*) (bit) (.*) is like (.*) (said) (.*)" and "what did (.*) (bite) is like what did (.*) (say)".

Basically the idea is to have dialogs with the bot that don't need the annotations in square brackets I've included to try to make it easier for you to understand. (Like writing code that doesn't need comments.) I want to speak to the program in the way that I would speak to people...