Demonstrates how a Transformer is created from a uCalc instance and used to apply Rules to text.

ID: 1335

				
					using uCalcSoftware;

var uc = new uCalc();

// 1. The uCalc instance (uc) is the factory

// 2. Create a Transformer from the instance
using (var t = new uCalc.Transformer(uc)) {
   // 3. Define a Rule on the transformer
   t.FromTo("apple", "FRUIT");

   // 4. Process text and get the result
   Console.WriteLine(t.Transform("An apple a day."));
};
				
			
An FRUIT a day.
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;

   // 1. The uCalc instance (uc) is the factory

   // 2. Create a Transformer from the instance
   {
      uCalc::Transformer t(uc);
      t.Owned(); // Causes t to be released when it goes out of scope
      // 3. Define a Rule on the transformer
      t.FromTo("apple", "FRUIT");

      // 4. Process text and get the result
      cout << t.Transform("An apple a day.") << endl;
   };
}
				
			
An FRUIT a day.
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      
      '// 1. The uCalc instance (uc) is the factory
      
      '// 2. Create a Transformer from the instance
      Using t As New uCalc.Transformer(uc)
         '// 3. Define a Rule on the transformer
         t.FromTo("apple", "FRUIT")
         
         '// 4. Process text and get the result
         Console.WriteLine(t.Transform("An apple a day."))
      End Using
   End Sub
End Module
				
			
An FRUIT a day.