EmbodimentLanguageComprehension AnswerFinder
From OpenCog
Contents |
Answer Finder
This module will do the question resolution. It will receive a list of Frames instances and will try to find grounding ones inside the AtomTable. These grounding frames will must contains SemeNodes to denote the objects referred in the question.
The first step of AnswerFinder is to call the Reference Resolution routine to ground all nouns and pronouns of the Parsed question. Then it will inspect the type of the question and start preparing the answer.
Answer types
There are basically two types of answers, yes/no and affirmative ones. The yes/no answer requires only a pattern matching to determine if the question subject is known or not, true or false, by the agent. OTOH affirmative answers requires, besides the pattern matching step, the creation of a Frames Instances list to be used to generate the final answer.
Once the set of Frames instances arrives at the AnswerFinder module, the type of the question was already determined by the Classifier. So it is straightforward to determine which answer we should give to the avatar.
Yes/No answer
After receiving a Yes/No question the AnswerFinder module will do a Pattern Matching with the incoming Frames Instances to determine if the answer is yes or no. Once determined the answer, a Relex Structure that describes it is then sent to NLGen which will then retrieve the corresponding sentence. Finally, the sentence is sent to the Communicator module to be processed as a 'say' action.
Suppose we need to answer the question: Are you angry?
The following frames will be stored into the AtomTable
Questioning:Message = truth-query Questioning:Addressee = #you Entity:Entity = #you // payload frames Emotion_directed:Experiencer = #you Emotion_directed:State = angry
After reference resolution we will have the additional:
ReferenceLink ConceptNode "#you" SemeNode "agent_01"
Given that State represents the situation of a given Entity, and the entity is #you (the agent). A rule will look for predicates, which represents perceptions, feelings and/or physiological needs, to retrieve the answer. In the case above, the AnswerFinder Module will look for the predicate:
EvaluationLink PredicateNode "angry" ListLink PetNode "agent_01"
If its Truth value was greater than 0.5 so the answer will be "Yes", otherwise the answer will be "No".
Affirmative answer
This type of answer requires one more step, if compared to yes/no questions. Once the answer contains more information than just yes/no it is necessary to format the final answer based on the involved Frames instances.
Suppose that someone make the question: Why the sky is blue? And the following Frames arrived at the AnswerFinder:
Questioning:Message = why Questioning:Addressee = #you Causation:Actor = sky Causation:Effect = blue Causation:Reason = $qVar Causation:Means = is // payload frames Color:Entity = sky Color:Color = blue
After the reference resolution, the following new structure is then added:
ReferenceLink ConceptNode "#you" SemeNode "agent_01"
After that, the AnswerFinder will start by the main Frame instance 'Reason' to prepare the frames used at the PatternMatch step. But after that we need to take a look at the Frames that were already stored into the AtomTable which is related to this answering process.
// ... here comes the frames description structures ... // EvaluationLink DefinedFrameElementNode "#Causation:Actor" ConceptNode "sky" EvaluationLink DefinedFrameElementNode "#Causation:Effect" ConceptNode "blue" EvaluationLink DefinedFrameElementNode "#Causation:Reason" ConceptNode "atmosphere" EvaluationLink DefinedFrameElementNode "#Causation:Means" ConceptNode "is"
After that, the following frames will be searched into the AtomTable:
// ... here comes the frames description structures ... // EvaluationLink DefinedFrameElementNode "#Causation:Actor" ConceptNode "sky" EvaluationLink DefinedFrameElementNode "#Causation:Effect" ConceptNode "blue" EvaluationLink DefinedFrameElementNode "#Causation:Reason" VariableNode "$qVar" EvaluationLink DefinedFrameElementNode "#Causation:Means" WordNode "is" EvaluationLink PredicateNode "color" ListLink ConceptNode "sky" ConceptNode "blue"
So, the VariableNode $qVar is then grounded by the ConceptNode "atmosphere" and the final Frames list, used to answer the question, will be:
Causation:Actor = ConceptNode "sky" Causation:Effect = ConceptNode "blue" Causation:Reason = ConceptNode "atmosphere" Causation:Means = WordNode "is"

