xpertrule.lineOfReasoning([subKnowledgeObject]);
This special method returns an array of all the executed Objects (all "captured" and " Knowledge" Objects) for the current runtime session (up to the point of the method's execution). If an optional Knowledge Object is passed then this array is limited to only having the Objects executed within this Knowledge Object. This returned array can optionally also include all assigned Objects.
var lor = xpertrule.lineOfReasoning();
The returned array object data format is as follows:
[
{atype: LOR_ATT, id: objectID},
{atype: LOR_TASK, id: objectID},
{atype: LOR_VAL, id: objectID},
{atype: LOR_EMPTYATT, id: objectID}
]
The 3 values for (atype) that can be returned are:
Assigned Objected are only included in the line of reasoning array if the following Knowledgebase Settings - Inference Settings option has been selected:
An example of a returned array:
[
{
"atype": 3,
"id": 66
},
{
"atype": 1,
"id": 67
},
{
"atype": 1,
"id": 65
},
{
"atype": 1,
"id": 62
},
{
"atype": 2,
"id": 70
}
]
The following JavaScript example processes the array returned by the lineOfReasoning method to generate text for a report:
var c, o;
var lor = xpertrule.lineOfReasoning();
var r = "";
for (c = 0; c < lor.length; c++){
switch (lor[c].atype) {
case LOR_TASK: // Knowledge Object
r += "[Decision] ";
break;
case LOR_ATT: // Captured Object
r += "[Question] ";
break;
case LOR_VAL: // Assigned Object (only included if option set in Knowledge-Base Settings)
r += "[Assigned] ";
break;
case LOR_EMPTYATT: // Encountered but did not capture a value
r += "[Assigned] ";
break;
}
o = xpertrule.findObject(lor[c].id);
r += "Name: " + o.aName + " " + // The Object's Name
"Description: (" + o.props.description + ") " + // The Object's "description" Property
"Value: (" + o.val() + ") "; // The Object's value
if (o.parentObj().aName == "List_Question") { // For List type Objects
r += "Value synonyms : (" + o.value(0).synonyms + ") "; // The selected value's "synonyms" property
}
r += "\n";
}
xpertrule.message(r);