|
From: <jen...@us...> - 2011-04-01 09:38:17
|
Revision: 2743
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2743&view=rev
Author: jenslehmann
Date: 2011-04-01 09:38:11 +0000 (Fri, 01 Apr 2011)
Log Message:
-----------
continued design of learning algorithm interfaces, including better support for active learning
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/OCEL.java
trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java
trunk/components-core/src/main/java/org/dllearner/core/ClassExpressionLearningAlgorithm.java
trunk/components-core/src/main/java/org/dllearner/core/FuzzyClassExpressionLearningAlgorithm.java
trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java
trunk/components-core/src/main/java/org/dllearner/core/SparqlQueryLearningAlgorithm.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/core/ActiveLearningAlgorithm.java
trunk/components-core/src/main/java/org/dllearner/core/Oracle.java
trunk/components-core/src/main/java/org/dllearner/core/ResumableLearningAlgorithm.java
trunk/components-core/src/main/java/org/dllearner/core/StoppableLearningAlgorithm.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java 2011-03-31 06:40:53 UTC (rev 2742)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -308,24 +308,6 @@
}
/* (non-Javadoc)
- * @see org.dllearner.core.LearningAlgorithm#pause()
- */
- @Override
- public void pause() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.dllearner.core.LearningAlgorithm#resume()
- */
- @Override
- public void resume() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
* @see org.dllearner.core.LearningAlgorithm#isRunning()
*/
@Override
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/OCEL.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/OCEL.java 2011-03-31 06:40:53 UTC (rev 2742)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/OCEL.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -487,18 +487,6 @@
return algorithm.getStartNode();
}
- /** {@inheritDoc} */
- @Override
- public void pause() {
- // TODO: not implemented
- }
-
- /** {@inheritDoc} */
- @Override
- public void resume() {
- // TODO: not implemented
- }
-
/* (non-Javadoc)
* @see org.dllearner.core.LearningAlgorithm#isRunning()
*/
Modified: trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java 2011-03-31 06:40:53 UTC (rev 2742)
+++ trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -39,10 +39,14 @@
* may require addition reasoner queries, because the learning
* algorithms usually use but do not necessarily store this information.
*
+ * Changes (March/April 2011): Learning algorithms no longer have to use
+ * this class, but it still serves as a prototypical template for class
+ * expression learning algorithms.
+ *
* @author Jens Lehmann
*
*/
-public abstract class AbstractCELA extends Component {
+public abstract class AbstractCELA extends Component implements ClassExpressionLearningAlgorithm, StoppableLearningAlgorithm {
/**
* The learning problem variable, which must be used by
@@ -102,43 +106,8 @@
* choose to store results.)
*/
public static final int MAX_NR_OF_RESULTS = 100;
-
+
/**
- * Starts the algorithm. It runs until paused, stopped, or
- * a termination criterion has been reached.
- */
- public abstract void start();
-
- /**
- * Pauses the algorithm (not all algorithms need to implement
- * this operation).
- */
- public void pause() { };
-
- /**
- * Resumes the algorithm (not all algorithms need to implement
- * this operation). You can use this method to continue
- * an algorithm run even after a termination criterion has been
- * reached. It will run until paused, stopped, or terminated
- * again.
- */
- public void resume() { };
-
- /**
- * Stops the algorithm gracefully. A stopped algorithm cannot be resumed anymore.
- * Use this method for cleanup and freeing memory.
- */
- public abstract void stop();
-
- /**
- * Returns whether the learning algorithm is running. Implementation
- * should use a boolean status variable in their implementations of
- * the start and resume methods.
- * @return True if the algorithm is running, false otherwise.
- */
- public abstract boolean isRunning();
-
- /**
* Every algorithm must be able to return the score of the
* best solution found.
*
Added: trunk/components-core/src/main/java/org/dllearner/core/ActiveLearningAlgorithm.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/ActiveLearningAlgorithm.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/ActiveLearningAlgorithm.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -0,0 +1,38 @@
+/**
+ * Copyright (C) 2007-2011, 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;
+
+
+/**
+ * Active Learning algorithms are those, which can use feedback from an oracle.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public interface ActiveLearningAlgorithm {
+
+ /**
+ * In order to separate/hide the implementation of an oracle from the active learning algorithm itself,
+ * an oracle object is passed to the algorithm.
+ * @param oracle The oracle to be used by the learning algorithm.
+ */
+ public void setOracle(Oracle oracle);
+
+}
Modified: trunk/components-core/src/main/java/org/dllearner/core/ClassExpressionLearningAlgorithm.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/ClassExpressionLearningAlgorithm.java 2011-03-31 06:40:53 UTC (rev 2742)
+++ trunk/components-core/src/main/java/org/dllearner/core/ClassExpressionLearningAlgorithm.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -19,6 +19,10 @@
*/
package org.dllearner.core;
+import java.util.List;
+
+import org.dllearner.core.owl.Description;
+
/**
* Basic interface for algorithms learning OWL/DL class expressions.
*
@@ -27,4 +31,19 @@
*/
public interface ClassExpressionLearningAlgorithm extends LearningAlgorithm {
+ /**
+ * @see #getCurrentlyBestEvaluatedDescriptions(int)
+ * @param nrOfDescriptions Limit for the number or returned descriptions.
+ * @return The best class descriptions found by the learning algorithm so far.
+ */
+ public List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions);
+
+ /**
+ * Return the best currently found concepts up to some maximum
+ * count (no minimality filter used).
+ * @param nrOfDescriptions Maximum number of descriptions returned.
+ * @return Return value is getCurrentlyBestDescriptions(nrOfDescriptions, 0.0, false).
+ */
+ public List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(int nrOfDescriptions);
+
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/FuzzyClassExpressionLearningAlgorithm.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/FuzzyClassExpressionLearningAlgorithm.java 2011-03-31 06:40:53 UTC (rev 2742)
+++ trunk/components-core/src/main/java/org/dllearner/core/FuzzyClassExpressionLearningAlgorithm.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -19,12 +19,33 @@
*/
package org.dllearner.core;
+import java.util.List;
+
+import org.dllearner.core.owl.Description;
+
/**
* Basic interface for algorithms learning fuzzy OWL/DL class expressions.
*
+ * TODO: Probably needs to be adapted.
+ *
* @author Jens Lehmann
*
*/
public interface FuzzyClassExpressionLearningAlgorithm extends LearningAlgorithm {
+ /**
+ * @see #getCurrentlyBestEvaluatedDescriptions(int)
+ * @param nrOfDescriptions Limit for the number or returned descriptions.
+ * @return The best class descriptions found by the learning algorithm so far.
+ */
+ public List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions);
+
+ /**
+ * Return the best currently found concepts up to some maximum
+ * count (no minimality filter used).
+ * @param nrOfDescriptions Maximum number of descriptions returned.
+ * @return Return value is getCurrentlyBestDescriptions(nrOfDescriptions, 0.0, false).
+ */
+ public List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(int nrOfDescriptions);
+
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java 2011-03-31 06:40:53 UTC (rev 2742)
+++ trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -19,6 +19,7 @@
*/
package org.dllearner.core;
+
/**
* Basic interface for all DL-Learner learning algorithms.
*
@@ -27,4 +28,10 @@
*/
public interface LearningAlgorithm {
+ /**
+ * Starts the algorithm. It runs until paused, stopped, or
+ * a termination criterion has been reached.
+ */
+ public abstract void start();
+
}
Added: trunk/components-core/src/main/java/org/dllearner/core/Oracle.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/Oracle.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/Oracle.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -0,0 +1,65 @@
+/**
+ * Copyright (C) 2007-2011, 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;
+
+import java.util.List;
+
+import org.dllearner.core.owl.Individual;
+
+/**
+ *
+ * An oracle can be used by a learning algorithm to interactively ask for the
+ * classification of an individual. Note that an oracle can either be a user or
+ * an automatic method, which means that the implementation of an oracle can
+ * reach from simple checks to more complex user interaction processes.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public interface Oracle {
+
+ /**
+ * This method should be called by a learning algorithm if it wants a list of individuals
+ * (including the special case of a single individual) to be classified by the oracle.
+ *
+ * For each of the individuals, which are specified in the parameter, the oracle must
+ * return a value in the obvious order. (The first element in the returned list classifies the first element
+ * of the list of individuals, the second element in the returned list classifies the
+ * second element of the individual list etc.) The following values should be used:
+ *
+ * <ul>
+ * <li>-1.0: Indicates that the individual does not belong to the learned class.</li>
+ * <li>Values between -1.0 and 1.0 indicate the degree to which an individual belongs to the class.</li>
+ * <li>1.0: The individual does belong to the learned class.</li>
+ * <li>-2.0: The oracle does not know how to classify the individual (e.g. no feedback given by a user).</li>
+ * </ul>
+ *
+ * Note that the most common case is that the individuals list contains a single element, which
+ * is answered by 1.0 or -1.0 by the oracle. However, the oracle interface is designed with a
+ * higher degree of flexibility in mind, which is required for some use cases.
+ *
+ * @param individuals A list of individuals, which should be classified by the oracle.
+ * @return For each element of the list, a classification value as explained above is
+ * returned.
+ *
+ */
+ public List<Double> classifyIndividuals(List<Individual> individuals);
+
+}
\ No newline at end of file
Added: trunk/components-core/src/main/java/org/dllearner/core/ResumableLearningAlgorithm.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/ResumableLearningAlgorithm.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/ResumableLearningAlgorithm.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -0,0 +1,45 @@
+/**
+ * Copyright (C) 2007-2011, 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;
+
+/**
+ * Interface for learning algorithms, which can be paused and later continued.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public interface ResumableLearningAlgorithm {
+
+ /**
+ * Pauses the algorithm (not all algorithms need to implement
+ * this operation).
+ */
+ public void pause();
+
+ /**
+ * Resumes the algorithm (not all algorithms need to implement
+ * this operation). You can use this method to continue
+ * an algorithm run even after a termination criterion has been
+ * reached. It will run until paused, stopped, or terminated
+ * again.
+ */
+ public void resume();
+
+}
Modified: trunk/components-core/src/main/java/org/dllearner/core/SparqlQueryLearningAlgorithm.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/SparqlQueryLearningAlgorithm.java 2011-03-31 06:40:53 UTC (rev 2742)
+++ trunk/components-core/src/main/java/org/dllearner/core/SparqlQueryLearningAlgorithm.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -19,12 +19,24 @@
*/
package org.dllearner.core;
+import java.util.List;
+
/**
* Basic interface for algorithms learning SPARQL queries.
*
+ * TODO: Check whether it is necessary to have a "real" SPARQL query class instead of
+ * only a string.
+ *
* @author Jens Lehmann
*
*/
public interface SparqlQueryLearningAlgorithm extends LearningAlgorithm {
+ /**
+ * @see #getCurrentlyBestEvaluatedDescriptions(int)
+ * @param nrOfDescriptions Limit for the number or returned descriptions.
+ * @return The best SPARQL queries found by the learning algorithm so far.
+ */
+ public List<String> getCurrentlyBestDescriptions(int nrOfDescriptions);
+
}
Added: trunk/components-core/src/main/java/org/dllearner/core/StoppableLearningAlgorithm.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/StoppableLearningAlgorithm.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/StoppableLearningAlgorithm.java 2011-04-01 09:38:11 UTC (rev 2743)
@@ -0,0 +1,47 @@
+/**
+ * Copyright (C) 2007-2011, 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;
+
+/**
+ *
+ * Interface for algorithms, which can be stopped and checked whether they are
+ * running. This allows learning algorithms to be run in separate threads or
+ * be terminated by the user.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public interface StoppableLearningAlgorithm extends LearningAlgorithm {
+
+ /**
+ * Stops the algorithm gracefully. A stopped algorithm cannot be resumed anymore.
+ * Use this method for cleanup and freeing memory.
+ */
+ public abstract void stop();
+
+ /**
+ * Returns whether the learning algorithm is running. Implementation
+ * should use a boolean status variable in their implementations of
+ * the start and resume methods.
+ * @return True if the algorithm is running, false otherwise.
+ */
+ public abstract boolean isRunning();
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2011-04-06 07:07:27
|
Revision: 2758
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2758&view=rev
Author: jenslehmann
Date: 2011-04-06 07:07:20 +0000 (Wed, 06 Apr 2011)
Log Message:
-----------
added option to allow/ignore classes in CELOE
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/CELOEConfigurator.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/ISLEConfigurator.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/OCELConfigurator.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2011-04-05 17:03:24 UTC (rev 2757)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2011-04-06 07:07:20 UTC (rev 2758)
@@ -38,6 +38,7 @@
import org.dllearner.core.ReasonerComponent;
import org.dllearner.core.configurators.CELOEConfigurator;
import org.dllearner.core.options.BooleanConfigOption;
+import org.dllearner.core.options.CommonConfigMappings;
import org.dllearner.core.options.CommonConfigOptions;
import org.dllearner.core.options.ConfigOption;
import org.dllearner.core.options.DoubleConfigOption;
@@ -183,7 +184,9 @@
options.add(new BooleanConfigOption("writeSearchTree", "specifies whether to write a search tree", false));
options.add(new StringConfigOption("searchTreeFile","file to use for the search tree", "log/searchTree.txt"));
options.add(new BooleanConfigOption("replaceSearchTree","specifies whether to replace the search tree in the log file after each run or append the new search tree", false));
- options.add(new DoubleConfigOption("expansionPenaltyFactor","heuristic penalty per syntactic construct used (lower = finds more complex expression, but might miss simple ones)", 0.1));
+ options.add(new DoubleConfigOption("expansionPenaltyFactor","heuristic penalty per syntactic construct used (lower = finds more complex expression, but might miss simple ones)", 0.1));
+ options.add(CommonConfigOptions.allowedConcepts());
+ options.add(CommonConfigOptions.ignoredConcepts());
return options;
}
@@ -193,9 +196,26 @@
@Override
public void init() throws ComponentInitException {
+
+ // compute used concepts/roles from allowed/ignored
+ // concepts/roles
+ Set<NamedClass> usedConcepts;
+ Set<NamedClass> allowedConcepts = CommonConfigMappings.getAtomicConceptSet(configurator.getAllowedConcepts());
+ Set<NamedClass> ignoredConcepts = CommonConfigMappings.getAtomicConceptSet(configurator.getIgnoredConcepts());
+ if(allowedConcepts != null) {
+ // sanity check to control if no non-existing concepts are in the list
+ Helper.checkConcepts(reasoner, allowedConcepts);
+ usedConcepts = allowedConcepts;
+ } else if(ignoredConcepts != null) {
+ usedConcepts = Helper.computeConceptsUsingIgnoreList(reasoner, ignoredConcepts);
+ } else {
+ usedConcepts = Helper.computeConcepts(reasoner);
+ }
+
// copy class hierarchy and modify it such that each class is only
// reachable via a single path
- ClassHierarchy classHierarchy = reasoner.getClassHierarchy().clone();
+// ClassHierarchy classHierarchy = reasoner.getClassHierarchy().clone();
+ ClassHierarchy classHierarchy = reasoner.getClassHierarchy().cloneAndRestrict(usedConcepts);
classHierarchy.thinOutSubsumptionHierarchy();
heuristic = new OEHeuristicRuntime(configurator);
Modified: trunk/components-core/src/main/java/org/dllearner/core/configurators/CELOEConfigurator.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/configurators/CELOEConfigurator.java 2011-04-05 17:03:24 UTC (rev 2757)
+++ trunk/components-core/src/main/java/org/dllearner/core/configurators/CELOEConfigurator.java 2011-04-06 07:07:20 UTC (rev 2758)
@@ -20,6 +20,7 @@
package org.dllearner.core.configurators;
+import java.util.Set;
import org.dllearner.algorithms.celoe.CELOE;
import org.dllearner.core.ComponentManager;
import org.dllearner.core.LearningProblem;
@@ -137,7 +138,7 @@
return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useBooleanDatatypes") ;
}
/**
-* useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm.
+* useDoubleDatatypes specifies whether double datatypes are used in the learning algorothm.
* mandatory: false| reinit necessary: true
* default value: true
* @return boolean
@@ -271,6 +272,26 @@
public double getExpansionPenaltyFactor() {
return (Double) ComponentManager.getInstance().getConfigOptionValue(cELOE, "expansionPenaltyFactor") ;
}
+/**
+* allowedConcepts concepts the algorithm is allowed to use.
+* mandatory: false| reinit necessary: true
+* default value: null
+* @return Set(String)
+**/
+@SuppressWarnings("unchecked")
+public Set<String> getAllowedConcepts() {
+return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(cELOE, "allowedConcepts") ;
+}
+/**
+* ignoredConcepts concepts the algorithm must ignore.
+* mandatory: false| reinit necessary: true
+* default value: null
+* @return Set(String)
+**/
+@SuppressWarnings("unchecked")
+public Set<String> getIgnoredConcepts() {
+return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(cELOE, "ignoredConcepts") ;
+}
/**
* @param useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm.
@@ -354,7 +375,7 @@
reinitNecessary = true;
}
/**
-* @param useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm.
+* @param useDoubleDatatypes specifies whether double datatypes are used in the learning algorothm.
* mandatory: false| reinit necessary: true
* default value: true
**/
@@ -488,6 +509,24 @@
ComponentManager.getInstance().applyConfigEntry(cELOE, "expansionPenaltyFactor", expansionPenaltyFactor);
reinitNecessary = true;
}
+/**
+* @param allowedConcepts concepts the algorithm is allowed to use.
+* mandatory: false| reinit necessary: true
+* default value: null
+**/
+public void setAllowedConcepts(Set<String> allowedConcepts) {
+ComponentManager.getInstance().applyConfigEntry(cELOE, "allowedConcepts", allowedConcepts);
+reinitNecessary = true;
+}
+/**
+* @param ignoredConcepts concepts the algorithm must ignore.
+* mandatory: false| reinit necessary: true
+* default value: null
+**/
+public void setIgnoredConcepts(Set<String> ignoredConcepts) {
+ComponentManager.getInstance().applyConfigEntry(cELOE, "ignoredConcepts", ignoredConcepts);
+reinitNecessary = true;
+}
/**
* true, if this component needs reinitializsation.
Modified: trunk/components-core/src/main/java/org/dllearner/core/configurators/ISLEConfigurator.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/configurators/ISLEConfigurator.java 2011-04-05 17:03:24 UTC (rev 2757)
+++ trunk/components-core/src/main/java/org/dllearner/core/configurators/ISLEConfigurator.java 2011-04-06 07:07:20 UTC (rev 2758)
@@ -137,7 +137,7 @@
return (Boolean) ComponentManager.getInstance().getConfigOptionValue(iSLE, "useBooleanDatatypes") ;
}
/**
-* useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm.
+* useDoubleDatatypes specifies whether double datatypes are used in the learning algorothm.
* mandatory: false| reinit necessary: true
* default value: true
* @return boolean
@@ -300,7 +300,7 @@
reinitNecessary = true;
}
/**
-* @param useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm.
+* @param useDoubleDatatypes specifies whether double datatypes are used in the learning algorothm.
* mandatory: false| reinit necessary: true
* default value: true
**/
Modified: trunk/components-core/src/main/java/org/dllearner/core/configurators/OCELConfigurator.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/configurators/OCELConfigurator.java 2011-04-05 17:03:24 UTC (rev 2757)
+++ trunk/components-core/src/main/java/org/dllearner/core/configurators/OCELConfigurator.java 2011-04-06 07:07:20 UTC (rev 2758)
@@ -277,7 +277,7 @@
return (Boolean) ComponentManager.getInstance().getConfigOptionValue(oCEL, "useBooleanDatatypes") ;
}
/**
-* useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm.
+* useDoubleDatatypes specifies whether double datatypes are used in the learning algorothm.
* mandatory: false| reinit necessary: true
* default value: true
* @return boolean
@@ -647,7 +647,7 @@
reinitNecessary = true;
}
/**
-* @param useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm.
+* @param useDoubleDatatypes specifies whether double datatypes are used in the learning algorothm.
* mandatory: false| reinit necessary: true
* default value: true
**/
Modified: trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java 2011-04-05 17:03:24 UTC (rev 2757)
+++ trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java 2011-04-06 07:07:20 UTC (rev 2758)
@@ -75,7 +75,7 @@
return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(posNegLPStandard, "negativeExamples") ;
}
/**
-* useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept..
+* useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept. - NO LONGER FULLY SUPPORTED..
* mandatory: false| reinit necessary: true
* default value: false
* @return boolean
@@ -93,7 +93,7 @@
return (Double) ComponentManager.getInstance().getConfigOptionValue(posNegLPStandard, "percentPerLenghtUnit") ;
}
/**
-* useMultiInstanceChecks See UseMultiInstanceChecks enum..
+* useMultiInstanceChecks See UseMultiInstanceChecks enum. - NO LONGER FULLY SUPPORTED..
* mandatory: false| reinit necessary: true
* default value: twoChecks
* @return String
@@ -146,7 +146,7 @@
ComponentManager.getInstance().applyConfigEntry(posNegLPStandard, "negativeExamples", negativeExamples);
}
/**
-* @param useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept..
+* @param useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept. - NO LONGER FULLY SUPPORTED..
* mandatory: false| reinit necessary: true
* default value: false
**/
@@ -164,7 +164,7 @@
reinitNecessary = true;
}
/**
-* @param useMultiInstanceChecks See UseMultiInstanceChecks enum..
+* @param useMultiInstanceChecks See UseMultiInstanceChecks enum. - NO LONGER FULLY SUPPORTED..
* mandatory: false| reinit necessary: true
* default value: twoChecks
**/
Modified: trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java 2011-04-05 17:03:24 UTC (rev 2757)
+++ trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java 2011-04-06 07:07:20 UTC (rev 2758)
@@ -75,7 +75,7 @@
return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(posNegLPStrict, "negativeExamples") ;
}
/**
-* useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept..
+* useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept. - NO LONGER FULLY SUPPORTED..
* mandatory: false| reinit necessary: true
* default value: false
* @return boolean
@@ -93,7 +93,7 @@
return (Double) ComponentManager.getInstance().getConfigOptionValue(posNegLPStrict, "percentPerLenghtUnit") ;
}
/**
-* useMultiInstanceChecks See UseMultiInstanceChecks enum..
+* useMultiInstanceChecks See UseMultiInstanceChecks enum. - NO LONGER FULLY SUPPORTED..
* mandatory: false| reinit necessary: true
* default value: twoChecks
* @return String
@@ -146,7 +146,7 @@
ComponentManager.getInstance().applyConfigEntry(posNegLPStrict, "negativeExamples", negativeExamples);
}
/**
-* @param useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept..
+* @param useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept. - NO LONGER FULLY SUPPORTED..
* mandatory: false| reinit necessary: true
* default value: false
**/
@@ -164,7 +164,7 @@
reinitNecessary = true;
}
/**
-* @param useMultiInstanceChecks See UseMultiInstanceChecks enum..
+* @param useMultiInstanceChecks See UseMultiInstanceChecks enum. - NO LONGER FULLY SUPPORTED..
* mandatory: false| reinit necessary: true
* default value: twoChecks
**/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-07-26 11:37:47
|
Revision: 2966
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2966&view=rev
Author: lorenz_b
Date: 2011-07-26 11:37:41 +0000 (Tue, 26 Jul 2011)
Log Message:
-----------
Some changes for better integration of QTL algorithm into DL-Learner.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java
trunk/components-core/src/main/java/org/dllearner/core/LearningProblemUnsupportedException.java
trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java
trunk/components-core/src/main/java/org/dllearner/learningproblems/PosOnlyLP.java
Modified: trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-07-26 11:37:28 UTC (rev 2965)
+++ trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-07-26 11:37:41 UTC (rev 2966)
@@ -106,8 +106,8 @@
"org.dllearner.algorithms.el.ELLearningAlgorithmDisjunctive",
"org.dllearner.algorithms.celoe.CELOE",
"org.dllearner.algorithms.fuzzydll.FuzzyCELOE", //added by Josue
- "org.dllearner.algorithms.isle.ISLE"
-
+ "org.dllearner.algorithms.isle.ISLE",
+ "org.dllearner.algorithm.qtl.QTL"
} ));
private static ComponentManager cm = null;
@@ -308,6 +308,10 @@
logger.warn("Warning: unregistered component " + component);
}
}
+
+ public ComponentPool getPool() {
+ return pool;
+ }
/**
* Applies a config entry to a component. If the entry is not valid, the method
Modified: trunk/components-core/src/main/java/org/dllearner/core/LearningProblemUnsupportedException.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/LearningProblemUnsupportedException.java 2011-07-26 11:37:28 UTC (rev 2965)
+++ trunk/components-core/src/main/java/org/dllearner/core/LearningProblemUnsupportedException.java 2011-07-26 11:37:41 UTC (rev 2966)
@@ -33,12 +33,12 @@
private static final long serialVersionUID = 177919265073997460L;
- public LearningProblemUnsupportedException(Class<? extends LearningProblem> problemClass, Class<? extends AbstractCELA> algorithmClass) {
+ public LearningProblemUnsupportedException(Class<? extends LearningProblem> problemClass, Class<? extends LearningAlgorithm> algorithmClass) {
super("Warning: No suitable constructor registered for algorithm "
+ algorithmClass.getName() + " and problem " + problemClass.getClass().getName() + ".");
}
- public LearningProblemUnsupportedException(Class<? extends LearningProblem> problemClass, Class<? extends AbstractCELA> algorithmClass, Collection<Class<? extends LearningProblem>> supportedProblems) {
+ public LearningProblemUnsupportedException(Class<? extends LearningProblem> problemClass, Class<? extends LearningAlgorithm> algorithmClass, Collection<Class<? extends LearningProblem>> supportedProblems) {
super("Warning: No suitable constructor registered for algorithm "
+ algorithmClass.getName() + " and problem " + problemClass.getClass().getName()
+ ". Registered constructors for " + algorithmClass.getName() + ": "
Modified: trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java 2011-07-26 11:37:28 UTC (rev 2965)
+++ trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java 2011-07-26 11:37:41 UTC (rev 2966)
@@ -71,5 +71,9 @@
@Override
public void init() throws ComponentInitException {
}
+
+ public SparqlEndpoint getEndpoint() {
+ return endpoint;
+ }
}
Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/PosOnlyLP.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/learningproblems/PosOnlyLP.java 2011-07-26 11:37:28 UTC (rev 2965)
+++ trunk/components-core/src/main/java/org/dllearner/learningproblems/PosOnlyLP.java 2011-07-26 11:37:41 UTC (rev 2966)
@@ -65,6 +65,7 @@
public PosOnlyLP() {
super(null);
+ configurator = new PosOnlyLPConfigurator(this);
}
public PosOnlyLP(ReasonerComponent reasoningService) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-07-27 09:22:11
|
Revision: 2969
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2969&view=rev
Author: lorenz_b
Date: 2011-07-27 09:22:02 +0000 (Wed, 27 Jul 2011)
Log Message:
-----------
Started new learning algorithms for property axioms.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,53 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.kb.SparqlEndpointKS;
+
+public class DisjointPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
+
+ @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
+ private String propertyToDescribe;
+
+ public String getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(String propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public DisjointPropertyAxiomLearner(SparqlEndpointKS ks){
+
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,53 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.kb.SparqlEndpointKS;
+
+public class EquivalentPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
+
+ @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
+ private String propertyToDescribe;
+
+ public String getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(String propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public EquivalentPropertyAxiomLearner(SparqlEndpointKS ks){
+
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,53 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.kb.SparqlEndpointKS;
+
+public class FunctionalPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
+
+ @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
+ private String propertyToDescribe;
+
+ public String getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(String propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public FunctionalPropertyAxiomLearner(SparqlEndpointKS ks){
+
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,53 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.kb.SparqlEndpointKS;
+
+public class PropertyDomainAxiomLearner extends Component implements AxiomLearningAlgorithm {
+
+ @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
+ private String propertyToDescribe;
+
+ public String getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(String propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public PropertyDomainAxiomLearner(SparqlEndpointKS ks){
+
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,53 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.kb.SparqlEndpointKS;
+
+public class PropertyRangeAxiomLearner extends Component implements AxiomLearningAlgorithm {
+
+ @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
+ private String propertyToDescribe;
+
+ public String getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(String propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public PropertyRangeAxiomLearner(SparqlEndpointKS ks){
+
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,53 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.kb.SparqlEndpointKS;
+
+public class ReflexivePropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
+
+ @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
+ private String propertyToDescribe;
+
+ public String getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(String propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public ReflexivePropertyAxiomLearner(SparqlEndpointKS ks){
+
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,53 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.kb.SparqlEndpointKS;
+
+public class SubPropertyOfAxiomLearner extends Component implements AxiomLearningAlgorithm {
+
+ @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
+ private String propertyToDescribe;
+
+ public String getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(String propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public SubPropertyOfAxiomLearner(SparqlEndpointKS ks){
+
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,53 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.kb.SparqlEndpointKS;
+
+public class SymmetricPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
+
+ @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
+ private String propertyToDescribe;
+
+ public String getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(String propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public SymmetricPropertyAxiomLearner(SparqlEndpointKS ks){
+
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,53 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.kb.SparqlEndpointKS;
+
+public class TransitivePropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
+
+ @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
+ private String propertyToDescribe;
+
+ public String getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(String propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public TransitivePropertyAxiomLearner(SparqlEndpointKS ks){
+
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -0,0 +1,15 @@
+package org.dllearner.core;
+
+import java.util.List;
+
+import org.dllearner.core.owl.Axiom;
+
+public interface AxiomLearningAlgorithm extends LearningAlgorithm {
+
+ /**
+ * @param nrOfAxioms Limit for the number or returned axioms.
+ * @return The best axiom found by the learning algorithm so far.
+ */
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms);
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-07-27 04:46:43 UTC (rev 2968)
+++ trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-07-27 09:22:02 UTC (rev 2969)
@@ -107,7 +107,8 @@
"org.dllearner.algorithms.celoe.CELOE",
"org.dllearner.algorithms.fuzzydll.FuzzyCELOE", //added by Josue
"org.dllearner.algorithms.isle.ISLE",
- "org.dllearner.algorithm.qtl.QTL"
+ "org.dllearner.algorithm.qtl.QTL",
+ "org.dllearner.algorithms.properties.SubPropertyOfAxiomLearner"
} ));
private static ComponentManager cm = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-07-28 08:30:47
|
Revision: 2971
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2971&view=rev
Author: lorenz_b
Date: 2011-07-28 08:30:40 +0000 (Thu, 28 Jul 2011)
Log Message:
-----------
Continued reasoner for SPARQL endpoints.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/core/config/
trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java
trunk/components-core/src/main/java/org/dllearner/core/config/IntegerEditor.java
trunk/components-core/src/main/java/org/dllearner/core/config/ObjectPropertyEditor.java
trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -11,7 +11,6 @@
public class DisjointPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
- @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
private String propertyToDescribe;
public String getPropertyToDescribe() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -11,7 +11,6 @@
public class EquivalentPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
- @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
private String propertyToDescribe;
public String getPropertyToDescribe() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -11,7 +11,6 @@
public class FunctionalPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
- @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
private String propertyToDescribe;
public String getPropertyToDescribe() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -11,7 +11,6 @@
public class PropertyDomainAxiomLearner extends Component implements AxiomLearningAlgorithm {
- @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
private String propertyToDescribe;
public String getPropertyToDescribe() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -11,7 +11,6 @@
public class PropertyRangeAxiomLearner extends Component implements AxiomLearningAlgorithm {
- @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
private String propertyToDescribe;
public String getPropertyToDescribe() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -11,7 +11,6 @@
public class ReflexivePropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
- @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
private String propertyToDescribe;
public String getPropertyToDescribe() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -1,29 +1,36 @@
package org.dllearner.algorithms.properties;
+import java.beans.PropertyEditor;
+import java.lang.reflect.Field;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.SparqlEndpoint;
+import org.springframework.beans.propertyeditors.CustomNumberEditor;
public class SubPropertyOfAxiomLearner extends Component implements AxiomLearningAlgorithm {
- @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
- private String propertyToDescribe;
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
+ private ObjectProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds;
- public String getPropertyToDescribe() {
- return propertyToDescribe;
- }
-
- public void setPropertyToDescribe(String propertyToDescribe) {
- this.propertyToDescribe = propertyToDescribe;
- }
-
+
+ private SparqlEndpointKS ks;
+
public SubPropertyOfAxiomLearner(SparqlEndpointKS ks){
-
+ this.ks = ks;
}
@Override
@@ -50,4 +57,42 @@
}
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public ObjectProperty getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public static void main(String[] args) throws Exception{
+ Map<String, String> propertiesMap = new HashMap<String, String>();
+ propertiesMap.put("propertyToDescribe", "http://dbpedia.org/ontology/locatedIn");
+ propertiesMap.put("maxExecutionTimeInSeconds", "20");
+
+ SubPropertyOfAxiomLearner l = new SubPropertyOfAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW()));
+
+ Field[] fields = l.getClass().getDeclaredFields();
+ for(Field f : fields){
+ ConfigOption option = f.getAnnotation(ConfigOption.class);
+ if(option != null){
+ String configValue = propertiesMap.get(option.name());
+ PropertyEditor editor = (PropertyEditor) option.propertyEditorClass().newInstance();
+ editor.setAsText(configValue);
+ f.set(l, editor.getValue());
+ }
+ }
+
+ System.out.println(l.getPropertyToDescribe());
+ System.out.println(l.getMaxExecutionTimeInSeconds());
+ }
+
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -11,7 +11,6 @@
public class SymmetricPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
- @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
private String propertyToDescribe;
public String getPropertyToDescribe() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -11,7 +11,6 @@
public class TransitivePropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
- @org.dllearner.ConfigOption(name="propertyToDescribe", description="property of which a axiom should be learned")
private String propertyToDescribe;
public String getPropertyToDescribe() {
Added: trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -0,0 +1,36 @@
+package org.dllearner.core.config;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Chris
+ * Date: 7/26/11
+ * Time: 8:55 PM
+ *
+ * This is an example annotation class allowing one to configure a field with a name, description, and corresponding property editor.
+ *
+ * Note: Only put this on Setters that take the actual object you want to end up with as the example expects it to be on the setter
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ConfigOption {
+
+ /**
+ * The name of this config option.
+ * @return The name of this config option.
+ */
+ String name();
+
+ /**
+ * The description of this config option
+ * @return
+ */
+ String description();
+
+ /**
+ * An implementation of the Property Editor to use
+ * @return
+ */
+ Class propertyEditorClass();
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/core/config/IntegerEditor.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/config/IntegerEditor.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/config/IntegerEditor.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -0,0 +1,82 @@
+package org.dllearner.core.config;
+
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyEditor;
+
+public class IntegerEditor implements PropertyEditor {
+
+ private Integer value;
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getAsText() {
+ return value.toString();
+ }
+
+ @Override
+ public Component getCustomEditor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getJavaInitializationString() {
+ return value.toString();
+ }
+
+ @Override
+ public String[] getTags() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean isPaintable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void paintValue(Graphics gfx, Rectangle box) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setAsText(String text) throws IllegalArgumentException {
+ value = Integer.valueOf(text);
+
+ }
+
+ @Override
+ public void setValue(Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean supportsCustomEditor() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/core/config/IntegerEditor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/core/config/ObjectPropertyEditor.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/config/ObjectPropertyEditor.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/config/ObjectPropertyEditor.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -0,0 +1,88 @@
+package org.dllearner.core.config;
+
+import org.dllearner.core.owl.ObjectProperty;
+
+import java.awt.*;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyEditor;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Chris
+ * Date: 7/26/11
+ * Time: 9:42 PM
+ * <p/>
+ * Basic Property Editor for the Object Property DL-Learner class. Doesn't have GUI support yet but we could add that later if we wanted.
+ */
+public class ObjectPropertyEditor implements PropertyEditor {
+
+
+ private ObjectProperty value;
+
+ @Override
+ public void setValue(Object value) {
+ this.value = (ObjectProperty) value;
+ }
+
+ @Override
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean isPaintable() {
+ /** Not right now, we're doing non gui work */
+ return false;
+ }
+
+ @Override
+ public void paintValue(Graphics gfx, Rectangle box) {
+
+ }
+
+ @Override
+ public String getJavaInitializationString() {
+ /** This returns the value needed to reconstitute the object from a string */
+ return value.getName();
+ }
+
+ @Override
+ public String getAsText() {
+ /** Get the text value of this object - for displaying in GUIS, etc */
+ return value.getName();
+ }
+
+ @Override
+ public void setAsText(String text) throws IllegalArgumentException {
+ value = new ObjectProperty(text);
+ }
+
+ @Override
+ public String[] getTags() {
+ /** If there was a known set of values it had to have, we could add that list here */
+ return new String[0];
+ }
+
+ @Override
+ public Component getCustomEditor() {
+ /** GUI stuff, if you wanted to edit it a custom way */
+ return null;
+ }
+
+ @Override
+ public boolean supportsCustomEditor() {
+ /** We don't support this right now, but maybe later */
+ return false;
+
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ /** More gui stuff, we don't need this for our basic example */
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ /** More gui stuff, we don't need this for our basic example */
+ }
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/core/config/ObjectPropertyEditor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -0,0 +1,22 @@
+package org.dllearner.core.config;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Chris
+ * Date: 7/26/11
+ * Time: 10:17 PM
+ * <p/>
+ * Making a basic extension so I can get a default constructor so that using reflection is simpler.
+ *
+ * I'm extending a Spring provided class for this.
+ */
+public class OurStringTrimmerEditor extends org.springframework.beans.propertyeditors.StringTrimmerEditor {
+
+
+ /**
+ * Default Constructor
+ */
+ public OurStringTrimmerEditor() {
+ super(true);
+ }
+}
Property changes on: trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2011-07-27 14:33:14 UTC (rev 2970)
+++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2011-07-28 08:30:40 UTC (rev 2971)
@@ -1,8 +1,11 @@
package org.dllearner.reasoning;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -16,17 +19,21 @@
import org.dllearner.core.owl.DatatypePropertyHierarchy;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
+import org.dllearner.core.owl.Intersection;
import org.dllearner.core.owl.NamedClass;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ObjectPropertyHierarchy;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.utilities.datastructures.SortedSetTuple;
+import com.clarkparsia.owlapiv3.XSD;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDF;
+import com.hp.hpl.jena.vocabulary.RDFS;
public class SPARQLReasoner implements SchemaReasoner, IndividualReasoner{
@@ -138,8 +145,30 @@
@Override
public Map<Individual, SortedSet<Individual>> getPropertyMembers(ObjectProperty objectProperty) {
- // TODO Auto-generated method stub
- return null;
+ Map<Individual, SortedSet<Individual>> subject2objects = new HashMap<Individual, SortedSet<Individual>>();
+ String query = String.format("select ?s ?o WHERE {" +
+ "?s %s ?o." +
+ " FILTER(isIRI(?o))}",
+ inAngleBrackets(objectProperty.getName()));
+
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ Individual sub;
+ Individual obj;
+ SortedSet<Individual> objects;
+ while(rs.hasNext()){
+ qs = rs.next();
+ sub = new Individual(qs.getResource("s").getURI());
+ obj = new Individual(qs.getResource("o").getURI());
+ objects = subject2objects.get(sub);
+ if(objects == null){
+ objects = new TreeSet<Individual>();
+ subject2objects.put(sub, objects);
+ }
+ objects.add(obj);
+
+ }
+ return subject2objects;
}
@Override
@@ -150,32 +179,124 @@
@Override
public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) {
- // TODO Auto-generated method stub
- return null;
+ Map<Individual, SortedSet<Double>> subject2objects = new HashMap<Individual, SortedSet<Double>>();
+ String query = String.format("select ?s ?o WHERE {" +
+ "?s %s ?o." +
+ " FILTER(DATATYPE(?o) = %s)}",
+ inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.DOUBLE.toStringID()));
+
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ Individual sub;
+ Double obj;
+ SortedSet<Double> objects;
+ while(rs.hasNext()){
+ qs = rs.next();
+ sub = new Individual(qs.getResource("s").getURI());
+ obj = qs.getLiteral("o").getDouble();
+ objects = subject2objects.get(sub);
+ if(objects == null){
+ objects = new TreeSet<Double>();
+ subject2objects.put(sub, objects);
+ }
+ objects.add(obj);
+
+ }
+ return subject2objects;
}
@Override
public Map<Individual, SortedSet<Integer>> getIntDatatypeMembers(DatatypeProperty datatypeProperty) {
- // TODO Auto-generated method stub
- return null;
+ Map<Individual, SortedSet<Integer>> subject2objects = new HashMap<Individual, SortedSet<Integer>>();
+ String query = String.format("select ?s ?o WHERE {" +
+ "?s %s ?o." +
+ " FILTER(DATATYPE(?o) = %s)}",
+ inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.INT.toStringID()));
+
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ Individual sub;
+ Integer obj;
+ SortedSet<Integer> objects;
+ while(rs.hasNext()){
+ qs = rs.next();
+ sub = new Individual(qs.getResource("s").getURI());
+ obj = qs.getLiteral("o").getInt();
+ objects = subject2objects.get(sub);
+ if(objects == null){
+ objects = new TreeSet<Integer>();
+ subject2objects.put(sub, objects);
+ }
+ objects.add(obj);
+
+ }
+ return subject2objects;
}
@Override
public Map<Individual, SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty) {
- // TODO Auto-generated method stub
- return null;
+ Map<Individual, SortedSet<Boolean>> subject2objects = new HashMap<Individual, SortedSet<Boolean>>();
+ String query = String.format("select ?s ?o WHERE {" +
+ "?s %s ?o." +
+ " FILTER(DATATYPE(?o) = %s)}",
+ inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.BOOLEAN.toStringID()));
+
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ Individual sub;
+ Boolean obj;
+ SortedSet<Boolean> objects;
+ while(rs.hasNext()){
+ qs = rs.next();
+ sub = new Individual(qs.getResource("s").getURI());
+ obj = qs.getLiteral("o").getBoolean();
+ objects = subject2objects.get(sub);
+ if(objects == null){
+ objects = new TreeSet<Boolean>();
+ subject2objects.put(sub, objects);
+ }
+ objects.add(obj);
+
+ }
+ return subject2objects;
}
@Override
public SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) {
- // TODO Auto-generated method stub
- return null;
+ SortedSet<Individual> members = new TreeSet<Individual>();
+ String query = String.format("select ?ind WHERE {" +
+ "?ind %s ?o." +
+ " FILTER(isLiteral(?o) && DATATYPE(?o) = %s && ?o=%s)}",
+ inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.BOOLEAN.toStringID()),
+ "\"true\"^^"+inAngleBrackets(XSD.BOOLEAN.toStringID()));
+
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ while(rs.hasNext()){
+ qs = rs.next();
+ members.add(new Individual(qs.getResource("ind").getURI()));
+
+ }
+ return members;
}
@Override
public SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) {
- // TODO Auto-generated method stub
- return null;
+ SortedSet<Individual> members = new TreeSet<Individual>();
+ String query = String.format("select ?ind WHERE {" +
+ "?ind %s ?o." +
+ " FILTER(isLiteral(?o) && DATATYPE(?o) = %s && ?o=%s)}",
+ inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.BOOLEAN.toStringID()),
+ "\"false\"^^"+inAngleBrackets(XSD.BOOLEAN.toStringID()));
+
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ while(rs.hasNext()){
+ qs = rs.next();
+ members.add(new Individual(qs.getResource("ind").getURI()));
+
+ }
+ return members;
}
@Override
@@ -186,25 +307,75 @@
@Override
public Set<NamedClass> getInconsistentClasses() {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException();
}
@Override
public Description getDomain(ObjectProperty objectProperty) {
- // TODO Auto-generated method stub
+ String query = String.format("select ?domain WHERE {" +
+ "%s %s ?domain. FILTER(isIRI(?domain))" +
+ "}",
+ inAngleBrackets(objectProperty.getName()), inAngleBrackets(RDFS.domain.getURI()));
+
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ List<Description> domains = new ArrayList<Description>();
+ while(rs.hasNext()){
+ qs = rs.next();
+ domains.add(new NamedClass(qs.getResource("domain").getURI()));
+
+ }
+ if(domains.size() == 1){
+ return domains.get(0);
+ } else if(domains.size() > 1){
+ return new Intersection(domains);
+ }
return null;
}
@Override
public Description getDomain(DatatypeProperty datatypeProperty) {
- // TODO Auto-generated method stub
+ String query = String.format("select ?domain WHERE {" +
+ "%s %s ?domain. FILTER(isIRI(?domain))" +
+ "}",
+ inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(RDFS.domain.getURI()));
+
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ List<Description> domains = new ArrayList<Description>();
+ while(rs.hasNext()){
+ qs = rs.next();
+ domains.add(new NamedClass(qs.getResource("domain").getURI()));
+
+ }
+ if(domains.size() == 1){
+ return domains.get(0);
+ } else if(domains.size() > 1){
+ return new Intersection(domains);
+ }
return null;
}
@Override
public Description getRange(ObjectProperty objectProperty) {
- // TODO Auto-generated method stub
+ String query = String.format("select ?range WHERE {" +
+ "%s %s ?range. FILTER(isIRI(?range))" +
+ "}",
+ inAngleBrackets(objectProperty.getName()), inAngleBrackets(RDFS.range.getURI()));
+
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ List<Description> ranges = new ArrayList<Description>();
+ while(rs.hasNext()){
+ qs = rs.next();
+ ranges.add(new NamedClass(qs.getResource("range").getURI()));
+
+ }
+ if(ranges.size() == 1){
+ return ranges.get(0);
+ } else if(ranges.size() > 1){
+ return new Intersection(ranges);
+ }
return null;
}
@@ -312,6 +483,7 @@
}
private ResultSet executeQuery(String query){
+ System.out.println(query);
QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
queryExecution.addDefaultGraph(dgu);
@@ -338,5 +510,29 @@
private String inAngleBrackets(String s){
return "<" + s + ">";
}
+
+ public static void main(String[] args) {
+ String NS = "http://dbpedia.org/ontology/";
+ SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW());
+ SPARQLReasoner r = new SPARQLReasoner(ks);
+
+// ObjectProperty oP = new ObjectProperty(NS + "league");
+// for(Entry<Individual, SortedSet<Individual>> entry : r.getPropertyMembers(oP).entrySet()){
+// System.out.println(entry.getKey());
+// System.out.println(entry.getValue());
+// }
+//
+// DatatypeProperty dP = new DatatypeProperty(NS+ "areaLand");
+// for(Entry<Individual, SortedSet<Double>> entry : r.getDoubleDatatypeMembers(dP).entrySet()){
+// System.out.println(entry.getKey());
+// System.out.println(entry.getValue());
+// }
+
+ DatatypeProperty dP = new DatatypeProperty(NS+ "internationally");
+ for(Individual ind : r.getTrueDatatypeMembers(dP)){
+ System.out.println(ind);
+ }
+
+ }
}
This was sent by the SourceForge.net collaborative develop...
[truncated message content] |
|
From: <lor...@us...> - 2011-08-03 05:58:55
|
Revision: 2977
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2977&view=rev
Author: lorenz_b
Date: 2011-08-03 05:58:49 +0000 (Wed, 03 Aug 2011)
Log Message:
-----------
Continued new learning algorithm for PropertyDomainAxioms.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-08-02 12:45:11 UTC (rev 2976)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-08-03 05:58:49 UTC (rev 2977)
@@ -2,12 +2,17 @@
import java.beans.PropertyEditor;
import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedSet;
+import java.util.TreeSet;
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
@@ -21,6 +26,7 @@
import org.dllearner.core.owl.Individual;
import org.dllearner.core.owl.NamedClass;
import org.dllearner.core.owl.ObjectProperty;
+import org.dllearner.core.owl.ObjectPropertyDomainAxiom;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.reasoning.SPARQLReasoner;
@@ -38,11 +44,17 @@
@ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
private ObjectProperty propertyToDescribe;
@ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
- private int maxExecutionTimeInSeconds;
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
private SPARQLReasoner reasoner;
private SparqlEndpointKS ks;
+ private List<Axiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
public PropertyDomainAxiomLearner(SparqlEndpointKS ks){
this.ks = ks;
}
@@ -63,25 +75,44 @@
this.propertyToDescribe = propertyToDescribe;
}
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
+
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
+ }
+
@Override
public void start() {
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<Axiom>();
//get existing domains
Description existingDomain = reasoner.getDomain(propertyToDescribe);
logger.debug("Existing domain: " + existingDomain);
//get subjects with types
- Map<Individual, Set<NamedClass>> individual2Types = getSubjectsWithTypes();
-
- //get subjects of property
- Map<Individual, SortedSet<Individual>> members = reasoner.getPropertyMembers(propertyToDescribe);
-
-
+ Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>();
+ while(!terminationCriteriaSatisfied()){
+ individual2Types.putAll(getSubjectsWithTypes(fetchedRows));
+ currentlyBestAxioms = buildBestAxioms(individual2Types);
+ fetchedRows += 1000;
+ }
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
}
@Override
public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- // TODO Auto-generated method stub
- return null;
+ List<Axiom> bestAxioms = new ArrayList<Axiom>();
+
+ Iterator<Axiom> it = currentlyBestAxioms.iterator();
+ while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
+ bestAxioms.add(it.next());
+ }
+
+ return bestAxioms;
}
@Override
@@ -96,31 +127,68 @@
}
- private Map<Individual, Set<NamedClass>> getSubjectsWithTypes(){
- Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>();
- int limit = 1000;
- int offset = 135000;
- boolean executeAgain = true;
+ private boolean terminationCriteriaSatisfied(){
+ boolean timeLimitExceeded = maxExecutionTimeInSeconds == 0 ? false : (System.currentTimeMillis() - startTime) >= maxExecutionTimeInSeconds * 1000;
+ boolean resultLimitExceeded = maxFetchedRows == 0 ? false : fetchedRows >= maxFetchedRows;
+ return timeLimitExceeded || resultLimitExceeded;
+ }
+
+ private List<Axiom> buildBestAxioms(Map<Individual, Set<NamedClass>> individual2Types){
+ List<Axiom> axioms = new ArrayList<Axiom>();
+ Map<NamedClass, Integer> result = new HashMap<NamedClass, Integer>();
+ for(Entry<Individual, Set<NamedClass>> entry : individual2Types.entrySet()){
+ for(NamedClass nc : entry.getValue()){
+ Integer cnt = result.get(nc);
+ if(cnt == null){
+ cnt = Integer.valueOf(1);
+ }
+ result.put(nc, Integer.valueOf(cnt + 1));
+ }
+ }
- while(executeAgain){
- String query = String.format("SELECT ?ind ?type WHERE {?ind %s ?o. ?ind a ?type.} LIMIT %d OFFSET %d", inAngleBrackets(propertyToDescribe.getURI().toString()), limit, offset);
- ResultSet rs = executeQuery(query);
- QuerySolution qs;
- Individual ind;
- Set<NamedClass> types;
- executeAgain = rs.hasNext();
- while(executeAgain && rs.hasNext()){
- qs = rs.next();
- ind = new Individual(qs.getResource("ind").getURI());
- types = individual2Types.get(ind);
- if(types == null){
- types = new HashSet<NamedClass>();
+ for(Entry<NamedClass, Integer> entry : sortByValues(result)){
+ axioms.add(new ObjectPropertyDomainAxiom(propertyToDescribe, entry.getKey()));
+ }
+
+ return axioms;
+ }
+
+ private SortedSet<Entry<NamedClass, Integer>> sortByValues(Map<NamedClass, Integer> map){
+ SortedSet<Entry<NamedClass, Integer>> sortedSet = new TreeSet<Map.Entry<NamedClass,Integer>>(new Comparator<Entry<NamedClass, Integer>>() {
+
+ @Override
+ public int compare(Entry<NamedClass, Integer> value1, Entry<NamedClass, Integer> value2) {
+ if(value1.getValue() < value2.getValue()){
+ return 1;
+ } else if(value2.getValue() < value1.getValue()){
+ return -1;
+ } else {
+ return value1.getKey().compareTo(value2.getKey());
}
- types.add(new NamedClass(qs.getResource("type").getURI()));
}
- offset += 1000;
+ });
+ sortedSet.addAll(map.entrySet());
+ return sortedSet;
+ }
+
+ private Map<Individual, Set<NamedClass>> getSubjectsWithTypes(int offset){
+ Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>();
+ int limit = 1000;
+ String query = String.format("SELECT ?ind ?type WHERE {?ind %s ?o. ?ind a ?type.} LIMIT %d OFFSET %d", inAngleBrackets(propertyToDescribe.getURI().toString()), limit, offset);
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ Individual ind;
+ Set<NamedClass> types;
+ while(rs.hasNext()){
+ qs = rs.next();
+ ind = new Individual(qs.getResource("ind").getURI());
+ types = individual2Types.get(ind);
+ if(types == null){
+ types = new HashSet<NamedClass>();
+ individual2Types.put(ind, types);
+ }
+ types.add(new NamedClass(qs.getResource("type").getURI()));
}
-
return individual2Types;
}
@@ -146,6 +214,7 @@
Map<String, String> propertiesMap = new HashMap<String, String>();
propertiesMap.put("propertyToDescribe", "http://dbpedia.org/ontology/league");
propertiesMap.put("maxExecutionTimeInSeconds", "20");
+ propertiesMap.put("maxFetchedRows", "5000");
PropertyDomainAxiomLearner l = new PropertyDomainAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()));
@@ -162,6 +231,7 @@
l.init();
l.start();
+ System.out.println(l.getCurrentlyBestAxioms(3));
}
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java 2011-08-02 12:45:11 UTC (rev 2976)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java 2011-08-03 05:58:49 UTC (rev 2977)
@@ -27,7 +27,7 @@
@Override
public void start() {
- // TODO Auto-generated method stub
+ //select COUNT(?o),COUNT(?o2) WHERE {?s dbpedia-owl:influencedBy ?o. ?o dbpedia-owl:influencedBy ?o1. OPTIONAL{?s dbpedia-owl:influencedBy ?o1. ?s dbpedia-owl:influencedBy ?o2}}
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java 2011-08-02 12:45:11 UTC (rev 2976)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java 2011-08-03 05:58:49 UTC (rev 2977)
@@ -54,8 +54,7 @@
* @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map)
*/
public String toString(String baseURI, Map<String, String> prefixes) {
- // TODO Auto-generated method stub
- return null;
+ return "Domain(" + getProperty() + ", " + getDomain() + ")";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-03 13:54:34
|
Revision: 2979
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2979&view=rev
Author: lorenz_b
Date: 2011-08-03 13:54:26 +0000 (Wed, 03 Aug 2011)
Log Message:
-----------
Added additional axioms type.
Continued property learning algorithms.
Added convenience class to configure components by analysing the annotations.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java
trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAxiomVisitor.java
trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/config/ConfigHelper.java
trunk/components-core/src/main/java/org/dllearner/core/owl/ReflexiveObjectPropertyAxiom.java
trunk/components-core/src/main/java/org/dllearner/learningproblems/AxiomScore.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-08-03 13:00:19 UTC (rev 2978)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-08-03 13:54:26 UTC (rev 2979)
@@ -5,6 +5,7 @@
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
import org.dllearner.kb.SparqlEndpointKS;
@@ -49,4 +50,10 @@
}
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-08-03 13:00:19 UTC (rev 2978)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-08-03 13:54:26 UTC (rev 2979)
@@ -5,6 +5,7 @@
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
import org.dllearner.kb.SparqlEndpointKS;
@@ -49,4 +50,10 @@
}
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java 2011-08-03 13:00:19 UTC (rev 2978)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java 2011-08-03 13:54:26 UTC (rev 2979)
@@ -1,41 +1,117 @@
package org.dllearner.algorithms.properties;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.FunctionalObjectPropertyAxiom;
+import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.learningproblems.AxiomScore;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
+import com.hp.hpl.jena.vocabulary.OWL;
+
public class FunctionalPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
- private String propertyToDescribe;
+private static final Logger logger = LoggerFactory.getLogger(TransitivePropertyAxiomLearner.class);
- public String getPropertyToDescribe() {
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
+ private ObjectProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+
+ public FunctionalPropertyAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public ObjectProperty getPropertyToDescribe() {
return propertyToDescribe;
}
- public void setPropertyToDescribe(String propertyToDescribe) {
+ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
this.propertyToDescribe = propertyToDescribe;
}
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
- public FunctionalPropertyAxiomLearner(SparqlEndpointKS ks){
-
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
}
@Override
public void start() {
- // TODO Auto-generated method stub
-
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+
+ //check if property is already declared as symmetric in knowledge base
+ String query = String.format("ASK {<%s> a <%s>}", propertyToDescribe, OWL.FunctionalProperty.getURI());
+ boolean declaredAsFunctional = executeAskQuery(query);
+ if(declaredAsFunctional) {
+ logger.info("Property is already declared as functional in knowledge base.");
+ }
+
+ //get fraction of instances s with <s p o> also exists <o p s>
+ query = "SELECT (COUNT(?s)) AS ?all ,(COUNT(?o1)) AS ?functional WHERE {?s <%s> ?o. OPTIONAL{?o <%s> ?s. ?o <%s> ?o1}}";
+ query = query.replace("%s", propertyToDescribe.getURI().toString());
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ while(rs.hasNext()){
+ qs = rs.next();
+ int all = qs.getLiteral("all").getInt();
+ int symmetric = qs.getLiteral("functional").getInt();
+ double frac = symmetric / (double)all;
+ currentlyBestAxioms.add(new EvaluatedAxiom(new FunctionalObjectPropertyAxiom(propertyToDescribe), new AxiomScore(frac)));
+ }
+
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
}
@Override
public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- // TODO Auto-generated method stub
- return null;
+ return Collections.singletonList(currentlyBestAxioms.get(0).getAxiom());
}
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ return Collections.singletonList(currentlyBestAxioms.get(0));
+ }
@Override
public Configurator getConfigurator() {
@@ -45,8 +121,34 @@
@Override
public void init() throws ComponentInitException {
- // TODO Auto-generated method stub
+ reasoner = new SPARQLReasoner(ks);
+ }
+
+ private boolean executeAskQuery(String query){
+ logger.info("Sending query \n {}", query);
+ QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ boolean result = queryExecution.execAsk();
+ return result;
}
-
+
+ private ResultSet executeQuery(String query){
+ logger.info("Sending query \n {}", query);
+
+ QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ ResultSet resultSet = queryExecution.execSelect();
+ return resultSet;
+ }
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-08-03 13:00:19 UTC (rev 2978)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-08-03 13:54:26 UTC (rev 2979)
@@ -17,6 +17,8 @@
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigHelper;
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.config.ObjectPropertyEditor;
@@ -29,6 +31,7 @@
import org.dllearner.core.owl.ObjectPropertyDomainAxiom;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.SparqlEndpoint;
+import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +54,7 @@
private SPARQLReasoner reasoner;
private SparqlEndpointKS ks;
- private List<Axiom> currentlyBestAxioms;
+ private List<EvaluatedAxiom> currentlyBestAxioms;
private long startTime;
private int fetchedRows;
@@ -88,7 +91,7 @@
logger.info("Start learning...");
startTime = System.currentTimeMillis();
fetchedRows = 0;
- currentlyBestAxioms = new ArrayList<Axiom>();
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
//get existing domains
Description existingDomain = reasoner.getDomain(propertyToDescribe);
logger.debug("Existing domain: " + existingDomain);
@@ -107,13 +110,22 @@
public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
List<Axiom> bestAxioms = new ArrayList<Axiom>();
- Iterator<Axiom> it = currentlyBestAxioms.iterator();
+ Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
- bestAxioms.add(it.next());
+ bestAxioms.add(it.next().getAxiom());
}
return bestAxioms;
}
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
+
+ List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max-1);
+
+ return bestAxioms;
+ }
@Override
public Configurator getConfigurator() {
@@ -133,8 +145,8 @@
return timeLimitExceeded || resultLimitExceeded;
}
- private List<Axiom> buildBestAxioms(Map<Individual, Set<NamedClass>> individual2Types){
- List<Axiom> axioms = new ArrayList<Axiom>();
+ private List<EvaluatedAxiom> buildBestAxioms(Map<Individual, Set<NamedClass>> individual2Types){
+ List<EvaluatedAxiom> axioms = new ArrayList<EvaluatedAxiom>();
Map<NamedClass, Integer> result = new HashMap<NamedClass, Integer>();
for(Entry<Individual, Set<NamedClass>> entry : individual2Types.entrySet()){
for(NamedClass nc : entry.getValue()){
@@ -146,13 +158,19 @@
}
}
+ EvaluatedAxiom evalAxiom;
for(Entry<NamedClass, Integer> entry : sortByValues(result)){
- axioms.add(new ObjectPropertyDomainAxiom(propertyToDescribe, entry.getKey()));
+ evalAxiom = new EvaluatedAxiom(new ObjectPropertyDomainAxiom(propertyToDescribe, entry.getKey()),
+ new AxiomScore(entry.getValue() / (double)individual2Types.keySet().size()));
+ axioms.add(evalAxiom);
}
return axioms;
}
+ /*
+ * Returns the entries of the map sorted by value.
+ */
private SortedSet<Entry<NamedClass, Integer>> sortByValues(Map<NamedClass, Integer> map){
SortedSet<Entry<NamedClass, Integer>> sortedSet = new TreeSet<Map.Entry<NamedClass,Integer>>(new Comparator<Entry<NamedClass, Integer>>() {
@@ -174,7 +192,7 @@
private Map<Individual, Set<NamedClass>> getSubjectsWithTypes(int offset){
Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>();
int limit = 1000;
- String query = String.format("SELECT ?ind ?type WHERE {?ind %s ?o. ?ind a ?type.} LIMIT %d OFFSET %d", inAngleBrackets(propertyToDescribe.getURI().toString()), limit, offset);
+ String query = String.format("SELECT ?ind ?type WHERE {?ind <%s> ?o. ?ind a ?type.} LIMIT %d OFFSET %d", propertyToDescribe.getURI().toString(), limit, offset);
ResultSet rs = executeQuery(query);
QuerySolution qs;
Individual ind;
@@ -192,10 +210,9 @@
return individual2Types;
}
- private String inAngleBrackets(String s){
- return "<" + s + ">";
- }
-
+ /*
+ * Executes a SELECT query and returns the result.
+ */
private ResultSet executeQuery(String query){
logger.info("Sending query \n {}", query);
@@ -218,6 +235,7 @@
PropertyDomainAxiomLearner l = new PropertyDomainAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()));
+
Field[] fields = l.getClass().getDeclaredFields();
for(Field f : fields){
ConfigOption option = f.getAnnotation(ConfigOption.class);
@@ -228,10 +246,10 @@
f.set(l, editor.getValue());
}
}
-
+ ConfigHelper.configurate(l, "propertyToDescribe", "test");
l.init();
l.start();
- System.out.println(l.getCurrentlyBestAxioms(3));
+ System.out.println(l.getCurrentlyBestEvaluatedAxioms(3));
}
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java 2011-08-03 13:00:19 UTC (rev 2978)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java 2011-08-03 13:54:26 UTC (rev 2979)
@@ -5,6 +5,7 @@
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
import org.dllearner.kb.SparqlEndpointKS;
@@ -49,4 +50,10 @@
}
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java 2011-08-03 13:00:19 UTC (rev 2978)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java 2011-08-03 13:54:26 UTC (rev 2979)
@@ -1,41 +1,117 @@
package org.dllearner.algorithms.properties;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.ObjectProperty;
+import org.dllearner.core.owl.ReflexiveObjectPropertyAxiom;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.learningproblems.AxiomScore;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
+import com.hp.hpl.jena.vocabulary.OWL2;
+
public class ReflexivePropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
- private String propertyToDescribe;
+ private static final Logger logger = LoggerFactory.getLogger(TransitivePropertyAxiomLearner.class);
- public String getPropertyToDescribe() {
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
+ private ObjectProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+
+ public ReflexivePropertyAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public ObjectProperty getPropertyToDescribe() {
return propertyToDescribe;
}
- public void setPropertyToDescribe(String propertyToDescribe) {
+ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
this.propertyToDescribe = propertyToDescribe;
}
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
- public ReflexivePropertyAxiomLearner(SparqlEndpointKS ks){
-
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
}
@Override
public void start() {
- // TODO Auto-generated method stub
-
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+
+ //check if property is already declared as reflexive in knowledge base
+ String query = String.format("ASK {<%s> a <%s>}", propertyToDescribe, OWL2.ReflexiveProperty.getURI());
+ boolean declaredAsReflexive = executeAskQuery(query);
+ if(declaredAsReflexive) {
+ logger.info("Property is already declared as reflexive in knowledge base.");
+ }
+
+ //get fraction of instances s with <s p o> also exists <o p s>
+ query = "SELECT (COUNT(?s)) AS ?all ,(COUNT(?o1)) AS ?reflexiv WHERE {?s <%s> ?o. OPTIONAL{?o <%s> ?s. ?o <%s> ?o1}}";
+ query = query.replace("%s", propertyToDescribe.getURI().toString());
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ while(rs.hasNext()){
+ qs = rs.next();
+ int all = qs.getLiteral("all").getInt();
+ int reflexive = qs.getLiteral("reflexiv").getInt();
+ double frac = reflexive / (double)all;
+ currentlyBestAxioms.add(new EvaluatedAxiom(new ReflexiveObjectPropertyAxiom(propertyToDescribe), new AxiomScore(frac)));
+ }
+
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
}
@Override
public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- // TODO Auto-generated method stub
- return null;
+ return Collections.singletonList(currentlyBestAxioms.get(0).getAxiom());
}
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ return Collections.singletonList(currentlyBestAxioms.get(0));
+ }
@Override
public Configurator getConfigurator() {
@@ -45,8 +121,35 @@
@Override
public void init() throws ComponentInitException {
- // TODO Auto-generated method stub
+ reasoner = new SPARQLReasoner(ks);
+ }
+
+ private boolean executeAskQuery(String query){
+ logger.info("Sending query \n {}", query);
+ QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ boolean result = queryExecution.execAsk();
+ return result;
}
+
+ private ResultSet executeQuery(String query){
+ logger.info("Sending query \n {}", query);
+
+ QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ ResultSet resultSet = queryExecution.execSelect();
+ return resultSet;
+ }
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-08-03 13:00:19 UTC (rev 2978)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-08-03 13:54:26 UTC (rev 2979)
@@ -11,6 +11,7 @@
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.config.ObjectPropertyEditor;
@@ -126,5 +127,11 @@
l.start();
}
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java 2011-08-03 13:00:19 UTC (rev 2978)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java 2011-08-03 13:54:26 UTC (rev 2979)
@@ -1,41 +1,118 @@
package org.dllearner.algorithms.properties;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.ObjectProperty;
+import org.dllearner.core.owl.ReflexiveObjectPropertyAxiom;
+import org.dllearner.core.owl.SymmetricObjectPropertyAxiom;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.learningproblems.AxiomScore;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
+import com.hp.hpl.jena.vocabulary.OWL2;
+
public class SymmetricPropertyAxiomLearner extends Component implements AxiomLearningAlgorithm {
- private String propertyToDescribe;
+ private static final Logger logger = LoggerFactory.getLogger(TransitivePropertyAxiomLearner.class);
- public String getPropertyToDescribe() {
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
+ private ObjectProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+
+ public SymmetricPropertyAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public ObjectProperty getPropertyToDescribe() {
return propertyToDescribe;
}
- public void setPropertyToDescribe(String propertyToDescribe) {
+ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
this.propertyToDescribe = propertyToDescribe;
}
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
- public SymmetricPropertyAxiomLearner(SparqlEndpointKS ks){
-
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
}
@Override
public void start() {
- // TODO Auto-generated method stub
-
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+
+ //check if property is already declared as symmetric in knowledge base
+ String query = String.format("ASK {<%s> a <%s>}", propertyToDescribe, OWL2.SymmetricProperty.getURI());
+ boolean declaredAsSymmetric = executeAskQuery(query);
+ if(declaredAsSymmetric) {
+ logger.info("Property is already declared as symmetric in knowledge base.");
+ }
+
+ //get fraction of instances s with <s p o> also exists <o p s>
+ query = "SELECT (COUNT(?s)) AS ?all ,(COUNT(?o1)) AS ?symmetric WHERE {?s <%s> ?o. OPTIONAL{?o <%s> ?s. ?o <%s> ?o1}}";
+ query = query.replace("%s", propertyToDescribe.getURI().toString());
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ while(rs.hasNext()){
+ qs = rs.next();
+ int all = qs.getLiteral("all").getInt();
+ int symmetric = qs.getLiteral("symmetric").getInt();
+ double frac = symmetric / (double)all;
+ currentlyBestAxioms.add(new EvaluatedAxiom(new SymmetricObjectPropertyAxiom(propertyToDescribe), new AxiomScore(frac)));
+ }
+
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
}
@Override
public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- // TODO Auto-generated method stub
- return null;
+ return Collections.singletonList(currentlyBestAxioms.get(0).getAxiom());
}
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ return Collections.singletonList(currentlyBestAxioms.get(0));
+ }
@Override
public Configurator getConfigurator() {
@@ -45,8 +122,35 @@
@Override
public void init() throws ComponentInitException {
- // TODO Auto-generated method stub
+ reasoner = new SPARQLReasoner(ks);
+ }
+
+ private boolean executeAskQuery(String query){
+ logger.info("Sending query \n {}", query);
+ QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ boolean result = queryExecution.execAsk();
+ return result;
}
+
+ private ResultSet executeQuery(String query){
+ logger.info("Sending query \n {}", query);
+
+ QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecutio...
[truncated message content] |
|
From: <lor...@us...> - 2011-08-05 09:05:32
|
Revision: 3003
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3003&view=rev
Author: lorenz_b
Date: 2011-08-05 09:05:26 +0000 (Fri, 05 Aug 2011)
Log Message:
-----------
Continued algorithms.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAxiomVisitor.java
trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentDatatypePropertiesAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-08-04 17:51:53 UTC (rev 3002)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-08-05 09:05:26 UTC (rev 3003)
@@ -1,44 +1,150 @@
package org.dllearner.algorithms.properties;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import org.dllearner.core.AbstractComponent;
import org.dllearner.core.AxiomLearningAlgorithm;
-import org.dllearner.core.AbstractComponent;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.EquivalentObjectPropertiesAxiom;
+import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.learningproblems.AxiomScore;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
+
@ComponentAnn(name="equivalent property axiom learner")
public class EquivalentPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
- private String propertyToDescribe;
+ private static final Logger logger = LoggerFactory.getLogger(EquivalentPropertyAxiomLearner.class);
- public String getPropertyToDescribe() {
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
+ private ObjectProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+ public EquivalentPropertyAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public ObjectProperty getPropertyToDescribe() {
return propertyToDescribe;
}
- public void setPropertyToDescribe(String propertyToDescribe) {
+ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
this.propertyToDescribe = propertyToDescribe;
}
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
- public EquivalentPropertyAxiomLearner(SparqlEndpointKS ks){
-
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
}
-
+
@Override
public void start() {
- // TODO Auto-generated method stub
-
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+ //get existing super properties
+ SortedSet<ObjectProperty> existingSuperProperties = reasoner.getSuperProperties(propertyToDescribe);
+ logger.debug("Existing super properties: " + existingSuperProperties);
+
+ //get subjects with types
+ int limit = 1000;
+ int offset = 0;
+ String queryTemplate = "SELECT ?p (COUNT(?s)) AS ?count WHERE {?s ?p ?o." +
+ "{SELECT ?s ?o WHERE {?s <%s> ?o.} LIMIT %d OFFSET %d}" +
+ "}";
+ String query;
+ Map<ObjectProperty, Integer> result = new HashMap<ObjectProperty, Integer>();
+ ObjectProperty prop;
+ Integer oldCnt;
+ boolean repeat = true;
+
+ while(!terminationCriteriaSatisfied() && repeat){
+ query = String.format(queryTemplate, propertyToDescribe, limit, offset);
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ repeat = false;
+ while(rs.hasNext()){
+ qs = rs.next();
+ prop = new ObjectProperty(qs.getResource("p").getURI());
+ int newCnt = qs.getLiteral("count").getInt();
+ oldCnt = result.get(prop);
+ if(oldCnt == null){
+ oldCnt = Integer.valueOf(newCnt);
+ }
+ result.put(prop, oldCnt);
+ qs.getLiteral("count").getInt();
+ repeat = true;
+ }
+ currentlyBestAxioms = buildAxioms(result);
+ offset += 1000;
+ }
+
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
}
@Override
public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- // TODO Auto-generated method stub
- return null;
+ List<Axiom> bestAxioms = new ArrayList<Axiom>();
+
+ Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
+ while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
+ bestAxioms.add(it.next().getAxiom());
+ }
+
+ return bestAxioms;
}
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
+
+ List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
+
+ return bestAxioms;
+ }
@Override
public Configurator getConfigurator() {
@@ -48,14 +154,65 @@
@Override
public void init() throws ComponentInitException {
- // TODO Auto-generated method stub
+ reasoner = new SPARQLReasoner(ks);
}
+
+ private boolean terminationCriteriaSatisfied(){
+ boolean timeLimitExceeded = maxExecutionTimeInSeconds == 0 ? false : (System.currentTimeMillis() - startTime) >= maxExecutionTimeInSeconds * 1000;
+ boolean resultLimitExceeded = maxFetchedRows == 0 ? false : fetchedRows >= maxFetchedRows;
+ return timeLimitExceeded || resultLimitExceeded;
+ }
+
+ private List<EvaluatedAxiom> buildAxioms(Map<ObjectProperty, Integer> property2Count){
+ List<EvaluatedAxiom> axioms = new ArrayList<EvaluatedAxiom>();
+
+ EvaluatedAxiom evalAxiom;
+ for(Entry<ObjectProperty, Integer> entry : sortByValues(property2Count)){
+ evalAxiom = new EvaluatedAxiom(new EquivalentObjectPropertiesAxiom(propertyToDescribe, entry.getKey()),
+ new AxiomScore(0));
+ axioms.add(evalAxiom);
+ }
+
+ return axioms;
+ }
+
+ /*
+ * Returns the entries of the map sorted by value.
+ */
+ private SortedSet<Entry<ObjectProperty, Integer>> sortByValues(Map<ObjectProperty, Integer> map){
+ SortedSet<Entry<ObjectProperty, Integer>> sortedSet = new TreeSet<Map.Entry<ObjectProperty,Integer>>(new Comparator<Entry<ObjectProperty, Integer>>() {
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
- // TODO Auto-generated method stub
- return null;
+ @Override
+ public int compare(Entry<ObjectProperty, Integer> value1, Entry<ObjectProperty, Integer> value2) {
+ if(value1.getValue() < value2.getValue()){
+ return 1;
+ } else if(value2.getValue() < value1.getValue()){
+ return -1;
+ } else {
+ return value1.getKey().compareTo(value2.getKey());
+ }
+ }
+ });
+ sortedSet.addAll(map.entrySet());
+ return sortedSet;
}
+
+ /*
+ * Executes a SELECT query and returns the result.
+ */
+ private ResultSet executeQuery(String query){
+ logger.info("Sending query \n {}", query);
+
+ QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ ResultSet resultSet = queryExecution.execSelect();
+ return resultSet;
+ }
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-08-04 17:51:53 UTC (rev 3002)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-08-05 09:05:26 UTC (rev 3003)
@@ -41,7 +41,7 @@
@ComponentAnn(name="subPropertyOf learner")
public class SubPropertyOfAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
-private static final Logger logger = LoggerFactory.getLogger(PropertyDomainAxiomLearner.class);
+ private static final Logger logger = LoggerFactory.getLogger(PropertyDomainAxiomLearner.class);
@ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
private ObjectProperty propertyToDescribe;
Added: trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentDatatypePropertiesAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentDatatypePropertiesAxiom.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentDatatypePropertiesAxiom.java 2011-08-05 09:05:26 UTC (rev 3003)
@@ -0,0 +1,55 @@
+package org.dllearner.core.owl;
+
+import java.util.Map;
+
+public class EquivalentDatatypePropertiesAxiom extends PropertyAxiom {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1085651734702155330L;
+ private DatatypeProperty role;
+ private DatatypeProperty equivRole;
+
+ public EquivalentDatatypePropertiesAxiom(DatatypeProperty equivRole, DatatypeProperty role) {
+ this.role = role;
+ this.equivRole = equivRole;
+ }
+
+ public DatatypeProperty getRole() {
+ return role;
+ }
+
+ public DatatypeProperty getEquivalentRole() {
+ return equivRole;
+ }
+
+ public int getLength() {
+ return 1 + role.getLength() + equivRole.getLength();
+ }
+
+ public String toString(String baseURI, Map<String,String> prefixes) {
+ return "EquivalentObjectProperties(" + equivRole.toString(baseURI, prefixes) + "," + role.toString(baseURI, prefixes) + ")";
+ }
+
+ public String toKBSyntaxString(String baseURI, Map<String,String> prefixes) {
+ return "EquivalentObjectProperties(" + equivRole.toKBSyntaxString(baseURI, prefixes) + "," + role.toKBSyntaxString(baseURI, prefixes) + ")";
+ }
+
+ @Override
+ public void accept(AxiomVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void accept(KBElementVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.dllearner.core.owl.KBElement#toManchesterSyntaxString(java.lang.String, java.util.Map)
+ */
+ @Override
+ public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
+ return "EquivalentObjectProperties(" + equivRole.toString(baseURI, prefixes) + "," + role.toString(baseURI, prefixes) + ")";
+ }
+}
Added: trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java 2011-08-05 09:05:26 UTC (rev 3003)
@@ -0,0 +1,55 @@
+package org.dllearner.core.owl;
+
+import java.util.Map;
+
+public class EquivalentObjectPropertiesAxiom extends PropertyAxiom {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1085651734702155330L;
+ private ObjectProperty role;
+ private ObjectProperty equivRole;
+
+ public EquivalentObjectPropertiesAxiom(ObjectProperty equivRole, ObjectProperty role) {
+ this.role = role;
+ this.equivRole = equivRole;
+ }
+
+ public ObjectProperty getRole() {
+ return role;
+ }
+
+ public ObjectProperty getEquivalentRole() {
+ return equivRole;
+ }
+
+ public int getLength() {
+ return 1 + role.getLength() + equivRole.getLength();
+ }
+
+ public String toString(String baseURI, Map<String,String> prefixes) {
+ return "EquivalentObjectProperties(" + equivRole.toString(baseURI, prefixes) + "," + role.toString(baseURI, prefixes) + ")";
+ }
+
+ public String toKBSyntaxString(String baseURI, Map<String,String> prefixes) {
+ return "EquivalentObjectProperties(" + equivRole.toKBSyntaxString(baseURI, prefixes) + "," + role.toKBSyntaxString(baseURI, prefixes) + ")";
+ }
+
+ @Override
+ public void accept(AxiomVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void accept(KBElementVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.dllearner.core.owl.KBElement#toManchesterSyntaxString(java.lang.String, java.util.Map)
+ */
+ @Override
+ public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
+ return "EquivalentObjectProperties(" + equivRole.toString(baseURI, prefixes) + "," + role.toString(baseURI, prefixes) + ")";
+ }
+}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAxiomVisitor.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAxiomVisitor.java 2011-08-04 17:51:53 UTC (rev 3002)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAxiomVisitor.java 2011-08-05 09:05:26 UTC (rev 3003)
@@ -39,6 +39,10 @@
public void visit(SubObjectPropertyAxiom axiom);
+ public void visit(EquivalentObjectPropertiesAxiom axiom);
+
+ public void visit(EquivalentDatatypePropertiesAxiom axiom);
+
void visit(DatatypePropertyDomainAxiom axiom);
void visit(ObjectPropertyDomainAxiom axiom);
Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java 2011-08-04 17:51:53 UTC (rev 3002)
+++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java 2011-08-05 09:05:26 UTC (rev 3003)
@@ -37,6 +37,8 @@
import org.dllearner.core.owl.DisjointClassesAxiom;
import org.dllearner.core.owl.DoubleDatatypePropertyAssertion;
import org.dllearner.core.owl.EquivalentClassesAxiom;
+import org.dllearner.core.owl.EquivalentDatatypePropertiesAxiom;
+import org.dllearner.core.owl.EquivalentObjectPropertiesAxiom;
import org.dllearner.core.owl.FunctionalObjectPropertyAxiom;
import org.dllearner.core.owl.Individual;
import org.dllearner.core.owl.InverseObjectPropertyAxiom;
@@ -257,6 +259,28 @@
addAxiom(axiomOWLAPI);
}
+ @Override
+ public void visit(EquivalentObjectPropertiesAxiom axiom) {
+ OWLObjectProperty role = factory.getOWLObjectProperty(
+ IRI.create(axiom.getRole().getName()));
+ OWLObjectProperty equivRole = factory.getOWLObjectProperty(
+ IRI.create(axiom.getEquivalentRole().getName()));
+ OWLAxiom axiomOWLAPI = factory.getOWLEquivalentObjectPropertiesAxiom(equivRole, role);
+ addAxiom(axiomOWLAPI);
+
+ }
+
+ @Override
+ public void visit(EquivalentDatatypePropertiesAxiom axiom) {
+ OWLDataProperty role = factory.getOWLDataProperty(
+ IRI.create(axiom.getRole().getName()));
+ OWLDataProperty equivRole = factory.getOWLDataProperty(
+ IRI.create(axiom.getEquivalentRole().getName()));
+ OWLAxiom axiomOWLAPI = factory.getOWLEquivalentDataPropertiesAxiom(equivRole, role);
+ addAxiom(axiomOWLAPI);
+
+ }
+
/*
* (non-Javadoc)
*
@@ -369,4 +393,6 @@
+
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-08 06:00:23
|
Revision: 3010
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3010&view=rev
Author: lorenz_b
Date: 2011-08-08 06:00:16 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
Continued algorithms.
Implemented missing toString() methods in some axioms.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/owl/FunctionalObjectPropertyAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyRangeAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/owl/ReflexiveObjectPropertyAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/owl/SubObjectPropertyAxiom.java
trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlQuery.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtendedQueryEngineHTTP.java
trunk/components-core/src/main/java/org/dllearner/kb/sparql/HttpQuery.java
Property Changed:
----------------
trunk/components-core/src/main/java/org/dllearner/kb/sparql/
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -23,6 +23,7 @@
import org.dllearner.core.owl.EquivalentObjectPropertiesAxiom;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.kb.sparql.SparqlQuery;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
@@ -211,7 +212,8 @@
private ResultSet executeQuery(String query){
logger.info("Sending query \n {}", query);
- QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
queryExecution.addDefaultGraph(dgu);
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -17,6 +17,7 @@
import org.dllearner.core.owl.FunctionalObjectPropertyAxiom;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
@@ -150,10 +151,14 @@
return result;
}
+ /*
+ * Executes a SELECT query and returns the result.
+ */
private ResultSet executeQuery(String query){
logger.info("Sending query \n {}", query);
- QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
queryExecution.addDefaultGraph(dgu);
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -30,6 +30,7 @@
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ObjectPropertyDomainAxiom;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
@@ -221,7 +222,8 @@
private ResultSet executeQuery(String query){
logger.info("Sending query \n {}", query);
- QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
queryExecution.addDefaultGraph(dgu);
}
@@ -232,28 +234,5 @@
return resultSet;
}
- public static void main(String[] args) throws Exception{
- Map<String, String> propertiesMap = new HashMap<String, String>();
- propertiesMap.put("propertyToDescribe", "http://dbpedia.org/ontology/writer");
- propertiesMap.put("maxExecutionTimeInSeconds", "10");
- propertiesMap.put("maxFetchedRows", "15000");
-
- PropertyDomainAxiomLearner l = new PropertyDomainAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()));
-
-
- Field[] fields = l.getClass().getDeclaredFields();
- for(Field f : fields){
- ConfigOption option = f.getAnnotation(ConfigOption.class);
- if(option != null){
- String configValue = propertiesMap.get(option.name());
- PropertyEditor editor = (PropertyEditor) option.propertyEditorClass().newInstance();
- editor.setAsText(configValue);
- f.set(l, editor.getValue());
- }
- }
- l.init();
- l.start();
- System.out.println(l.getCurrentlyBestEvaluatedAxioms(3));
- }
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -28,6 +28,7 @@
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ObjectPropertyRangeAxiom;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
@@ -218,7 +219,8 @@
private ResultSet executeQuery(String query){
logger.info("Sending query \n {}", query);
- QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
queryExecution.addDefaultGraph(dgu);
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -17,6 +17,7 @@
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ReflexiveObjectPropertyAxiom;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
@@ -143,10 +144,14 @@
return result;
}
+ /*
+ * Executes a SELECT query and returns the result.
+ */
private ResultSet executeQuery(String query){
logger.info("Sending query \n {}", query);
- QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
queryExecution.addDefaultGraph(dgu);
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -10,9 +10,6 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import org.aksw.commons.sparql.api.core.QueryExecutionFactory;
-import org.aksw.commons.sparql.api.http.QueryExecutionFactoryHttp;
-import org.aksw.commons.sparql.api.pagination.core.QueryExecutionFactoryPaginated;
import org.dllearner.core.AbstractComponent;
import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
@@ -26,6 +23,7 @@
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.SubObjectPropertyAxiom;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
@@ -215,7 +213,8 @@
private ResultSet executeQuery(String query){
logger.info("Sending query \n {}", query);
- QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
queryExecution.addDefaultGraph(dgu);
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -17,6 +17,7 @@
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.SymmetricObjectPropertyAxiom;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
@@ -143,10 +144,14 @@
return result;
}
+ /*
+ * Executes a SELECT query and returns the result.
+ */
private ResultSet executeQuery(String query){
logger.info("Sending query \n {}", query);
- QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
queryExecution.addDefaultGraph(dgu);
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -17,6 +17,7 @@
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.TransitiveObjectPropertyAxiom;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
@@ -144,10 +145,14 @@
return result;
}
+ /*
+ * Executes a SELECT query and returns the result.
+ */
private ResultSet executeQuery(String query){
logger.info("Sending query \n {}", query);
- QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
queryExecution.addDefaultGraph(dgu);
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -50,6 +50,6 @@
*/
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
- return "EquivalentObjectProperties(" + equivRole.toString(baseURI, prefixes) + "," + role.toString(baseURI, prefixes) + ")";
+ return equivRole.toString(baseURI, prefixes) + " EquivalentTo: " + role.toString(baseURI, prefixes);
}
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/FunctionalObjectPropertyAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/FunctionalObjectPropertyAxiom.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/FunctionalObjectPropertyAxiom.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -50,6 +50,6 @@
*/
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
- return "FUNCTIONALOBJECTPROPERTYAXIOM NOT IMPLEMENTED";
+ return "Functional(" + role.toManchesterSyntaxString(baseURI, prefixes) + ")";
}
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -76,7 +76,7 @@
*/
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
- return "OBJECTPROPERTYDOMAIN NOT IMPLEMENTED";
+ return "Domain(" + getProperty().toManchesterSyntaxString(baseURI, prefixes) + ", " + getDomain().toManchesterSyntaxString(baseURI, prefixes) + ")";
}
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyRangeAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyRangeAxiom.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyRangeAxiom.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -48,7 +48,7 @@
* @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map)
*/
public String toString(String baseURI, Map<String, String> prefixes) {
- return "Domain(" + getProperty() + ", " + getRange() + ")";
+ return "Range(" + getProperty() + ", " + getRange() + ")";
}
public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) {
@@ -80,7 +80,7 @@
*/
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
- return "OBJECTPROPERTYRANGE NOT IMPLEMENTED";
+ return "Range(" + getProperty().toManchesterSyntaxString(baseURI, prefixes) + ", " + getRange().toManchesterSyntaxString(baseURI, prefixes) + ")";
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ReflexiveObjectPropertyAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/ReflexiveObjectPropertyAxiom.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/ReflexiveObjectPropertyAxiom.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -44,6 +44,6 @@
*/
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
- return "Transitive(" + role.toString(baseURI, prefixes) + ")";
+ return "Reflexive(" + role.toManchesterSyntaxString(baseURI, prefixes) + ")";
}
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/SubObjectPropertyAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/SubObjectPropertyAxiom.java 2011-08-05 13:47:08 UTC (rev 3009)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/SubObjectPropertyAxiom.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -50,6 +50,6 @@
*/
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
- return "Subrole(" + subRole.toString(baseURI, prefixes) + "," + role.toString(baseURI, prefixes) + ")";
+ return subRole.toString(baseURI, prefixes) + " SubPropertyOf: " + role.toString(baseURI, prefixes);
}
}
Property changes on: trunk/components-core/src/main/java/org/dllearner/kb/sparql
___________________________________________________________________
Modified: svn:ignore
- SparqlQueryDescriptionConvertRDFS.java
+ SparqlQueryDescriptionConvertRDFS.java
Added: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtendedQueryEngineHTTP.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtendedQueryEngineHTTP.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtendedQueryEngineHTTP.java 2011-08-08 06:00:16 UTC (rev 3010)
@@ -0,0 +1,376 @@
+package org.dllearner.kb.sparql;
+
+import com.hp.hpl.jena.query.*;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.sparql.engine.http.HttpParams;
+import com.hp.hpl.jena.sparql.engine.http.Params;
+import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
+import com.hp.hpl.jena.sparql.resultset.XMLInput;
+import com.hp.hpl.jena.sparql.util.Context;
+import com.hp.hpl.jena.sparql.util.graph.GraphFactory;
+import com.hp.hpl.jena.util.FileManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by Claus Stadler
+ * Date: Oct 25, 2010
+ * Time: 10:15:31 PM
+ */
+class DisconnectorThread
+ extends Thread {
+ private static final Logger logger = LoggerFactory.getLogger(DisconnectorThread.class);
+
+ private HttpQuery connection;
+
+ private long timeOut;
+
+ private boolean canceled = false;
+
+ public DisconnectorThread(HttpQuery connection, long timeOut) {
+ this.connection = connection;
+ this.timeOut = timeOut;
+ }
+
+ public void run() {
+ synchronized (this) {
+
+ while(!canceled && connection.getConnection() == null) {
+ //logger.trace("Waiting for connection...");
+
+ try {
+ this.wait(500l);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ long startTime = System.currentTimeMillis();
+
+ long remaining;
+ while (!canceled && (remaining = (timeOut - (System.currentTimeMillis() - startTime))) > 0) {
+ logger.trace("Forced disconnect in " + remaining + "ms");
+ try {
+ this.wait(remaining);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ if (!canceled && connection.getConnection() != null) {
+ logger.warn("Disconnecting Http connection since a sparql query is taking too long");
+ connection.getConnection().disconnect();
+ canceled = true;
+ }
+ }
+ }
+
+ public void cancel() {
+ synchronized (this) {
+ if(!this.canceled) {
+ logger.trace("Disconnect cancelled");
+ }
+
+ this.canceled = true;
+ this.notify();
+ }
+ }
+}
+
+/**
+ * A QueryEngineHTTP that is capable of closing connections after a given timeout.
+ *
+ * Jena now provides one on its own
+ */
+public class ExtendedQueryEngineHTTP
+ implements QueryExecution {
+ private static Logger log = LoggerFactory.getLogger(QueryEngineHTTP.class);
+
+ public static final String QUERY_MIME_TYPE = "application/sparql-query";
+ String queryString;
+ String service;
+ Context context = null;
+
+
+ long timeOut = 0l;
+
+ public void setTimeOut(long timeOut) {
+ this.timeOut = timeOut;
+ }
+
+ public long getTimeOut() {
+ return timeOut;
+ }
+
+
+ //Params
+ Params params = null;
+
+ // Protocol
+ List<String> defaultGraphURIs = new ArrayList<String>();
+ List<String> namedGraphURIs = new ArrayList<String>();
+ private String user = null;
+ private char[] password = null;
+
+ // Releasing HTTP input streams is important. We remember this for SELECT,
+ // and will close when the engine is closed
+ private InputStream retainedConnection = null;
+
+ public ExtendedQueryEngineHTTP(String serviceURI, Query query) {
+ this(serviceURI, query.toString());
+ }
+
+ public ExtendedQueryEngineHTTP(String serviceURI, String queryString) {
+ this.queryString = queryString;
+ service = serviceURI;
+ // Copy the global context to freeze it.
+ context = new Context(ARQ.getContext());
+ }
+
+// public void setParams(Params params)
+// { this.params = params ; }
+
+ // Meaning-less
+
+ public void setFileManager(FileManager fm) {
+ throw new UnsupportedOperationException("FileManagers do not apply to remote query execution");
+ }
+
+ public void setInitialBinding(QuerySolution binding) {
+ throw new UnsupportedOperationException("Initial bindings not supported for remote queries");
+ }
+
+ public void setInitialBindings(ResultSet table) {
+ throw new UnsupportedOperationException("Initial bindings not supported for remote queries");
+ }
+
+ /**
+ * @param defaultGraphURIs The defaultGraphURIs to set.
+ */
+ public void setDefaultGraphURIs(List<String> defaultGraphURIs) {
+ this.defaultGraphURIs = defaultGraphURIs;
+ }
+
+ /**
+ * @param namedGraphURIs The namedGraphURIs to set.
+ */
+ public void setNamedGraphURIs(List<String> namedGraphURIs) {
+ this.namedGraphURIs = namedGraphURIs;
+ }
+
+ public void addParam(String field, String value) {
+ if (params == null)
+ params = new Params();
+ params.addParam(field, value);
+ }
+
+ /**
+ * @param defaultGraph The defaultGraph to add.
+ */
+ public void addDefaultGraph(String defaultGraph) {
+ if (defaultGraphURIs == null)
+ defaultGraphURIs = new ArrayList<String>();
+ defaultGraphURIs.add(defaultGraph);
+ }
+
+ /**
+ * @param name The URI to add.
+ */
+ public void addNamedGraph(String name) {
+ if (namedGraphURIs == null)
+ namedGraphURIs = new ArrayList<String>();
+ namedGraphURIs.add(name);
+ }
+
+ /**
+ * Set user and password for basic authentication.
+ * After the request is made (one of the exec calls), the application
+ * can overwrite the password array to remove details of the secret.
+ *
+ * @param user
+ * @param password
+ */
+ public void setBasicAuthentication(String user, char[] password) {
+ this.user = user;
+ this.password = password;
+ }
+
+ private InputStream doTimedExec(HttpQuery httpQuery) {
+ DisconnectorThread stopTask = null;
+ if (timeOut > 0) {
+ stopTask = new DisconnectorThread(httpQuery, timeOut);
+// stopTask.start();
+ }
+
+ InputStream in;
+ try {
+ in = httpQuery.exec();
+ }
+ finally {
+ if (stopTask != null) {
+ stopTask.cancel();
+ }
+ }
+
+ return in;
+ }
+
+
+ public ResultSet execSelect() {
+ HttpQuery httpQuery = makeHttpQuery();
+ // TODO Allow other content types.
+ httpQuery.setAccept(HttpParams.contentTypeResultsXML);
+
+ InputStream in = doTimedExec(httpQuery);
+
+
+ ResultSet rs = ResultSetFactory.fromXML(in);
+ retainedConnection = in; // This will be closed on close()
+ return rs;
+ }
+
+ public Model execConstruct() {
+ return execConstruct(GraphFactory.makeJenaDefaultModel());
+ }
+
+ public Model execConstruct(Model model) {
+ return execModel(model);
+ }
+
+ public Model execDescribe() {
+ return execDescribe(GraphFactory.makeJenaDefaultModel());
+ }
+
+ public Model execDescribe(Model model) {
+ return execModel(model);
+ }
+
+ private Model execModel(Model model) {
+ HttpQuery httpQuery = makeHttpQuery();
+ httpQuery.setAccept(HttpParams.contentTypeRDFXML);
+ InputStream in = doTimedExec(httpQuery);
+ model.read(in, null);
+ return model;
+ }
+
+ public boolean execAsk() {
+ HttpQuery httpQuery = makeHttpQuery();
+ httpQuery.setAccept(HttpParams.contentTypeResultsXML);
+ InputStream in = doTimedExec(httpQuery);
+ boolean result = XMLInput.booleanFromXML(in);
+ // Ensure connection is released
+ try {
+ in.close();
+ }
+ catch (java.io.IOException e) {
+ log.warn("Failed to close connection", e);
+ }
+ return result;
+ }
+
+ public Context getContext() {
+ return context;
+ }
+
+ private HttpQuery makeHttpQuery() {
+ HttpQuery httpQuery = new HttpQuery(service);
+ httpQuery.setTimeOut((int)timeOut);
+ httpQuery.addParam(HttpParams.pQuery, queryString);
+
+ for (Iterator<String> iter = defaultGraphURIs.iterator(); iter.hasNext();) {
+ String dft = iter.next();
+ httpQuery.addParam(HttpParams.pDefaultGraph, dft);
+ }
+ for (Iterator<String> iter = namedGraphURIs.iterator(); iter.hasNext();) {
+ String name = iter.next();
+ httpQuery.addParam(HttpParams.pNamedGraph, name);
+ }
+
+ if (params != null)
+ httpQuery.merge(params);
+
+ httpQuery.setBasicAuthentication(user, password);
+ return httpQuery;
+ }
+
+ public void abort() {
+ }
+
+ public void close() {
+ if (retainedConnection != null) {
+ try {
+ retainedConnection.close();
+ }
+ catch (java.io.IOException e) {
+ log.warn("Failed to close connection", e);
+ }
+ finally {
+ retainedConnection = null;
+ }
+ }
+ }
+
+ @Override
+ public void setTimeout(long timeout, TimeUnit timeoutUnits) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setTimeout(long timeout) {
+ this.timeOut = timeout;
+ }
+
+ @Override
+ public void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setTimeout(long timeout1, long timeout2) {
+ //To change body of implemented methods use...
[truncated message content] |
|
From: <lor...@us...> - 2011-08-08 13:35:22
|
Revision: 3013
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3013&view=rev
Author: lorenz_b
Date: 2011-08-08 13:35:14 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
Continued algorithms.
Added more OWL axioms.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAxiomVisitor.java
trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlQuery.java
trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubDataPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/config/DataPropertyEditor.java
trunk/components-core/src/main/java/org/dllearner/core/owl/DisjointDatatypePropertyAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/owl/DisjointObjectPropertyAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/owl/FunctionalDatatypePropertyAxiom.java
trunk/components-core/src/main/java/org/dllearner/core/owl/SubDatatypePropertyAxiom.java
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-08 13:35:14 UTC (rev 3013)
@@ -0,0 +1,233 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.dllearner.core.AbstractComponent;
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.ComponentAnn;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.DatatypeProperty;
+import org.dllearner.core.owl.DatatypePropertyDomainAxiom;
+import org.dllearner.core.owl.Description;
+import org.dllearner.core.owl.Individual;
+import org.dllearner.core.owl.NamedClass;
+import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
+import org.dllearner.learningproblems.AxiomScore;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+
+@ComponentAnn(name="property domain axiom learner")
+public class DataPropertyDomainAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+
+ private static final Logger logger = LoggerFactory.getLogger(DataPropertyDomainAxiomLearner.class);
+
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=DatatypeProperty.class)
+ private DatatypeProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+ public DataPropertyDomainAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public DatatypeProperty getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(DatatypeProperty propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
+
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
+ }
+
+ @Override
+ public void start() {
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+ //get existing domains
+ Description existingDomain = reasoner.getDomain(propertyToDescribe);
+ logger.info("Existing domain: " + existingDomain);
+
+ //get subjects with types
+ Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>();
+ Map<Individual, Set<NamedClass>> newIndividual2Types;
+ boolean repeat = true;
+ while(!terminationCriteriaSatisfied() && repeat){
+ newIndividual2Types = getSubjectsWithTypes(fetchedRows);
+ individual2Types.putAll(newIndividual2Types);
+ currentlyBestAxioms = buildBestAxioms(individual2Types);
+ fetchedRows += 1000;
+ repeat = !newIndividual2Types.isEmpty();
+ }
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ List<Axiom> bestAxioms = new ArrayList<Axiom>();
+
+ Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
+ while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
+ bestAxioms.add(it.next().getAxiom());
+ }
+
+ return bestAxioms;
+ }
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
+
+ List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
+
+ return bestAxioms;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ reasoner = new SPARQLReasoner(ks);
+
+ }
+
+ private boolean terminationCriteriaSatisfied(){
+ boolean timeLimitExceeded = maxExecutionTimeInSeconds == 0 ? false : (System.currentTimeMillis() - startTime) >= maxExecutionTimeInSeconds * 1000;
+ boolean resultLimitExceeded = maxFetchedRows == 0 ? false : fetchedRows >= maxFetchedRows;
+ return timeLimitExceeded || resultLimitExceeded;
+ }
+
+ private List<EvaluatedAxiom> buildBestAxioms(Map<Individual, Set<NamedClass>> individual2Types){
+ List<EvaluatedAxiom> axioms = new ArrayList<EvaluatedAxiom>();
+ Map<NamedClass, Integer> result = new HashMap<NamedClass, Integer>();
+ for(Entry<Individual, Set<NamedClass>> entry : individual2Types.entrySet()){
+ for(NamedClass nc : entry.getValue()){
+ Integer cnt = result.get(nc);
+ if(cnt == null){
+ cnt = Integer.valueOf(1);
+ }
+ result.put(nc, Integer.valueOf(cnt + 1));
+ }
+ }
+
+ EvaluatedAxiom evalAxiom;
+ for(Entry<NamedClass, Integer> entry : sortByValues(result)){
+ evalAxiom = new EvaluatedAxiom(new DatatypePropertyDomainAxiom(propertyToDescribe, entry.getKey()),
+ new AxiomScore(entry.getValue() / (double)individual2Types.keySet().size()));
+ axioms.add(evalAxiom);
+ }
+
+ return axioms;
+ }
+
+ /*
+ * Returns the entries of the map sorted by value.
+ */
+ private SortedSet<Entry<NamedClass, Integer>> sortByValues(Map<NamedClass, Integer> map){
+ SortedSet<Entry<NamedClass, Integer>> sortedSet = new TreeSet<Map.Entry<NamedClass,Integer>>(new Comparator<Entry<NamedClass, Integer>>() {
+
+ @Override
+ public int compare(Entry<NamedClass, Integer> value1, Entry<NamedClass, Integer> value2) {
+ if(value1.getValue() < value2.getValue()){
+ return 1;
+ } else if(value2.getValue() < value1.getValue()){
+ return -1;
+ } else {
+ return value1.getKey().compareTo(value2.getKey());
+ }
+ }
+ });
+ sortedSet.addAll(map.entrySet());
+ return sortedSet;
+ }
+
+ private Map<Individual, Set<NamedClass>> getSubjectsWithTypes(int offset){
+ Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>();
+ int limit = 1000;
+ String query = String.format("SELECT ?ind ?type WHERE {?ind <%s> ?o. ?ind a ?type.} LIMIT %d OFFSET %d", propertyToDescribe.getURI().toString(), limit, offset);
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ Individual ind;
+ Set<NamedClass> types;
+ while(rs.hasNext()){
+ qs = rs.next();
+ ind = new Individual(qs.getResource("ind").getURI());
+ types = individual2Types.get(ind);
+ if(types == null){
+ types = new HashSet<NamedClass>();
+ individual2Types.put(ind, types);
+ }
+ types.add(new NamedClass(qs.getResource("type").getURI()));
+ }
+ return individual2Types;
+ }
+
+ /*
+ * Executes a SELECT query and returns the result.
+ */
+ private ResultSet executeQuery(String query){
+ logger.info("Sending query \n {}", query);
+
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ ResultSet resultSet = queryExecution.execSelect();
+ return resultSet;
+ }
+
+
+}
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java 2011-08-08 13:35:14 UTC (rev 3013)
@@ -0,0 +1,234 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractComponent;
+import org.dllearner.core.ComponentAnn;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.Description;
+import org.dllearner.core.owl.Individual;
+import org.dllearner.core.owl.NamedClass;
+import org.dllearner.core.owl.ObjectProperty;
+import org.dllearner.core.owl.ObjectPropertyRangeAxiom;
+import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
+import org.dllearner.learningproblems.AxiomScore;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
+
+@ComponentAnn(name="property range learner")
+public class DataPropertyRangeAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+
+ private static final Logger logger = LoggerFactory.getLogger(DataPropertyRangeAxiomLearner.class);
+
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
+ private ObjectProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+ public DataPropertyRangeAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public ObjectProperty getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
+
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
+ }
+
+ @Override
+ public void start() {
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+ //get existing range
+ Description existingRange = reasoner.getRange(propertyToDescribe);
+ logger.debug("Existing range: " + existingRange);
+
+ //get objects with types
+ Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>();
+ Map<Individual, Set<NamedClass>> newIndividual2Types;
+ boolean repeat = true;
+ while(!terminationCriteriaSatisfied() && repeat){
+ newIndividual2Types = getObjectsWithTypes(fetchedRows);
+ individual2Types.putAll(newIndividual2Types);
+ currentlyBestAxioms = buildBestAxioms(individual2Types);
+ fetchedRows += 1000;
+ repeat = !newIndividual2Types.isEmpty();
+ }
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ List<Axiom> bestAxioms = new ArrayList<Axiom>();
+
+ Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
+ while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
+ bestAxioms.add(it.next().getAxiom());
+ }
+
+ return bestAxioms;
+ }
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
+
+ List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
+
+ return bestAxioms;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ reasoner = new SPARQLReasoner(ks);
+
+ }
+
+ private boolean terminationCriteriaSatisfied(){
+ boolean timeLimitExceeded = maxExecutionTimeInSeconds == 0 ? false : (System.currentTimeMillis() - startTime) >= maxExecutionTimeInSeconds * 1000;
+ boolean resultLimitExceeded = maxFetchedRows == 0 ? false : fetchedRows >= maxFetchedRows;
+ return timeLimitExceeded || resultLimitExceeded;
+ }
+
+ private List<EvaluatedAxiom> buildBestAxioms(Map<Individual, Set<NamedClass>> individual2Types){
+ List<EvaluatedAxiom> axioms = new ArrayList<EvaluatedAxiom>();
+ Map<NamedClass, Integer> result = new HashMap<NamedClass, Integer>();
+ for(Entry<Individual, Set<NamedClass>> entry : individual2Types.entrySet()){
+ for(NamedClass nc : entry.getValue()){
+ Integer cnt = result.get(nc);
+ if(cnt == null){
+ cnt = Integer.valueOf(1);
+ }
+ result.put(nc, Integer.valueOf(cnt + 1));
+ }
+ }
+
+ EvaluatedAxiom evalAxiom;
+ for(Entry<NamedClass, Integer> entry : sortByValues(result)){
+ evalAxiom = new EvaluatedAxiom(new ObjectPropertyRangeAxiom(propertyToDescribe, entry.getKey()),
+ new AxiomScore(entry.getValue() / (double)individual2Types.keySet().size()));
+ axioms.add(evalAxiom);
+ }
+
+ return axioms;
+ }
+
+ /*
+ * Returns the entries of the map sorted by value.
+ */
+ private SortedSet<Entry<NamedClass, Integer>> sortByValues(Map<NamedClass, Integer> map){
+ SortedSet<Entry<NamedClass, Integer>> sortedSet = new TreeSet<Map.Entry<NamedClass,Integer>>(new Comparator<Entry<NamedClass, Integer>>() {
+
+ @Override
+ public int compare(Entry<NamedClass, Integer> value1, Entry<NamedClass, Integer> value2) {
+ if(value1.getValue() < value2.getValue()){
+ return 1;
+ } else if(value2.getValue() < value1.getValue()){
+ return -1;
+ } else {
+ return value1.getKey().compareTo(value2.getKey());
+ }
+ }
+ });
+ sortedSet.addAll(map.entrySet());
+ return sortedSet;
+ }
+
+ private Map<Individual, Set<NamedClass>> getObjectsWithTypes(int offset){
+ Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>();
+ int limit = 1000;
+ String query = String.format("SELECT ?ind ?type WHERE {?s <%s> ?ind. ?ind a ?type.} LIMIT %d OFFSET %d", propertyToDescribe.getName(), limit, offset);
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ Individual ind;
+ Set<NamedClass> types;
+ while(rs.hasNext()){
+ qs = rs.next();
+ ind = new Individual(qs.getResource("ind").getURI());
+ types = individual2Types.get(ind);
+ if(types == null){
+ types = new HashSet<NamedClass>();
+ individual2Types.put(ind, types);
+ }
+ types.add(new NamedClass(qs.getResource("type").getURI()));
+ }
+ return individual2Types;
+ }
+
+ /*
+ * Executes a SELECT query and returns the result.
+ */
+ private ResultSet executeQuery(String query){
+ logger.info("Sending query \n {}", query);
+
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ ResultSet resultSet = queryExecution.execSelect();
+ return resultSet;
+ }
+
+}
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java 2011-08-08 13:35:14 UTC (rev 3013)
@@ -0,0 +1,143 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.dllearner.core.AbstractComponent;
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.ComponentAnn;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.DataPropertyEditor;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.DatatypeProperty;
+import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.hp.hpl.jena.query.ResultSet;
+
+@ComponentAnn(name="disjoint property axiom learner")
+public class DisjointDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+
+ private static final Logger logger = LoggerFactory.getLogger(PropertyDomainAxiomLearner.class);
+
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=DataPropertyEditor.class)
+ private DatatypeProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+ public DisjointDataPropertyAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public DatatypeProperty getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(DatatypeProperty propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
+
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
+ }
+
+ @Override
+ public void start() {
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+
+ //TODO
+
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ List<Axiom> bestAxioms = new ArrayList<Axiom>();
+
+ Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
+ while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
+ bestAxioms.add(it.next().getAxiom());
+ }
+
+ return bestAxioms;
+ }
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
+
+ List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
+
+ return bestAxioms;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ reasoner = new SPARQLReasoner(ks);
+
+ }
+
+ private boolean terminationCriteriaSatisfied(){
+ boolean timeLimitExceeded = maxExecutionTimeInSeconds == 0 ? false : (System.currentTimeMillis() - startTime) >= maxExecutionTimeInSeconds * 1000;
+ boolean resultLimitExceeded = maxFetchedRows == 0 ? false : fetchedRows >= maxFetchedRows;
+ return timeLimitExceeded || resultLimitExceeded;
+ }
+
+
+ /*
+ * Executes a SELECT query and returns the result.
+ */
+ private ResultSet executeQuery(String query){
+ logger.info("Sending query \n {}", query);
+
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ ResultSet resultSet = queryExecution.execSelect();
+ return resultSet;
+ }
+
+}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-08-08 06:59:56 UTC (rev 3012)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-08-08 13:35:14 UTC (rev 3013)
@@ -1,44 +1,107 @@
package org.dllearner.algorithms.properties;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import org.dllearner.core.AbstractComponent;
import org.dllearner.core.AxiomLearningAlgorithm;
-import org.dllearner.core.AbstractComponent;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.hp.hpl.jena.query.ResultSet;
+
@ComponentAnn(name="disjoint property axiom learner")
public class DisjointPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
- private String propertyToDescribe;
+ private static final Logger logger = LoggerFactory.getLogger(PropertyDomainAxiomLearner.class);
- public String getPropertyToDescribe() {
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
+ private ObjectProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+ public DisjointPropertyAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public ObjectProperty getPropertyToDescribe() {
return propertyToDescribe;
}
- public void setPropertyToDescribe(String propertyToDescribe) {
+ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
this.propertyToDescribe = propertyToDescribe;
}
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
- public DisjointPropertyAxiomLearner(SparqlEndpointKS ks){
-
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
}
-
+
@Override
public void start() {
- // TODO Auto-generated method stub
-
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+
+ //TODO
+
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
}
@Override
public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- // TODO Auto-generated method stub
- return null;
+ List<Axiom> bestAxioms = new ArrayList<Axiom>();
+
+ Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
+ while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
+ bestAxioms.add(it.next().getAxiom());
+ }
+
+ return bestAxioms;
}
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
+
+ List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
+
+ return bestAxioms;
+ }
@Override
public Configurator getConfigurator() {
@@ -48,14 +111,33 @@
@Override
public void init() throws ComponentInitException {
- // TODO Auto-generated method stub
+ reasoner = new SPARQLReasoner(ks);
}
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
- // TODO Auto-generated method stub
- return null;
+
+ private boolean terminationCriteriaSatisfied(){
+ boolean timeLimitExceeded = maxExecutionTimeInSeconds == 0 ? false : (System.currentTimeMillis() - startTime) >= maxExecutionTimeInSeconds * 1000;
+ boolean resultLimitExceeded = maxFetchedRows == 0 ? false : fetchedRows >= maxFetchedRows;
+ return timeLimitExceeded || resultLimitExceeded;
}
+
+
+ /*
+ * Executes a SELECT query and returns the result.
+ */
+ private ResultSet executeQuery(String query){
+ logger.info("Sending query \n {}", query);
+
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ ResultSet resultSet = queryExecution.execSelect();
+ return resultSet;
+ }
}
...
[truncated message content] |
|
From: <lor...@us...> - 2011-08-09 09:42:47
|
Revision: 3016
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3016&view=rev
Author: lorenz_b
Date: 2011-08-09 09:42:41 +0000 (Tue, 09 Aug 2011)
Log Message:
-----------
Small changes.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypePropertyDomainAxiom.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-09 08:37:17 UTC (rev 3015)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-09 09:42:41 UTC (rev 3016)
@@ -18,6 +18,7 @@
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.DataPropertyEditor;
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
@@ -41,7 +42,7 @@
private static final Logger logger = LoggerFactory.getLogger(DataPropertyDomainAxiomLearner.class);
- @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=DatatypeProperty.class)
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=DataPropertyEditor.class)
private DatatypeProperty propertyToDescribe;
@ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
private int maxExecutionTimeInSeconds = 10;
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypePropertyDomainAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypePropertyDomainAxiom.java 2011-08-09 08:37:17 UTC (rev 3015)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypePropertyDomainAxiom.java 2011-08-09 09:42:41 UTC (rev 3016)
@@ -52,30 +52,19 @@
* @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map)
*/
public String toString(String baseURI, Map<String, String> prefixes) {
- // TODO Auto-generated method stub
- return null;
+ return "Domain(" + getProperty() + ", " + getDomain() + ")";
}
- /* (non-Javadoc)
- * @see org.dllearner.core.owl.KBElement#toKBSyntaxString(java.lang.String, java.util.Map)
- */
+
public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) {
- // TODO Auto-generated method stub
- return null;
+ return "OPDOMAIN(" + property.toKBSyntaxString(baseURI, prefixes) + ") = " + domain.toKBSyntaxString(baseURI, prefixes);
}
-
- /* (non-Javadoc)
- * @see org.dllearner.core.owl.Axiom#accept(org.dllearner.core.owl.AxiomVisitor)
- */
@Override
public void accept(AxiomVisitor visitor) {
visitor.visit(this);
}
- /* (non-Javadoc)
- * @see org.dllearner.core.owl.KBElement#accept(org.dllearner.core.owl.KBElementVisitor)
- */
public void accept(KBElementVisitor visitor) {
visitor.visit(this);
}
@@ -85,8 +74,7 @@
*/
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
- // TODO Auto-generated method stub
- return null;
- }
+ return "Domain(" + getProperty().toManchesterSyntaxString(baseURI, prefixes) + ", " + getDomain().toManchesterSyntaxString(baseURI, prefixes) + ")";
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-09 12:42:04
|
Revision: 3019
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3019&view=rev
Author: lorenz_b
Date: 2011-08-09 12:41:57 +0000 (Tue, 09 Aug 2011)
Log Message:
-----------
Fixed some bugs.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/Datatype.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-09 11:55:06 UTC (rev 3018)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-09 12:41:57 UTC (rev 3019)
@@ -29,6 +29,7 @@
import org.dllearner.core.owl.NamedClass;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
+import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
@@ -155,8 +156,10 @@
Integer cnt = result.get(nc);
if(cnt == null){
cnt = Integer.valueOf(1);
+ } else {
+ cnt = Integer.valueOf(cnt + 1);
}
- result.put(nc, Integer.valueOf(cnt + 1));
+ result.put(nc, cnt);
}
}
@@ -230,5 +233,14 @@
return resultSet;
}
+ public static void main(String[] args) throws Exception{
+ DataPropertyDomainAxiomLearner l = new DataPropertyDomainAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW()));
+ l.setPropertyToDescribe(new DatatypeProperty("http://dbpedia.org/ontology/AutomobileEngine/height"));
+ l.setMaxExecutionTimeInSeconds(0);
+ l.init();
+ l.start();
+ System.out.println(l.getCurrentlyBestEvaluatedAxioms(5));
+ }
+
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java 2011-08-09 11:55:06 UTC (rev 3018)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java 2011-08-09 12:41:57 UTC (rev 3019)
@@ -156,8 +156,10 @@
Integer cnt = result.get(nc);
if(cnt == null){
cnt = Integer.valueOf(1);
+ } else {
+ cnt = Integer.valueOf(cnt + 1);
}
- result.put(nc, Integer.valueOf(cnt + 1));
+ result.put(nc, cnt);
}
}
@@ -208,30 +210,11 @@
types = new HashSet<Datatype>();
individual2Datatypes.put(ind, types);
}
- types.add(getDatatypeForURI(qs.getResource("datatype").getURI()));
+ types.add(new Datatype(qs.getResource("datatype").getURI()));
}
return individual2Datatypes;
}
- private Datatype getDatatypeForURI(String uri){
- return new Datatype(uri);
-// if(uri.equals(OWL2Datatype.BOOLEAN.getURI()))
-// return OWL2Datatype.BOOLEAN.getDatatype();
-// else if(uri.equals(OWL2Datatype.DOUBLE.getURI()))
-// return OWL2Datatype.DOUBLE.getDatatype();
-// else if(uri.equals(OWL2Datatype.INT.getURI()))
-// return OWL2Datatype.INT.getDatatype();
-// else if(uri.equals(OWL2Datatype.INTEGER.getURI()))
-// return OWL2Datatype.INTEGER.getDatatype();
-// else if(uri.equals(OWL2Datatype.STRING.getURI()))
-// return OWL2Datatype.STRING.getDatatype();
-// else if(uri.equals(OWL2Datatype.DATE.getURI()))
-// return OWL2Datatype.DATE.getDatatype();
-// else if(uri.equals(OWL2Datatype.DATETIME.getURI()))
-// return OWL2Datatype.DATETIME.getDatatype();
-// throw new Error("Unsupported datatype " + uri + ". Please inform a DL-Learner developer to add it.");
- }
-
/*
* Executes a SELECT query and returns the result.
*/
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-08-09 11:55:06 UTC (rev 3018)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-08-09 12:41:57 UTC (rev 3019)
@@ -19,6 +19,7 @@
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.DataPropertyEditor;
import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.DisjointObjectPropertyAxiom;
@@ -39,7 +40,7 @@
private static final Logger logger = LoggerFactory.getLogger(PropertyDomainAxiomLearner.class);
- @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=DataPropertyEditor.class)
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
private ObjectProperty propertyToDescribe;
@ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
private int maxExecutionTimeInSeconds = 10;
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-08-09 11:55:06 UTC (rev 3018)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-08-09 12:41:57 UTC (rev 3019)
@@ -1,7 +1,5 @@
package org.dllearner.algorithms.properties;
-import java.beans.PropertyEditor;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
@@ -14,8 +12,8 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import org.dllearner.core.AbstractComponent;
import org.dllearner.core.AxiomLearningAlgorithm;
-import org.dllearner.core.AbstractComponent;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -24,6 +22,7 @@
import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.DatatypeProperty;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
import org.dllearner.core.owl.NamedClass;
@@ -39,7 +38,6 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
@ComponentAnn(name="property domain axiom learner")
public class PropertyDomainAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
@@ -159,8 +157,10 @@
Integer cnt = result.get(nc);
if(cnt == null){
cnt = Integer.valueOf(1);
+ } else {
+ cnt = Integer.valueOf(cnt + 1);
}
- result.put(nc, Integer.valueOf(cnt + 1));
+ result.put(nc, cnt);
}
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java 2011-08-09 11:55:06 UTC (rev 3018)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java 2011-08-09 12:41:57 UTC (rev 3019)
@@ -12,8 +12,8 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import org.dllearner.core.AbstractComponent;
import org.dllearner.core.AxiomLearningAlgorithm;
-import org.dllearner.core.AbstractComponent;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -22,6 +22,7 @@
import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.DatatypeProperty;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
import org.dllearner.core.owl.NamedClass;
@@ -29,6 +30,7 @@
import org.dllearner.core.owl.ObjectPropertyRangeAxiom;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
+import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
@@ -36,7 +38,6 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
@ComponentAnn(name="property range learner")
public class PropertyRangeAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
@@ -156,13 +157,15 @@
Integer cnt = result.get(nc);
if(cnt == null){
cnt = Integer.valueOf(1);
+ } else {
+ cnt = Integer.valueOf(cnt + 1);
}
- result.put(nc, Integer.valueOf(cnt + 1));
+ result.put(nc, cnt);
}
}
EvaluatedAxiom evalAxiom;
- for(Entry<NamedClass, Integer> entry : sortByValues(result)){
+ for(Entry<NamedClass, Integer> entry : sortByValues(result)){System.out.println(entry.getKey());System.out.println(entry.getValue());
evalAxiom = new EvaluatedAxiom(new ObjectPropertyRangeAxiom(propertyToDescribe, entry.getKey()),
new AxiomScore(entry.getValue() / (double)individual2Types.keySet().size()));
axioms.add(evalAxiom);
@@ -195,7 +198,7 @@
private Map<Individual, Set<NamedClass>> getObjectsWithTypes(int offset){
Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>();
int limit = 1000;
- String query = String.format("SELECT ?ind ?type WHERE {?s <%s> ?ind. ?ind a ?type.} LIMIT %d OFFSET %d", propertyToDescribe.getName(), limit, offset);
+ String query = String.format("SELECT DISTINCT ?ind ?type WHERE {?s <%s> ?ind. ?ind a ?type.} LIMIT %d OFFSET %d", propertyToDescribe.getName(), limit, offset);
ResultSet rs = executeQuery(query);
QuerySolution qs;
Individual ind;
@@ -230,5 +233,14 @@
ResultSet resultSet = queryExecution.execSelect();
return resultSet;
}
+
+ public static void main(String[] args) throws Exception{
+ PropertyRangeAxiomLearner l = new PropertyRangeAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW()));
+ l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/aircraftElectronic"));
+ l.setMaxExecutionTimeInSeconds(0);
+ l.init();
+ l.start();
+ System.out.println(l.getCurrentlyBestEvaluatedAxioms(5));
+ }
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/Datatype.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/Datatype.java 2011-08-09 11:55:06 UTC (rev 3018)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/Datatype.java 2011-08-09 12:41:57 UTC (rev 3019)
@@ -65,5 +65,30 @@
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
return uri.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Datatype other = (Datatype) obj;
+ if (uri == null) {
+ if (other.uri != null)
+ return false;
+ } else if (!uri.equals(other.uri))
+ return false;
+ return true;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-10 13:47:48
|
Revision: 3023
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3023&view=rev
Author: lorenz_b
Date: 2011-08-10 13:47:39 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
Renamed algorithms.
Added algorithm for inversefunctional object property axioms.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubDataPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/config/ConfigHelper.java
trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAxiomVisitor.java
trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java
trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexiveObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubObjectPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitiveObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/InverseFunctionalObjectPropertyAxiom.java
Removed Paths:
-------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexivePropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitivePropertyAxiomLearner.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-10 09:04:00 UTC (rev 3022)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-10 13:47:39 UTC (rev 3023)
@@ -38,7 +38,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="property domain axiom learner")
+@ComponentAnn(name="dataproperty domain axiom learner")
public class DataPropertyDomainAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(DataPropertyDomainAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java 2011-08-10 09:04:00 UTC (rev 3022)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java 2011-08-10 13:47:39 UTC (rev 3023)
@@ -38,7 +38,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="property range learner")
+@ComponentAnn(name="dataproperty range learner")
public class DataPropertyRangeAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(DataPropertyRangeAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java 2011-08-10 09:04:00 UTC (rev 3022)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java 2011-08-10 13:47:39 UTC (rev 3023)
@@ -35,10 +35,10 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="disjoint property axiom learner")
+@ComponentAnn(name="disjoint dataproperty axiom learner")
public class DisjointDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
- private static final Logger logger = LoggerFactory.getLogger(PropertyDomainAxiomLearner.class);
+ private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner.class);
@ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=DataPropertyEditor.class)
private DatatypeProperty propertyToDescribe;
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-08-10 09:04:00 UTC (rev 3022)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointPropertyAxiomLearner.java 2011-08-10 13:47:39 UTC (rev 3023)
@@ -35,10 +35,10 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="disjoint property axiom learner")
+@ComponentAnn(name="disjoint objectproperty axiom learner")
public class DisjointPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
-private static final Logger logger = LoggerFactory.getLogger(PropertyDomainAxiomLearner.class);
+private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner.class);
@ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
private ObjectProperty propertyToDescribe;
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java 2011-08-10 09:04:00 UTC (rev 3022)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java 2011-08-10 13:47:39 UTC (rev 3023)
@@ -32,7 +32,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="equivalent property axiom learner")
+@ComponentAnn(name="equivalent dataproperty axiom learner")
public class EquivalentDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(EquivalentDataPropertyAxiomLearner.class);
Copied: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java (from rev 3022, trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java)
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java 2011-08-10 13:47:39 UTC (rev 3023)
@@ -0,0 +1,227 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.dllearner.core.AbstractComponent;
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.ComponentAnn;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.EquivalentObjectPropertiesAxiom;
+import org.dllearner.core.owl.ObjectProperty;
+import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
+import org.dllearner.kb.sparql.SparqlQuery;
+import org.dllearner.learningproblems.AxiomScore;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
+
+@ComponentAnn(name="equivalent objectproperty axiom learner")
+public class EquivalentObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+
+ private static final Logger logger = LoggerFactory.getLogger(EquivalentObjectPropertyAxiomLearner.class);
+
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
+ private ObjectProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+ public EquivalentObjectPropertyAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public ObjectProperty getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
+
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
+ }
+
+ @Override
+ public void start() {
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+ //get existing super properties
+ SortedSet<ObjectProperty> existingSuperProperties = reasoner.getSuperProperties(propertyToDescribe);
+ logger.debug("Existing super properties: " + existingSuperProperties);
+
+ //get subjects with types
+ int limit = 1000;
+ int offset = 0;
+ String queryTemplate = "SELECT ?p COUNT(?s) AS ?count WHERE {?s ?p ?o." +
+ "{SELECT ?s ?o WHERE {?s <%s> ?o.} LIMIT %d OFFSET %d}" +
+ "}";
+ String query;
+ Map<ObjectProperty, Integer> result = new HashMap<ObjectProperty, Integer>();
+ ObjectProperty prop;
+ Integer oldCnt;
+ boolean repeat = true;
+
+ while(!terminationCriteriaSatisfied() && repeat){
+ query = String.format(queryTemplate, propertyToDescribe, limit, offset);
+ ResultSet rs = executeQuery(query);
+ QuerySolution qs;
+ repeat = false;
+ while(rs.hasNext()){
+ qs = rs.next();
+ prop = new ObjectProperty(qs.getResource("p").getURI());
+ int newCnt = qs.getLiteral("count").getInt();
+ oldCnt = result.get(prop);
+ if(oldCnt == null){
+ oldCnt = Integer.valueOf(newCnt);
+ }
+ result.put(prop, oldCnt);
+ qs.getLiteral("count").getInt();
+ repeat = true;
+ }
+ if(!result.isEmpty()){
+ currentlyBestAxioms = buildAxioms(result);
+ offset += 1000;
+ }
+
+ }
+
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
+ }
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ List<Axiom> bestAxioms = new ArrayList<Axiom>();
+
+ Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
+ while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
+ bestAxioms.add(it.next().getAxiom());
+ }
+
+ return bestAxioms;
+ }
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
+
+ List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
+
+ return bestAxioms;
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ reasoner = new SPARQLReasoner(ks);
+
+ }
+
+ private boolean terminationCriteriaSatisfied(){
+ boolean timeLimitExceeded = maxExecutionTimeInSeconds == 0 ? false : (System.currentTimeMillis() - startTime) >= maxExecutionTimeInSeconds * 1000;
+ boolean resultLimitExceeded = maxFetchedRows == 0 ? false : fetchedRows >= maxFetchedRows;
+ return timeLimitExceeded || resultLimitExceeded;
+ }
+
+ private List<EvaluatedAxiom> buildAxioms(Map<ObjectProperty, Integer> property2Count){
+ List<EvaluatedAxiom> axioms = new ArrayList<EvaluatedAxiom>();
+ Integer all = property2Count.get(propertyToDescribe);
+ property2Count.remove(propertyToDescribe);
+
+ EvaluatedAxiom evalAxiom;
+ for(Entry<ObjectProperty, Integer> entry : sortByValues(property2Count)){
+ evalAxiom = new EvaluatedAxiom(new EquivalentObjectPropertiesAxiom(propertyToDescribe, entry.getKey()),
+ new AxiomScore(entry.getValue() / (double)all));
+ axioms.add(evalAxiom);
+ }
+
+ property2Count.put(propertyToDescribe, all);
+ return axioms;
+ }
+
+ /*
+ * Returns the entries of the map sorted by value.
+ */
+ private SortedSet<Entry<ObjectProperty, Integer>> sortByValues(Map<ObjectProperty, Integer> map){
+ SortedSet<Entry<ObjectProperty, Integer>> sortedSet = new TreeSet<Map.Entry<ObjectProperty,Integer>>(new Comparator<Entry<ObjectProperty, Integer>>() {
+
+ @Override
+ public int compare(Entry<ObjectProperty, Integer> value1, Entry<ObjectProperty, Integer> value2) {
+ if(value1.getValue() < value2.getValue()){
+ return 1;
+ } else if(value2.getValue() < value1.getValue()){
+ return -1;
+ } else {
+ return value1.getKey().compareTo(value2.getKey());
+ }
+ }
+ });
+ sortedSet.addAll(map.entrySet());
+ return sortedSet;
+ }
+
+ /*
+ * Executes a SELECT query and returns the result.
+ */
+ private ResultSet executeQuery(String query){
+ logger.info("Sending query \n {}", query);
+
+ ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
+ queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
+ for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
+ queryExecution.addDefaultGraph(dgu);
+ }
+ for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
+ queryExecution.addNamedGraph(ngu);
+ }
+ ResultSet resultSet = queryExecution.execSelect();
+ return resultSet;
+ }
+
+}
Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-08-10 09:04:00 UTC (rev 3022)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentPropertyAxiomLearner.java 2011-08-10 13:47:39 UTC (rev 3023)
@@ -1,227 +0,0 @@
-package org.dllearner.algorithms.properties;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
-import org.dllearner.core.ComponentAnn;
-import org.dllearner.core.ComponentInitException;
-import org.dllearner.core.EvaluatedAxiom;
-import org.dllearner.core.config.ConfigOption;
-import org.dllearner.core.config.IntegerEditor;
-import org.dllearner.core.config.ObjectPropertyEditor;
-import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
-import org.dllearner.core.owl.EquivalentObjectPropertiesAxiom;
-import org.dllearner.core.owl.ObjectProperty;
-import org.dllearner.kb.SparqlEndpointKS;
-import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
-import org.dllearner.kb.sparql.SparqlQuery;
-import org.dllearner.learningproblems.AxiomScore;
-import org.dllearner.reasoning.SPARQLReasoner;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.hp.hpl.jena.query.QuerySolution;
-import com.hp.hpl.jena.query.ResultSet;
-import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
-
-@ComponentAnn(name="equivalent property axiom learner")
-public class EquivalentPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
-
- private static final Logger logger = LoggerFactory.getLogger(EquivalentPropertyAxiomLearner.class);
-
- @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
- private ObjectProperty propertyToDescribe;
- @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
- private int maxExecutionTimeInSeconds = 10;
- @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
- private int maxFetchedRows = 0;
-
- private SPARQLReasoner reasoner;
- private SparqlEndpointKS ks;
-
- private List<EvaluatedAxiom> currentlyBestAxioms;
- private long startTime;
- private int fetchedRows;
-
- public EquivalentPropertyAxiomLearner(SparqlEndpointKS ks){
- this.ks = ks;
- }
-
- public int getMaxExecutionTimeInSeconds() {
- return maxExecutionTimeInSeconds;
- }
-
- public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
- this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
- }
-
- public ObjectProperty getPropertyToDescribe() {
- return propertyToDescribe;
- }
-
- public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
- this.propertyToDescribe = propertyToDescribe;
- }
-
- public int getMaxFetchedRows() {
- return maxFetchedRows;
- }
-
- public void setMaxFetchedRows(int maxFetchedRows) {
- this.maxFetchedRows = maxFetchedRows;
- }
-
- @Override
- public void start() {
- logger.info("Start learning...");
- startTime = System.currentTimeMillis();
- fetchedRows = 0;
- currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
- //get existing super properties
- SortedSet<ObjectProperty> existingSuperProperties = reasoner.getSuperProperties(propertyToDescribe);
- logger.debug("Existing super properties: " + existingSuperProperties);
-
- //get subjects with types
- int limit = 1000;
- int offset = 0;
- String queryTemplate = "SELECT ?p COUNT(?s) AS ?count WHERE {?s ?p ?o." +
- "{SELECT ?s ?o WHERE {?s <%s> ?o.} LIMIT %d OFFSET %d}" +
- "}";
- String query;
- Map<ObjectProperty, Integer> result = new HashMap<ObjectProperty, Integer>();
- ObjectProperty prop;
- Integer oldCnt;
- boolean repeat = true;
-
- while(!terminationCriteriaSatisfied() && repeat){
- query = String.format(queryTemplate, propertyToDescribe, limit, offset);
- ResultSet rs = executeQuery(query);
- QuerySolution qs;
- repeat = false;
- while(rs.hasNext()){
- qs = rs.next();
- prop = new ObjectProperty(qs.getResource("p").getURI());
- int newCnt = qs.getLiteral("count").getInt();
- oldCnt = result.get(prop);
- if(oldCnt == null){
- oldCnt = Integer.valueOf(newCnt);
- }
- result.put(prop, oldCnt);
- qs.getLiteral("count").getInt();
- repeat = true;
- }
- if(!result.isEmpty()){
- currentlyBestAxioms = buildAxioms(result);
- offset += 1000;
- }
-
- }
-
- logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
- }
-
- @Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- List<Axiom> bestAxioms = new ArrayList<Axiom>();
-
- Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
- while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
- bestAxioms.add(it.next().getAxiom());
- }
-
- return bestAxioms;
- }
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
- int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
-
- List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
-
- return bestAxioms;
- }
-
- @Override
- public Configurator getConfigurator() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void init() throws ComponentInitException {
- reasoner = new SPARQLReasoner(ks);
-
- }
-
- private boolean terminationCriteriaSatisfied(){
- boolean timeLimitExceeded = maxExecutionTimeInSeconds == 0 ? false : (System.currentTimeMillis() - startTime) >= maxExecutionTimeInSeconds * 1000;
- boolean resultLimitExceeded = maxFetchedRows == 0 ? false : fetchedRows >= maxFetchedRows;
- return timeLimitExceeded || resultLimitExceeded;
- }
-
- private List<EvaluatedAxiom> buildAxioms(Map<ObjectProperty, Integer> property2Count){
- List<EvaluatedAxiom> axioms = new ArrayList<EvaluatedAxiom>();
- Integer all = property2Count.get(propertyToDescribe);
- property2Count.remove(propertyToDescribe);
-
- EvaluatedAxiom evalAxiom;
- for(Entry<ObjectProperty, Integer> entry : sortByValues(property2Count)){
- evalAxiom = new EvaluatedAxiom(new EquivalentObjectPropertiesAxiom(propertyToDescribe, entry.getKey()),
- new AxiomScore(entry.getValue() / (double)all));
- axioms.add(evalAxiom);
- }
-
- property2Count.put(propertyToDescribe, all);
- return axioms;
- }
-
- /*
- * Returns the entries of the map sorted by value.
- */
- private SortedSet<Entry<ObjectProperty, Integer>> sortByValues(Map<ObjectProperty, Integer> map){
- SortedSet<Entry<ObjectProperty, Integer>> sortedSet = new TreeSet<Map.Entry<ObjectProperty,Integer>>(new Comparator<Entry<ObjectProperty, Integer>>() {
-
- @Override
- public int compare(Entry<ObjectProperty, Integer> value1, Entry<ObjectProperty, Integer> value2) {
- if(value1.getValue() < value2.getValue()){
- return 1;
- } else if(value2.getValue() < value1.getValue()){
- return -1;
- } else {
- return value1.getKey().compareTo(value2.getKey());
- }
- }
- });
- sortedSet.addAll(map.entrySet());
- return sortedSet;
- }
-
- /*
- * Executes a SELECT query and returns the result.
- */
- private ResultSet executeQuery(String query){
- logger.info("Sending query \n {}", query);
-
- ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(ks.getEndpoint().getURL().toString(), query);
- queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000);
- for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) {
- queryExecution.addDefaultGraph(dgu);
- }
- for (String ngu : ks.getEndpoint().getNamedGraphURIs()) {
- queryExecution.addNamedGraph(ngu);
- }
- ResultSet resultSet = queryExecution.execSelect();
- return resultSet;
- }
-
-}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java 2011-08-10 09:04:00 UTC (rev 3022)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java 2011-08-10 13:47:39 UTC (rev 3023)
@@ -28,7 +28,7 @@
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
import com.hp.hpl.jena.vocabulary.OWL;
-@ComponentAnn(name="functional property axiom learner")
+@ComponentAnn(name="functional dataproperty axiom learner")
public class FunctionalDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(FunctionalDataPropertyAxiomLearner.class);
Copied: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java (from rev 3022, trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalPropertyAxiomLearner.java)
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2011-08-10 13:47:39 UTC (rev 3023)
@@ -0,0 +1,171 @@
+package org.dllearner.algorithms.properties;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractComponent;
+import org.dllearner.core.ComponentAnn;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
+import org.dllearner.core.configurators.Configurator;
+import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.FunctionalObjectPropertyAxiom;
+import org.dllearner.core.owl.ObjectProperty;
+import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
+import org.dllearner.learningproblems.AxiomScore;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
+import com.hp.hpl.jena.vocabulary.OWL;
+
+@ComponentAnn(name="functional objectproperty axiom learner")
+public class FunctionalObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+
+ private static final Logger logger = LoggerFactory.getLogger(FunctionalObjectPropertyAxiomLearner.class);
+
+ @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class)
+ private ObjectProperty propertyToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedAxiom> currentlyBestAxioms;
+ private long startTime;
+ private int fetchedRows;
+
+
+ public FunctionalObjectPropertyAxiomLearner(SparqlEndpointKS ks){
+ this.ks = ks;
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
+ }
+
+ public ObjectProperty getPropertyToDescribe() {
+ return propertyToDescribe;
+ }
+
+ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) {
+ this.propertyToDescribe = propertyToDescribe;
+ }
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
+
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
+ }
+
+ @Override
+ public void start() {
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestAxioms = new ArrayList<EvaluatedAxiom>();
+
+ //check if property is already declared as symmetric in knowledge base
+ String query = String.format("ASK {<%s> a <%s>}", propertyToDescribe, OWL.FunctionalProperty.getURI());
+ boolean declaredAsFunctional = executeAskQuery(query);
+ if(declaredAsFunctional) {
+ logger.info("Property is already declared as functional in knowledge base.");
+ }
+
+ //get number of instances of s with <s p o>
+ query = String.format("SELECT (COUNT(DISTINCT ?s)) AS ?all WHERE {?s <%s> ?o.}", prop...
[truncated message content] |
|
From: <lor...@us...> - 2011-08-15 07:30:24
|
Revision: 3038
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3038&view=rev
Author: lorenz_b
Date: 2011-08-15 07:30:18 +0000 (Mon, 15 Aug 2011)
Log Message:
-----------
Continued output.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java
trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java
Modified: trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-11 16:01:34 UTC (rev 3037)
+++ trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-15 07:30:18 UTC (rev 3038)
@@ -1,14 +1,26 @@
package org.dllearner.core;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.commons.codec.digest.DigestUtils;
import org.dllearner.core.owl.Axiom;
import org.dllearner.utilities.EnrichmentVocabulary;
+import org.dllearner.utilities.owl.OWLAPIConverter;
+import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor;
import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLAnnotation;
+import org.semanticweb.owlapi.model.OWLAnnotationAxiom;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
+import org.semanticweb.owlapi.util.DefaultPrefixManager;
import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl;
+import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxObjectRenderer;
+import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxPrefixNameShortFormProvider;
public class EvaluatedAxiom {
@@ -33,17 +45,29 @@
return axiom + "(" + score.getAccuracy()+ ")";
}
- public void toRDF(){
+ public List<OWLAxiom> toRDF(){
OWLDataFactory f = new OWLDataFactoryImpl();
String id = DigestUtils.md5Hex(axiom.toString()) + score.getAccuracy();
OWLNamedIndividual ind = f.getOWLNamedIndividual(IRI.create(EnrichmentVocabulary.NS + id));
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ ManchesterOWLSyntaxObjectRenderer r = new ManchesterOWLSyntaxObjectRenderer(pw, new ManchesterOWLSyntaxPrefixNameShortFormProvider(new DefaultPrefixManager()));
+ OWLAxiom ax = OWLAPIConverter.getOWLAPIAxiom(axiom);
+ ax.accept(r);
+
OWLAxiom ax1 = f.getOWLClassAssertionAxiom(EnrichmentVocabulary.Suggestion, ind);
- OWLAxiom ax2 = f.getOWLObjectPropertyAssertionAxiom(EnrichmentVocabulary.hasAxiom, ind, null);
+ OWLAxiom ax2 = f.getOWLDataPropertyAssertionAxiom(EnrichmentVocabulary.hasAxiom, ind, sw.toString());
OWLAxiom ax3 = f.getOWLDataPropertyAssertionAxiom(EnrichmentVocabulary.confidence, ind, score.getAccuracy());
- System.out.println(ax1);
+ List<OWLAxiom> axioms = new ArrayList<OWLAxiom>();
+ axioms.add(ax1);
+ axioms.add(ax2);
+ axioms.add(ax3);
+
+ return axioms;
}
Modified: trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java 2011-08-11 16:01:34 UTC (rev 3037)
+++ trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java 2011-08-15 07:30:18 UTC (rev 3038)
@@ -25,7 +25,7 @@
//the object properties
public static final OWLObjectProperty creation = factory.getOWLObjectProperty(IRI.create(NS + "creation"));
- public static final OWLObjectProperty hasAxiom = factory.getOWLObjectProperty(IRI.create(NS + "hasAxiom"));
+// public static final OWLObjectProperty hasAxiom = factory.getOWLObjectProperty(IRI.create(NS + "hasAxiom"));
public static final OWLObjectProperty hasChange = factory.getOWLObjectProperty(IRI.create(NS + "hasChange"));
@@ -49,4 +49,6 @@
public static final OWLDataProperty version = factory.getOWLDataProperty(IRI.create(NS + "version"));
+ public static final OWLDataProperty hasAxiom = factory.getOWLDataProperty(IRI.create(NS + "hasAxiom"));
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-15 14:49:00
|
Revision: 3046
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3046&view=rev
Author: lorenz_b
Date: 2011-08-15 14:48:54 +0000 (Mon, 15 Aug 2011)
Log Message:
-----------
Started simple subclass axioms learner for SPARQL endpoints.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/core/config/NamedClassEditor.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-15 14:22:11 UTC (rev 3045)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-15 14:48:54 UTC (rev 3046)
@@ -19,13 +19,37 @@
*/
package org.dllearner.algorithms;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import org.dllearner.algorithms.properties.ObjectPropertyDomainAxiomLearner;
import org.dllearner.core.ClassExpressionLearningAlgorithm;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
import org.dllearner.core.EvaluatedDescription;
+import org.dllearner.core.Score;
+import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.config.IntegerEditor;
+import org.dllearner.core.config.NamedClassEditor;
+import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.owl.Description;
+import org.dllearner.core.owl.Individual;
+import org.dllearner.core.owl.NamedClass;
+import org.dllearner.core.owl.ObjectProperty;
+import org.dllearner.kb.SparqlEndpointKS;
+import org.dllearner.kb.sparql.SparqlQuery;
+import org.dllearner.learningproblems.ClassScore;
+import org.dllearner.reasoning.SPARQLReasoner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+
/**
* Learns sub classes using SPARQL queries.
*
@@ -34,6 +58,26 @@
*
*/
public class SimpleSubclassLearner implements ClassExpressionLearningAlgorithm {
+
+ private static final Logger logger = LoggerFactory.getLogger(SimpleSubclassLearner.class);
+
+ @ConfigOption(name="classToDescribe", description="", propertyEditorClass=NamedClassEditor.class)
+ private NamedClass classToDescribe;
+ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class)
+ private int maxExecutionTimeInSeconds = 10;
+ @ConfigOption(name="maxFetchedRows", description="The maximum number of rows fetched from the endpoint to approximate the result.", propertyEditorClass=IntegerEditor.class)
+ private int maxFetchedRows = 0;
+
+ private SPARQLReasoner reasoner;
+ private SparqlEndpointKS ks;
+
+ private List<EvaluatedDescription> currentlyBestEvaluatedDescriptions;
+ private long startTime;
+ private int fetchedRows;
+
+ public SimpleSubclassLearner(SparqlEndpointKS ks) {
+ this.ks = ks;
+ }
@Override
public List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions) {
@@ -50,14 +94,97 @@
@Override
public void start() {
- // TODO Auto-generated method stub
+ logger.info("Start learning...");
+ startTime = System.currentTimeMillis();
+ fetchedRows = 0;
+ currentlyBestEvaluatedDescriptions = new ArrayList<EvaluatedDescription>();
+
+ Map<Individual, SortedSet<NamedClass>> ind2Types = new HashMap<Individual, SortedSet<NamedClass>>();
+ int limit = 1000;
+ int offset = 0;
+ while(!terminationCriteriaSatisfied()){
+ addIndividualsWithTypes(ind2Types, limit, offset);
+ }
+
+ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
}
@Override
public void init() throws ComponentInitException {
- // TODO Auto-generated method stub
+ reasoner = new SPARQLReasoner(ks);
+ }
+
+ public int getMaxExecutionTimeInSeconds() {
+ return maxExecutionTimeInSeconds;
+ }
+ public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
+ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
}
+ public NamedClass getPropertyToDescribe() {
+ return classToDescribe;
+ }
+
+ public void setPropertyToDescribe(NamedClass classToDescribe) {
+ this.classToDescribe = classToDescribe;
+ }
+
+ public int getMaxFetchedRows() {
+ return maxFetchedRows;
+ }
+
+ public void setMaxFetchedRows(int maxFetchedRows) {
+ this.maxFetchedRows = maxFetchedRows;
+ }
+
+ private void addIndividualsWithTypes(Map<Individual, SortedSet<NamedClass>> ind2Types, int limit, int offset){
+ String query = String.format("SELECT ?ind ?type WHERE {?ind a <%s>. ?ind a ?type} LIMIT %d OFFSET %d", classToDescribe.getName(), limit, offset);
+
+ ResultSet rs = new SparqlQuery(query, ks.getEndpoint()).send();
+ Individual ind;
+ NamedClass newType;
+ QuerySolution qs;
+ SortedSet<NamedClass> types;
+ while(rs.hasNext()){
+ qs = rs.next();
+ ind = new Individual(qs.getResource("ind").getURI());
+ newType = new NamedClass(qs.getResource("type").getURI());
+ types = ind2Types.get(ind);
+ if(types == null){
+ types = new TreeSet<NamedClass>();
+ ind2Types.put(ind, types);
+ }
+ types.add(newType);
+ }
+ }
+
+ private void createEvaluatedDescriptions(Map<Individual, SortedSet<NamedClass>> ind2Types){
+
+ }
+
+ private double computeScore(){
+ return 0;
+ }
+
+ private boolean terminationCriteriaSatisfied(){
+ boolean timeLimitExceeded = maxExecutionTimeInSeconds == 0 ? false : (System.currentTimeMillis() - startTime) >= maxExecutionTimeInSeconds * 1000;
+ boolean resultLimitExceeded = maxFetchedRows == 0 ? false : fetchedRows >= maxFetchedRows;
+ return timeLimitExceeded || resultLimitExceeded;
+ }
+
+ public static void main(String[] args) {
+ Map<String, SortedSet<String>> map = new HashMap<String, SortedSet<String>>();
+ SortedSet<String> set = new TreeSet<String>();
+ set.add("2");set.add("3");
+ map.put("1", set);
+
+ set = new TreeSet<String>();
+ set.add("2");set.add("4");
+ map.put("1", set);
+
+ System.out.println(map);
+ }
+
}
Added: trunk/components-core/src/main/java/org/dllearner/core/config/NamedClassEditor.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/config/NamedClassEditor.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/core/config/NamedClassEditor.java 2011-08-15 14:48:54 UTC (rev 3046)
@@ -0,0 +1,90 @@
+package org.dllearner.core.config;
+
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyEditor;
+
+import org.dllearner.core.owl.NamedClass;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Chris
+ * Date: 7/26/11
+ * Time: 9:42 PM
+ * <p/>
+ * Basic Property Editor for the Object Property DL-Learner class. Doesn't have GUI support yet but we could add that later if we wanted.
+ */
+public class NamedClassEditor implements PropertyEditor {
+
+
+ private NamedClass value;
+
+ @Override
+ public void setValue(Object value) {
+ this.value = (NamedClass) value;
+ }
+
+ @Override
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean isPaintable() {
+ /** Not right now, we're doing non gui work */
+ return false;
+ }
+
+ @Override
+ public void paintValue(Graphics gfx, Rectangle box) {
+
+ }
+
+ @Override
+ public String getJavaInitializationString() {
+ /** This returns the value needed to reconstitute the object from a string */
+ return value.getName();
+ }
+
+ @Override
+ public String getAsText() {
+ /** Get the text value of this object - for displaying in GUIS, etc */
+ return value.getName();
+ }
+
+ @Override
+ public void setAsText(String text) throws IllegalArgumentException {
+ value = new NamedClass(text);
+ }
+
+ @Override
+ public String[] getTags() {
+ /** If there was a known set of values it had to have, we could add that list here */
+ return new String[0];
+ }
+
+ @Override
+ public Component getCustomEditor() {
+ /** GUI stuff, if you wanted to edit it a custom way */
+ return null;
+ }
+
+ @Override
+ public boolean supportsCustomEditor() {
+ /** We don't support this right now, but maybe later */
+ return false;
+
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ /** More gui stuff, we don't need this for our basic example */
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ /** More gui stuff, we don't need this for our basic example */
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-16 08:08:10
|
Revision: 3049
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3049&view=rev
Author: lorenz_b
Date: 2011-08-16 08:08:04 +0000 (Tue, 16 Aug 2011)
Log Message:
-----------
Continued subclass learner.
Added URI to Thing class.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/Thing.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-15 22:15:14 UTC (rev 3048)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-16 08:08:04 UTC (rev 3049)
@@ -44,6 +44,7 @@
import org.dllearner.core.owl.NamedClass;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ObjectPropertyDomainAxiom;
+import org.dllearner.core.owl.Thing;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.kb.sparql.SparqlQuery;
@@ -87,8 +88,11 @@
@Override
public List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions) {
- // TODO Auto-generated method stub
- return null;
+ List<Description> bestDescriptions = new ArrayList<Description>();
+ for(EvaluatedDescription evDesc : getCurrentlyBestEvaluatedDescriptions(nrOfDescriptions)){
+ bestDescriptions.add(evDesc.getDescription());
+ }
+ return bestDescriptions;
}
@Override
@@ -105,6 +109,13 @@
fetchedRows = 0;
currentlyBestEvaluatedDescriptions = new ArrayList<EvaluatedDescription>();
+ //get existing super classes
+ SortedSet<Description> existingSuperClasses = reasoner.getSuperClasses(classToDescribe);
+ if(!existingSuperClasses.isEmpty()){
+ logger.info("Existing super classes: " + existingSuperClasses);
+ }
+
+
Map<Individual, SortedSet<NamedClass>> ind2Types = new HashMap<Individual, SortedSet<NamedClass>>();
int limit = 1000;
while(!terminationCriteriaSatisfied()){
@@ -114,7 +125,7 @@
}
- logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
+ logger.info("...finished in {}ms. (Got {} rows)", (System.currentTimeMillis()-startTime), fetchedRows);
}
@Override
@@ -185,10 +196,14 @@
EvaluatedDescription evalDesc;
for(Entry<NamedClass, Integer> entry : sortByValues(result)){
- evalDesc = new EvaluatedDescription(entry.getKey(),
- new AxiomScore(entry.getValue() / (double)individual2Types.keySet().size()));
- currentlyBestEvaluatedDescriptions.add(evalDesc);
+ if(!entry.getKey().getURI().equals(Thing.instance.getURI())){//omit owl:Thing
+ evalDesc = new EvaluatedDescription(entry.getKey(),
+ new AxiomScore(entry.getValue() / (double)individual2Types.keySet().size()));
+ currentlyBestEvaluatedDescriptions.add(evalDesc);
+ }
+
}
+
}
private SortedSet<Entry<NamedClass, Integer>> sortByValues(Map<NamedClass, Integer> map){
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/Thing.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/Thing.java 2011-08-15 22:15:14 UTC (rev 3048)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/Thing.java 2011-08-16 08:08:04 UTC (rev 3049)
@@ -19,6 +19,7 @@
*/
package org.dllearner.core.owl;
+import java.net.URI;
import java.util.Map;
/**
@@ -42,6 +43,8 @@
private static final long serialVersionUID = -880276915058868775L;
public static final Thing instance = new Thing();
+ private static final URI uri = URI.create("http://www.w3.org/2002/07/owl#Thing");
+
public String toString(String baseURI, Map<String,String> prefixes) {
return "TOP";
}
@@ -57,7 +60,11 @@
//return "owl:Thing";
return "Thing";
- }
+ }
+
+ public URI getURI(){
+ return uri;
+ }
public int getLength() {
return 1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-16 14:49:05
|
Revision: 3052
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3052&view=rev
Author: lorenz_b
Date: 2011-08-16 14:48:58 +0000 (Tue, 16 Aug 2011)
Log Message:
-----------
Continued enrichment vocabulary.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java
trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java
trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-16 10:08:40 UTC (rev 3051)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-16 14:48:58 UTC (rev 3052)
@@ -54,6 +54,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
@@ -158,8 +159,10 @@
}
private void addIndividualsWithTypes(Map<Individual, SortedSet<NamedClass>> ind2Types, int limit, int offset){
- String query = String.format("SELECT DISTINCT ?ind ?type WHERE {?ind a <%s>. ?ind a ?type} LIMIT %d OFFSET %d", classToDescribe.getName(), limit, offset);
+// String query = String.format("SELECT DISTINCT ?ind ?type WHERE {?ind a <%s>. ?ind a ?type} LIMIT %d OFFSET %d", classToDescribe.getName(), limit, offset);
+ String query = String.format("SELECT DISTINCT ?ind ?type WHERE {?ind a ?type. {SELECT ?ind {?ind a <%s>} LIMIT %d OFFSET %d}}", classToDescribe.getName(), limit, offset);
+
ResultSet rs = new SparqlQuery(query, ks.getEndpoint()).send();
Individual ind;
NamedClass newType;
@@ -176,6 +179,7 @@
}
types.add(newType);
}
+
}
private void createEvaluatedDescriptions(Map<Individual, SortedSet<NamedClass>> individual2Types){
Modified: trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-16 10:08:40 UTC (rev 3051)
+++ trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-16 14:48:58 UTC (rev 3052)
@@ -3,6 +3,7 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.apache.commons.codec.digest.DigestUtils;
@@ -13,6 +14,7 @@
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLAnnotation;
import org.semanticweb.owlapi.model.OWLAnnotationAxiom;
+import org.semanticweb.owlapi.model.OWLAnnotationSubject;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
@@ -57,9 +59,11 @@
ManchesterOWLSyntaxObjectRenderer r = new ManchesterOWLSyntaxObjectRenderer(pw, new ManchesterOWLSyntaxPrefixNameShortFormProvider(new DefaultPrefixManager()));
OWLAxiom ax = OWLAPIConverter.getOWLAPIAxiom(axiom);
ax.accept(r);
+ System.out.println(sw.toString());
OWLAxiom ax1 = f.getOWLClassAssertionAxiom(EnrichmentVocabulary.Suggestion, ind);
OWLAxiom ax2 = f.getOWLDataPropertyAssertionAxiom(EnrichmentVocabulary.hasAxiom, ind, sw.toString());
+// f.getOWLAnnotationAssertionAxiom(f.getOWLAnnotationProperty(IRI.create("annoProp")), ind.getIRI(), ax);
OWLAxiom ax3 = f.getOWLDataPropertyAssertionAxiom(EnrichmentVocabulary.confidence, ind, score.getAccuracy());
List<OWLAxiom> axioms = new ArrayList<OWLAxiom>();
Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2011-08-16 10:08:40 UTC (rev 3051)
+++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2011-08-16 14:48:58 UTC (rev 3052)
@@ -467,6 +467,22 @@
}
return superClasses;
}
+
+ public SortedSet<Description> getSuperClasses(Description description, boolean direct){
+ if(!(description instanceof NamedClass)){
+ throw new IllegalArgumentException("Only named classes are supported.");
+ }
+ SortedSet<Description> superClasses = new TreeSet<Description>();
+ //this query is virtuoso specific
+ String query = String.format("SELECT DISTINCT ?y WHERE {" +
+ "{ SELECT ?x ?y WHERE { ?x rdfs:subClassOf ?y } }" +
+ "OPTION ( TRANSITIVE, T_DISTINCT, t_in(?x), t_out(?y), t_step('path_id') as ?path, t_step(?x) as ?route, t_step('step_no') AS ?jump, T_DIRECTION 3 )" +
+ "FILTER ( ?x = <%s> )}", ((NamedClass)description).getURI().toString());
+
+
+
+ return superClasses;
+ }
@Override
public SortedSet<Description> getSubClasses(Description description) {
Modified: trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java 2011-08-16 10:08:40 UTC (rev 3051)
+++ trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java 2011-08-16 14:48:58 UTC (rev 3052)
@@ -17,13 +17,19 @@
//the classes
public static final OWLClass ChangeSet = factory.getOWLClass(IRI.create(NS + "ChangeSet"));
+ public static final OWLClass SuggestionSet = factory.getOWLClass(IRI.create(NS + "SuggestionSet"));
+
public static final OWLClass Suggestion = factory.getOWLClass(IRI.create(NS + "Suggestion"));
public static final OWLClass Parameter = factory.getOWLClass(IRI.create(NS + "Parameter"));
+ public static final OWLClass Creation = factory.getOWLClass(IRI.create(NS + "Creation"));
+ public static final OWLClass AlgorithmRun = factory.getOWLClass(IRI.create(NS + "AlgorithmRun"));
+
+
//the object properties
- public static final OWLObjectProperty creation = factory.getOWLObjectProperty(IRI.create(NS + "creation"));
+ public static final OWLObjectProperty creator = factory.getOWLObjectProperty(IRI.create(NS + "creatr"));
// public static final OWLObjectProperty hasAxiom = factory.getOWLObjectProperty(IRI.create(NS + "hasAxiom"));
@@ -31,6 +37,8 @@
public static final OWLObjectProperty hasInput = factory.getOWLObjectProperty(IRI.create(NS + "hasInput"));
+ public static final OWLObjectProperty hasSuggestion = factory.getOWLObjectProperty(IRI.create(NS + "hasSuggestion"));
+
public static final OWLObjectProperty hasParameter = factory.getOWLObjectProperty(IRI.create(NS + "hasParameter"));
public static final OWLObjectProperty usedAlgorithm = factory.getOWLObjectProperty(IRI.create(NS + "usedAlgorithm"));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-17 08:26:39
|
Revision: 3055
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3055&view=rev
Author: lorenz_b
Date: 2011-08-17 08:26:33 +0000 (Wed, 17 Aug 2011)
Log Message:
-----------
Continued enrichment vocabulary and more readable output.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java
trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java
Modified: trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-17 07:07:55 UTC (rev 3054)
+++ trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-17 08:26:33 UTC (rev 3055)
@@ -3,20 +3,18 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.commons.codec.digest.DigestUtils;
import org.dllearner.core.owl.Axiom;
import org.dllearner.utilities.EnrichmentVocabulary;
import org.dllearner.utilities.owl.OWLAPIConverter;
-import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor;
import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLAnnotation;
-import org.semanticweb.owlapi.model.OWLAnnotationAxiom;
-import org.semanticweb.owlapi.model.OWLAnnotationSubject;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLIndividual;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.util.DefaultPrefixManager;
@@ -47,11 +45,12 @@
return axiom + "(" + score.getAccuracy()+ ")";
}
- public List<OWLAxiom> toRDF(){
+ public Map<OWLIndividual, List<OWLAxiom>> toRDF(String defaultNamespace){
+ Map<OWLIndividual, List<OWLAxiom>> ind2Axioms = new HashMap<OWLIndividual, List<OWLAxiom>>();
OWLDataFactory f = new OWLDataFactoryImpl();
String id = DigestUtils.md5Hex(axiom.toString()) + score.getAccuracy();
- OWLNamedIndividual ind = f.getOWLNamedIndividual(IRI.create(EnrichmentVocabulary.NS + id));
+ OWLNamedIndividual ind = f.getOWLNamedIndividual(IRI.create(defaultNamespace + id));
StringWriter sw = new StringWriter();
@@ -59,7 +58,6 @@
ManchesterOWLSyntaxObjectRenderer r = new ManchesterOWLSyntaxObjectRenderer(pw, new ManchesterOWLSyntaxPrefixNameShortFormProvider(new DefaultPrefixManager()));
OWLAxiom ax = OWLAPIConverter.getOWLAPIAxiom(axiom);
ax.accept(r);
- System.out.println(sw.toString());
OWLAxiom ax1 = f.getOWLClassAssertionAxiom(EnrichmentVocabulary.Suggestion, ind);
OWLAxiom ax2 = f.getOWLDataPropertyAssertionAxiom(EnrichmentVocabulary.hasAxiom, ind, sw.toString());
@@ -71,7 +69,9 @@
axioms.add(ax2);
axioms.add(ax3);
- return axioms;
+ ind2Axioms.put(ind, axioms);
+
+ return ind2Axioms;
}
Modified: trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java 2011-08-17 07:07:55 UTC (rev 3054)
+++ trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java 2011-08-17 08:26:33 UTC (rev 3055)
@@ -29,7 +29,7 @@
//the object properties
- public static final OWLObjectProperty creator = factory.getOWLObjectProperty(IRI.create(NS + "creatr"));
+ public static final OWLObjectProperty creator = factory.getOWLObjectProperty(IRI.create(NS + "creator"));
// public static final OWLObjectProperty hasAxiom = factory.getOWLObjectProperty(IRI.create(NS + "hasAxiom"));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2011-08-17 10:59:13
|
Revision: 3059
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3059&view=rev
Author: jenslehmann
Date: 2011-08-17 10:59:06 +0000 (Wed, 17 Aug 2011)
Log Message:
-----------
introduction of short names and versions for components
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/IrreflexiveObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexiveObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubDataPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubObjectPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitiveObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/ComponentAnn.java
trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -77,7 +77,7 @@
* @author Jens Lehmann
*
*/
-@ComponentAnn(name="CELOE")
+@ComponentAnn(name="CELOE", shortName="celoe", version=1.0)
public class CELOE extends AbstractCELA {
private static Logger logger = Logger.getLogger(CELOE.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -38,7 +38,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="dataproperty domain axiom learner")
+@ComponentAnn(name="dataproperty domain axiom learner", shortName="dpldomain", version=0.1)
public class DataPropertyDomainAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(DataPropertyDomainAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -38,7 +38,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="dataproperty range learner")
+@ComponentAnn(name="dataproperty range learner", shortName="dblrange", version=0.1)
public class DataPropertyRangeAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(DataPropertyRangeAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -35,7 +35,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="disjoint dataproperty axiom learner")
+@ComponentAnn(name="disjoint dataproperty axiom learner", shortName="dpldisjoint", version=0.1)
public class DisjointDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -35,7 +35,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="disjoint objectproperty axiom learner")
+@ComponentAnn(name="disjoint objectproperty axiom learner", shortName="opldisjoint", version=0.1)
public class DisjointObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -32,7 +32,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="equivalent dataproperty axiom learner")
+@ComponentAnn(name="equivalent dataproperty axiom learner", shortName="dplequiv", version=0.1)
public class EquivalentDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(EquivalentDataPropertyAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -34,7 +34,7 @@
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
-@ComponentAnn(name="equivalent objectproperty axiom learner")
+@ComponentAnn(name="equivalent objectproperty axiom learner", shortName="oplequiv", version=0.1)
public class EquivalentObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(EquivalentObjectPropertyAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -28,7 +28,7 @@
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
import com.hp.hpl.jena.vocabulary.OWL;
-@ComponentAnn(name="functional dataproperty axiom learner")
+@ComponentAnn(name="functional dataproperty axiom learner", shortName="dplfunc", version=0.1)
public class FunctionalDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(FunctionalDataPropertyAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -28,7 +28,7 @@
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
import com.hp.hpl.jena.vocabulary.OWL;
-@ComponentAnn(name="functional objectproperty axiom learner")
+@ComponentAnn(name="functional objectproperty axiom learner", shortName="oplfunc", version=0.1)
public class FunctionalObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(FunctionalObjectPropertyAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -28,7 +28,7 @@
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
import com.hp.hpl.jena.vocabulary.OWL;
-@ComponentAnn(name="inversefunctional objectproperty axiom learner")
+@ComponentAnn(name="inversefunctional objectproperty axiom learner", shortName="oplinvfunc", version=0.1)
public class InverseFunctionalObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(InverseFunctionalObjectPropertyAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/IrreflexiveObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/IrreflexiveObjectPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/IrreflexiveObjectPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -28,7 +28,7 @@
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
import com.hp.hpl.jena.vocabulary.OWL2;
-@ComponentAnn(name="irreflexive objectproperty axiom learner")
+@ComponentAnn(name="irreflexive objectproperty axiom learner", shortName="oplirrefl", version=0.1)
public class IrreflexiveObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(IrreflexiveObjectPropertyAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -39,7 +39,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="objectproperty domain axiom learner")
+@ComponentAnn(name="objectproperty domain axiom learner", shortName="opldomain", version=0.1)
public class ObjectPropertyDomainAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyRangeAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyRangeAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -39,7 +39,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="objectproperty range learner")
+@ComponentAnn(name="objectproperty range learner", shortName="oplrange", version=0.1)
public class ObjectPropertyRangeAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyRangeAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexiveObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexiveObjectPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexiveObjectPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -28,7 +28,7 @@
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
import com.hp.hpl.jena.vocabulary.OWL2;
-@ComponentAnn(name="reflexive objectproperty axiom learner")
+@ComponentAnn(name="reflexive objectproperty axiom learner", shortName="oplrefl", version=0.1)
public class ReflexiveObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(ReflexiveObjectPropertyAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubDataPropertyOfAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubDataPropertyOfAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubDataPropertyOfAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -32,7 +32,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-@ComponentAnn(name="data subPropertyOf axiom learner")
+@ComponentAnn(name="data subPropertyOf axiom learner", shortName="dplsubprop", version=0.1)
public class SubDataPropertyOfAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubObjectPropertyOfAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubObjectPropertyOfAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubObjectPropertyOfAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -36,7 +36,7 @@
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
-@ComponentAnn(name="object subPropertyOf axiom learner")
+@ComponentAnn(name="object subPropertyOf axiom learner", shortName="oplsubprop", version=0.1)
public class SubObjectPropertyOfAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricObjectPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricObjectPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -28,7 +28,7 @@
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
import com.hp.hpl.jena.vocabulary.OWL2;
-@ComponentAnn(name="symmetric objectproperty axiom learner")
+@ComponentAnn(name="symmetric objectproperty axiom learner", shortName="oplsymm", version=0.1)
public class SymmetricObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(SymmetricObjectPropertyAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitiveObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitiveObjectPropertyAxiomLearner.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitiveObjectPropertyAxiomLearner.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -29,7 +29,7 @@
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
import com.hp.hpl.jena.vocabulary.OWL;
-@ComponentAnn(name="transitive objectproperty axiom learner")
+@ComponentAnn(name="transitive objectproperty axiom learner", shortName="opltrans", version=0.1)
public class TransitiveObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(TransitiveObjectPropertyAxiomLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/core/ComponentAnn.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/ComponentAnn.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/core/ComponentAnn.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -40,4 +40,17 @@
*/
String name();
+ /**
+ * The short name of this component, which should exclusively consist of
+ * lower case ASCII symbols without whitespace.
+ * @return The short name of this component.
+ */
+ String shortName();
+
+ /**
+ * The version of this component. 1.0 indicates a stable component. Developers
+ * should increase the version number in case of major implementation changes.
+ * @return A version number of this component.
+ */
+ double version();
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java 2011-08-17 10:58:25 UTC (rev 3058)
+++ trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java 2011-08-17 10:59:06 UTC (rev 3059)
@@ -43,11 +43,11 @@
* The description of this config option
* @return
*/
- String description();
+ String description() default "no description available";
/**
* An implementation of the Property Editor to use
* @return
*/
- Class propertyEditorClass();
+ Class<?> propertyEditorClass();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-18 09:22:22
|
Revision: 3067
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3067&view=rev
Author: lorenz_b
Date: 2011-08-18 09:22:16 +0000 (Thu, 18 Aug 2011)
Log Message:
-----------
Added axiom learning interface.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/DisjointClassesAxiom.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java 2011-08-18 08:55:11 UTC (rev 3066)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java 2011-08-18 09:22:16 UTC (rev 3067)
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -29,14 +30,18 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.ClassExpressionLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedAxiom;
import org.dllearner.core.EvaluatedDescription;
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.config.NamedClassEditor;
+import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.Description;
+import org.dllearner.core.owl.DisjointClassesAxiom;
import org.dllearner.core.owl.NamedClass;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
@@ -58,7 +63,7 @@
*
*/
@ComponentAnn(name = "disjoint classes learner", shortName = "cldisjoint", version = 0.1)
-public class DisjointClassesLearner implements ClassExpressionLearningAlgorithm {
+public class DisjointClassesLearner implements ClassExpressionLearningAlgorithm, AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(DisjointClassesLearner.class);
@@ -178,6 +183,30 @@
return currentlyBestEvaluatedDescriptions.subList(0, max);
}
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ List<Axiom> bestAxioms = new ArrayList<Axiom>();
+
+ for(EvaluatedAxiom evAx : getCurrentlyBestEvaluatedAxioms(nrOfAxioms)){
+ bestAxioms.add(evAx.getAxiom());
+ }
+
+ return bestAxioms;
+ }
+
+ @Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ List<EvaluatedAxiom> axioms = new ArrayList<EvaluatedAxiom>();
+ Set<Description> descriptions;
+ for(EvaluatedDescription ed : getCurrentlyBestEvaluatedDescriptions(nrOfAxioms)){
+ descriptions = new HashSet<Description>();
+ descriptions.add(classToDescribe);
+ descriptions.add(ed.getDescription());
+ axioms.add(new EvaluatedAxiom(new DisjointClassesAxiom(descriptions), new AxiomScore(ed.getAccuracy())));
+ }
+ return axioms;
+ }
+
private List<EvaluatedDescription> buildEvaluatedClassDescriptions(Map<NamedClass, Integer> class2Count, Set<NamedClass> allClasses){
List<EvaluatedDescription> evalDescs = new ArrayList<EvaluatedDescription>();
@@ -265,7 +294,5 @@
}
-
-
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-18 08:55:11 UTC (rev 3066)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-18 09:22:16 UTC (rev 3067)
@@ -24,38 +24,33 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
+import java.util.Map.Entry;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.Map.Entry;
-import org.dllearner.algorithms.properties.ObjectPropertyDomainAxiomLearner;
+import org.dllearner.core.AxiomLearningAlgorithm;
import org.dllearner.core.ClassExpressionLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
import org.dllearner.core.EvaluatedDescription;
-import org.dllearner.core.Score;
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.config.NamedClassEditor;
-import org.dllearner.core.config.ObjectPropertyEditor;
+import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
import org.dllearner.core.owl.NamedClass;
-import org.dllearner.core.owl.ObjectProperty;
-import org.dllearner.core.owl.ObjectPropertyDomainAxiom;
+import org.dllearner.core.owl.SubClassAxiom;
import org.dllearner.core.owl.Thing;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.kb.sparql.SparqlQuery;
import org.dllearner.learningproblems.AxiomScore;
-import org.dllearner.learningproblems.ClassScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
@@ -67,7 +62,7 @@
*
*/
@ComponentAnn(name = "simple subclass learner", shortName = "clsub", version = 0.1)
-public class SimpleSubclassLearner implements ClassExpressionLearningAlgorithm {
+public class SimpleSubclassLearner implements ClassExpressionLearningAlgorithm, AxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(SimpleSubclassLearner.class);
@@ -104,8 +99,28 @@
int max = Math.min(currentlyBestEvaluatedDescriptions.size(), nrOfDescriptions);
return currentlyBestEvaluatedDescriptions.subList(0, max);
}
+
+ @Override
+ public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
+ List<Axiom> bestAxioms = new ArrayList<Axiom>();
+
+ for(EvaluatedAxiom evAx : getCurrentlyBestEvaluatedAxioms(nrOfAxioms)){
+ bestAxioms.add(evAx.getAxiom());
+ }
+
+ return bestAxioms;
+ }
@Override
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ List<EvaluatedAxiom> axioms = new ArrayList<EvaluatedAxiom>();
+ for(EvaluatedDescription ed : getCurrentlyBestEvaluatedDescriptions(nrOfAxioms)){
+ axioms.add(new EvaluatedAxiom(new SubClassAxiom(classToDescribe, ed.getDescription()), new AxiomScore(ed.getAccuracy())));
+ }
+ return axioms;
+ }
+
+ @Override
public void start() {
logger.info("Start learning...");
startTime = System.currentTimeMillis();
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DisjointClassesAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/DisjointClassesAxiom.java 2011-08-18 08:55:11 UTC (rev 3066)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/DisjointClassesAxiom.java 2011-08-18 09:22:16 UTC (rev 3067)
@@ -52,8 +52,7 @@
* @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map)
*/
public String toString(String baseURI, Map<String, String> prefixes) {
- // TODO Auto-generated method stub
- return null;
+ return "DisjointClasses()";
}
public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-19 08:51:29
|
Revision: 3070
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3070&view=rev
Author: lorenz_b
Date: 2011-08-19 08:51:21 +0000 (Fri, 19 Aug 2011)
Log Message:
-----------
Added methods to get only axioms whose accuracy is above a specific threshold.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/IrreflexiveObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyRangeAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexiveObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubDataPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubObjectPropertyOfAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitiveObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java
trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java
Added Paths:
-----------
trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -30,7 +30,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ClassExpressionLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
@@ -63,7 +63,7 @@
*
*/
@ComponentAnn(name = "disjoint classes learner", shortName = "cldisjoint", version = 0.1)
-public class DisjointClassesLearner implements ClassExpressionLearningAlgorithm, AxiomLearningAlgorithm {
+public class DisjointClassesLearner extends AbstractAxiomLearningAlgorithm implements ClassExpressionLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(DisjointClassesLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -28,7 +28,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ClassExpressionLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
@@ -62,7 +62,7 @@
*
*/
@ComponentAnn(name = "simple subclass learner", shortName = "clsub", version = 0.1)
-public class SimpleSubclassLearner implements ClassExpressionLearningAlgorithm, AxiomLearningAlgorithm {
+public class SimpleSubclassLearner extends AbstractAxiomLearningAlgorithm implements ClassExpressionLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(SimpleSubclassLearner.class);
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -3,15 +3,13 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedSet;
import java.util.TreeSet;
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -19,7 +17,6 @@
import org.dllearner.core.config.DataPropertyEditor;
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.DatatypeProperty;
import org.dllearner.core.owl.DatatypePropertyDomainAxiom;
import org.dllearner.core.owl.Description;
@@ -37,7 +34,7 @@
import com.hp.hpl.jena.query.ResultSet;
@ComponentAnn(name="dataproperty domain axiom learner", shortName="dpldomain", version=0.1)
-public class DataPropertyDomainAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class DataPropertyDomainAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(DataPropertyDomainAxiomLearner.class);
@@ -107,25 +104,9 @@
}
@Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- List<Axiom> bestAxioms = new ArrayList<Axiom>();
-
- Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
- while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
- bestAxioms.add(it.next().getAxiom());
- }
-
- return bestAxioms;
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms() {
+ return currentlyBestAxioms;
}
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
- int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
-
- List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
-
- return bestAxioms;
- }
@Override
public Configurator getConfigurator() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -10,8 +10,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -36,7 +35,7 @@
import com.hp.hpl.jena.query.ResultSet;
@ComponentAnn(name="dataproperty range learner", shortName="dblrange", version=0.1)
-public class DataPropertyRangeAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class DataPropertyRangeAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(DataPropertyRangeAxiomLearner.class);
@@ -106,25 +105,9 @@
}
@Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- List<Axiom> bestAxioms = new ArrayList<Axiom>();
-
- Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
- while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
- bestAxioms.add(it.next().getAxiom());
- }
-
- return bestAxioms;
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms() {
+ return currentlyBestAxioms;
}
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
- int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
-
- List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
-
- return bestAxioms;
- }
@Override
public Configurator getConfigurator() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -11,8 +10,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -20,10 +18,8 @@
import org.dllearner.core.config.DataPropertyEditor;
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.DatatypeProperty;
import org.dllearner.core.owl.DisjointDatatypePropertyAxiom;
-import org.dllearner.core.owl.SubDatatypePropertyAxiom;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.kb.sparql.SparqlEndpoint;
@@ -36,7 +32,7 @@
import com.hp.hpl.jena.query.ResultSet;
@ComponentAnn(name="disjoint dataproperty axiom learner", shortName="dpldisjoint", version=0.1)
-public class DisjointDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class DisjointDataPropertyAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner.class);
@@ -133,25 +129,9 @@
}
@Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- List<Axiom> bestAxioms = new ArrayList<Axiom>();
-
- Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
- while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
- bestAxioms.add(it.next().getAxiom());
- }
-
- return bestAxioms;
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms() {
+ return currentlyBestAxioms;
}
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
- int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
-
- List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
-
- return bestAxioms;
- }
@Override
public Configurator getConfigurator() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -11,8 +10,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -20,13 +18,11 @@
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.DisjointObjectPropertyAxiom;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
import org.dllearner.kb.sparql.SPARQLTasks;
-import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
@@ -36,7 +32,7 @@
import com.hp.hpl.jena.query.ResultSet;
@ComponentAnn(name="disjoint objectproperty axiom learner", shortName="opldisjoint", version=0.1)
-public class DisjointObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class DisjointObjectPropertyAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner.class);
@@ -132,27 +128,13 @@
logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime));
}
-
- @Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- List<Axiom> bestAxioms = new ArrayList<Axiom>();
-
- for(EvaluatedAxiom evAx : getCurrentlyBestEvaluatedAxioms(nrOfAxioms)){
- bestAxioms.add(evAx.getAxiom());
- }
-
- return bestAxioms;
- }
@Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
- int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
-
- List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
-
- return bestAxioms;
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms() {
+ return currentlyBestAxioms;
}
+
@Override
public Configurator getConfigurator() {
// TODO Auto-generated method stub
@@ -238,12 +220,6 @@
return resultSet;
}
- public static void main(String[] args) throws Exception{
- DisjointObjectPropertyAxiomLearner l = new DisjointObjectPropertyAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()));
- l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/assembly"));
- l.init();
- l.start();
- System.out.println(l.getCurrentlyBestEvaluatedAxioms(5));
- }
-
+
+
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -3,15 +3,13 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedSet;
import java.util.TreeSet;
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -19,7 +17,6 @@
import org.dllearner.core.config.DataPropertyEditor;
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.DatatypeProperty;
import org.dllearner.core.owl.EquivalentDatatypePropertiesAxiom;
import org.dllearner.kb.SparqlEndpointKS;
@@ -33,7 +30,7 @@
import com.hp.hpl.jena.query.ResultSet;
@ComponentAnn(name="equivalent dataproperty axiom learner", shortName="dplequiv", version=0.1)
-public class EquivalentDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class EquivalentDataPropertyAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(EquivalentDataPropertyAxiomLearner.class);
@@ -129,25 +126,9 @@
}
@Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- List<Axiom> bestAxioms = new ArrayList<Axiom>();
-
- Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
- while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
- bestAxioms.add(it.next().getAxiom());
- }
-
- return bestAxioms;
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms() {
+ return currentlyBestAxioms;
}
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
- int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
-
- List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
-
- return bestAxioms;
- }
@Override
public Configurator getConfigurator() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -3,15 +3,13 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedSet;
import java.util.TreeSet;
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -19,12 +17,10 @@
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.EquivalentObjectPropertiesAxiom;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP;
-import org.dllearner.kb.sparql.SparqlQuery;
import org.dllearner.learningproblems.AxiomScore;
import org.dllearner.reasoning.SPARQLReasoner;
import org.slf4j.Logger;
@@ -32,10 +28,9 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
-import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
@ComponentAnn(name="equivalent objectproperty axiom learner", shortName="oplequiv", version=0.1)
-public class EquivalentObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class EquivalentObjectPropertyAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(EquivalentObjectPropertyAxiomLearner.class);
@@ -131,25 +126,9 @@
}
@Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- List<Axiom> bestAxioms = new ArrayList<Axiom>();
-
- Iterator<EvaluatedAxiom> it = currentlyBestAxioms.iterator();
- while(bestAxioms.size() < nrOfAxioms && it.hasNext()){
- bestAxioms.add(it.next().getAxiom());
- }
-
- return bestAxioms;
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms() {
+ return currentlyBestAxioms;
}
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
- int max = Math.min(currentlyBestAxioms.size(), nrOfAxioms);
-
- List<EvaluatedAxiom> bestAxioms = currentlyBestAxioms.subList(0, max);
-
- return bestAxioms;
- }
@Override
public Configurator getConfigurator() {
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -1,11 +1,9 @@
package org.dllearner.algorithms.properties;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -13,7 +11,6 @@
import org.dllearner.core.config.DataPropertyEditor;
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.DatatypeProperty;
import org.dllearner.core.owl.FunctionalDatatypePropertyAxiom;
import org.dllearner.kb.SparqlEndpointKS;
@@ -29,7 +26,7 @@
import com.hp.hpl.jena.vocabulary.OWL;
@ComponentAnn(name="functional dataproperty axiom learner", shortName="dplfunc", version=0.1)
-public class FunctionalDataPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class FunctionalDataPropertyAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(FunctionalDataPropertyAxiomLearner.class);
@@ -117,12 +114,7 @@
}
@Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- return currentlyBestAxioms.isEmpty() ? Collections.<Axiom>emptyList() : Collections.singletonList(currentlyBestAxioms.get(0).getAxiom());
- }
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms() {
return currentlyBestAxioms;
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -1,11 +1,9 @@
package org.dllearner.algorithms.properties;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.dllearner.core.AxiomLearningAlgorithm;
-import org.dllearner.core.AbstractComponent;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -13,7 +11,6 @@
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.FunctionalObjectPropertyAxiom;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
@@ -29,7 +26,7 @@
import com.hp.hpl.jena.vocabulary.OWL;
@ComponentAnn(name="functional objectproperty axiom learner", shortName="oplfunc", version=0.1)
-public class FunctionalObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class FunctionalObjectPropertyAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(FunctionalObjectPropertyAxiomLearner.class);
@@ -117,12 +114,7 @@
}
@Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- return currentlyBestAxioms.isEmpty() ? Collections.<Axiom>emptyList() : Collections.singletonList(currentlyBestAxioms.get(0).getAxiom());
- }
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms() {
return currentlyBestAxioms;
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -1,11 +1,9 @@
package org.dllearner.algorithms.properties;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -13,7 +11,6 @@
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.InverseFunctionalObjectPropertyAxiom;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
@@ -29,7 +26,7 @@
import com.hp.hpl.jena.vocabulary.OWL;
@ComponentAnn(name="inversefunctional objectproperty axiom learner", shortName="oplinvfunc", version=0.1)
-public class InverseFunctionalObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class InverseFunctionalObjectPropertyAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(InverseFunctionalObjectPropertyAxiomLearner.class);
@@ -117,12 +114,7 @@
}
@Override
- public List<Axiom> getCurrentlyBestAxioms(int nrOfAxioms) {
- return currentlyBestAxioms.isEmpty() ? Collections.<Axiom>emptyList() : Collections.singletonList(currentlyBestAxioms.get(0).getAxiom());
- }
-
- @Override
- public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) {
+ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms() {
return currentlyBestAxioms;
}
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/IrreflexiveObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/IrreflexiveObjectPropertyAxiomLearner.java 2011-08-18 14:49:21 UTC (rev 3069)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/IrreflexiveObjectPropertyAxiomLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
@@ -1,11 +1,9 @@
package org.dllearner.algorithms.properties;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.dllearner.core.AbstractComponent;
-import org.dllearner.core.AxiomLearningAlgorithm;
+import org.dllearner.core.AbstractAxiomLearningAlgorithm;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedAxiom;
@@ -13,7 +11,6 @@
import org.dllearner.core.config.IntegerEditor;
import org.dllearner.core.config.ObjectPropertyEditor;
import org.dllearner.core.configurators.Configurator;
-import org.dllearner.core.owl.Axiom;
import org.dllearner.core.owl.IrreflexiveObjectPropertyAxiom;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.SparqlEndpointKS;
@@ -29,7 +26,7 @@
import com.hp.hpl.jena.vocabulary.OWL2;
@ComponentAnn(name="irreflexive objectproperty axiom learner", shortName="oplirrefl", version=0.1)
-public class IrreflexiveObjectPropertyAxiomLearner extends AbstractComponent implements AxiomLearningAlgorithm {
+public class IrreflexiveObjectPropertyAxiomLearner extends AbstractAxiomLearningAlgorithm {
private static final Logger logger = LoggerFactory.getLogger(IrreflexiveObjectPropertyAxiomLearner.cl...
[truncated message content] |
|
From: <lor...@us...> - 2011-08-19 11:07:06
|
Revision: 3071
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3071&view=rev
Author: lorenz_b
Date: 2011-08-19 11:07:00 +0000 (Fri, 19 Aug 2011)
Log Message:
-----------
Small changes.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/SubClassAxiom.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-19 08:51:21 UTC (rev 3070)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-19 11:07:00 UTC (rev 3071)
@@ -215,14 +215,15 @@
}
}
+ //omit owl:Thing and classToDescribe
+ result.remove(new NamedClass(Thing.instance.getURI()));
+ result.remove(classToDescribe);
+
EvaluatedDescription evalDesc;
for(Entry<NamedClass, Integer> entry : sortByValues(result)){
- if(!entry.getKey().getURI().equals(Thing.instance.getURI())){//omit owl:Thing
- evalDesc = new EvaluatedDescription(entry.getKey(),
- new AxiomScore(entry.getValue() / (double)individual2Types.keySet().size()));
- currentlyBestEvaluatedDescriptions.add(evalDesc);
- }
-
+ evalDesc = new EvaluatedDescription(entry.getKey(),
+ new AxiomScore(entry.getValue() / (double)individual2Types.keySet().size()));
+ currentlyBestEvaluatedDescriptions.add(evalDesc);
}
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/SubClassAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/SubClassAxiom.java 2011-08-19 08:51:21 UTC (rev 3070)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/SubClassAxiom.java 2011-08-19 11:07:00 UTC (rev 3071)
@@ -51,6 +51,6 @@
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
// TODO Auto-generated method stub
- return "SUBCLASS NOT IMPLEMENTED";
+ return subConcept.toManchesterSyntaxString(baseURI, prefixes) + " subClassOf: " + superConcept.toManchesterSyntaxString(baseURI, prefixes);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sha...@us...> - 2011-08-24 11:12:15
|
Revision: 3110
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3110&view=rev
Author: shadowtm
Date: 2011-08-24 11:12:08 +0000 (Wed, 24 Aug 2011)
Log Message:
-----------
Added back constructors that were in use by the Start program. Also added default initialization in case teh OWLAPIReasoner wasn't working.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java
trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java
trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java
Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java 2011-08-24 10:48:36 UTC (rev 3109)
+++ trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java 2011-08-24 11:12:08 UTC (rev 3110)
@@ -20,6 +20,7 @@
package org.dllearner.learningproblems;
import java.util.Set;
+import java.util.TreeSet;
import org.dllearner.core.AbstractLearningProblem;
import org.dllearner.core.AbstractReasonerComponent;
@@ -36,9 +37,9 @@
*/
public abstract class PosNegLP extends AbstractLearningProblem {
- protected Set<Individual> positiveExamples;
- protected Set<Individual> negativeExamples;
- protected Set<Individual> allExamples;
+ protected Set<Individual> positiveExamples = new TreeSet<Individual>();
+ protected Set<Individual> negativeExamples = new TreeSet<Individual>();
+ protected Set<Individual> allExamples = new TreeSet<Individual>();
@org.dllearner.core.config.ConfigOption(name = "useRetrievalForClassification", description = "\"Specifies whether to use retrieval or instance checks for testing a concept. - NO LONGER FULLY SUPPORTED.",defaultValue = "false", propertyEditorClass = BoolEditor.class)
private boolean useRetrievalForClassification = false;
Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java 2011-08-24 10:48:36 UTC (rev 3109)
+++ trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java 2011-08-24 11:12:08 UTC (rev 3110)
@@ -72,6 +72,10 @@
public PosNegLPStandard() {
}
+ public PosNegLPStandard(AbstractReasonerComponent reasoningService){
+ super(reasoningService);
+ }
+
public PosNegLPStandard(AbstractReasonerComponent reasoningService, SortedSet<Individual> positiveExamples, SortedSet<Individual> negativeExamples) {
this.setReasoner(reasoningService);
this.positiveExamples = positiveExamples;
Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java 2011-08-24 10:48:36 UTC (rev 3109)
+++ trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java 2011-08-24 11:12:08 UTC (rev 3110)
@@ -152,6 +152,10 @@
@Override
public void init() throws ComponentInitException {
+ if(rc == null){
+ rc = new OWLAPIReasoner(sources);
+ rc.init();
+ }
// try {
atomicConcepts = rc.getNamedClasses();
datatypeProperties = rc.getDatatypeProperties();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2011-08-24 11:55:47
|
Revision: 3113
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3113&view=rev
Author: jenslehmann
Date: 2011-08-24 11:55:41 +0000 (Wed, 24 Aug 2011)
Log Message:
-----------
re-added createConfigOption methods
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/kb/KBFile.java
trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java
trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java
Modified: trunk/components-core/src/main/java/org/dllearner/kb/KBFile.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/kb/KBFile.java 2011-08-24 11:20:17 UTC (rev 3112)
+++ trunk/components-core/src/main/java/org/dllearner/kb/KBFile.java 2011-08-24 11:55:41 UTC (rev 3113)
@@ -22,12 +22,15 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URI;
+import java.util.Collection;
+import java.util.LinkedList;
import org.apache.log4j.Logger;
import org.dllearner.core.ComponentAnn;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.AbstractKnowledgeSource;
import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.options.URLConfigOption;
import org.dllearner.core.owl.KB;
import org.dllearner.parser.KBParser;
import org.dllearner.parser.ParseException;
@@ -73,6 +76,15 @@
this.kb = kb;
}
+ public static Collection<org.dllearner.core.options.ConfigOption<?>> createConfigOptions() {
+ Collection<org.dllearner.core.options.ConfigOption<?>> options = new LinkedList<org.dllearner.core.options.ConfigOption<?>>();
+// options.add(new StringConfigOption("filename", "pointer to the KB file on local file system",null, true, true));
+ URLConfigOption urlOption = new URLConfigOption("url", "URL pointer to the KB file",null, false, true);
+ urlOption.setRefersToFile(true);
+ options.add(urlOption);
+ return options;
+ }
+
public static String getName() {
return "KB file";
}
Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java 2011-08-24 11:20:17 UTC (rev 3112)
+++ trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java 2011-08-24 11:55:41 UTC (rev 3113)
@@ -19,11 +19,17 @@
package org.dllearner.learningproblems;
+import java.util.Collection;
+import java.util.LinkedList;
import java.util.Set;
import java.util.TreeSet;
import org.dllearner.core.AbstractLearningProblem;
import org.dllearner.core.AbstractReasonerComponent;
+import org.dllearner.core.options.BooleanConfigOption;
+import org.dllearner.core.options.CommonConfigOptions;
+import org.dllearner.core.options.StringConfigOption;
+import org.dllearner.core.options.StringSetConfigOption;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
import org.dllearner.utilities.Helper;
@@ -84,6 +90,20 @@
super(reasoningService);
}
+ public static Collection<org.dllearner.core.options.ConfigOption<?>> createConfigOptions() {
+ Collection<org.dllearner.core.options.ConfigOption<?>> options = new LinkedList<org.dllearner.core.options.ConfigOption<?>>();
+ options.add(new StringSetConfigOption("positiveExamples",
+ "positive examples",null, true, false));
+ options.add(new StringSetConfigOption("negativeExamples",
+ "negative examples",null, true, false));
+ options.add(new BooleanConfigOption("useRetrievalForClassficiation",
+ "Specifies whether to use retrieval or instance checks for testing a concept. - NO LONGER FULLY SUPPORTED.", false));
+ options.add(CommonConfigOptions.getPercentPerLenghtUnitOption(0.05));
+ StringConfigOption multiInstanceChecks = new StringConfigOption("useMultiInstanceChecks", "See UseMultiInstanceChecks enum. - NO LONGER FULLY SUPPORTED.","twoChecks");
+ multiInstanceChecks.setAllowedValues(new String[] {"never", "twoChecks", "oneCheck"});
+ options.add(multiInstanceChecks);
+ return options;
+ }
/*
* (non-Javadoc)
Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java 2011-08-24 11:20:17 UTC (rev 3112)
+++ trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java 2011-08-24 11:55:41 UTC (rev 3113)
@@ -19,7 +19,9 @@
package org.dllearner.learningproblems;
+import java.util.Collection;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -28,6 +30,9 @@
import org.dllearner.core.EvaluatedDescription;
import org.dllearner.core.AbstractReasonerComponent;
import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.options.BooleanConfigOption;
+import org.dllearner.core.options.DoubleConfigOption;
+import org.dllearner.core.options.StringConfigOption;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
import org.dllearner.learningproblems.Heuristics.HeuristicType;
@@ -82,6 +87,18 @@
this.negativeExamples = negativeExamples;
}
+ public static Collection<org.dllearner.core.options.ConfigOption<?>> createConfigOptions() {
+ Collection<org.dllearner.core.options.ConfigOption<?>> options = new LinkedList<org.dllearner.core.options.ConfigOption<?>>(PosNegLP.createConfigOptions());
+ BooleanConfigOption approx = new BooleanConfigOption("useApproximations", "whether to use stochastic approximations for computing accuracy", false);
+ options.add(approx);
+ DoubleConfigOption approxAccuracy = new DoubleConfigOption("approxAccuracy", "accuracy of the approximation (only for expert use)", 0.05);
+ options.add(approxAccuracy);
+ StringConfigOption accMethod = new StringConfigOption("accuracyMethod", "Specifies, which method/function to use for computing accuracy.","predacc"); // or domain/range of a property.
+ accMethod.setAllowedValues(new String[] {"fmeasure", "predacc"});
+ options.add(accMethod);
+ return options;
+ }
+
@Override
public void init() {
super.init();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-08-24 18:37:24
|
Revision: 3117
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3117&view=rev
Author: lorenz_b
Date: 2011-08-24 18:37:17 +0000 (Wed, 24 Aug 2011)
Log Message:
-----------
Added more axioms to converter.
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java
trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java
trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLLearnerAxiomConvertVisitor.java
trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java 2011-08-24 14:38:09 UTC (rev 3116)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java 2011-08-24 18:37:17 UTC (rev 3117)
@@ -22,9 +22,11 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -173,8 +175,12 @@
property2Count.remove(propertyToDescribe);
EvaluatedAxiom evalAxiom;
+ Set<ObjectProperty> properties;
for(Entry<ObjectProperty, Integer> entry : sortByValues(property2Count)){
- evalAxiom = new EvaluatedAxiom(new EquivalentObjectPropertiesAxiom(propertyToDescribe, entry.getKey()),
+ properties = new HashSet<ObjectProperty>();
+ properties.add(propertyToDescribe);
+ properties.add(entry.getKey());
+ evalAxiom = new EvaluatedAxiom(new EquivalentObjectPropertiesAxiom(properties),
new AxiomScore(entry.getValue() / (double)all));
axioms.add(evalAxiom);
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java 2011-08-24 14:38:09 UTC (rev 3116)
+++ trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java 2011-08-24 18:37:17 UTC (rev 3117)
@@ -19,40 +19,57 @@
package org.dllearner.core.owl;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
public class EquivalentObjectPropertiesAxiom extends PropertyAxiom {
- /**
- *
- */
+
private static final long serialVersionUID = -1085651734702155330L;
- private ObjectProperty role;
- private ObjectProperty equivRole;
+ private Set<ObjectProperty> equivalentProperties;
- public EquivalentObjectPropertiesAxiom(ObjectProperty equivRole, ObjectProperty role) {
- this.role = role;
- this.equivRole = equivRole;
+ public EquivalentObjectPropertiesAxiom(Set<ObjectProperty> equivalentProperties) {
+ this.equivalentProperties = equivalentProperties;
}
- public ObjectProperty getRole() {
- return role;
+ public Set<ObjectProperty> getEquivalentProperties() {
+ return equivalentProperties;
}
- public ObjectProperty getEquivalentRole() {
- return equivRole;
- }
-
public int getLength() {
- return 1 + role.getLength() + equivRole.getLength();
+ int length = 1;
+ for(ObjectProperty p: equivalentProperties)
+ length += p.getLength();
+ return length;
}
public String toString(String baseURI, Map<String,String> prefixes) {
- return "EquivalentObjectProperties(" + equivRole.toString(baseURI, prefixes) + "," + role.toString(baseURI, prefixes) + ")";
+ StringBuffer sb = new StringBuffer();
+ sb.append("EquivalentObjectProperties(");
+ Iterator<ObjectProperty> it = equivalentProperties.iterator();
+ while(it.hasNext()){
+ sb.append(it.next().toString(baseURI, prefixes));
+ if(it.hasNext()){
+ sb.append(", ");
+ }
+ }
+ sb.append(")");
+ return sb.toString();
}
public String toKBSyntaxString(String baseURI, Map<String,String> prefixes) {
- return "EquivalentObjectProperties(" + equivRole.toKBSyntaxString(baseURI, prefixes) + "," + role.toKBSyntaxString(baseURI, prefixes) + ")";
+ StringBuffer sb = new StringBuffer();
+ sb.append("EquivalentObjectProperties(");
+ Iterator<ObjectProperty> it = equivalentProperties.iterator();
+ while(it.hasNext()){
+ sb.append(it.next().toKBSyntaxString(baseURI, prefixes));
+ if(it.hasNext()){
+ sb.append(", ");
+ }
+ }
+ sb.append(")");
+ return sb.toString();
}
@Override
@@ -69,6 +86,16 @@
*/
@Override
public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
- return equivRole.toString(baseURI, prefixes) + " EquivalentTo: " + role.toString(baseURI, prefixes);
+ StringBuffer sb = new StringBuffer();
+ sb.append("EquivalentObjectProperties(");
+ Iterator<ObjectProperty> it = equivalentProperties.iterator();
+ while(it.hasNext()){
+ sb.append(it.next().toManchesterSyntaxString(baseURI, prefixes));
+ if(it.hasNext()){
+ sb.append(", ");
+ }
+ }
+ sb.append(")");
+ return sb.toString();
}
}
Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLLearnerAxiomConvertVisitor.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLLearnerAxiomConvertVisitor.java 2011-08-24 14:38:09 UTC (rev 3116)
+++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLLearnerAxiomConvertVisitor.java 2011-08-24 18:37:17 UTC (rev 3117)
@@ -20,18 +20,35 @@
package org.dllearner.utilities.owl;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import org.dllearner.core.owl.AsymmetricObjectPropertyAxiom;
import org.dllearner.core.owl.Axiom;
+import org.dllearner.core.owl.Datatype;
import org.dllearner.core.owl.DatatypeProperty;
import org.dllearner.core.owl.DatatypePropertyDomainAxiom;
+import org.dllearner.core.owl.DatatypePropertyRangeAxiom;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.DisjointClassesAxiom;
+import org.dllearner.core.owl.DisjointDatatypePropertyAxiom;
+import org.dllearner.core.owl.DisjointObjectPropertyAxiom;
+import org.dllearner.core.owl.EquivalentClassesAxiom;
+import org.dllearner.core.owl.EquivalentDatatypePropertiesAxiom;
+import org.dllearner.core.owl.EquivalentObjectPropertiesAxiom;
+import org.dllearner.core.owl.FunctionalDatatypePropertyAxiom;
+import org.dllearner.core.owl.FunctionalObjectPropertyAxiom;
+import org.dllearner.core.owl.InverseFunctionalObjectPropertyAxiom;
+import org.dllearner.core.owl.IrreflexiveObjectPropertyAxiom;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ObjectPropertyDomainAxiom;
+import org.dllearner.core.owl.ObjectPropertyRangeAxiom;
import org.dllearner.core.owl.ReflexiveObjectPropertyAxiom;
import org.dllearner.core.owl.SubClassAxiom;
+import org.dllearner.core.owl.SubDatatypePropertyAxiom;
+import org.dllearner.core.owl.SubObjectPropertyAxiom;
+import org.dllearner.core.owl.SymmetricObjectPropertyAxiom;
+import org.dllearner.core.owl.TransitiveObjectPropertyAxiom;
import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom;
import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom;
@@ -42,6 +59,7 @@
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom;
+import org.semanticweb.owlapi.model.OWLDataPropertyExpression;
import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom;
import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom;
import org.semanticweb.owlapi.model.OWLDeclarationAxiom;
@@ -63,6 +81,7 @@
import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom;
+import org.semanticweb.owlapi.model.OWLObjectPropertyExpression;
import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom;
import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom;
import org.semanticweb.owlapi.model.OWLSameIndividualAxiom;
@@ -164,9 +183,12 @@
}
@Override
- public void visit(OWLEquivalentObjectPropertiesAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLEquivalentObjectPropertiesAxiom ax) {
+ Set<ObjectProperty> properties = new HashSet<ObjectProperty>();
+ for(OWLObjectPropertyExpression expr : ax.getProperties()){
+ properties.add(new ObjectProperty(expr.asOWLObjectProperty().toStringID()));
+ }
+ axiom = new EquivalentObjectPropertiesAxiom(properties);
}
@Override
@@ -182,21 +204,25 @@
}
@Override
- public void visit(OWLDisjointDataPropertiesAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLDisjointDataPropertiesAxiom ax) {
+ Iterator<OWLDataPropertyExpression> iter = ax.getProperties().iterator();
+ DatatypeProperty p1 = new DatatypeProperty(iter.next().asOWLDataProperty().toStringID());
+ DatatypeProperty p2 = new DatatypeProperty(iter.next().asOWLDataProperty().toStringID());
+ axiom = new DisjointDatatypePropertyAxiom(p1, p2);
}
@Override
- public void visit(OWLDisjointObjectPropertiesAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLDisjointObjectPropertiesAxiom ax) {
+ Iterator<OWLObjectPropertyExpression> iter = ax.getProperties().iterator();
+ ObjectProperty p1 = new ObjectProperty(iter.next().asOWLObjectProperty().toStringID());
+ ObjectProperty p2 = new ObjectProperty(iter.next().asOWLObjectProperty().toStringID());
+ axiom = new DisjointObjectPropertyAxiom(p1, p2);
}
@Override
- public void visit(OWLObjectPropertyRangeAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLObjectPropertyRangeAxiom ax) {
+ axiom = new ObjectPropertyRangeAxiom(new ObjectProperty(ax.getProperty().asOWLObjectProperty().toStringID()),
+ DLLearnerDescriptionConvertVisitor.getDLLearnerDescription(ax.getRange()));
}
@Override
@@ -206,14 +232,14 @@
}
@Override
- public void visit(OWLFunctionalObjectPropertyAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLFunctionalObjectPropertyAxiom ax) {
+ axiom = new FunctionalObjectPropertyAxiom(new ObjectProperty(ax.getProperty().asOWLObjectProperty().toStringID()));
}
@Override
- public void visit(OWLSubObjectPropertyOfAxiom arg0) {
- // TODO Auto-generated method stub
+ public void visit(OWLSubObjectPropertyOfAxiom ax) {
+ axiom = new SubObjectPropertyAxiom(new ObjectProperty(ax.getSubProperty().asOWLObjectProperty().toStringID()),
+ new ObjectProperty(ax.getSuperProperty().asOWLObjectProperty().toStringID()));
}
@@ -224,27 +250,27 @@
}
@Override
- public void visit(OWLSymmetricObjectPropertyAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLSymmetricObjectPropertyAxiom ax) {
+ axiom = new SymmetricObjectPropertyAxiom(new ObjectProperty(ax.getProperty().asOWLObjectProperty().toStringID()));
}
@Override
- public void visit(OWLDataPropertyRangeAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLDataPropertyRangeAxiom ax) {
+ axiom = new DatatypePropertyRangeAxiom(new DatatypeProperty(ax.getProperty().asOWLDataProperty().toStringID()),
+ new Datatype(ax.getRange().asOWLDatatype().toStringID()));
}
@Override
- public void visit(OWLFunctionalDataPropertyAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLFunctionalDataPropertyAxiom ax) {
+ axiom = new FunctionalDatatypePropertyAxiom(new DatatypeProperty(ax.getProperty().asOWLDataProperty().toStringID()));
}
@Override
- public void visit(OWLEquivalentDataPropertiesAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLEquivalentDataPropertiesAxiom ax) {
+ Iterator<OWLDataPropertyExpression> iter = ax.getProperties().iterator();
+ DatatypeProperty p1 = new DatatypeProperty(iter.next().asOWLDataProperty().toStringID());
+ DatatypeProperty p2 = new DatatypeProperty(iter.next().asOWLDataProperty().toStringID());
+ axiom = new EquivalentDatatypePropertiesAxiom(p1, p2);
}
@Override
@@ -254,9 +280,11 @@
}
@Override
- public void visit(OWLEquivalentClassesAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLEquivalentClassesAxiom ax) {
+ Iterator<OWLClassExpression> iter = ax.getClassExpressions().iterator();
+ Description d1 = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription(iter.next());
+ Description d2 = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription(iter.next());
+ axiom = new EquivalentClassesAxiom(d1, d2);
}
@Override
@@ -266,27 +294,24 @@
}
@Override
- public void visit(OWLTransitiveObjectPropertyAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLTransitiveObjectPropertyAxiom ax) {
+ axiom = new TransitiveObjectPropertyAxiom(new ObjectProperty(ax.getProperty().asOWLObjectProperty().toStringID()));
}
@Override
- public void visit(OWLIrreflexiveObjectPropertyAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLIrreflexiveObjectPropertyAxiom ax) {
+ axiom = new IrreflexiveObjectPropertyAxiom(new ObjectProperty(ax.getProperty().asOWLObjectProperty().toStringID()));
}
@Override
- public void visit(OWLSubDataPropertyOfAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLSubDataPropertyOfAxiom ax) {
+ axiom = new SubDatatypePropertyAxiom(new DatatypeProperty(ax.getSubProperty().asOWLDataProperty().toStringID()),
+ new DatatypeProperty(ax.getSuperProperty().asOWLDataProperty().toStringID()));
}
@Override
- public void visit(OWLInverseFunctionalObjectPropertyAxiom arg0) {
- // TODO Auto-generated method stub
-
+ public void visit(OWLInverseFunctionalObjectPropertyAxiom ax) {
+ axiom = new InverseFunctionalObjectPropertyAxiom(new ObjectProperty(ax.getProperty().asOWLObjectProperty().toStringID()));
}
@Override
Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java 2011-08-24 14:38:09 UTC (rev 3116)
+++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java 2011-08-24 18:37:17 UTC (rev 3117)
@@ -49,6 +49,7 @@
import org.dllearner.core.owl.InverseObjectPropertyAxiom;
import org.dllearner.core.owl.IrreflexiveObjectPropertyAxiom;
import org.dllearner.core.owl.KB;
+import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ObjectPropertyAssertion;
import org.dllearner.core.owl.ObjectPropertyDomainAxiom;
import org.dllearner.core.owl.ObjectPropertyRangeAxiom;
@@ -268,11 +269,11 @@
@Override
public void visit(EquivalentObjectPropertiesAxiom axiom) {
- OWLObjectProperty role = factory.getOWLObjectProperty(
- IRI.create(axiom.getRole().getName()));
- OWLObjectProperty equivRole = factory.getOWLObjectProperty(
- IRI.create(axiom.getEquivalentRole().getName()));
- OWLAxiom axiomOWLAPI = factory.getOWLEquivalentObjectPropertiesAxiom(equivRole, role);
+ Set<OWLObjectProperty> properties = new HashSet<OWLObjectProperty>();
+ for(ObjectProperty prop : axiom.getEquivalentProperties()){
+ properties.add(factory.getOWLObjectProperty(IRI.create(prop.getName())));
+ }
+ OWLAxiom axiomOWLAPI = factory.getOWLEquivalentObjectPropertiesAxiom(properties);
addAxiom(axiomOWLAPI);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|