From: <lor...@us...> - 2010-08-05 10:56:16
|
Revision: 2243 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2243&view=rev Author: lorenz_b Date: 2010-08-05 10:56:09 +0000 (Thu, 05 Aug 2010) Log Message: ----------- Added OWLlink support for OWLAPIReasoner and FastInstanceChecker. Added OWLlink lib. Added simple OWLlink test class. Moved reasoner JUnit test. Modified Paths: -------------- trunk/doc/configOptions.txt trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Added Paths: ----------- trunk/lib/owllink/ trunk/lib/owllink/license.txt trunk/lib/owllink/owllink-bin.jar trunk/lib/owllink/releasenotes.txt trunk/src/dl-learner/org/dllearner/test/OWLLinkReasonerTest.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTest.java Modified: trunk/doc/configOptions.txt =================================================================== --- trunk/doc/configOptions.txt 2010-08-05 10:10:37 UTC (rev 2242) +++ trunk/doc/configOptions.txt 2010-08-05 10:56:09 UTC (rev 2243) @@ -191,11 +191,17 @@ conf file usage: reasoner = fastInstanceChecker; option name: reasonerType -description: FaCT++, HermiT or Pellet to dematerialize -allowed values: String [fact, hermit, pellet] +description: FaCT++, HermiT, OWLlink or Pellet to dematerialize +allowed values: String [fact, hermit, owllink, pellet] default value: pellet conf file usage: fastInstanceChecker.reasonerType = pellet; +option name: owlLinkURL +description: the URL to the remote OWLlink server +allowed values: URL +default value: http://localhost:8080/ +conf file usage: fastInstanceChecker.owlLinkURL = http://localhost:8080/; + option name: defaultNegation description: Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class. allowed values: boolean @@ -215,12 +221,18 @@ conf file usage: reasoner = owlAPIReasoner; option name: reasonerType -description: FaCT++,, HermiT or Pellet, which means "fact", "hermit" or "pellet" -allowed values: String [fact, hermit, pellet] +description: FaCT++, HermiT, OWLlink or Pellet, which means "fact", "hermit", "owllink" or "pellet" +allowed values: String [fact, hermit, owllink, pellet] default value: pellet conf file usage: owlAPIReasoner.reasonerType = pellet; +option name: owlLinkURL +description: the URL to the remote OWLlink server +allowed values: URL +default value: http://localhost:8080/ +conf file usage: owlAPIReasoner.owlLinkURL = http://localhost:8080/; + component: Pellet reasoner (org.dllearner.reasoning.PelletReasoner) =================================================================== @@ -1027,8 +1039,8 @@ conf file usage: refinement.instanceBasedDisjoints = true; -component: refinement operator based learning algorithm II (org.dllearner.algorithms.refinement2.ROLComponent2) -=============================================================================================================== +component: OCEL (org.dllearner.algorithms.refinement2.ROLComponent2) +==================================================================== conf file usage: algorithm = refexamples; @@ -1110,6 +1122,18 @@ default value: not set conf file usage: refexamples.ignoredConcepts = ; +option name: allowedRoles +description: roles the algorithm is allowed to use +allowed values: Set<String> +default value: not set +conf file usage: refexamples.allowedRoles = ; + +option name: ignoredRoles +description: roles the algorithm must ignore +allowed values: Set<String> +default value: not set +conf file usage: refexamples.ignoredRoles = ; + option name: useAllConstructor description: specifies whether the universal concept constructor is used in the learning algorithm allowed values: boolean Added: trunk/lib/owllink/license.txt =================================================================== --- trunk/lib/owllink/license.txt (rev 0) +++ trunk/lib/owllink/license.txt 2010-08-05 10:56:09 UTC (rev 2243) @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. Added: trunk/lib/owllink/owllink-bin.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/owllink/owllink-bin.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lib/owllink/releasenotes.txt =================================================================== --- trunk/lib/owllink/releasenotes.txt (rev 0) +++ trunk/lib/owllink/releasenotes.txt 2010-08-05 10:56:09 UTC (rev 2243) @@ -0,0 +1,11 @@ +---------------------------------- +OWLlink API +Release 1.0.1 +---------------------------------- + +Documentation can be found at http://owllink-owlapi.sourceforge.net + +The OWLlink API 1.0.1 is based on the OWL API 3. + +Note that previous version of the OWLlink API are based on a non-stable version of OWL API 3 that is incompatible with +the official released OWL API 3. Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2010-08-05 10:10:37 UTC (rev 2242) +++ trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2010-08-05 10:56:09 UTC (rev 2243) @@ -20,6 +20,7 @@ package org.dllearner.core.configurators; +import java.net.URL; import java.util.Set; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; @@ -51,7 +52,7 @@ } /** -* reasonerType FaCT++, HermiT or Pellet to dematerialize. +* reasonerType FaCT++, HermiT, OWLlink or Pellet to dematerialize. * mandatory: false| reinit necessary: true * default value: pellet * @return String @@ -60,6 +61,15 @@ return (String) ComponentManager.getInstance().getConfigOptionValue(fastInstanceChecker, "reasonerType") ; } /** +* owlLinkURL the URL to the remote OWLlink server. +* mandatory: false| reinit necessary: true +* default value: http://localhost:8080/ +* @return URL +**/ +public URL getOwlLinkURL() { +return (URL) ComponentManager.getInstance().getConfigOptionValue(fastInstanceChecker, "owlLinkURL") ; +} +/** * defaultNegation Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class.. * mandatory: false| reinit necessary: true * default value: true @@ -70,7 +80,7 @@ } /** -* @param reasonerType FaCT++, HermiT or Pellet to dematerialize. +* @param reasonerType FaCT++, HermiT, OWLlink or Pellet to dematerialize. * mandatory: false| reinit necessary: true * default value: pellet **/ @@ -79,6 +89,15 @@ reinitNecessary = true; } /** +* @param owlLinkURL the URL to the remote OWLlink server. +* mandatory: false| reinit necessary: true +* default value: http://localhost:8080/ +**/ +public void setOwlLinkURL(URL owlLinkURL) { +ComponentManager.getInstance().applyConfigEntry(fastInstanceChecker, "owlLinkURL", owlLinkURL); +reinitNecessary = true; +} +/** * @param defaultNegation Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class.. * mandatory: false| reinit necessary: true * default value: true Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2010-08-05 10:10:37 UTC (rev 2242) +++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2010-08-05 10:56:09 UTC (rev 2243) @@ -20,6 +20,7 @@ package org.dllearner.core.configurators; +import java.net.URL; import java.util.Set; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; @@ -51,7 +52,7 @@ } /** -* reasonerType FaCT++,, HermiT or Pellet, which means "fact", "hermit" or "pellet". +* reasonerType FaCT++, HermiT, OWLlink or Pellet, which means "fact", "hermit", "owllink" or "pellet". * mandatory: false| reinit necessary: true * default value: pellet * @return String @@ -59,9 +60,18 @@ public String getReasonerType() { return (String) ComponentManager.getInstance().getConfigOptionValue(oWLAPIReasoner, "reasonerType") ; } +/** +* owlLinkURL the URL to the remote OWLlink server. +* mandatory: false| reinit necessary: true +* default value: http://localhost:8080/ +* @return URL +**/ +public URL getOwlLinkURL() { +return (URL) ComponentManager.getInstance().getConfigOptionValue(oWLAPIReasoner, "owlLinkURL") ; +} /** -* @param reasonerType FaCT++,, HermiT or Pellet, which means "fact", "hermit" or "pellet". +* @param reasonerType FaCT++, HermiT, OWLlink or Pellet, which means "fact", "hermit", "owllink" or "pellet". * mandatory: false| reinit necessary: true * default value: pellet **/ @@ -69,6 +79,15 @@ ComponentManager.getInstance().applyConfigEntry(oWLAPIReasoner, "reasonerType", reasonerType); reinitNecessary = true; } +/** +* @param owlLinkURL the URL to the remote OWLlink server. +* mandatory: false| reinit necessary: true +* default value: http://localhost:8080/ +**/ +public void setOwlLinkURL(URL owlLinkURL) { +ComponentManager.getInstance().applyConfigEntry(oWLAPIReasoner, "owlLinkURL", owlLinkURL); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2010-08-05 10:10:37 UTC (rev 2242) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2010-08-05 10:56:09 UTC (rev 2243) @@ -20,6 +20,8 @@ package org.dllearner.reasoning; import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; import java.util.Collection; import java.util.LinkedList; import java.util.List; @@ -43,6 +45,7 @@ import org.dllearner.core.options.ConfigOption; import org.dllearner.core.options.InvalidConfigOptionValueException; import org.dllearner.core.options.StringConfigOption; +import org.dllearner.core.options.URLConfigOption; import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.BooleanValueRestriction; import org.dllearner.core.owl.Constant; @@ -151,11 +154,17 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); StringConfigOption type = new StringConfigOption("reasonerType", - "FaCT++, HermiT or Pellet to dematerialize", "pellet", false, true); - type.setAllowedValues(new String[] { "fact", "hermit", "pellet" }); + "FaCT++, HermiT, OWLlink or Pellet to dematerialize", "pellet", false, true); + type.setAllowedValues(new String[] { "fact", "hermit", "owllink", "pellet" }); // closure option? see: // http://owlapi.svn.sourceforge.net/viewvc/owlapi/owl1_1/trunk/tutorial/src/main/java/uk/ac/manchester/owl/tutorial/examples/ClosureAxiomsExample.java?view=markup options.add(type); + try { + URLConfigOption owlLinkURL = new URLConfigOption("owlLinkURL", "the URL to the remote OWLlink server", new URL("http://localhost:8080/"), false, true); + options.add(owlLinkURL); + } catch (MalformedURLException e) { + e.printStackTrace(); + } options.add(new BooleanConfigOption("defaultNegation", "Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class.", true, false, true)); StringConfigOption forallSemantics = new StringConfigOption("forallRetrievalSemantics", "This option controls how to interpret the all quantifier in \forall r.C. The standard option is" + @@ -195,6 +204,7 @@ // rc = new OWLAPIReasoner(sources); rc = ComponentFactory.getOWLAPIReasoner(sources); rc.getConfigurator().setReasonerType(configurator.getReasonerType()); + rc.getConfigurator().setOwlLinkURL(configurator.getOwlLinkURL()); rc.init(); // try { Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2010-08-05 10:10:37 UTC (rev 2242) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2010-08-05 10:56:09 UTC (rev 2243) @@ -20,6 +20,7 @@ package org.dllearner.reasoning; import java.io.File; +import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -32,11 +33,11 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; -import java.util.Map.Entry; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -48,6 +49,7 @@ import org.dllearner.core.options.ConfigOption; import org.dllearner.core.options.InvalidConfigOptionValueException; import org.dllearner.core.options.StringConfigOption; +import org.dllearner.core.options.URLConfigOption; import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.Datatype; @@ -99,7 +101,10 @@ import org.semanticweb.owlapi.model.OWLTypedLiteral; import org.semanticweb.owlapi.model.RemoveAxiom; import org.semanticweb.owlapi.model.UnknownOWLOntologyException; +import org.semanticweb.owlapi.owllink.OWLlinkHTTPXMLReasonerFactory; +import org.semanticweb.owlapi.owllink.OWLlinkReasonerConfiguration; import org.semanticweb.owlapi.reasoner.FreshEntityPolicy; +import org.semanticweb.owlapi.reasoner.IllegalConfigurationException; import org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy; import org.semanticweb.owlapi.reasoner.Node; import org.semanticweb.owlapi.reasoner.NodeSet; @@ -181,11 +186,18 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - StringConfigOption type = new StringConfigOption("reasonerType", "FaCT++,, HermiT or Pellet, which means \"fact\", \"hermit\" or \"pellet\"", "pellet", false, true); - type.setAllowedValues(new String[] {"fact", "pellet", "hermit"}); + StringConfigOption type = new StringConfigOption("reasonerType", "FaCT++, HermiT, OWLlink or Pellet, which means \"fact\", \"hermit\", \"owllink\" or \"pellet\"", "pellet", false, true); + type.setAllowedValues(new String[] {"fact", "hermit", "owllink", "pellet" }); + // closure option? see: // http://owlapi.svn.sourceforge.net/viewvc/owlapi/owl1_1/trunk/tutorial/src/main/java/uk/ac/manchester/owl/tutorial/examples/ClosureAxiomsExample.java?view=markup options.add(type); + try { + URLConfigOption owlLinkURL = new URLConfigOption("owlLinkURL", "the URL to the remote OWLlink server", new URL("http://localhost:8080/"), false, true); + options.add(owlLinkURL); + } catch (MalformedURLException e) { + e.printStackTrace(); + } return options; } @@ -299,6 +311,11 @@ // TODO: add method to find datatypes } } + try { + ontology = manager.createOntology(IRI.create("http://dl-learner/all"), new HashSet<OWLOntology>(owlAPIOntologies)); + } catch (OWLOntologyCreationException e1) { + e1.printStackTrace(); + } //configure reasoner ReasonerProgressMonitor progressMonitor = new NullReasonerProgressMonitor(); @@ -318,7 +335,7 @@ } else if(configurator.getReasonerType().equals("hermit")){ // instantiate HermiT reasoner reasoner = new ReasonerFactory().createNonBufferingReasoner(ontology, conf); - } else { + } else if(configurator.getReasonerType().equals("pellet")){ // instantiate Pellet reasoner reasoner = PelletReasonerFactory.getInstance().createNonBufferingReasoner(ontology, conf); @@ -326,6 +343,16 @@ // output will be very large Logger pelletLogger = Logger.getLogger("org.mindswap.pellet"); pelletLogger.setLevel(Level.WARN); + } else { + try { + OWLlinkHTTPXMLReasonerFactory factory = new OWLlinkHTTPXMLReasonerFactory(); + URL url = getConfigurator().getOwlLinkURL();//Configure the server end-point + OWLlinkReasonerConfiguration config = new OWLlinkReasonerConfiguration(url); + reasoner = factory.createNonBufferingReasoner(ontology, config); + System.out.println(reasoner.getReasonerName()); + } catch (IllegalConfigurationException e) { + e.printStackTrace(); + } } /* Added: trunk/src/dl-learner/org/dllearner/test/OWLLinkReasonerTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/OWLLinkReasonerTest.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/OWLLinkReasonerTest.java 2010-08-05 10:56:09 UTC (rev 2243) @@ -0,0 +1,44 @@ +package org.dllearner.test; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.owllink.OWLlinkHTTPXMLReasonerFactory; +import org.semanticweb.owlapi.owllink.OWLlinkReasoner; +import org.semanticweb.owlapi.owllink.OWLlinkReasonerConfiguration; +import org.semanticweb.owlapi.reasoner.NodeSet; + +public class OWLLinkReasonerTest { + + /** + * @param args + * @throws OWLOntologyCreationException + * @throws MalformedURLException + */ + public static void main(String[] args) throws OWLOntologyCreationException, MalformedURLException { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + + OWLOntology ontology = manager.createOntology(IRI.create("tutorial")); + OWLClass A = manager.getOWLDataFactory().getOWLClass(IRI.create("http://tutorial#A")); + OWLClass B = manager.getOWLDataFactory().getOWLClass(IRI.create("http://tutorial#B")); + OWLAxiom a = manager.getOWLDataFactory().getOWLSubClassOfAxiom(A, B); + manager.addAxiom(ontology, a); + + OWLlinkHTTPXMLReasonerFactory factory = new OWLlinkHTTPXMLReasonerFactory(); + URL url = new URL("http://localhost:8080");//Configure the server end-point + OWLlinkReasonerConfiguration config = new OWLlinkReasonerConfiguration(url); + OWLlinkReasoner reasoner = factory.createReasoner(ontology, config); + + NodeSet<OWLClass> classes = reasoner.getSubClasses(manager.getOWLDataFactory().getOWLThing(), true); + System.out.println(classes.getFlattened()); + + } + +} Deleted: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTest.java 2010-08-05 10:10:37 UTC (rev 2242) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTest.java 2010-08-05 10:56:09 UTC (rev 2243) @@ -1,116 +0,0 @@ -package org.dllearner.test.junit; - -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import org.dllearner.cli.Start; -import org.dllearner.core.ComponentInitException; -import org.dllearner.core.ComponentManager; -import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.LearningProblem; -import org.dllearner.parser.ParseException; -import org.dllearner.reasoning.FastInstanceChecker; -import org.dllearner.utilities.owl.ConceptComparator; -import org.junit.Test; - -public class ReasonerTest { - - private ConceptComparator comparator = new ConceptComparator(); - - @Test - public void compareReasoners() throws FileNotFoundException, ComponentInitException, ParseException{ - - ComponentManager cm = ComponentManager.getInstance(); - Start start; - FastInstanceChecker reasoner; - LearningProblem lp; - LearningAlgorithm la; - KnowledgeSource ks; - - for(File conf : getTestConfigFiles()){ - start = new Start(conf); - lp = start.getLearningProblem(); - la = start.getLearningAlgorithm(); - ks = start.getSources().iterator().next(); - - TreeSet<? extends EvaluatedDescription> result = new TreeSet<EvaluatedDescription>(); - - for(String type : getReasonerTypes()){ - System.out.println("Using " + type + " reasoner..."); - try { - reasoner = cm.reasoner(FastInstanceChecker.class, ks); - reasoner.getConfigurator().setReasonerType(type); - reasoner.init(); - - lp.changeReasonerComponent(reasoner); - lp.init(); - - la.init(); - la.start(); - if(!result.isEmpty()){ - assertTrue(compareTreeSets(la.getCurrentlyBestEvaluatedDescriptions(), result)); - } - - result = la.getCurrentlyBestEvaluatedDescriptions(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - } - - } - - private Set<File> getTestConfigFiles(){ - Set<File> files = new HashSet<File>(); - File directory = new File("test" + File.separator + "testReasoners"); - for(File file : directory.listFiles()){ - if(file.toString().endsWith(".conf")){ - files.add(file); - } - } - return files; - } - - private List<String> getReasonerTypes(){ - List<String> reasonerTypes = new LinkedList<String>(); - reasonerTypes.add("pellet"); - reasonerTypes.add("hermit"); - reasonerTypes.add("fact"); - - return reasonerTypes; - } - - public boolean compareTreeSets(TreeSet<? extends EvaluatedDescription> tree1, TreeSet<? extends EvaluatedDescription> tree2){ - boolean equal = true; - - List<? extends EvaluatedDescription> list1 = new ArrayList<EvaluatedDescription>(tree1); - List<? extends EvaluatedDescription> list2 = new ArrayList<EvaluatedDescription>(tree2); - - EvaluatedDescription d1; - EvaluatedDescription d2; - for(int i = 0; i < list1.size(); i++){ - d1 = list1.get(i); - d2 = list2.get(i); - if(!(comparator.compare(d1.getDescription(), d2.getDescription()) == 0) && - d1.getAccuracy() == d2.getAccuracy()){ - equal = false; - break; - } - } - - return equal; - } - -} 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:10:37 UTC (rev 2242) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2010-08-05 10:56:09 UTC (rev 2243) @@ -22,15 +22,24 @@ import static org.junit.Assert.assertTrue; import java.io.File; +import java.io.FileNotFoundException; import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.SortedSet; +import java.util.TreeSet; import org.apache.log4j.Logger; +import org.dllearner.cli.Start; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.DatatypeProperty; @@ -48,6 +57,7 @@ import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.test.junit.TestOntologies.TestOntology; +import org.dllearner.utilities.owl.ConceptComparator; import org.junit.Test; /** @@ -61,6 +71,8 @@ private static Logger logger = Logger.getLogger(ReasonerTests.class); private String baseURI; + + private ConceptComparator comparator = new ConceptComparator(); public KB getSimpleKnowledgeBase() { String kb = "person SUB TOP."; @@ -276,7 +288,7 @@ assertTrue(reasoner.getDomain(property).equals(description)); - file = "examples/ore/koala.owl"; + file = "test/ore/koala.owl"; ks = cm.knowledgeSource(OWLFile.class); cm.applyConfigEntry(ks, "url", new File(file).toURI().toURL()); ks.init(); @@ -298,6 +310,93 @@ System.out.println(res); } + @Test + public void compareReasoners() throws FileNotFoundException, ComponentInitException, ParseException{ + + ComponentManager cm = ComponentManager.getInstance(); + Start start; + FastInstanceChecker reasoner; + LearningProblem lp; + LearningAlgorithm la; + KnowledgeSource ks; + + for(File conf : getTestConfigFiles()){ + start = new Start(conf); + lp = start.getLearningProblem(); + la = start.getLearningAlgorithm(); + ks = start.getSources().iterator().next(); + + TreeSet<? extends EvaluatedDescription> result = new TreeSet<EvaluatedDescription>(); + + for(String type : getReasonerTypes()){ + System.out.println("Using " + type + " reasoner..."); + try { + reasoner = cm.reasoner(FastInstanceChecker.class, ks); + reasoner.getConfigurator().setReasonerType(type); + reasoner.init(); + + lp.changeReasonerComponent(reasoner); + lp.init(); + + la.init(); + la.start(); + if(!result.isEmpty()){ + assertTrue(compareTreeSets(la.getCurrentlyBestEvaluatedDescriptions(), result)); + } + + result = la.getCurrentlyBestEvaluatedDescriptions(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + } + + } + + public boolean compareTreeSets(TreeSet<? extends EvaluatedDescription> tree1, TreeSet<? extends EvaluatedDescription> tree2){ + boolean equal = true; + + List<? extends EvaluatedDescription> list1 = new ArrayList<EvaluatedDescription>(tree1); + List<? extends EvaluatedDescription> list2 = new ArrayList<EvaluatedDescription>(tree2); + + EvaluatedDescription d1; + EvaluatedDescription d2; + for(int i = 0; i < list1.size(); i++){ + d1 = list1.get(i); + d2 = list2.get(i); + if(!(comparator.compare(d1.getDescription(), d2.getDescription()) == 0) && + d1.getAccuracy() == d2.getAccuracy()){ + equal = false; + break; + } + } + + return equal; + } + + private Set<File> getTestConfigFiles(){ + Set<File> files = new HashSet<File>(); + File directory = new File("test" + File.separator + "testReasoners"); + for(File file : directory.listFiles()){ + if(file.toString().endsWith(".conf")){ + files.add(file); + } + } + return files; + } + + private List<String> getReasonerTypes(){ + List<String> reasonerTypes = new LinkedList<String>(); + reasonerTypes.add("pellet"); + reasonerTypes.add("hermit"); + reasonerTypes.add("fact"); + reasonerTypes.add("owllink"); + + return reasonerTypes; + } + private List<Individual> getIndSet(String... inds) { List<Individual> individuals = new LinkedList<Individual>(); for(String ind : inds) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |