From: <lor...@us...> - 2011-12-05 09:15:19
|
Revision: 3470 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3470&view=rev Author: lorenz_b Date: 2011-12-05 09:15:13 +0000 (Mon, 05 Dec 2011) Log Message: ----------- Started rewriting tests without ComponentManager. Modified Paths: -------------- trunk/components-core/src/test/java/org/dllearner/test/ComponentTest.java trunk/components-core/src/test/java/org/dllearner/test/junit/TestOntologies.java Modified: trunk/components-core/src/test/java/org/dllearner/test/ComponentTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/ComponentTest.java 2011-12-05 08:59:27 UTC (rev 3469) +++ trunk/components-core/src/test/java/org/dllearner/test/ComponentTest.java 2011-12-05 09:15:13 UTC (rev 3470) @@ -21,6 +21,7 @@ import java.io.File; import java.net.MalformedURLException; +import java.util.Collections; import java.util.Set; import java.util.TreeSet; @@ -32,6 +33,7 @@ import org.dllearner.core.AbstractLearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.owl.Individual; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.reasoning.OWLAPIReasoner; @@ -51,40 +53,30 @@ */ public static void main(String[] args) throws ComponentInitException, MalformedURLException { - // get singleton instance of component manager - ComponentManager cm = ComponentManager.getInstance(); - // create knowledge source - AbstractKnowledgeSource source = cm.knowledgeSource(OWLFile.class); - String example = "examples/family/uncle.owl"; - cm.applyConfigEntry(source, "url", new File(example).toURI().toURL()); - source.init(); + String example = "../examples/family/uncle.owl"; + AbstractKnowledgeSource source = new OWLFile(example); // create OWL API reasoning service with standard settings - AbstractReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, source); + AbstractReasonerComponent reasoner = new OWLAPIReasoner(Collections.singleton(source)); reasoner.init(); // create a learning problem and set positive and negative examples - AbstractLearningProblem lp = cm.learningProblem(PosNegLPStandard.class, reasoner); - Set<String> positiveExamples = new TreeSet<String>(); - positiveExamples.add("http://localhost/foo#heinz"); - positiveExamples.add("http://localhost/foo#alex"); - Set<String> negativeExamples = new TreeSet<String>(); - negativeExamples.add("http://localhost/foo#jan"); - negativeExamples.add("http://localhost/foo#anna"); - negativeExamples.add("http://localhost/foo#hanna"); - cm.applyConfigEntry(lp, "positiveExamples", positiveExamples); - cm.applyConfigEntry(lp, "negativeExamples", negativeExamples); + PosNegLPStandard lp = new PosNegLPStandard(reasoner); + Set<Individual> positiveExamples = new TreeSet<Individual>(); + positiveExamples.add(new Individual("http://localhost/foo#heinz")); + positiveExamples.add(new Individual("http://localhost/foo#alex")); + Set<Individual> negativeExamples = new TreeSet<Individual>(); + negativeExamples.add(new Individual("http://localhost/foo#jan")); + negativeExamples.add(new Individual("http://localhost/foo#anna")); + negativeExamples.add(new Individual("http://localhost/foo#hanna")); + lp.setPositiveExamples(positiveExamples); + lp.setNegativeExamples(negativeExamples); lp.init(); // create the learning algorithm - AbstractCELA la = null; - try { - la = cm.learningAlgorithm(OCEL.class, lp, reasoner); - la.init(); - } catch (LearningProblemUnsupportedException e) { - e.printStackTrace(); - } + AbstractCELA la = new OCEL(lp, reasoner); + la.init(); // start the algorithm and print the best concept found la.start(); Modified: trunk/components-core/src/test/java/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/junit/TestOntologies.java 2011-12-05 08:59:27 UTC (rev 3469) +++ trunk/components-core/src/test/java/org/dllearner/test/junit/TestOntologies.java 2011-12-05 09:15:13 UTC (rev 3470) @@ -21,6 +21,7 @@ import java.io.File; import java.net.MalformedURLException; +import java.util.Collections; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; @@ -119,23 +120,23 @@ kbString += "OPRANGE(hasOwner) = person.\n"; kbString += "hasOwner(opel123,person123).\n"; } else if(ont.equals(TestOntology.FATHER)) { - owlFile = "examples/father.owl"; + owlFile = "../examples/father.owl"; } else if(ont.equals(TestOntology.FATHER_OE)) { - owlFile = "examples/family/father_oe.owl"; + owlFile = "../examples/family/father_oe.owl"; } else if(ont.equals(TestOntology.CARCINOGENESIS)) { - owlFile = "examples/carcinogenesis/carcinogenesis.owl"; + owlFile = "../examples/carcinogenesis/carcinogenesis.owl"; } else if(ont.equals(TestOntology.EPC_OE)) { - owlFile = "examples/epc/sap_epc_oe.owl"; + owlFile = "../examples/epc/sap_epc_oe.owl"; } else if(ont.equals(TestOntology.KRK_ZERO_ONE)) { - owlFile = "examples/krk/KRK_ZERO_ONE.owl"; + owlFile = "../examples/krk/KRK_ZERO_ONE.owl"; } else if(ont.equals(TestOntology.DBPEDIA_OWL)) { owlFile = "/home/jl/promotion/ontologien/dbpedia.owl"; } else if(ont.equals(TestOntology.TRAINS_OWL)) { - owlFile = "examples/cross-benchmark/trains/trains.owl"; + owlFile = "../examples/cross-benchmark/trains/trains.owl"; } else if(ont.equals(TestOntology.SWORE)) { - owlFile = "examples/swore/swore.rdf"; + owlFile = "../examples/swore/swore.rdf"; } else if(ont.equals(TestOntology.MDM)) { - owlFile = "test/MDM0.73.owl"; + owlFile = "../test/MDM0.73.owl"; } try { @@ -148,17 +149,10 @@ source = new KBFile(kb); // do nothing for empty ontology } else { - source = cm.knowledgeSource(OWLFile.class); - try { - cm.applyConfigEntry(source, "url", new File(owlFile).toURI().toURL()); - } catch (MalformedURLException e) { - e.printStackTrace(); - } + source = new OWLFile(owlFile); } - AbstractReasonerComponent rc = cm.reasoner(OWLAPIReasoner.class, source); -// ReasonerComponent rc = cm.reasoner(FastInstanceChecker.class, source); - source.init(); + AbstractReasonerComponent rc = new OWLAPIReasoner(Collections.singleton(source)); rc.init(); return rc; } catch(ParseException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |