package aminePlatform.test.util; /******************************************************************* Amine - Artificial Intelligence platform for the development of Intelligent Systems. Copyright (C) 2004 AmineGroup. GNU Lesser General Public License This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *********************************************************************/ import aminePlatform.util.*; import aminePlatform.guis.util.AmineFrame; import javax.swing.*; import java.util.*; import java.awt.event.*; /** *
Title : AmineObjectsTest class
*Description : Test the AmineObjects API
* @author Adil KABBAJ * @version 2 */ public class AmineObjectsTest extends JDialog implements AmineConstants { public AmineObjectsTest() { this.setTitle("AmineObjectsTest"); StringBuffer output = new StringBuffer(""); JScrollPane scrol; JTextArea text; try { // Test1 : Create and print Objects Without Lexicon, Ontology ... Term embededTerm = (Term) Term.parse("person(Ahmed, 34, address(453, \"Ishbilya road\", Rabat), [TaxiDriver, Physicien])"); output.append("\nListInTerm : \n" + embededTerm); Term copyOfEmbededTerm = (Term) embededTerm.copy(); output.append("\nCopy of the ListInTerm : \n" + copyOfEmbededTerm); Term embededTerm2 = (Term) Term.parse("person(Ahmed, 34, [address(453, \"Ishbilya road\", Rabat), address(8, x, Tanger)], [TaxiDriver, Physicien])"); output.append("\nListOfTerms : \n" + embededTerm2); // Test 5 : Amine Object Operations (equals, maximalJoin, generalize, subsume) output.append("\n**************************************************\n"); output.append("\nTest 5 : Amine Object Operations (equals, maximalJoin, generalize, subsume)"); output.append("\nValue of three Object : \n"); AmineList amineListTermAndSet = AmineList.parse("[person(Ahmed, 34, [address(453, \"Ishbilya road\", Rabat), a2], [TaxiDriver, P]), 888, {mon, thu}, kjb]"); output.append("\namineListTermAndSet : \n" + amineListTermAndSet); AmineList amineListTermAndSet2 = AmineList.parse("[person(Ahmed, x1, [address(453, y, Rabat), address(8, x2, Tanger)], [TaxiDriver, Physicien]), 888|L]"); output.append("\namineListTermAndSet2 : \n" + amineListTermAndSet2); output.append("\nTest amineListTermAndSet.equal(amineListTermAndSet2) : \n" + AmineObjects.equal(amineListTermAndSet,amineListTermAndSet2)); Object maximalJoinResult = AmineObjects.maximalJoin(amineListTermAndSet, amineListTermAndSet2); output.append("\nTest AmineObjects.maximalJoin(amineListTermAndSet,amineListTermAndSet2) : \n" + maximalJoinResult); Object generalizeResult = AmineObjects.generalize(amineListTermAndSet, amineListTermAndSet2); output.append("\nTest AmineObjects.generalize(amineListTermAndSet,amineListTermAndSet2) : \n" + generalizeResult); output.append("\nTest AmineObjects.subsume(amineListTermAndSet,amineListTermAndSet2) : \n" + AmineObjects.subsume(amineListTermAndSet, amineListTermAndSet2)); output.append("\nTest AmineObjects.subsume(generalizeResult,amineListTermAndSet2) : \n" + AmineObjects.subsume(generalizeResult, amineListTermAndSet2)); Object subsumeWithResult = AmineObjects.match(SUBSUME_WITH_RSLT, generalizeResult, amineListTermAndSet2); output.append("\nTest AmineObjects.match(SUBSUME_WITH_RSLT, generalizeResult, amineListTermAndSet2) : \n" + subsumeWithResult); text = new JTextArea(22, 30); text.setText(output.toString()); scrol = new JScrollPane(text); this.getContentPane().add(scrol); this.setLocation(100, 100); this.setSize(400, 450); this.show(); } catch (Exception ex) { System.out.println(ex.getMessage()); } } public static void main(String[] args) { AmineObjectsTest amineObjectsTest = new AmineObjectsTest(); amineObjectsTest.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(-1); } }); } }