Example #1
0
		public void PerformProcess(IBinder binder)	{
			// generate dummy business objects
			Hashtable businessObjects = DummyData.GetInstance().GetBusinessObjects(nbDecaCustomers);


			// instantiate an inference engine, bind my data and process the rules
			IEImpl ie = new IEImpl(binder);
			ie.LogHandlers += new DispatchLog(HandleLogEvent);
			ie.LoadRuleBase(new RuleML08DatalogAdapter(ruleBaseFile, System.IO.FileAccess.Read));		
			ie.Process(businessObjects);
			
			// processing is done, let's analyze the results
			QueryResultSet qrs = ie.RunQuery("Fraudulent Customers");
			Console.WriteLine("\nDetected {0} fraudulent customers.", qrs.Count);
			if (qrs.Count != 2 * nbDecaCustomers)
				Console.WriteLine("\nError! " + 2* nbDecaCustomers + " was expected.");
			
			// check if the customer objects have been flagged correctly
			int flaggedCount = 0;
			foreach(Customer customer in (ArrayList)businessObjects["CUSTOMERS"])
				if (customer.Fraudulent)
					flaggedCount++;
			
			if (flaggedCount != 2 * nbDecaCustomers)
				throw new Exception("\nError! " + 2* nbDecaCustomers + " flagged Customer objects were expected.\n");
			else
				Console.WriteLine("\nCustomer objects were correctly flagged\n");
		}
Example #2
0
        public void BeforeAfterFlowEngineBinder()
        {
            IInferenceEngine ie = new IEImpl(new FlowEngineBinder(ruleFilesFolder + "testbinder1.ruleml.xbre",
                                   											BindingTypes.BeforeAfter));

            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + "testbinder.ruleml",
                                                       FileAccess.Read));

            ie.NewFactHandler += new NewFactEvent(ShowAllNewFacts);

            Hashtable bo = new Hashtable();
            bo.Add("THEDUKE", new Character("The Duke", "hello world"));
            bo.Add("BOBBYBOB", new Character("Bobby Bob", "what the?"));
            bo.Add("JOHNQDOE", new Character("John Q. Doe", "hello, who am i?"));
            bo.Add("DANNYDAN", new Character("Danny Dan", "get out of my world"));

            ie.Process(bo);

            QueryResultSet qrs = ie.RunQuery("all polite");
            Assert.AreEqual(2, qrs.Count, "polite Count");

            // here, we should have got one result (Danny Dan), but the politness of The Duke has
            // mutexed the "mundane" implication.
            qrs = ie.RunQuery("all mundane");
            Assert.AreEqual(0, qrs.Count, "mundane Count");
        }