From: <jen...@us...> - 2008-11-10 16:54:06
|
Revision: 1503 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1503&view=rev Author: jenslehmann Date: 2008-11-10 16:53:59 +0000 (Mon, 10 Nov 2008) Log Message: ----------- - reasoner component redesign continued - SVN partially broken Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java trunk/src/dl-learner/org/dllearner/examples/KRKModular.java trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/ReasonerType.java trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java trunk/src/dl-learner/org/dllearner/scripts/NewSample.java trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java trunk/src/dl-learner/org/dllearner/scripts/Sample.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/test/ComponentTest.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifier.java trunk/src/dl-learner/org/dllearner/tools/ore/SPARQLTest.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyClassRewriter.java trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyCloser.java trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyCloserOWLAPI.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/utilities/components/ trunk/src/dl-learner/org/dllearner/utilities/components/ComponentCombo.java trunk/src/dl-learner/org/dllearner/utilities/components/ReasonerComponentFactory.java trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIConverter.java trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIDescriptionConvertVisitor.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java trunk/src/dl-learner/org/dllearner/utilities/learn/ComponentCombo.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparqlold.java trunk/src/dl-learner/org/dllearner/utilities/learn/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/learn/SPARQLMassLearning.java trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -30,7 +30,6 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.config.CommonConfigOptions; import org.dllearner.core.config.ConfigEntry; Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -29,7 +29,6 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.CommonConfigOptions; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -34,7 +34,6 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.CommonConfigMappings; @@ -358,13 +357,13 @@ // prepare subsumption and role hierarchies, because they are needed // during the run of the algorithm - reasoner.prepareSubsumptionHierarchy(usedConcepts); +// reasoner.prepareSubsumptionHierarchy(usedConcepts); if(improveSubsumptionHierarchy) reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - reasoner.prepareRoleHierarchy(usedRoles); +// reasoner.prepareRoleHierarchy(usedRoles); // prepare datatype hierarchy only if necessary - if(reasoner.hasDatatypeSupport()) - reasoner.prepareDatatypePropertyHierarchy(); +// if(reasoner.hasDatatypeSupport()) +// reasoner.prepareDatatypePropertyHierarchy(); // create a refinement operator and pass all configuration // variables to it Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -36,7 +36,6 @@ import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -18,7 +18,6 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.CommonConfigMappings; @@ -373,10 +372,10 @@ // prepare subsumption and role hierarchies, because they are needed // during the run of the algorithm - reasoner.prepareSubsumptionHierarchy(usedConcepts); +// reasoner.prepareSubsumptionHierarchy(usedConcepts); if(improveSubsumptionHierarchy) reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - reasoner.prepareRoleHierarchy(usedRoles); +// reasoner.prepareRoleHierarchy(usedRoles); } public static String getName() { Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -57,7 +57,6 @@ import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.OntologyFormat; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.ConfigEntry; Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -25,7 +25,7 @@ import org.dllearner.core.owl.Individual; import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; import org.dllearner.learningproblems.ScoreTwoValued; -import org.dllearner.reasoning.OWLAPIDescriptionConvertVisitor; +import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; import org.dllearner.utilities.owl.OWLAPIRenderers; import org.json.JSONArray; import org.json.JSONException; Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -64,6 +64,8 @@ * create method() and methodImpl() as before, but this time methodImpl() is * not abstract and throws a {@link ReasoningMethodUnsupportedException} * </li> + * <li>a few very basic methods (where we do not care about statistics) + * do not have an "Impl" variant, e.g. getting all named classes of a KB</li> * </ul> * Note, that the method delegation is done to collect statistical information * about reasoning performance, e.g. count how often certain methods were called @@ -189,10 +191,18 @@ @Override public final Set<NamedClass> getTypes(Individual individual) { - return getTypesImpl(individual); + Set<NamedClass> types = null; + try { + types = getTypesImpl(individual); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + } + return types; } - protected abstract Set<NamedClass> getTypesImpl(Individual individual); + protected Set<NamedClass> getTypesImpl(Individual individual) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException("Reasoner does not support to determine type of individual."); + } @Override public final boolean subsumes(Description superClass, Description subClass) { @@ -210,7 +220,8 @@ return result; } - public Set<Description> subsumes(Set<Description> superConcepts, Description subConcept) { + @Override + public final Set<Description> subsumes(Set<Description> superConcepts, Description subConcept) { reasoningStartTimeTmp = System.nanoTime(); Set<Description> result = null; try { Modified: trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -33,8 +33,8 @@ public boolean subsumes(Description superConcept, Description subConcept); - public Set<Description> subsumes(Description superConcept, Set<Description> subConcepts); + //public Set<Description> subsumes(Description superConcept, Set<Description> subConcepts); public Set<Description> subsumes(Set<Description> superConcepts, Description subConcept); - + } Modified: trunk/src/dl-learner/org/dllearner/examples/KRKModular.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -22,7 +22,6 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.ComponentFactory; import org.dllearner.core.owl.ClassAssertionAxiom; import org.dllearner.core.owl.Description; Modified: trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -46,7 +46,6 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.kb.OWLFile; @@ -151,8 +150,8 @@ // TODO Auto-generated catch block e1.printStackTrace(); } - rs = cm.reasoningService(reasoner); - Set<Individual> individualsSet = rs.getIndividuals(); +// rs = cm.reasoningService(reasoner); + Set<Individual> individualsSet = reasoner.getIndividuals(); individuals = new LinkedList<Individual>(individualsSet); DefaultListModel listModel = new DefaultListModel(); Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -38,7 +38,7 @@ import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGConverter; -import org.dllearner.reasoning.OWLAPIAxiomConvertVisitor; +import org.dllearner.utilities.owl.OWLAPIAxiomConvertVisitor; import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.model.OWLOntologyCreationException; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -25,7 +25,6 @@ import java.util.TreeSet; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.configurators.PosNegDefinitionLPConfigurator; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -24,7 +24,6 @@ import java.util.TreeSet; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.ConfigEntry; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -23,7 +23,6 @@ import java.util.SortedSet; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.configurators.ComponentFactory; import org.dllearner.core.configurators.PosNegInclusionLPConfigurator; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -26,7 +26,6 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.CommonConfigMappings; import org.dllearner.core.config.CommonConfigOptions; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -20,7 +20,6 @@ package org.dllearner.learningproblems; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.configurators.ComponentFactory; import org.dllearner.core.configurators.PosOnlyDefinitionLPConfigurator; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -20,7 +20,6 @@ package org.dllearner.learningproblems; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.InvalidConfigOptionValueException; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -26,7 +26,6 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.config.CommonConfigMappings; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -268,7 +268,6 @@ * * TODO Does not yet take ignored roles into account. */ - @Override public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( roleComparator); @@ -289,7 +288,7 @@ // bei null bleibt; bei der aktuellen Implementierung ist der parent-Link // nicht immer null, was bei GP negative Auswirkungen haben könnte // Update: wird durch klonen innerhalb der GP-Operationen erledigt - public Set<NamedClass> getAtomicConcepts() { + public Set<NamedClass> getNamedClasses() { /* * if(Config.algorithm == Config.Algorithm.GP || Config.algorithm == * Config.Algorithm.HYBRID_GP) { Set<AtomicConcept> returnSet = new @@ -343,7 +342,7 @@ return atomicConcepts; } - public Set<ObjectProperty> getAtomicRoles() { + public Set<ObjectProperty> getObjectProperties() { return atomicRoles; } @@ -394,6 +393,7 @@ return digIndividuals; } + @Override public ReasonerType getReasonerType() { return ReasonerType.DIG; } @@ -412,7 +412,7 @@ } @Override - public Set<Description> subsumes(Description superConcept, Set<Description> subConcepts) { + public Set<Description> subsumesImpl(Description superConcept, Set<Description> subConcepts) { String subsumesDIG = asksPrefix; int id = 0; // ID-Konzept-Zuordnung speichern, da bei der Antwort nur die IDs @@ -439,7 +439,7 @@ } @Override - public Set<Description> subsumes(Set<Description> superConcepts, Description subConcept) { + public Set<Description> subsumesImpl(Set<Description> superConcepts, Description subConcept) { String subsumesDIG = asksPrefix; int id = 0; Map<String, Description> queryMap = new HashMap<String, Description>(); Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -182,13 +182,13 @@ rc.getConfigurator().setReasonerType(configurator.getReasonerType()); rc.init(); - try { - atomicConcepts = rc.getAtomicConcepts(); +// try { + atomicConcepts = rc.getNamedClasses(); datatypeProperties = rc.getDatatypeProperties(); booleanDatatypeProperties = rc.getBooleanDatatypeProperties(); doubleDatatypeProperties = rc.getDoubleDatatypeProperties(); intDatatypeProperties = rc.getIntDatatypeProperties(); - atomicRoles = rc.getAtomicRoles(); + atomicRoles = rc.getObjectProperties(); individuals = rc.getIndividuals(); // rs = new ReasonerComponent(rc); @@ -201,7 +201,7 @@ logger.debug("dematerialising concepts"); - for (NamedClass atomicConcept : rc.getAtomicConcepts()) { + for (NamedClass atomicConcept : rc.getNamedClasses()) { SortedSet<Individual> pos = rc.retrieval(atomicConcept); classInstancesPos.put(atomicConcept, pos); @@ -244,10 +244,10 @@ long dematDuration = System.currentTimeMillis() - dematStartTime; logger.debug("TBox dematerialised in " + dematDuration + " ms"); - } catch (ReasoningMethodUnsupportedException e) { - throw new ComponentInitException( - "Underlying reasoner does not support all necessary reasoning methods.", e); - } +// } catch (ReasoningMethodUnsupportedException e) { +// throw new ComponentInitException( +// "Underlying reasoner does not support all necessary reasoning methods.", e); +// } } @Override @@ -562,8 +562,7 @@ * * @see org.dllearner.core.Reasoner#prepareSubsumptionHierarchy(java.util.Set) */ - @Override - public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) { + public void prepareSubsumptionHierarchyImpl(Set<NamedClass> allowedConcepts) { rc.prepareSubsumptionHierarchy(allowedConcepts); } @@ -573,7 +572,7 @@ } @Override - public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { + public void prepareRoleHierarchyImpl(Set<ObjectProperty> allowedRoles) { rc.prepareRoleHierarchy(allowedRoles); } @@ -583,8 +582,8 @@ } @Override - public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedRoles) { - rc.prepareDatatypePropertyHierarchy(allowedRoles); + public void prepareDatatypePropertyHierarchyImpl(Set<DatatypeProperty> allowedRoles) { + rc.prepareDatatypePropertyHierarchyImpl(allowedRoles); } @Override @@ -617,7 +616,7 @@ cm.applyConfigEntry(owl, "url", owlFile); owl.init(); ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, owl); - cm.reasoningService(reasoner); +// cm.reasoningService(reasoner); reasoner.init(); KBParser.internalNamespace = "http://example.com/father#"; @@ -698,4 +697,12 @@ return true; } + /* (non-Javadoc) + * @see org.dllearner.core.ReasonerComponent#getTypesImpl(org.dllearner.core.owl.Individual) + */ + @Override + protected Set<NamedClass> getTypesImpl(Individual individual) { + return rc.getTypesImpl(individual); + } + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -10,7 +10,6 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningMethodUnsupportedException; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.configurators.ComponentFactory; @@ -89,6 +88,7 @@ } + @Override public ReasonerType getReasonerType() { return ReasonerType.FAST_RETRIEVAL; } @@ -109,11 +109,12 @@ return Helper.getIndividualSet(fastRetrieval.calculateSets(concept).getPosSet()); } - public Set<NamedClass> getAtomicConcepts() { + public Set<NamedClass> getNamedClasses() { return atomicConcepts; } - public Set<ObjectProperty> getAtomicRoles() { + @Override + public Set<ObjectProperty> getObjectProperties() { return atomicRoles; } @@ -134,19 +135,19 @@ return rs.subsumes(superConcept, subConcept); } - @Override - public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { - rs.prepareRoleHierarchy(allowedRoles); - } +// @Override +// public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { +// rs.prepareRoleHierarchy(allowedRoles); +// } @Override public ObjectPropertyHierarchy getRoleHierarchy() { return rs.getRoleHierarchy(); } - public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) { - rs.prepareSubsumptionHierarchy(allowedConcepts); - } +// public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) { +// rs.prepareSubsumptionHierarchy(allowedConcepts); +// } @Override public SubsumptionHierarchy getSubsumptionHierarchy() { Deleted: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -1,325 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.reasoning; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - -import org.dllearner.core.owl.Axiom; -import org.dllearner.core.owl.AxiomVisitor; -import org.dllearner.core.owl.BooleanDatatypePropertyAssertion; -import org.dllearner.core.owl.ClassAssertionAxiom; -import org.dllearner.core.owl.DataRange; -import org.dllearner.core.owl.Datatype; -import org.dllearner.core.owl.DatatypePropertyDomainAxiom; -import org.dllearner.core.owl.DatatypePropertyRangeAxiom; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.DifferentIndividualsAxiom; -import org.dllearner.core.owl.DisjointClassesAxiom; -import org.dllearner.core.owl.DoubleDatatypePropertyAssertion; -import org.dllearner.core.owl.EquivalentClassesAxiom; -import org.dllearner.core.owl.FunctionalObjectPropertyAxiom; -import org.dllearner.core.owl.Individual; -import org.dllearner.core.owl.InverseObjectPropertyAxiom; -import org.dllearner.core.owl.KB; -import org.dllearner.core.owl.ObjectPropertyAssertion; -import org.dllearner.core.owl.ObjectPropertyDomainAxiom; -import org.dllearner.core.owl.ObjectPropertyRangeAxiom; -import org.dllearner.core.owl.SubClassAxiom; -import org.dllearner.core.owl.SubObjectPropertyAxiom; -import org.dllearner.core.owl.SymmetricObjectPropertyAxiom; -import org.dllearner.core.owl.TransitiveObjectPropertyAxiom; -import org.semanticweb.owl.model.AddAxiom; -import org.semanticweb.owl.model.OWLAxiom; -import org.semanticweb.owl.model.OWLDataFactory; -import org.semanticweb.owl.model.OWLDataProperty; -import org.semanticweb.owl.model.OWLDataType; -import org.semanticweb.owl.model.OWLDescription; -import org.semanticweb.owl.model.OWLIndividual; -import org.semanticweb.owl.model.OWLObjectProperty; -import org.semanticweb.owl.model.OWLOntology; -import org.semanticweb.owl.model.OWLOntologyChangeException; -import org.semanticweb.owl.model.OWLOntologyManager; -import org.semanticweb.owl.model.OWLTypedConstant; -import org.semanticweb.owl.vocab.XSDVocabulary; - -// static import for easy access to the description converter -import static org.dllearner.reasoning.OWLAPIDescriptionConvertVisitor.getOWLDescription; - -/** - * A converter from DL-Learner axioms to OWL API axioms based on the visitor - * pattern. - * - * TODO: Investigate whether OWLOntologyManager and OWLOntology should be - * removed as parameters. It would be natural to have a DL-Learner KB as input - * and an OWL API OWLOntology as output. - * - * @author Jens Lehmann - * - */ -public class OWLAPIAxiomConvertVisitor implements AxiomVisitor { - - OWLDataFactory factory; - private OWLOntology ontology; - private OWLOntologyManager manager; - - public OWLAPIAxiomConvertVisitor(OWLOntologyManager manager, OWLOntology ontology, KB kb) { - this.manager = manager; - this.ontology = ontology; - factory = manager.getOWLDataFactory(); - } - - public static void fillOWLOntology(OWLOntologyManager manager, OWLOntology ontology, KB kb) { - OWLAPIAxiomConvertVisitor converter = new OWLAPIAxiomConvertVisitor(manager, ontology, kb); - for(Axiom axiom : kb.getTbox()) - axiom.accept(converter); - for(Axiom axiom : kb.getRbox()) - axiom.accept(converter); - for(Axiom axiom : kb.getAbox()) - axiom.accept(converter); - } - - // convencience function for adding an axiom to the ontology - private void addAxiom(OWLAxiom axiom) { - AddAxiom addAxiom = new AddAxiom(ontology, axiom); - try { - manager.applyChange(addAxiom); - } catch (OWLOntologyChangeException e) { - e.printStackTrace(); - } - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.dl.AxiomVisitor#visit(org.dllearner.core.dl.ObjectPropertyAssertion) - */ - public void visit(ObjectPropertyAssertion axiom) { - OWLObjectProperty role = factory.getOWLObjectProperty(URI - .create(((ObjectPropertyAssertion) axiom).getRole().getName())); - OWLIndividual i1 = factory.getOWLIndividual(URI.create(((ObjectPropertyAssertion) axiom) - .getIndividual1().getName())); - OWLIndividual i2 = factory.getOWLIndividual(URI.create(((ObjectPropertyAssertion) axiom) - .getIndividual2().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLObjectPropertyAssertionAxiom(i1, role, i2); - addAxiom(axiomOWLAPI); - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.ClassAssertionAxiom) - */ - public void visit(ClassAssertionAxiom axiom) { - OWLDescription d = getOWLDescription(axiom.getConcept()); - OWLIndividual i = factory.getOWLIndividual(URI.create(((ClassAssertionAxiom) axiom) - .getIndividual().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLClassAssertionAxiom(i, d); - addAxiom(axiomOWLAPI); - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.DoubleDatatypePropertyAssertion) - */ - public void visit(DoubleDatatypePropertyAssertion axiom) { - OWLIndividual i = factory.getOWLIndividual(URI.create(axiom.getIndividual().getName())); - OWLDataProperty dp = factory.getOWLDataProperty(URI.create(axiom.getDatatypeProperty().getName())); - Double value = axiom.getValue(); - OWLDataType doubleType = factory.getOWLDataType(XSDVocabulary.DOUBLE.getURI()); - OWLTypedConstant valueConstant = factory.getOWLTypedConstant(value.toString(), doubleType); - OWLAxiom axiomOWLAPI = factory.getOWLDataPropertyAssertionAxiom(i, dp, valueConstant); - addAxiom(axiomOWLAPI); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.BooleanDatatypePropertyAssertion) - */ - public void visit(BooleanDatatypePropertyAssertion axiom) { - OWLIndividual i = factory.getOWLIndividual(URI.create(axiom.getIndividual().getName())); - OWLDataProperty dp = factory.getOWLDataProperty(URI.create(axiom.getDatatypeProperty().getName())); - Boolean value = axiom.getValue(); - OWLDataType booleanType = factory.getOWLDataType(XSDVocabulary.BOOLEAN.getURI()); - OWLTypedConstant valueConstant = factory.getOWLTypedConstant(value.toString(), booleanType); - OWLAxiom axiomOWLAPI = factory.getOWLDataPropertyAssertionAxiom(i, dp, valueConstant); - addAxiom(axiomOWLAPI); - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.FunctionalObjectPropertyAxiom) - */ - public void visit(FunctionalObjectPropertyAxiom axiom) { - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(((FunctionalObjectPropertyAxiom) axiom).getRole().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLFunctionalObjectPropertyAxiom(role); - addAxiom(axiomOWLAPI); - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.InverseObjectPropertyAxiom) - */ - public void visit(InverseObjectPropertyAxiom axiom) { - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(((InverseObjectPropertyAxiom) axiom).getRole().getName())); - OWLObjectProperty inverseRole = factory.getOWLObjectProperty( - URI.create(((InverseObjectPropertyAxiom) axiom).getInverseRole().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLInverseObjectPropertiesAxiom(role, inverseRole); - addAxiom(axiomOWLAPI); - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.SymmetricObjectPropertyAxiom) - */ - public void visit(SymmetricObjectPropertyAxiom axiom) { - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(((SymmetricObjectPropertyAxiom) axiom).getRole().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLSymmetricObjectPropertyAxiom(role); - addAxiom(axiomOWLAPI); - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.TransitiveObjectPropertyAxiom) - */ - public void visit(TransitiveObjectPropertyAxiom axiom) { - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(axiom.getRole().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLTransitiveObjectPropertyAxiom(role); - addAxiom(axiomOWLAPI); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.SubObjectPropertyAxiom) - */ - public void visit(SubObjectPropertyAxiom axiom) { - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(((SubObjectPropertyAxiom) axiom).getRole().getName())); - OWLObjectProperty subRole = factory.getOWLObjectProperty( - URI.create(((SubObjectPropertyAxiom) axiom).getSubRole().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLSubObjectPropertyAxiom(subRole, role); - addAxiom(axiomOWLAPI); - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.owl.TerminologicalAxiomVisitor#visit(org.dllearner.core.owl.EquivalentClassesAxiom) - */ - public void visit(EquivalentClassesAxiom axiom) { - OWLDescription d1 = getOWLDescription(axiom.getConcept1()); - OWLDescription d2 = getOWLDescription(axiom.getConcept2()); - Set<OWLDescription> ds = new HashSet<OWLDescription>(); - ds.add(d1); - ds.add(d2); - OWLAxiom axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); - addAxiom(axiomOWLAPI); - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.owl.TerminologicalAxiomVisitor#visit(org.dllearner.core.owl.SubClassAxiom) - */ - public void visit(SubClassAxiom axiom) { - OWLDescription d1 = getOWLDescription(axiom.getSubConcept()); - OWLDescription d2 = getOWLDescription(axiom.getSuperConcept()); - Set<OWLDescription> ds = new HashSet<OWLDescription>(); - ds.add(d1); - ds.add(d2); - OWLAxiom axiomOWLAPI = factory.getOWLSubClassAxiom(d1,d2); - addAxiom(axiomOWLAPI); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.DatatypePropertyDomainAxiom) - */ - public void visit(DatatypePropertyDomainAxiom datatypePropertyDomainAxiom) { - OWLDescription d = getOWLDescription(datatypePropertyDomainAxiom.getDomain()); - OWLDataProperty dp = factory.getOWLDataProperty(URI.create(datatypePropertyDomainAxiom.getProperty().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLDataPropertyDomainAxiom(dp, d); - addAxiom(axiomOWLAPI); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.ObjectPropertyDomainAxiom) - */ - public void visit(ObjectPropertyDomainAxiom objectPropertyDomainAxiom) { - OWLDescription d = getOWLDescription(objectPropertyDomainAxiom.getDomain()); - OWLObjectProperty op = factory.getOWLObjectProperty(URI.create(objectPropertyDomainAxiom.getProperty().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLObjectPropertyDomainAxiom(op, d); - addAxiom(axiomOWLAPI); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.DatatypePropertyRangeAxiom) - */ - public void visit(DatatypePropertyRangeAxiom axiom) { - DataRange dr = axiom.getRange(); - Datatype dt = (Datatype) dr; - OWLDataType odt = factory.getOWLDataType(dt.getURI()); - OWLDataProperty dp = factory.getOWLDataProperty(URI.create(axiom.getProperty().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLDataPropertyRangeAxiom(dp, odt); - addAxiom(axiomOWLAPI); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.ObjectPropertyRangeAxiom) - */ - public void visit(ObjectPropertyRangeAxiom axiom) { - OWLDescription d = getOWLDescription(axiom.getRange()); - OWLObjectProperty op = factory.getOWLObjectProperty(URI.create(axiom.getProperty().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLObjectPropertyRangeAxiom(op, d); - addAxiom(axiomOWLAPI); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.DifferentIndividualsAxiom) - */ - public void visit(DifferentIndividualsAxiom axiom) { - Set<Individual> individuals = axiom.getIndividuals(); - Set<OWLIndividual> owlAPIIndividuals = new HashSet<OWLIndividual>(); - for(Individual individual : individuals) - owlAPIIndividuals.add(factory.getOWLIndividual(URI.create(individual.getName()))); - OWLAxiom axiomOWLAPI = factory.getOWLDifferentIndividualsAxiom(owlAPIIndividuals); - addAxiom(axiomOWLAPI); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.TerminologicalAxiomVisitor#visit(org.dllearner.core.owl.DisjointClassesAxiom) - */ - public void visit(DisjointClassesAxiom axiom) { - Set<Description> descriptions = axiom.getDescriptions(); - Set<OWLDescription> owlAPIDescriptions = new HashSet<OWLDescription>(); - for(Description description : descriptions) - owlAPIDescriptions.add(getOWLDescription(description)); - OWLAxiom axiomOWLAPI = factory.getOWLDisjointClassesAxiom(owlAPIDescriptions); - addAxiom(axiomOWLAPI); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -1,361 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.reasoning; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; -import java.util.Stack; - -import org.dllearner.algorithms.gp.ADC; -import org.dllearner.core.owl.Constant; -import org.dllearner.core.owl.Datatype; -import org.dllearner.core.owl.DatatypeExactCardinalityRestriction; -import org.dllearner.core.owl.DatatypeMaxCardinalityRestriction; -import org.dllearner.core.owl.DatatypeMinCardinalityRestriction; -import org.dllearner.core.owl.DatatypeProperty; -import org.dllearner.core.owl.DatatypeSomeRestriction; -import org.dllearner.core.owl.DatatypeValueRestriction; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.DescriptionVisitor; -import org.dllearner.core.owl.DoubleMinValue; -import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.Negation; -import org.dllearner.core.owl.Nothing; -import org.dllearner.core.owl.ObjectAllRestriction; -import org.dllearner.core.owl.ObjectExactCardinalityRestriction; -import org.dllearner.core.owl.ObjectMaxCardinalityRestriction; -import org.dllearner.core.owl.ObjectMinCardinalityRestriction; -import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.ObjectValueRestriction; -import org.dllearner.core.owl.SimpleDoubleDataRange; -import org.dllearner.core.owl.Thing; -import org.dllearner.core.owl.TypedConstant; -import org.dllearner.core.owl.Union; -import org.dllearner.core.owl.UntypedConstant; -import org.dllearner.parser.KBParser; -import org.dllearner.parser.ParseException; -import org.semanticweb.owl.apibinding.OWLManager; -import org.semanticweb.owl.model.OWLConstant; -import org.semanticweb.owl.model.OWLDataFactory; -import org.semanticweb.owl.model.OWLDataProperty; -import org.semanticweb.owl.model.OWLDataRange; -import org.semanticweb.owl.model.OWLDataType; -import org.semanticweb.owl.model.OWLDescription; -import org.semanticweb.owl.model.OWLIndividual; -import org.semanticweb.owl.model.OWLObjectProperty; -import org.semanticweb.owl.model.OWLTypedConstant; -import org.semanticweb.owl.vocab.OWLRestrictedDataRangeFacetVocabulary; -import org.semanticweb.owl.vocab.XSDVocabulary; - -/** - * Converter from DL-Learner descriptions to OWL API descriptions based - * on the visitor pattern. - * - * @author Jens Lehmann - * - */ -public class OWLAPIDescriptionConvertVisitor implements DescriptionVisitor { - - // private OWLDescription description; - private Stack<OWLDescription> stack = new Stack<OWLDescription>(); - - private OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory(); - - public OWLDescription getOWLDescription() { - return stack.pop(); - } - - /** - * Converts a DL-Learner description into an OWL API decription. - * @param description DL-Learner description. - * @return Corresponding OWL API description. - */ - public static OWLDescription getOWLDescription(Description description) { - OWLAPIDescriptionConvertVisitor converter = new OWLAPIDescriptionConvertVisitor(); - description.accept(converter); - return converter.getOWLDescription(); - } - - /** - * Used for testing the OWL API converter. - * - * @param args - */ - public static void main(String[] args) { - try { - Description d = KBParser.parseConcept("(male AND (rich OR NOT stupid))"); - OWLDescription od = OWLAPIDescriptionConvertVisitor.getOWLDescription(d); - System.out.println(d); - System.out.println(od); - } catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Negation) - */ - public void visit(Negation description) { - description.getChild(0).accept(this); - OWLDescription d = stack.pop(); - stack.push(factory.getOWLObjectComplementOf(d)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectAllRestriction) - */ - public void visit(ObjectAllRestriction description) { - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(description.getRole().getName())); - description.getChild(0).accept(this); - OWLDescription d = stack.pop(); - stack.push(factory.getOWLObjectAllRestriction(role, d)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectSomeRestriction) - */ - public void visit(ObjectSomeRestriction description) { - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(description.getRole().getName())); - description.getChild(0).accept(this); - OWLDescription d = stack.pop(); - stack.push(factory.getOWLObjectSomeRestriction(role, d)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Nothing) - */ - public void visit(Nothing description) { - stack.push(factory.getOWLNothing()); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Thing) - */ - public void visit(Thing description) { - stack.push(factory.getOWLThing()); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Intersection) - */ - public void visit(Intersection description) { - Set<OWLDescription> descriptions = new HashSet<OWLDescription>(); - for(Description child : description.getChildren()) { - child.accept(this); - descriptions.add(stack.pop()); - } - stack.push(factory.getOWLObjectIntersectionOf(descriptions)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Union) - */ - public void visit(Union description) { - Set<OWLDescription> descriptions = new HashSet<OWLDescription>(); - for(Description child : description.getChildren()) { - child.accept(this); - descriptions.add(stack.pop()); - } - stack.push(factory.getOWLObjectUnionOf(descriptions)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectMinCardinalityRestriction) - */ - public void visit(ObjectMinCardinalityRestriction description) { - // TODO Taken from ObjectSomeRestriction above, hope its correct - //throw new Error("OWLAPIDescriptionConverter: not implemented"); - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(description.getRole().getName())); - description.getChild(0).accept(this); - OWLDescription d = stack.pop(); - int minmax = description.getCardinality(); - stack.push(factory.getOWLObjectMinCardinalityRestriction(role, minmax, d)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectExactCardinalityRestriction) - */ - public void visit(ObjectExactCardinalityRestriction description) { - // TODO Taken from ObjectSomeRestriction above, hope its correct - //throw new Error("OWLAPIDescriptionConverter: not implemented"); - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(description.getRole().getName())); - description.getChild(0).accept(this); - OWLDescription d = stack.pop(); - int minmax = description.getCardinality(); - stack.push(factory.getOWLObjectExactCardinalityRestriction(role, minmax, d)); - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectMaxCardinalityRestriction) - */ - public void visit(ObjectMaxCardinalityRestriction description) { - // TODO Taken from ObjectSomeRestriction above, hope its correct - //throw new Error("OWLAPIDescriptionConverter: not implemented"); - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(description.getRole().getName())); - description.getChild(0).accept(this); - OWLDescription d = stack.pop(); - int minmax = description.getCardinality(); - stack.push(factory.getOWLObjectMaxCardinalityRestriction(role, minmax, d)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectValueRestriction) - */ - public void visit(ObjectValueRestriction description) { - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(((ObjectProperty)description.getRestrictedPropertyExpression()).getName())); - OWLIndividual i = factory.getOWLIndividual(URI.create(description.getIndividual().getName())); - stack.push(factory.getOWLObjectValueRestriction(role, i)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.DatatypeValueRestriction) - */ - public void visit(DatatypeValueRestriction description) { - // convert OWL constant to OWL API constant - Constant c = description.getValue(); - OWLConstant constant = convertConstant(c); - /* - if(c instanceof TypedConstant) { - Datatype dt = ((TypedConstant)c).getDatatype(); - OWLDataType odt = convertDatatype(dt); - constant = factory.getOWLTypedConstant(c.getLiteral(), odt); - } else { - UntypedConstant uc = (UntypedConstant) c; - if(uc.hasLang()) { - constant = factory.getOWLUntypedConstant(uc.getLiteral(), uc.getLang()); - } else { - constant = factory.getOWLUntypedConstant(uc.getLiteral()); - } - } - */ - - // get datatype property - DatatypeProperty dtp = description.getRestrictedPropertyExpresssion(); - OWLDataProperty prop = factory.getOWLDataProperty(URI.create(dtp.getName())); - - stack.push(factory.getOWLDataValueRestriction(prop, constant)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.NamedClass) - */ - public void visit(NamedClass description) { - stack.push(factory.getOWLClass(URI.create(description.getName()))); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.algorithms.gp.ADC) - */ - public void visit(ADC description) { - // TODO Auto-generated method stub - throw new Error("OWLAPIDescriptionConverter: not implemented"); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.DatatypeMinCardinalityRestriction) - */ - public void visit(DatatypeMinCardinalityRestriction description) { - // TODO Auto-generated method stub - throw new Error("OWLAPIDescriptionConverter: not implemented"); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.DatatypeExactCardinalityRestriction) - */ - public void visit(DatatypeExactCardinalityRestriction description) { - // TODO Auto-generated method stub - throw new Error("OWLAPIDescriptionConverter: not implemented"); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.DatatypeMaxCardinalityRestriction) - */ - public void visit(DatatypeMaxCardinalityRestriction description) { - // TODO Auto-generated method stub - throw new Error("OWLAPIDescriptionConverter: not implemented"); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.DatatypeSomeRestriction) - */ - public void visit(DatatypeSomeRestriction description) { - - // TODO: currently works only for double min/max - - DatatypeProperty dp = (DatatypeProperty) description.getRestrictedPropertyExpression(); - // currently only double restrictions implemented - SimpleDoubleDataRange dr = (SimpleDoubleDataRange) description.getDataRange(); - Double value = dr.getValue(); - - OWLDataType doubleDataType = factory.getOWLDataType(XSDVocabulary.DOUBLE.getURI()); - OWLTypedConstant constant = factory.getOWLTypedConstant(value.toString(), doubleDataType); - - OWLRestrictedDataRangeFacetVocabulary facet; - if(dr instanceof DoubleMinValue) - facet = OWLRestrictedDataRangeFacetVocabulary.MIN_INCLUSIVE; - else - facet = OWLRestrictedDataRangeFacetVocabulary.MAX_INCLUSIVE; - - OWLDataRange owlDataRange = factory.getOWLDataRangeRestriction(doubleDataType, facet, constant); - OWLDataProperty odp = factory.getOWLDataProperty(URI.create(dp.getName())); - OWLDescription d = factory.getOWLDataSomeRestriction(odp, owlDataRange); - - stack.push(d); - } - - public OWLDataType convertDatatype(Datatype datatype) { - if(datatype.equals(Datatype.BOOLEAN)) - return factory.getOWLDataType(Datatype.BOOLEAN.getURI()); - else if(datatype.equals(Datatype.INT)) - return factory.getOWLDataType(Datatype.INT.getURI()); - else if(datatype.equals(Datatype.DOUBLE)) - return factory.getOWLDataType(Datatype.DOUBLE.getURI()); - - throw new Error("OWLAPIDescriptionConverter: datatype not implemented"); - } - - private OWLConstant convertConstant(Constant constant) { - OWLConstant owlConstant; - if(constant instanceof TypedConstant) { - Datatype dt = ((TypedConstant)constant).getDatatype(); - OWLDataType odt = convertDatatype(dt); - owlConstant = factory.getOWLTypedConstant(constant.getLiteral(), odt); - } else { - UntypedConstant uc = (UntypedConstant) constant; - if(uc.hasLang()) { - owlConstant = factory.getOWLUntypedConstant(uc.getLiteral(), uc.getLang()); - } else { - owlConstant = factory.getOWLUntypedConstant(uc.getLiteral()); - } - } - return owlConstant; - } -} Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-11-10 13:46:08 UTC (rev 1502) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-11-10 16:53:59 UTC (rev 1503) @@ -65,6 +65,8 @@ import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.OWLAPIAxiomConvertVisitor; +import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; import org.dllearner.utilities.owl.RoleComparator; import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.inference.OWLReasoner; @@ -370,14 +372,14 @@ /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getAtomicConcepts() */ - public Set<NamedClass> getAtomicConcepts() { + public Set<NamedClass> getNamedClasses() { return atomicConcepts; } /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getAtomicRoles() */ - public Set<ObjectProperty> getAtomicRoles() { + public Set<ObjectProperty> getObjectProperties() { return atomicRoles; } @@ -396,11 +398,12 @@ /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getReasonerType() */ + @Override public ReasonerType getReasonerType() { if(configurator.getReasonerType().equals("fact")) - return ReasonerType.FACT; + return ReasonerType.OWLAPI_FACT; else - return ReasonerType.PELLET; + return ReasonerType.OWLAPI_PELLET; } /* (non-Javadoc) @@ -422,22 +425,22 @@ conceptComparator); // refinements of top - TreeSet<Description> tmp = getMoreSpecialConcepts(new Thing()); + TreeSet<Description> tmp = getMoreSpecialConceptsImpl(new Thing()); tmp.retainAll(allowedConceptsInSubsumptionHierarchy); subsumptionHierarchyDown.put(new Thing(), tmp); // refinements of bottom - tmp = getMoreGeneralConcepts(new Nothing()); + tmp = getMoreGeneralConceptsImpl(new Nothing()); tmp.retainAll(allowedConceptsInSubsumptionHierarchy); subsumptionHierarchyUp.put(new Nothing(), tmp); // refinements of atomic concepts for (NamedClass atom : atomicConcepts) { - tmp = getMoreSpecialConcepts(atom); + tmp = getMoreSpecialConceptsImpl(atom); tmp.retainAll(allowedConceptsInSubsumptionHierarchy); subsumptionHierarchyDown.put(atom, tmp); - tmp = getMoreGeneralConcepts(atom); + tmp = getMoreGeneralConceptsImpl(atom); tmp.retainAll(allowedConceptsInSubsumptionHierarchy); subsumptionHierarchyUp.put(atom, tmp); } @@ -455,7 +458,6 @@ /* (non-Javadoc) * @see org.dllearner.core.Reasoner#prepareRoleHierarchy(java.util.Set) */ - @Override public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { // code copied from DIG reasoner @@ -466,8 +468,8 @@ // refinement of atomic concepts for (ObjectProperty role : atomicRoles) { - roleHierarchyDown.put(role, getMoreSpecialRoles(role)); - roleHierarchyUp.put(role, getMoreGeneralRoles(role)); + roleHierarchyDown.put(role, getMoreSpecialRolesImpl(role)); + roleHierarchyUp.put(role, getMoreGeneralRolesImpl(role)); } roleHierarchy = new ObjectPropertyHierarchy(allowedRoles, roleHierarchyUp, @@ -480,7 +482,7 @@ } @Override - public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedRoles) { + public void prepareDatatypePropertyHierarchyImpl(Set<DatatypeProperty> allowedRoles)... [truncated message content] |