A practical example parsing multiple command variations for different intents, such as playing music and setting alarms.

ID: 1455

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.DefaultRuleSet.CaseSensitive = false;

// Define multiple rules for different intents
t.FromTo("play music by {artist}", "INTENT:PLAY_MUSIC ARTIST:{artist}");
t.FromTo("play the song {song_title}", "INTENT:PLAY_MUSIC SONG:{song_title}");
t.FromTo("set an alarm for {time}", "INTENT:SET_ALARM TIME:{time}");

Console.WriteLine(t.Transform("play music by Queen"));
Console.WriteLine(t.Transform("play the song Bohemian Rhapsody"));
Console.WriteLine(t.Transform("set an alarm for 7 am"));
				
			
INTENT:PLAY_MUSIC ARTIST:Queen
INTENT:PLAY_MUSIC SONG:Bohemian Rhapsody
INTENT:SET_ALARM TIME:7 am
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.DefaultRuleSet().CaseSensitive(false);

   // Define multiple rules for different intents
   t.FromTo("play music by {artist}", "INTENT:PLAY_MUSIC ARTIST:{artist}");
   t.FromTo("play the song {song_title}", "INTENT:PLAY_MUSIC SONG:{song_title}");
   t.FromTo("set an alarm for {time}", "INTENT:SET_ALARM TIME:{time}");

   cout << t.Transform("play music by Queen") << endl;
   cout << t.Transform("play the song Bohemian Rhapsody") << endl;
   cout << t.Transform("set an alarm for 7 am") << endl;
}
				
			
INTENT:PLAY_MUSIC ARTIST:Queen
INTENT:PLAY_MUSIC SONG:Bohemian Rhapsody
INTENT:SET_ALARM TIME:7 am
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      t.DefaultRuleSet.CaseSensitive = false
      
      '// Define multiple rules for different intents
      t.FromTo("play music by {artist}", "INTENT:PLAY_MUSIC ARTIST:{artist}")
      t.FromTo("play the song {song_title}", "INTENT:PLAY_MUSIC SONG:{song_title}")
      t.FromTo("set an alarm for {time}", "INTENT:SET_ALARM TIME:{time}")
      
      Console.WriteLine(t.Transform("play music by Queen"))
      Console.WriteLine(t.Transform("play the song Bohemian Rhapsody"))
      Console.WriteLine(t.Transform("set an alarm for 7 am"))
   End Sub
End Module
				
			
INTENT:PLAY_MUSIC ARTIST:Queen
INTENT:PLAY_MUSIC SONG:Bohemian Rhapsody
INTENT:SET_ALARM TIME:7 am