All Tutorials / Jlucben / Synbot Plugin Tutorial - interface to Syn Bot Software

Synbot Plugin Tutorial - interface to Syn Bot Software

Step 10 : SIML Tips and Tricks Continued

Using Pattern reductions

In the Pattern Reductions SIML file , you can specify patterns which will be evaluate first for every User Input to the Bot.
Look at the example below in which pattern reduction is used to specify several common syntax forms for a request.
COULD YOU TELL ME - CAN YOU GIVE US - I WOULD LIKE YOU TO GIVE - I JUST WANT YOU TELL ME - I WANT TO KNOW - COULD I KNOW - GIVE US - TELL ME - .....

User Input I WANT TO KNOW WHAT IS YOUR NAME will in this case switch to the evaluation of Pattern WHAT IS YOUR NAME due to the Goto tag
Bot variables values can be set in the Pattern Reductions Models in ordered to be tested in the switched Pattern Model.

Code:

[Map Name="Peux_Tu_en"]
[MapItem Content="can you" Value="T" /]
[MapItem Content="could you" Value="T" /]
[/Map]
[Map Name="Pourrai_je_en"]
[MapItem Content="can I" Value="T" /]
[MapItem Content="could I" Value="T" /]
[MapItem Content="can we" Value="T" /]
[MapItem Content="could we" Value="T" /]
[/Map]
[Map Name="Aimerai_voudrai_je_en"]
[MapItem Content="I would like" Value="T" /]
[MapItem Content="I wish" Value="T" /]
[MapItem Content="I just wish" Value="T" /]
[MapItem Content="I want" Value="T" /]
[MapItem Content="I just want" Value="T" /]
[/Map]

Code:

[Map Name="current_verb_1_en"]
[MapItem Content="tell" Value="1100000000" /]
[MapItem Content="give" Value="0100000000" /]
[/Map]
[Map Name="current_verb_2_en"]
[MapItem Content="know" Value="1100000000" /]
[/Map]

Code:

[Model]
[Pattern]
[Item][MAP:PEUX_TU_EN] [MAP:CURRENT_VERB_1_EN] *[/Item]
[Item][MAP:PEUX_TU_EN] [MAP:CURRENT_VERB_1_EN] ME *[/Item]
[Item][MAP:PEUX_TU_EN] [MAP:CURRENT_VERB_1_EN] US *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_JE_EN] YOU [MAP:CURRENT_VERB_1_EN] *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_JE_EN] YOU TO [MAP:CURRENT_VERB_1_EN] *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_JE_EN] YOU [MAP:CURRENT_VERB_1_EN] ME *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_JE_EN] YOU TO [MAP:CURRENT_VERB_1_EN] ME *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_JE_EN] YOU [MAP:CURRENT_VERB_1_EN] US *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_JE_EN] YOU TO [MAP:CURRENT_VERB_1_EN] US *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_NOUS_EN] YOU [MAP:CURRENT_VERB_1_EN] *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_NOUS_EN] YOU TO [MAP:CURRENT_VERB_1_EN] *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_NOUS_EN] YOU [MAP:CURRENT_VERB_1_EN] ME *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_NOUS_EN] YOU TO [MAP:CURRENT_VERB_1_EN] ME *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_NOUS_EN] YOU [MAP:CURRENT_VERB_1_EN] US *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_NOUS_EN] YOU TO [MAP:CURRENT_VERB_1_EN] US *[/Item]
[/Pattern]
[Response xml:space="preserve"]
[Think]
[Var Set="tempflag"][Map Get="current_verb_1_en"][Match Index="2" /][/Map][/Var]
[Var Set="Typego1"][Text CharAt="1"][Var Get="tempflag" /][/Text][/Var]
[Var Set="Typego2"][Text CharAt="2"][Var Get="tempflag" /][/Text][/Var]
[If User="Userlanguage" Value="en"][Goto xml:space="preserve"][Match Index="3" /][/Goto][/If]
[/Think]
[/Response]
[/Model]
[Model]
[Pattern]
[Item][MAP:POURRAI_JE_EN] [MAP:CURRENT_VERB_2_EN] *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_JE_EN] TO [MAP:CURRENT_VERB_2_EN] *[/Item]
[Item][MAP:AIMERAI_VOUDRAI_NOUS_EN] TO [MAP:CURRENT_VERB_2_EN] *[/Item]
[/Pattern]
[Response xml:space="preserve"]
[Think]
[Var Set="tempflag"][Map Get="current_verb_2_en"][Match Index="2" /][/Map][/Var]
[Var Set="Typego1"][Text CharAt="1"][Var Get="tempflag" /][/Text][/Var]
[Var Set="Typego2"][Text CharAt="2"][Var Get="tempflag" /][/Text][/Var]
[If User="Userlanguage" Value="en"][Goto xml:space="preserve"][Match Index="3" /][/Goto][/If]
[/Think]
[/Response]
[/Model]
[Model]
[Pattern]
[Item][MAP:CURRENT_VERB_1_EN] *[/Item]
[Item][MAP:CURRENT_VERB_1_EN] ME *[/Item]
[Item][MAP:CURRENT_VERB_1_EN] US *[/Item]
[/Pattern]
[Response xml:space="preserve"]
[Think]
[Var Set="tempflag"][Map Get="current_verb_1_en"][Match Index="1" /][/Map][/Var]
[Var Set="Typego1"][Text CharAt="1"][Var Get="tempflag" /][/Text][/Var]
[Var Set="Typego2"][Text CharAt="2"][Var Get="tempflag" /][/Text][/Var]
[If User="Userlanguage" Value="en"][Goto xml:space="preserve"][Match Index="2" /][/Goto][/If]
[/Think]
[/Response]
[/Model]

The example is used to filter authorized syntaxic forms by testing values set in pattern reductions models for bot variables - For example
GIVE ME YOUR VOLTAGE - I WANT TO KNOW WHAT YOUR VOLTAGE IS are correct.
GIVE ME WHAT YOUR VOLTAGE IS - YOUR VOLTAGE are incorrect

Code:

[Model]
[Pattern]
[Item]WHAT IS YOUR VOLTAGE[/Item]
[/Pattern]
[Response xml:space="preserve"]
[If Var="Typego1" Value=""][Var Think:Set="Typego1"]1[/Var][/If]
[If Var="Typego1" Value="1"][Goto xml:space="preserve"]XXXXXQUERYEZ VOLTAGE[/Goto][/If]
[Goto xml:space="preserve"]XXXXXQUERYEZ CLEARAIGFLAGS[/Goto]
[/Response]
[/Model]
[Model]
[Pattern]
[Item]WHAT YOUR VOLTAGE IS[/Item]
[/Pattern]
[Response xml:space="preserve"]
[If Var="Typego1" Value="1"][Goto xml:space="preserve"]XXXXXQUERYEZ VOLTAGE[/Goto][/If]
[Goto xml:space="preserve"]XXXXXQUERYEZ CLEARAIGFLAGS[/Goto]
[/Response]
[/Model]
[Model]
[Pattern]
[Item]YOUR VOLTAGE[/Item]
[/Pattern]
[Response xml:space="preserve"]
[If Var="Typego2" Value="1"][Goto xml:space="preserve"]XXXXXQUERYEZ VOLTAGE[/Goto][/If]
[Goto xml:space="preserve"]XXXXXQUERYEZ CLEARAIGFLAGS[/Goto]
[/Response]
[/Model]


Pattern WHAT YOUR VOLTAGE IS will be correctly interpretated (No Empty Response) if value of TypeGo1 variable is 1 which is not the case if Pattern reduction Model was GIVE ME but is correct if it was TELL ME
We can also test if there was or not a Pattern reduction interpretation - YOUR VOLTAGE is incorrect if value of TypeGo2 Variable is 1 - value only set in a Pattern reduction Model