Page 1 of 1

Auto Parse SynData

Posted: Thu Oct 02, 2014 6:07 pm
by Leslie
Though to create true computable data a SynParser is applied but sometimes its all about adding a Data when a particular pattern is found in the message.

Say for instance you wish to create a function that will change color to the specified value. This function should be Triggered whenever the sentence Change Color To is used along with some color value. The function ofcourse will take a ColorData as its second value.

Sample Code

CSharp Code

public class ChangeColorTerm : SynData
{
public ChangeColorTerm()
{
//This data will be added to the Context ff the caller message contains the pattern below
this.Data.AddPattern("change color to");
}
}
By convention the Class name is suffixed with the word Term to indicate that its a trigger and is used as the first parameter for a function.

Sample Code to add the above SynData to Engine

CSharp Code

Engine.AddAutoParser(new ChangeColorTerm());