コード例 #1
0
		public void LearningTest()
		{
			MathTextBitmap bitmap = 
				new MathTextBitmap(new FloatBitmap(5,5), new Gdk.Point(0,0));
			
			bitmap.ProcessImage(new List<BitmapProcesses.BitmapProcess>());
			
			CharacteristicTreeDatabase database = 
				new CharacteristicTreeDatabase();
			
			MathSymbol aSymbol = new MathSymbol("a");
			MathSymbol bSymbol = new MathSymbol("b");
			
			database.Learn(bitmap, aSymbol);
			
			List<MathSymbol> symbols = database.Match(bitmap);
			
			bool a1Learned = symbols.Count == 1 
				&& symbols[0] == aSymbol;
			
			bool a2Learned = true;
							
			a2Learned =	database.Learn(bitmap, aSymbol);
			
			
			database.Learn(bitmap, bSymbol);
			symbols = database.Match(bitmap);
			
			bool b1Learned = symbols.Count == 2;
			
			Assert.IsTrue(a1Learned, "Fallo el aprender la primera a");
			Assert.IsFalse(a2Learned, "No se detecto el conflicto de la segunda a");
			Assert.IsTrue(b1Learned, "Fallo el aprender la b");
		}
コード例 #2
0
		public void RepeatedSymbolNotAdded()
		{
			CharacteristicTreeDatabase database = new CharacteristicTreeDatabase();
			
			database.RootNode = new CharacteristicNode();
			
			
			database.RootNode.AddSymbol(new MathSymbol("hola"));
			
			int count1 = database.RootNode.Symbols.Count;			
			
			bool learnt = database.RootNode.AddSymbol(new MathSymbol("hola"));
			
			int count2 = database.RootNode.Symbols.Count;
			
			Assert.AreEqual(count1,count2,"Simbolo añadido");
			Assert.IsFalse(learnt,"Simbolo aprendido");
		}