HELP!

lineOfReasoning

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:

  • 1 for (LOR_ATT): An Object that has been captured via user input e.g. Dialog or Chat
  • 2 for (LOR_TASK): A Knowledge Object Decision e.g. from a Decision Tree Leaf node)
  • 3 for (LOR_VAL): An Object that has been assigned a value via scripting (both XpertScript or JavaScript) n.b. required Knowledge-Base setting
  • 6 for (LOR_EMPTYATT): An object encountered in inference which did not capture a value (as it's object system property "promptonempty" was set to false

Assigned Objected are only included in the line of reasoning array if the following Knowledgebase Settings - Inference Settings option has been selected:

Add Assignments to LOR

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);

On This Page