From: <jen...@us...> - 2008-11-12 12:07:55
|
Revision: 1509 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1509&view=rev Author: jenslehmann Date: 2008-11-12 12:07:48 +0000 (Wed, 12 Nov 2008) Log Message: ----------- - started EL learning algorithm - object property hierarchy creation now also implemented directly in reasoner component (ignored roles not working yet) Modified Paths: -------------- trunk/lib/components.ini 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/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java trunk/src/dl-learner/org/dllearner/core/Component.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java trunk/src/dl-learner/org/dllearner/core/owl/ClassHierarchy.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.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/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/algorithms/el/SearchTreeNode.java trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmConfigurator.java Modified: trunk/lib/components.ini =================================================================== --- trunk/lib/components.ini 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/lib/components.ini 2008-11-12 12:07:48 UTC (rev 1509) @@ -24,3 +24,4 @@ org.dllearner.algorithms.gp.GP org.dllearner.algorithms.DBpediaNavigationSuggestor org.dllearner.algorithms.SimpleSuggestionLearningAlgorithm +org.dllearner.algorithms.el.ELLearningAlgorithm \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -287,7 +287,7 @@ } } - @Override +// @Override public Score getSolutionScore() { return bestScore; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -189,7 +189,7 @@ return learner.getCurrentlyBestEvaluatedDescriptions(nrOfDescriptions, accuracyThreshold, filterNonMinimalDescriptions); } - @Override +// @Override public Score getSolutionScore() { return learner.getSolutionScore(); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -120,7 +120,7 @@ logger.info("fitness: " + bestFitness); } - @Override +// @Override public Score getSolutionScore() { return bestScore; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -94,7 +94,7 @@ } - @Override +// @Override public Score getSolutionScore() { return solutionScore; } Added: trunk/src/dl-learner/org/dllearner/algorithms/el/ELHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELHeuristic.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELHeuristic.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -0,0 +1,35 @@ +/** + * 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.algorithms.el; + +import java.util.Comparator; + +/** + * Marker interface for heuristics in the EL learning + * algorithms. A heuristic implements a method + * to decide which one of two given nodes seems to be more + * promising with respect to the learning problem we consider. + * + * @author Jens Lehmann + * + */ +public interface ELHeuristic extends Comparator<SearchTreeNode> { + +} Added: trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -0,0 +1,215 @@ +/** + * 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.algorithms.el; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.Score; +import org.dllearner.core.configurators.Configurator; +import org.dllearner.core.configurators.ELLearningAlgorithmConfigurator; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Thing; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.refinementoperators.ELDown; +import org.dllearner.utilities.owl.EvaluatedDescriptionSet; + +/** + * A learning algorithm for EL, which will be based on a (hopefully) + * ideal refinement operator. + * + * TODO redundancy check + * + * @author Jens Lehmann + * + */ +public class ELLearningAlgorithm extends LearningAlgorithm { + + private ELLearningAlgorithmConfigurator configurator; + + private ELDown operator; + + private boolean isRunning = false; + private boolean stop = false; + + // a set with limited size (currently the ordering is defined in the class itself) + private EvaluatedDescriptionSet bestEvaluatedDescriptions = new EvaluatedDescriptionSet(LearningAlgorithm.MAX_NR_OF_RESULTS); + + private SearchTreeNode startNode; + private ELHeuristic heuristic; + private SortedSet<SearchTreeNode> candidates; + + public ELLearningAlgorithm(PosNegLP problem, ReasonerComponent reasoner) { + super(problem, reasoner); + } + + public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { + Collection<Class<? extends LearningProblem>> problems = new LinkedList<Class<? extends LearningProblem>>(); + problems.add(PosNegLP.class); + return problems; + } + + // we can assume a PosNegLP, because it is the only supported one + private PosNegLP getLearningProblem() { + return (PosNegLP) learningProblem; + } + + @Override + public Configurator getConfigurator() { + return configurator; + } + + @Override + public void init() throws ComponentInitException { + // currently we use the stable heuristic + heuristic = new StableHeuristic(); + candidates = new TreeSet<SearchTreeNode>(heuristic); + + operator = new ELDown(reasoner); + } + + @Override + public void start() { + stop = false; + isRunning = true; + reset(); + + ELDescriptionTree top = new ELDescriptionTree(reasoner, Thing.instance); + addDescriptionTree(top, null); + + while(!stop && !stoppingCriteriaSatisfied()) { + // pick the best candidate according to the heuristic + SearchTreeNode best = candidates.last(); + // apply operator + Set<ELDescriptionTree> refinements = operator.refine(best.getDescriptionTree()); + // add all refinements to search tree, candidates, best descriptions + for(ELDescriptionTree refinement : refinements) { + addDescriptionTree(refinement, best); + } + } + + isRunning = false; + } + + // evaluates a description in tree form + private void addDescriptionTree(ELDescriptionTree descriptionTree, SearchTreeNode parentNode) { + + // create search tree node + SearchTreeNode node = new SearchTreeNode(descriptionTree); + + // convert tree to standard description + Description description = descriptionTree.transformToDescription(); + int negCovers = getLearningProblem().coveredNegativeExamplesOrTooWeak(description); + if(negCovers == -1) { + node.setTooWeak(); + } else { + node.setCoveredNegatives(negCovers); + } + + // link to parent (unless start node) + if(parentNode == null) { + startNode = node; + } else { + parentNode.addChild(node); + } + + if(!node.isTooWeak()) { + // add as candidate + candidates.add(node); + + // check whether we want to add it to the best evaluated descriptions; + // to do this we pick the worst considered evaluated description + // (remember that the set has limited size, so it's likely not the worst overall) + EvaluatedDescription worst = bestEvaluatedDescriptions.getSet().first(); + // the description has a chance to make it in the set if it has + // at least as high accuracy - if not we can save the reasoner calls + // for fully computing the evaluated description + if(worst.getCoveredNegatives().size() >= node.getCoveredNegatives()) { + Score score = learningProblem.computeScore(description); + EvaluatedDescription ed = new EvaluatedDescription(description, score); + bestEvaluatedDescriptions.add(ed); + } + // TODO add a method to EvaluatedDescriptionSet for returning the + // minimum accuracy required + } + + } + + private boolean stoppingCriteriaSatisfied() { + // stop if we have a node covering all positives and none of the negatives + SearchTreeNode bestNode = candidates.last(); + return (bestNode.getCoveredNegatives() == 0); + } + + private void reset() { + // set all values back to their default values (used for running + // the algorithm more than once) + candidates.clear(); + bestEvaluatedDescriptions.getSet().clear(); + } + + @Override + public void stop() { + stop = true; + } + + @Override + public boolean isRunning() { + return isRunning; + } + + @Override + public Description getCurrentlyBestDescription() { + return getCurrentlyBestEvaluatedDescription().getDescription(); + } + + @Override + public List<Description> getCurrentlyBestDescriptions() { + return bestEvaluatedDescriptions.toDescriptionList(); + } + + @Override + public EvaluatedDescription getCurrentlyBestEvaluatedDescription() { + return bestEvaluatedDescriptions.getSet().last(); + } + + @Override + public SortedSet<EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions() { + return bestEvaluatedDescriptions.getSet(); + } + + /** + * @return the startNode + */ + public SearchTreeNode getStartNode() { + return startNode; + } + +} Added: trunk/src/dl-learner/org/dllearner/algorithms/el/SearchTreeNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/SearchTreeNode.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/SearchTreeNode.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -0,0 +1,90 @@ +/** + * 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.algorithms.el; + +import java.util.List; + +/** + * A node in the search tree of an EL algorithm. + * + * @author Jens Lehmann + * + */ +public class SearchTreeNode { + + private ELDescriptionTree descriptionTree; + + private List<SearchTreeNode> children; + + private int coveredNegatives; + private boolean tooWeak = false; + + public SearchTreeNode(ELDescriptionTree descriptionTree) { + this.descriptionTree = descriptionTree; + } + + /** + * @return the tooWeak + */ + public boolean isTooWeak() { + return tooWeak; + } + + /** + * @param tooWeak the tooWeak to set + */ + public void setTooWeak() { + tooWeak = true; + } + + /** + * @param coveredNegatives the coveredNegatives to set + */ + public void setCoveredNegatives(int coveredNegatives) { + this.coveredNegatives = coveredNegatives; + tooWeak = false; + } + + /** + * @return the coveredNegatives + */ + public int getCoveredNegatives() { + return coveredNegatives; + } + + public void addChild(SearchTreeNode node) { + children.add(node); + } + + /** + * @return the descriptionTree + */ + public ELDescriptionTree getDescriptionTree() { + return descriptionTree; + } + + /** + * @return the children + */ + public List<SearchTreeNode> getChildren() { + return children; + } + +} Added: trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -0,0 +1,39 @@ +/** + * 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.algorithms.el; + +/** + * A stable comparator for search tree nodes. Stable means that the order + * of nodes will not change during the run of the learning algorithm. In + * this implementation, this is ensured by using only covered examples + * and tree size as criteria. + * + * @author Jens Lehmann + * + */ +public class StableHeuristic implements ELHeuristic { + + @Override + public int compare(SearchTreeNode o1, SearchTreeNode o2) { + // TODO Auto-generated method stub + return 0; + } + +} Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -946,7 +946,7 @@ System.exit(0); } - @Override +// @Override public Score getSolutionScore() { return bestScore; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -430,7 +430,7 @@ algorithm.start(); } - @Override +// @Override public Score getSolutionScore() { return algorithm.getSolutionScore(); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -26,7 +26,7 @@ /** * This comparator is stable, because it only takes covered examples, concept - * length and the concepts itself (using again a stable comparator) into a + * length and the concepts itself (using again a stable comparator) into * account, which do not change during the run of the algorithm. * * @author Jens Lehmann Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -1099,7 +1099,7 @@ return best; } - @Override +// @Override public Score getSolutionScore() { if(posOnly) return posOnlyLearningProblem.computeScore(getCurrentlyBestDescription()); Modified: trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -28,6 +28,7 @@ import org.dllearner.algorithms.BruteForceLearner; import org.dllearner.algorithms.DBpediaNavigationSuggestor; import org.dllearner.algorithms.RandomGuesser; +import org.dllearner.algorithms.el.ELLearningAlgorithm; import org.dllearner.algorithms.gp.GP; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.algorithms.refinement.ROLearner; @@ -89,7 +90,8 @@ learningAlgorithmMapping.put("gp", GP.class); learningAlgorithmMapping.put("refinement", ROLearner.class); learningAlgorithmMapping.put("refexamples", ExampleBasedROLComponent.class); - learningAlgorithmMapping.put("dbpediaNavigationSuggestor", DBpediaNavigationSuggestor.class); + learningAlgorithmMapping.put("dbpediaNavigationSuggestor", DBpediaNavigationSuggestor.class); + learningAlgorithmMapping.put("el", ELLearningAlgorithm.class); // you do not need to edit anything below Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -36,14 +36,18 @@ */ public abstract class Component { -protected Configurator configurator; + protected Configurator configurator; + /** + * For each component, a configurator class is generated in package + * org.dllearner.core.configurators using the script + * {@link org.dllearner.scripts.ConfigJavaGenerator}. The configurator + * provides set and get methods for the configuration options of + * a component. + * @return An object allowing to configure this component. + */ public abstract Configurator getConfigurator(); - //return configurator; - //} - - /** * Returns the name of this component. By default, "unnamed * component" is returned, but all implementations of components @@ -83,6 +87,15 @@ * perform an action (usually setting an internal variable to * an appropriate value). * + * Since the availability of configurators, it is optional for + * components to implement this method. Instead of using this method + * to take an action based on a configuration value, components can + * also use the getters defined in the components configurator. + * + * Important note: Never call this method directly. All calls are + * done via the {@link org.dllearner.core.ComponentManager}. + * + * @see #getConfigurator() * @param <T> Type of the config entry (Integer, String etc.). * @param entry A configuration entry. * @throws InvalidConfigOptionValueException This exception is thrown if the @@ -94,15 +107,8 @@ * an interval for the value). This means that, as a component developer, you * often do not need to implement further validity checks. */ - public abstract <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException; + protected <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { + + } - /** - * Gets the value of a configuration option of this component. - * - * @param <T> Option type. - * @param option A configuration option of this component. - * @return Current value of the configuration option. - */ -// now implemented in ComponentManager -// public abstract <T> T getConfigValue(ConfigOption<T> option) throws UnknownConfigOptionException; } Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -96,9 +96,10 @@ /** * This is the maximum number of results, which the learning - * algorithms need to keep. (Often algorithms do not need - * to store any results except the best one, so this limit - * is used to limit the performance cost for storing results.) + * algorithms are asked to store. (Note, that algorithms are not + * required to store any results except the best one, so this limit + * is used to limit the performance cost for those which + * choose to store results.) */ public static final int MAX_NR_OF_RESULTS = 100; @@ -143,8 +144,8 @@ * * @return Best score. */ - @Deprecated - public abstract Score getSolutionScore(); +// @Deprecated +// public abstract Score getSolutionScore(); /** * @see #getCurrentlyBestEvaluatedDescription() Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -47,6 +47,7 @@ import org.dllearner.utilities.datastructures.SortedSetTuple; import org.dllearner.utilities.owl.ConceptComparator; import org.dllearner.utilities.owl.OWLVocabulary; +import org.dllearner.utilities.owl.RoleComparator; /** * Abstract component representing a reasoner. Only a few reasoning operations @@ -770,21 +771,37 @@ return getObjectPropertyHierarchy().getMoreGeneralRoles(role); } + protected SortedSet<ObjectProperty> getSuperPropertiesImpl(ObjectProperty role) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + @Override public final SortedSet<ObjectProperty> getSubProperties(ObjectProperty role) { return getObjectPropertyHierarchy().getMoreSpecialRoles(role); } + protected SortedSet<ObjectProperty> getSubPropertiesImpl(ObjectProperty role) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + @Override public final TreeSet<ObjectProperty> getMostGeneralProperties() { return getObjectPropertyHierarchy().getMostGeneralRoles(); } +// protected SortedSet<ObjectProperty> getMostGeneralPropertiesImpl(ObjectProperty role) throws ReasoningMethodUnsupportedException { +// throw new ReasoningMethodUnsupportedException(); +// } + @Override public final TreeSet<ObjectProperty> getMostSpecialProperties() { return getObjectPropertyHierarchy().getMostSpecialRoles(); } +// protected SortedSet<ObjectProperty> getMostSpecialPropertiesImpl(ObjectProperty role) throws ReasoningMethodUnsupportedException { +// throw new ReasoningMethodUnsupportedException(); +// } + @Override public final SortedSet<DatatypeProperty> getSuperProperties(DatatypeProperty role) { return getDatatypePropertyHierarchy().getMoreGeneralRoles(role); @@ -810,7 +827,8 @@ * called explicitly, it is called the first time, it is needed). * * @return The class hierarchy. - * @throws ReasoningMethodUnsupportedException + * @throws ReasoningMethodUnsupportedException If any method needed to + * create the hierarchy is not supported by the underlying reasoner. */ public final ClassHierarchy prepareSubsumptionHierarchy() throws ReasoningMethodUnsupportedException { ConceptComparator conceptComparator = new ConceptComparator(); @@ -824,8 +842,6 @@ subsumptionHierarchyUp.put(Thing.instance, new TreeSet<Description>()); subsumptionHierarchyDown.put(Thing.instance, tmp); - - // ... bottom ... tmp = getSuperClassesImpl(Nothing.instance); subsumptionHierarchyUp.put(Nothing.instance, tmp); @@ -849,8 +865,6 @@ subsumptionHierarchyUp.put(atom, tmp); } - - return new ClassHierarchy(subsumptionHierarchyUp, subsumptionHierarchyDown); } @@ -873,13 +887,28 @@ * * @return The object property hierarchy. * @throws ReasoningMethodUnsupportedException - * Thrown if object property hierarchy creation is not supported - * by the reasoner. + * Thrown if a reasoning method for object property + * hierarchy creation is not supported by the reasoner. */ public ObjectPropertyHierarchy prepareRoleHierarchy() throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException( - "Object property hierarchy creation not supported by this reasoner."); + + RoleComparator roleComparator = new RoleComparator(); + TreeMap<ObjectProperty, SortedSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, SortedSet<ObjectProperty>>( + roleComparator); + TreeMap<ObjectProperty, SortedSet<ObjectProperty>> roleHierarchyDown = new TreeMap<ObjectProperty, SortedSet<ObjectProperty>>( + roleComparator); + + // refinement of atomic concepts + Set<ObjectProperty> atomicRoles = getObjectProperties(); + for (ObjectProperty role : atomicRoles) { + roleHierarchyDown.put(role, getSubPropertiesImpl(role)); + roleHierarchyUp.put(role, getSuperPropertiesImpl(role)); + } + + roleHierarchy = new ObjectPropertyHierarchy(atomicRoles, roleHierarchyUp, + roleHierarchyDown); + return roleHierarchy; } @Override Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -26,6 +26,7 @@ import org.dllearner.algorithms.DBpediaNavigationSuggestor; import org.dllearner.algorithms.RandomGuesser; import org.dllearner.algorithms.SimpleSuggestionLearningAlgorithm; +import org.dllearner.algorithms.el.ELLearningAlgorithm; import org.dllearner.algorithms.gp.GP; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.algorithms.refinement.ROLearner; @@ -121,7 +122,7 @@ /** * @param positiveExamples positive examples * @param negativeExamples negative examples -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @return a component ready for initialization PosNegDefinitionLP **/ public static PosNegDefinitionLP getPosNegDefinitionLP(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { @@ -131,7 +132,7 @@ /** * @param positiveExamples positive examples * @param negativeExamples negative examples -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @return a component ready for initialization PosNegDefinitionLPStrict **/ public static PosNegDefinitionLPStrict getPosNegDefinitionLPStrict(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { @@ -141,7 +142,7 @@ /** * @param positiveExamples positive examples * @param negativeExamples negative examples -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @return a component ready for initialization PosNegInclusionLP **/ public static PosNegInclusionLP getPosNegInclusionLP(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { @@ -150,7 +151,7 @@ /** * @param positiveExamples positive examples -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @return a component ready for initialization PosOnlyDefinitionLP **/ public static PosOnlyDefinitionLP getPosOnlyDefinitionLP(ReasonerComponent reasoningService, Set<String> positiveExamples) { @@ -159,7 +160,7 @@ /** * @param positiveExamples positive examples -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @return a component ready for initialization PosOnlyInclusionLP **/ public static PosOnlyInclusionLP getPosOnlyInclusionLP(ReasonerComponent reasoningService, Set<String> positiveExamples) { @@ -168,7 +169,7 @@ /** * @param learningProblem see LearningProblem -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see * @return a component ready for initialization BruteForceLearner **/ @@ -178,7 +179,7 @@ /** * @param learningProblem see LearningProblem -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see * @return a component ready for initialization DBpediaNavigationSuggestor **/ @@ -188,7 +189,7 @@ /** * @param learningProblem see LearningProblem -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see * @return a component ready for initialization RandomGuesser **/ @@ -198,7 +199,7 @@ /** * @param learningProblem see LearningProblem -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see * @return a component ready for initialization SimpleSuggestionLearningAlgorithm **/ @@ -208,8 +209,18 @@ /** * @param learningProblem see LearningProblem -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see +* @return a component ready for initialization ELLearningAlgorithm +**/ +public static ELLearningAlgorithm getELLearningAlgorithm(LearningProblem learningProblem, ReasonerComponent reasoningService) throws LearningProblemUnsupportedException { +return ELLearningAlgorithmConfigurator.getELLearningAlgorithm(learningProblem, reasoningService); +} + +/** +* @param learningProblem see LearningProblem +* @param reasoningService see ReasoningService +* @throws LearningProblemUnsupportedException see * @return a component ready for initialization GP **/ public static GP getGP(LearningProblem learningProblem, ReasonerComponent reasoningService) throws LearningProblemUnsupportedException { @@ -218,7 +229,7 @@ /** * @param learningProblem see LearningProblem -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see * @return a component ready for initialization ExampleBasedROLComponent **/ @@ -228,7 +239,7 @@ /** * @param learningProblem see LearningProblem -* @param reasoningService see ReasonerComponent +* @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see * @return a component ready for initialization ROLearner **/ Added: trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmConfigurator.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -0,0 +1,69 @@ +/** + * 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.core.configurators; + +import org.dllearner.algorithms.el.ELLearningAlgorithm; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasonerComponent; + +/** +* automatically generated, do not edit manually. +* run org.dllearner.scripts.ConfigJavaGenerator to update +**/ +public class ELLearningAlgorithmConfigurator implements Configurator { + +private boolean reinitNecessary = false; +@SuppressWarnings("unused") + +private ELLearningAlgorithm eLLearningAlgorithm; + +/** +* @param eLLearningAlgorithm see ELLearningAlgorithm +**/ +public ELLearningAlgorithmConfigurator(ELLearningAlgorithm eLLearningAlgorithm){ +this.eLLearningAlgorithm = eLLearningAlgorithm; +} + +/** +* @param reasoningService see reasoningService +* @param learningProblem see learningProblem +* @throws LearningProblemUnsupportedException see +* @return ELLearningAlgorithm +**/ +public static ELLearningAlgorithm getELLearningAlgorithm(LearningProblem learningProblem, ReasonerComponent reasoningService) throws LearningProblemUnsupportedException{ +ELLearningAlgorithm component = ComponentManager.getInstance().learningAlgorithm(ELLearningAlgorithm.class, learningProblem, reasoningService); +return component; +} + + + +/** +* true, if this component needs reinitializsation. +* @return boolean +**/ +public boolean isReinitNecessary(){ +return reinitNecessary; +} + + +} Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -153,7 +153,7 @@ /** * saveExtractedFragment Specifies whether the extracted ontology is written to a file or not. The OWL file is written to the cache dir.Some DBpedia URI will make the XML invalid. * mandatory: false| reinit necessary: true -* default value: true +* default value: false * @return boolean **/ public boolean getSaveExtractedFragment() { @@ -365,7 +365,7 @@ /** * @param saveExtractedFragment Specifies whether the extracted ontology is written to a file or not. The OWL file is written to the cache dir.Some DBpedia URI will make the XML invalid. * mandatory: false| reinit necessary: true -* default value: true +* default value: false **/ public void setSaveExtractedFragment(boolean saveExtractedFragment) { ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "saveExtractedFragment", saveExtractedFragment); Modified: trunk/src/dl-learner/org/dllearner/core/owl/ClassHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ClassHierarchy.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/core/owl/ClassHierarchy.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -55,8 +55,6 @@ this.subsumptionHierarchyUp = subsumptionHierarchyUp; this.subsumptionHierarchyDown = subsumptionHierarchyDown; - - } public SortedSet<Description> getSuperClasses(Description concept) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -27,23 +27,20 @@ import org.dllearner.utilities.owl.RoleComparator; /** - * Represents a hierarchy of roles. + * Represents a hierarchy of object properties (roles in Description Logics). * - * TODO: Currently, the role hierarchy pruning algorithm (analogous to the - * subsumption hierarchy) is not implemented. - * * @author Jens Lehmann * */ public class ObjectPropertyHierarchy { RoleComparator rc = new RoleComparator(); - TreeMap<ObjectProperty,TreeSet<ObjectProperty>> roleHierarchyUp; - TreeMap<ObjectProperty,TreeSet<ObjectProperty>> roleHierarchyDown; + TreeMap<ObjectProperty,SortedSet<ObjectProperty>> roleHierarchyUp; + TreeMap<ObjectProperty,SortedSet<ObjectProperty>> roleHierarchyDown; TreeSet<ObjectProperty> mostGeneralRoles = new TreeSet<ObjectProperty>(rc); TreeSet<ObjectProperty> mostSpecialRoles = new TreeSet<ObjectProperty>(rc); - public ObjectPropertyHierarchy(Set<ObjectProperty> atomicRoles, TreeMap<ObjectProperty,TreeSet<ObjectProperty>> roleHierarchyUp , TreeMap<ObjectProperty,TreeSet<ObjectProperty>> roleHierarchyDown) { + public ObjectPropertyHierarchy(Set<ObjectProperty> atomicRoles, TreeMap<ObjectProperty,SortedSet<ObjectProperty>> roleHierarchyUp , TreeMap<ObjectProperty,SortedSet<ObjectProperty>> roleHierarchyDown) { this.roleHierarchyUp = roleHierarchyUp; this.roleHierarchyDown = roleHierarchyDown; @@ -56,17 +53,15 @@ } } - @SuppressWarnings("unchecked") public SortedSet<ObjectProperty> getMoreGeneralRoles(ObjectProperty role) { // we clone all concepts before returning them such that they cannot be // modified externally - return (TreeSet<ObjectProperty>) roleHierarchyUp.get(role).clone(); + return new TreeSet<ObjectProperty>(roleHierarchyUp.get(role)); } - @SuppressWarnings("unchecked") public SortedSet<ObjectProperty> getMoreSpecialRoles(ObjectProperty role) { - return (TreeSet<ObjectProperty>) roleHierarchyDown.get(role).clone(); - } + return new TreeSet<ObjectProperty>(roleHierarchyDown.get(role)); + } /** * Implements a subsumption check using the hierarchy (no further @@ -99,7 +94,7 @@ return str; } - private String toString(TreeMap<ObjectProperty,TreeSet<ObjectProperty>> hierarchy, ObjectProperty role, int depth) { + private String toString(TreeMap<ObjectProperty,SortedSet<ObjectProperty>> hierarchy, ObjectProperty role, int depth) { String str = ""; for(int i=0; i<depth; i++) str += " "; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -81,7 +81,7 @@ /** * This method computes (using the reasoner) whether a concept is too weak. - * If it is not weak, it returns the number of covered negative example. It + * If it is not weak, it returns the number of covered negative examples. It * can use retrieval or instance checks for classification. * * @see org.dllearner.learningproblems.PosNegLP.UseMultiInstanceChecks Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -268,22 +268,22 @@ * * TODO Does not yet take ignored roles into account. */ - public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { - TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - roleComparator); - TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - roleComparator); - - // Refinement atomarer Konzepte - for (ObjectProperty role : atomicRoles) { - roleHierarchyDown.put(role, getMoreSpecialRolesDIG(role)); - roleHierarchyUp.put(role, getMoreGeneralRolesDIG(role)); - } +// public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// +// // Refinement atomarer Konzepte +// for (ObjectProperty role : atomicRoles) { +// roleHierarchyDown.put(role, getMoreSpecialRolesDIG(role)); +// roleHierarchyUp.put(role, getMoreGeneralRolesDIG(role)); +// } +// +// roleHierarchy = new ObjectPropertyHierarchy(allowedRoles, roleHierarchyUp, +// roleHierarchyDown); +// } - roleHierarchy = new ObjectPropertyHierarchy(allowedRoles, roleHierarchyUp, - roleHierarchyDown); - } - // eigentlich müsste man klonen um sicherzustellen, dass der parent-Link // bei null bleibt; bei der aktuellen Implementierung ist der parent-Link // nicht immer null, was bei GP negative Auswirkungen haben könnte @@ -562,7 +562,8 @@ return resultsSet; } - private TreeSet<ObjectProperty> getMoreGeneralRolesDIG(ObjectProperty role) { + @Override + protected TreeSet<ObjectProperty> getSuperPropertiesImpl(ObjectProperty role) { String moreGeneralRolesDIG = asksPrefix; moreGeneralRolesDIG += "<rparents id=\"query_parents\">"; moreGeneralRolesDIG += "<ratom name=\"" + role.getName() + "\" />"; @@ -587,7 +588,8 @@ return resultsSet; } - private TreeSet<ObjectProperty> getMoreSpecialRolesDIG(ObjectProperty role) { + @Override + protected TreeSet<ObjectProperty> getSubPropertiesImpl(ObjectProperty role) { String moreSpecialRolesDIG = asksPrefix; moreSpecialRolesDIG += "<rchildren id=\"query_children\">"; moreSpecialRolesDIG += "<ratom name=\"" + role.getName() + "\" />"; Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -534,6 +534,26 @@ return intDatatypeProperties; } + @Override + protected SortedSet<Description> getSuperClassesImpl(Description concept) throws ReasoningMethodUnsupportedException { + return rc.getSuperClassesImpl(concept); + } + + @Override + protected SortedSet<Description> getSubClassesImpl(Description concept) throws ReasoningMethodUnsupportedException { + return rc.getSubClassesImpl(concept); + } + + @Override + protected SortedSet<ObjectProperty> getSuperPropertiesImpl(ObjectProperty role) throws ReasoningMethodUnsupportedException { + return rc.getSuperPropertiesImpl(role); + } + + @Override + protected SortedSet<ObjectProperty> getSubPropertiesImpl(ObjectProperty role) throws ReasoningMethodUnsupportedException { + return rc.getSubPropertiesImpl(role); + } + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -56,7 +56,6 @@ import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Nothing; import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.TypedConstant; import org.dllearner.core.owl.UntypedConstant; @@ -124,7 +123,7 @@ private ConceptComparator conceptComparator = new ConceptComparator(); private RoleComparator roleComparator = new RoleComparator(); // private ClassHierarchy subsumptionHierarchy; - private ObjectPropertyHierarchy roleHierarchy; +// private ObjectPropertyHierarchy roleHierarchy; private DatatypePropertyHierarchy datatypePropertyHierarchy; // private Set<Description> allowedConceptsInSubsumptionHierarchy; @@ -405,46 +404,46 @@ return ReasonerType.OWLAPI_PELLET; } - @Override - public ObjectPropertyHierarchy prepareRoleHierarchy() { - // code copied from DIG reasoner - - TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - roleComparator); - TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - roleComparator); - - // refinement of atomic concepts - for (ObjectProperty role : atomicRoles) { - roleHierarchyDown.put(role, getMoreSpecialRolesImpl(role)); - roleHierarchyUp.put(role, getMoreGeneralRolesImpl(role)); - } - - roleHierarchy = new ObjectPropertyHierarchy(atomicRoles, roleHierarchyUp, - roleHierarchyDown); - return roleHierarchy; - } +// @Override +// public ObjectPropertyHierarchy prepareRoleHierarchy() { +// // code copied from DIG reasoner +// +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// +// // refinement of atomic concepts +// for (ObjectProperty role : atomicRoles) { +// roleHierarchyDown.put(role, getMoreSpecialRolesImpl(role)); +// roleHierarchyUp.put(role, getMoreGeneralRolesImpl(role)); +// } +// +// roleHierarchy = new ObjectPropertyHierarchy(atomicRoles, roleHierarchyUp, +// roleHierarchyDown); +// return roleHierarchy; +// } /* (non-Javadoc) * @see org.dllearner.core.Reasoner#prepareRoleHierarchy(java.util.Set) */ - public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { - // code copied from DIG reasoner - - TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - roleComparator); - TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - roleComparator); - - // refinement of atomic concepts - for (ObjectProperty role : atomicRoles) { - roleHierarchyDown.put(role, getMoreSpecialRolesImpl(role)); - roleHierarchyUp.put(role, getMoreGeneralRolesImpl(role)); - } - - roleHierarchy = new ObjectPropertyHierarchy(allowedRoles, roleHierarchyUp, - roleHierarchyDown); - } +// public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { +// // code copied from DIG reasoner +// +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// +// // refinement of atomic concepts +// for (ObjectProperty role : atomicRoles) { +// roleHierarchyDown.put(role, getMoreSpecialRolesImpl(role)); +// roleHierarchyUp.put(role, getMoreGeneralRolesImpl(role)); +// } +// +// roleHierarchy = new ObjectPropertyHierarchy(allowedRoles, roleHierarchyUp, +// roleHierarchyDown); +// } // @Override // public ObjectPropertyHierarchy getRoleHierarchy() { @@ -508,7 +507,8 @@ return getFirstClasses(classes); } - private TreeSet<ObjectProperty> getMoreGeneralRolesImpl(ObjectProperty role) { + @Override + protected TreeSet<ObjectProperty> getSuperPropertiesImpl(ObjectProperty role) { Set<Set<OWLObjectProperty>> properties; try { properties = reasoner.getSuperProperties(getOWLAPIDescription(role)); @@ -519,7 +519,8 @@ return getFirstObjectProperties(properties); } - private TreeSet<ObjectProperty> getMoreSpecialRolesImpl(ObjectProperty role) { + @Override + protected TreeSet<ObjectProperty> getSubPropertiesImpl(ObjectProperty role) { Set<Set<OWLObjectProperty>> properties; try { properties = reasoner.getSubProperties(getOWLAPIDescription(role)); Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java 2008-11-11 17:06:49 UTC (rev 1508) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java 2008-11-12 12:07:48 UTC (rev 1509) @@ -21,10 +21,13 @@ import java.util.Collection; import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.owl.Description; /** * A set of evaluated descriptions, which is bound by a maximum @@ -68,4 +71,11 @@ return set; } + public List<Description> toDescriptionList() { + List<Description> list = new LinkedList<Description>(); + for(EvaluatedDescription ed : set) { + list.add(ed.getDescription()); + } + return list; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |