Auto Parse SynData

Old forums and posts related to unsupported version of Syn Virtual Assistant.

Auto Parse SynData

Postby Leslie » Thu Oct 02, 2014 6:07 pm

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());
User avatar
Leslie
Lead Software Architect
 
Posts: 287
Joined: Fri Sep 14, 2012 12:20 pm

Return to Archived (Old Posts)

Who is online

Users browsing this forum: No registered users and 1 guest
cron