From: <jen...@us...> - 2010-08-05 13:16:31
|
Revision: 2244 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2244&view=rev Author: jenslehmann Date: 2010-08-05 13:16:25 +0000 (Thu, 05 Aug 2010) Log Message: ----------- unit test for loading several knowledge bases Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2010-08-05 10:56:09 UTC (rev 2243) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2010-08-05 13:16:25 UTC (rev 2244) @@ -357,6 +357,24 @@ } /** + * Factory method for creating a reasoner component from a set of + * knowledge sources. + * @see #reasoner(Class, KnowledgeSource) + * @param <T> The type of this method is a subclass of reasoner component. + * @param reasoner A class object, where the class is subclass of ReasonerComponent. + * @param sources A set of knowledge sources. + * @return A reasoner component. + */ + public <T extends ReasonerComponent> T reasoner(Class<T> reasoner, + KnowledgeSource ... sources) { + Set<KnowledgeSource> s = new HashSet<KnowledgeSource>(); + for(KnowledgeSource source : sources) { + s.add(source); + } + return reasoner(reasoner, s); + } + + /** * This method returns an instance of <code>ReasonerComponent</code>. The * difference between <code>ReasonerComponent</code> and <code>ReasonerComponent</code> * is that the former delegates all calls to the latter and collects statistics Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2010-08-05 10:56:09 UTC (rev 2243) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2010-08-05 13:16:25 UTC (rev 2244) @@ -49,6 +49,7 @@ import org.dllearner.core.owl.KB; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.Thing; import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; import org.dllearner.parser.KBParser; @@ -311,6 +312,29 @@ } @Test + public void multipleKnowledgeSourcesTest() throws ComponentInitException { + String file1 = "examples/father.owl"; + String file2 = "examples/lymphography/lymphography.owl"; + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource ks1 = cm.knowledgeSource(OWLFile.class); + KnowledgeSource ks2 = cm.knowledgeSource(OWLFile.class); + try { + cm.applyConfigEntry(ks1, "url", new File(file1).toURI().toURL()); + cm.applyConfigEntry(ks2, "url", new File(file2).toURI().toURL()); + } catch (MalformedURLException e) { + // should never happen + e.printStackTrace(); + } + ks1.init(); + ks2.init(); + ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, ks1, ks2); + reasoner.init(); + baseURI = reasoner.getBaseURI(); + System.out.println(reasoner.getSubClasses(Thing.instance)); + assertTrue(reasoner.getSubClasses(Thing.instance).size()==55); + } + + @Test public void compareReasoners() throws FileNotFoundException, ComponentInitException, ParseException{ ComponentManager cm = ComponentManager.getInstance(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |