|
From: <ku...@us...> - 2008-09-08 17:59:52
|
Revision: 1179
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1179&view=rev
Author: kurzum
Date: 2008-09-08 17:59:49 +0000 (Mon, 08 Sep 2008)
Log Message:
-----------
more small changes
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/examples/KRKModular.java
trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java
trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java
trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java
trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java
Modified: trunk/src/dl-learner/org/dllearner/examples/KRKModular.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2008-09-08 17:26:27 UTC (rev 1178)
+++ trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2008-09-08 17:59:49 UTC (rev 1179)
@@ -23,6 +23,7 @@
import org.dllearner.core.LearningProblem;
import org.dllearner.core.ReasonerComponent;
import org.dllearner.core.ReasoningService;
+import org.dllearner.core.configurators.ComponentFactory;
import org.dllearner.core.owl.ClassAssertionAxiom;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
@@ -485,8 +486,10 @@
KBFile kbFile = new KBFile(this.kb);
Set<KnowledgeSource> ks = new HashSet<KnowledgeSource>();
ks.add(kbFile);
- reasoner = new OWLAPIReasoner(ks);
- ((OWLAPIReasoner)reasoner).setReasonerType("fact");
+
+ reasoner = ComponentFactory.getOWLAPIReasoner(ks);
+
+ ((OWLAPIReasoner)reasoner).getConfigurator().setReasonerType("fact");
try{
reasoner.init();
}catch (Exception e) {e.printStackTrace();}
Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-09-08 17:26:27 UTC (rev 1178)
+++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-09-08 17:59:49 UTC (rev 1179)
@@ -27,6 +27,7 @@
import org.dllearner.core.ReasoningService;
import org.dllearner.core.Score;
import org.dllearner.core.config.ConfigOption;
+import org.dllearner.core.configurators.PosNegDefinitionLPConfigurator;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
import org.dllearner.utilities.Helper;
@@ -46,15 +47,22 @@
*/
public class PosNegDefinitionLP extends PosNegLP implements DefinitionLP {
+ private PosNegDefinitionLPConfigurator configurator;
+ public PosNegDefinitionLPConfigurator getConfigurator() {
+ return configurator;
+ }
+
public PosNegDefinitionLP(ReasoningService reasoningService) {
super(reasoningService);
+ this.configurator = new PosNegDefinitionLPConfigurator(this);
}
public PosNegDefinitionLP(ReasoningService reasoningService, SortedSet<Individual> positiveExamples, SortedSet<Individual> negativeExamples) {
super(reasoningService);
this.positiveExamples = positiveExamples;
this.negativeExamples = negativeExamples;
+ this.configurator = new PosNegDefinitionLPConfigurator(this);
}
/*
Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-08 17:26:27 UTC (rev 1178)
+++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-08 17:59:49 UTC (rev 1179)
@@ -626,9 +626,9 @@
rc.releaseKB();
}
- public void setReasonerType(String type){
+ /*public void setReasonerType(String type){
configurator.setReasonerType(type);
- }
+ }*/
@Override
Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-08 17:26:27 UTC (rev 1178)
+++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-08 17:59:49 UTC (rev 1179)
@@ -945,9 +945,9 @@
return owlAPIOntologies;
}
- public void setReasonerType(String type){
+ /*public void setReasonerType(String type){
configurator.setReasonerType(type);
- }
+ }*/
@Override
public boolean hasDatatypeSupport() {
Modified: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-09-08 17:26:27 UTC (rev 1178)
+++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-09-08 17:59:49 UTC (rev 1179)
@@ -85,6 +85,7 @@
allIndividuals.addAll( reasoningService.getIndividuals());
reasoningService = null;
+ ComponentManager.getInstance().freeAllComponents();
int count = 1;
while(count<10000){
Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java 2008-09-08 17:26:27 UTC (rev 1178)
+++ trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java 2008-09-08 17:59:49 UTC (rev 1179)
@@ -81,11 +81,11 @@
break;
case OWLAPIREASONERFACT:
rc = cm.reasoner(OWLAPIReasoner.class, ks);
- ((OWLAPIReasoner)rc).setReasonerType("fact");
+ ((OWLAPIReasoner)rc).getConfigurator().setReasonerType("fact");
break;
case OWLAPIREASONERPELLET:
rc = cm.reasoner(OWLAPIReasoner.class, ks);
- ((OWLAPIReasoner)rc).setReasonerType("pellet");
+ ((OWLAPIReasoner)rc).getConfigurator().setReasonerType("pellet");
break;
default:
rc = cm.reasoner(FastInstanceChecker.class, ks);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ku...@us...> - 2008-09-09 09:42:42
|
Revision: 1182
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1182&view=rev
Author: kurzum
Date: 2008-09-09 09:42:37 +0000 (Tue, 09 Sep 2008)
Log Message:
-----------
minor changes
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-09 09:42:10 UTC (rev 1181)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-09 09:42:37 UTC (rev 1182)
@@ -24,6 +24,7 @@
import org.dllearner.algorithms.BruteForceLearner;
import org.dllearner.algorithms.DBpediaNavigationSuggestor;
import org.dllearner.algorithms.RandomGuesser;
+import org.dllearner.algorithms.SimpleSuggestionLearningAlgorithm;
import org.dllearner.algorithms.gp.GP;
import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent;
import org.dllearner.algorithms.refinement.ROLearner;
@@ -32,11 +33,14 @@
import org.dllearner.core.LearningProblemUnsupportedException;
import org.dllearner.core.ReasoningService;
import org.dllearner.kb.KBFile;
+import org.dllearner.kb.OWLAPIOntology;
import org.dllearner.kb.OWLFile;
import org.dllearner.kb.sparql.SparqlKnowledgeSource;
import org.dllearner.learningproblems.PosNegDefinitionLP;
+import org.dllearner.learningproblems.PosNegDefinitionLPStrict;
import org.dllearner.learningproblems.PosNegInclusionLP;
import org.dllearner.learningproblems.PosOnlyDefinitionLP;
+import org.dllearner.learningproblems.PosOnlyInclusionLP;
import org.dllearner.reasoning.DIGReasoner;
import org.dllearner.reasoning.FastInstanceChecker;
import org.dllearner.reasoning.FastRetrievalReasoner;
@@ -57,6 +61,13 @@
}
/**
+* @return a component ready for initialization OWLAPIOntology
+**/
+public static OWLAPIOntology getOWLAPIOntology() {
+return OWLAPIOntologyConfigurator.getOWLAPIOntology();
+}
+
+/**
* @param url URL pointing to the OWL file
* @return a component ready for initialization OWLFile
**/
@@ -119,6 +130,16 @@
* @param positiveExamples positive examples
* @param negativeExamples negative examples
* @param reasoningService see ReasoningService
+* @return a component ready for initialization PosNegDefinitionLPStrict
+**/
+public static PosNegDefinitionLPStrict getPosNegDefinitionLPStrict(ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) {
+return PosNegDefinitionLPStrictConfigurator.getPosNegDefinitionLPStrict(reasoningService, positiveExamples, negativeExamples);
+}
+
+/**
+* @param positiveExamples positive examples
+* @param negativeExamples negative examples
+* @param reasoningService see ReasoningService
* @return a component ready for initialization PosNegInclusionLP
**/
public static PosNegInclusionLP getPosNegInclusionLP(ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) {
@@ -135,6 +156,15 @@
}
/**
+* @param positiveExamples positive examples
+* @param reasoningService see ReasoningService
+* @return a component ready for initialization PosOnlyInclusionLP
+**/
+public static PosOnlyInclusionLP getPosOnlyInclusionLP(ReasoningService reasoningService, Set<String> positiveExamples) {
+return PosOnlyInclusionLPConfigurator.getPosOnlyInclusionLP(reasoningService, positiveExamples);
+}
+
+/**
* @param learningProblem see LearningProblem
* @param reasoningService see ReasoningService
* @throws LearningProblemUnsupportedException see
@@ -168,6 +198,16 @@
* @param learningProblem see LearningProblem
* @param reasoningService see ReasoningService
* @throws LearningProblemUnsupportedException see
+* @return a component ready for initialization SimpleSuggestionLearningAlgorithm
+**/
+public static SimpleSuggestionLearningAlgorithm getSimpleSuggestionLearningAlgorithm(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException {
+return SimpleSuggestionLearningAlgorithmConfigurator.getSimpleSuggestionLearningAlgorithm(learningProblem, reasoningService);
+}
+
+/**
+* @param learningProblem see LearningProblem
+* @param reasoningService see ReasoningService
+* @throws LearningProblemUnsupportedException see
* @return a component ready for initialization GP
**/
public static GP getGP(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException {
Added: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
@@ -0,0 +1,62 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package org.dllearner.core.configurators;
+
+import org.dllearner.core.ComponentManager;
+import org.dllearner.kb.OWLAPIOntology;
+
+/**
+* automatically generated, do not edit manually.
+* run org.dllearner.scripts.ConfigJavaGenerator to update
+**/
+public class OWLAPIOntologyConfigurator {
+
+private boolean reinitNecessary = false;
+@SuppressWarnings("unused")
+
+private OWLAPIOntology oWLAPIOntology;
+
+/**
+* @param oWLAPIOntology see OWLAPIOntology
+**/
+public OWLAPIOntologyConfigurator(OWLAPIOntology oWLAPIOntology){
+this.oWLAPIOntology = oWLAPIOntology;
+}
+
+/**
+* @return OWLAPIOntology
+**/
+public static OWLAPIOntology getOWLAPIOntology() {
+OWLAPIOntology component = ComponentManager.getInstance().knowledgeSource(OWLAPIOntology.class);
+return component;
+}
+
+
+
+/**
+* true, if this component needs reinitializsation
+**/
+public boolean isReinitNecessary(){
+return reinitNecessary;
+}
+
+
+}
Added: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
@@ -0,0 +1,212 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package org.dllearner.core.configurators;
+
+import java.util.Set;
+import org.dllearner.core.ComponentManager;
+import org.dllearner.core.ReasoningService;
+import org.dllearner.learningproblems.PosNegDefinitionLPStrict;
+
+/**
+* automatically generated, do not edit manually.
+* run org.dllearner.scripts.ConfigJavaGenerator to update
+**/
+public class PosNegDefinitionLPStrictConfigurator {
+
+private boolean reinitNecessary = false;
+@SuppressWarnings("unused")
+
+private PosNegDefinitionLPStrict posNegDefinitionLPStrict;
+
+/**
+* @param posNegDefinitionLPStrict see PosNegDefinitionLPStrict
+**/
+public PosNegDefinitionLPStrictConfigurator(PosNegDefinitionLPStrict posNegDefinitionLPStrict){
+this.posNegDefinitionLPStrict = posNegDefinitionLPStrict;
+}
+
+/**
+* @param positiveExamples positive examples
+* @param negativeExamples negative examples
+* @return PosNegDefinitionLPStrict
+**/
+public static PosNegDefinitionLPStrict getPosNegDefinitionLPStrict(ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) {
+PosNegDefinitionLPStrict component = ComponentManager.getInstance().learningProblem(PosNegDefinitionLPStrict.class, reasoningService);
+ComponentManager.getInstance().applyConfigEntry(component, "positiveExamples", positiveExamples);
+ComponentManager.getInstance().applyConfigEntry(component, "negativeExamples", negativeExamples);
+return component;
+}
+
+/**
+* positiveExamples positive examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+* @return Set(String)
+**/
+@SuppressWarnings("unchecked")
+public Set<String> getPositiveExamples() {
+return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(posNegDefinitionLPStrict, "positiveExamples") ;
+}
+/**
+* negativeExamples negative examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+* @return Set(String)
+**/
+@SuppressWarnings("unchecked")
+public Set<String> getNegativeExamples() {
+return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(posNegDefinitionLPStrict, "negativeExamples") ;
+}
+/**
+* useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept..
+* mandatory: false| reinit necessary: true
+* default value: false
+* @return boolean
+**/
+public boolean getUseRetrievalForClassficiation() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(posNegDefinitionLPStrict, "useRetrievalForClassficiation") ;
+}
+/**
+* percentPerLenghtUnit describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one.
+* mandatory: false| reinit necessary: true
+* default value: 0.05
+* @return double
+**/
+public double getPercentPerLenghtUnit() {
+return (Double) ComponentManager.getInstance().getConfigOptionValue(posNegDefinitionLPStrict, "percentPerLenghtUnit") ;
+}
+/**
+* useMultiInstanceChecks See UseMultiInstanceChecks enum..
+* mandatory: false| reinit necessary: true
+* default value: twoChecks
+* @return String
+**/
+public String getUseMultiInstanceChecks() {
+return (String) ComponentManager.getInstance().getConfigOptionValue(posNegDefinitionLPStrict, "useMultiInstanceChecks") ;
+}
+/**
+* penaliseNeutralExamples if set to true neutral examples are penalised.
+* mandatory: false| reinit necessary: true
+* default value: null
+* @return boolean
+**/
+public boolean getPenaliseNeutralExamples() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(posNegDefinitionLPStrict, "penaliseNeutralExamples") ;
+}
+/**
+* accuracyPenalty penalty for pos/neg examples which are classified as neutral.
+* mandatory: false| reinit necessary: true
+* default value: 1.0
+* @return double
+**/
+public double getAccuracyPenalty() {
+return (Double) ComponentManager.getInstance().getConfigOptionValue(posNegDefinitionLPStrict, "accuracyPenalty") ;
+}
+/**
+* errorPenalty penalty for pos. examples classified as negative or vice versa.
+* mandatory: false| reinit necessary: true
+* default value: 3.0
+* @return double
+**/
+public double getErrorPenalty() {
+return (Double) ComponentManager.getInstance().getConfigOptionValue(posNegDefinitionLPStrict, "errorPenalty") ;
+}
+
+/**
+* @param positiveExamples positive examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+**/
+public void setPositiveExamples(Set<String> positiveExamples) {
+ComponentManager.getInstance().applyConfigEntry(posNegDefinitionLPStrict, "positiveExamples", positiveExamples);
+}
+/**
+* @param negativeExamples negative examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+**/
+public void setNegativeExamples(Set<String> negativeExamples) {
+ComponentManager.getInstance().applyConfigEntry(posNegDefinitionLPStrict, "negativeExamples", negativeExamples);
+}
+/**
+* @param useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept..
+* mandatory: false| reinit necessary: true
+* default value: false
+**/
+public void setUseRetrievalForClassficiation(boolean useRetrievalForClassficiation) {
+ComponentManager.getInstance().applyConfigEntry(posNegDefinitionLPStrict, "useRetrievalForClassficiation", useRetrievalForClassficiation);
+reinitNecessary = true;
+}
+/**
+* @param percentPerLenghtUnit describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one.
+* mandatory: false| reinit necessary: true
+* default value: 0.05
+**/
+public void setPercentPerLenghtUnit(double percentPerLenghtUnit) {
+ComponentManager.getInstance().applyConfigEntry(posNegDefinitionLPStrict, "percentPerLenghtUnit", percentPerLenghtUnit);
+reinitNecessary = true;
+}
+/**
+* @param useMultiInstanceChecks See UseMultiInstanceChecks enum..
+* mandatory: false| reinit necessary: true
+* default value: twoChecks
+**/
+public void setUseMultiInstanceChecks(String useMultiInstanceChecks) {
+ComponentManager.getInstance().applyConfigEntry(posNegDefinitionLPStrict, "useMultiInstanceChecks", useMultiInstanceChecks);
+reinitNecessary = true;
+}
+/**
+* @param penaliseNeutralExamples if set to true neutral examples are penalised.
+* mandatory: false| reinit necessary: true
+* default value: null
+**/
+public void setPenaliseNeutralExamples(boolean penaliseNeutralExamples) {
+ComponentManager.getInstance().applyConfigEntry(posNegDefinitionLPStrict, "penaliseNeutralExamples", penaliseNeutralExamples);
+reinitNecessary = true;
+}
+/**
+* @param accuracyPenalty penalty for pos/neg examples which are classified as neutral.
+* mandatory: false| reinit necessary: true
+* default value: 1.0
+**/
+public void setAccuracyPenalty(double accuracyPenalty) {
+ComponentManager.getInstance().applyConfigEntry(posNegDefinitionLPStrict, "accuracyPenalty", accuracyPenalty);
+reinitNecessary = true;
+}
+/**
+* @param errorPenalty penalty for pos. examples classified as negative or vice versa.
+* mandatory: false| reinit necessary: true
+* default value: 3.0
+**/
+public void setErrorPenalty(double errorPenalty) {
+ComponentManager.getInstance().applyConfigEntry(posNegDefinitionLPStrict, "errorPenalty", errorPenalty);
+reinitNecessary = true;
+}
+
+/**
+* true, if this component needs reinitializsation
+**/
+public boolean isReinitNecessary(){
+return reinitNecessary;
+}
+
+
+}
Added: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
@@ -0,0 +1,84 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package org.dllearner.core.configurators;
+
+import java.util.Set;
+import org.dllearner.core.ComponentManager;
+import org.dllearner.core.ReasoningService;
+import org.dllearner.learningproblems.PosOnlyInclusionLP;
+
+/**
+* automatically generated, do not edit manually.
+* run org.dllearner.scripts.ConfigJavaGenerator to update
+**/
+public class PosOnlyInclusionLPConfigurator {
+
+private boolean reinitNecessary = false;
+@SuppressWarnings("unused")
+
+private PosOnlyInclusionLP posOnlyInclusionLP;
+
+/**
+* @param posOnlyInclusionLP see PosOnlyInclusionLP
+**/
+public PosOnlyInclusionLPConfigurator(PosOnlyInclusionLP posOnlyInclusionLP){
+this.posOnlyInclusionLP = posOnlyInclusionLP;
+}
+
+/**
+* @param positiveExamples positive examples
+* @return PosOnlyInclusionLP
+**/
+public static PosOnlyInclusionLP getPosOnlyInclusionLP(ReasoningService reasoningService, Set<String> positiveExamples) {
+PosOnlyInclusionLP component = ComponentManager.getInstance().learningProblem(PosOnlyInclusionLP.class, reasoningService);
+ComponentManager.getInstance().applyConfigEntry(component, "positiveExamples", positiveExamples);
+return component;
+}
+
+/**
+* positiveExamples positive examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+* @return Set(String)
+**/
+@SuppressWarnings("unchecked")
+public Set<String> getPositiveExamples() {
+return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(posOnlyInclusionLP, "positiveExamples") ;
+}
+
+/**
+* @param positiveExamples positive examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+**/
+public void setPositiveExamples(Set<String> positiveExamples) {
+ComponentManager.getInstance().applyConfigEntry(posOnlyInclusionLP, "positiveExamples", positiveExamples);
+}
+
+/**
+* true, if this component needs reinitializsation
+**/
+public boolean isReinitNecessary(){
+return reinitNecessary;
+}
+
+
+}
Added: trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
@@ -0,0 +1,65 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package org.dllearner.core.configurators;
+
+import org.dllearner.algorithms.SimpleSuggestionLearningAlgorithm;
+import org.dllearner.core.ComponentManager;
+import org.dllearner.core.LearningProblem;
+import org.dllearner.core.LearningProblemUnsupportedException;
+import org.dllearner.core.ReasoningService;
+
+/**
+* automatically generated, do not edit manually.
+* run org.dllearner.scripts.ConfigJavaGenerator to update
+**/
+public class SimpleSuggestionLearningAlgorithmConfigurator {
+
+private boolean reinitNecessary = false;
+@SuppressWarnings("unused")
+
+private SimpleSuggestionLearningAlgorithm simpleSuggestionLearningAlgorithm;
+
+/**
+* @param simpleSuggestionLearningAlgorithm see SimpleSuggestionLearningAlgorithm
+**/
+public SimpleSuggestionLearningAlgorithmConfigurator(SimpleSuggestionLearningAlgorithm simpleSuggestionLearningAlgorithm){
+this.simpleSuggestionLearningAlgorithm = simpleSuggestionLearningAlgorithm;
+}
+
+/**
+* @return SimpleSuggestionLearningAlgorithm
+**/
+public static SimpleSuggestionLearningAlgorithm getSimpleSuggestionLearningAlgorithm(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException{
+SimpleSuggestionLearningAlgorithm component = ComponentManager.getInstance().learningAlgorithm(SimpleSuggestionLearningAlgorithm.class, learningProblem, reasoningService);
+return component;
+}
+
+
+
+/**
+* true, if this component needs reinitializsation
+**/
+public boolean isReinitNecessary(){
+return reinitNecessary;
+}
+
+
+}
Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-09 09:42:10 UTC (rev 1181)
+++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-09 09:42:37 UTC (rev 1182)
@@ -142,6 +142,7 @@
public OWLAPIReasoner(Set<KnowledgeSource> sources) {
this.sources = sources;
this.configurator = new OWLAPIReasonerConfigurator(this);
+
}
public static String getName() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ku...@us...> - 2008-09-09 11:24:30
|
Revision: 1183
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1183&view=rev
Author: kurzum
Date: 2008-09-09 11:24:26 +0000 (Tue, 09 Sep 2008)
Log Message:
-----------
compatible with checkstyle
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java
trunk/src/dl-learner/org/dllearner/utilities/Files.java
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class BruteForceLearnerConfigurator {
+public class BruteForceLearnerConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -45,6 +45,9 @@
}
/**
+* @param reasoningService see reasoningService
+* @param learningProblem see learningProblem
+* @throws LearningProblemUnsupportedException see
* @return BruteForceLearner
**/
public static BruteForceLearner getBruteForceLearner(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException{
@@ -91,7 +94,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -50,8 +50,10 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class ComponentFactory {
+public final class ComponentFactory {
+private ComponentFactory(){}
+
/**
* @param filename pointer to the KB file on local file system
* @return a component ready for initialization KBFile
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -31,7 +31,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class DBpediaNavigationSuggestorConfigurator {
+public class DBpediaNavigationSuggestorConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -46,6 +46,9 @@
}
/**
+* @param reasoningService see reasoningService
+* @param learningProblem see learningProblem
+* @throws LearningProblemUnsupportedException see
* @return DBpediaNavigationSuggestor
**/
public static DBpediaNavigationSuggestor getDBpediaNavigationSuggestor(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException{
@@ -528,7 +531,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class DIGReasonerConfigurator {
+public class DIGReasonerConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -44,6 +44,7 @@
}
/**
+* @param knowledgeSource see knowledgeSource
* @return DIGReasoner
**/
public static DIGReasoner getDIGReasoner(Set<KnowledgeSource> knowledgeSource) {
@@ -108,7 +109,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -31,7 +31,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class ExampleBasedROLComponentConfigurator {
+public class ExampleBasedROLComponentConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -46,6 +46,9 @@
}
/**
+* @param reasoningService see reasoningService
+* @param learningProblem see learningProblem
+* @throws LearningProblemUnsupportedException see
* @return ExampleBasedROLComponent
**/
public static ExampleBasedROLComponent getExampleBasedROLComponent(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException{
@@ -582,7 +585,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class FastInstanceCheckerConfigurator {
+public class FastInstanceCheckerConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -44,6 +44,7 @@
}
/**
+* @param knowledgeSource see knowledgeSource
* @return FastInstanceChecker
**/
public static FastInstanceChecker getFastInstanceChecker(Set<KnowledgeSource> knowledgeSource) {
@@ -72,7 +73,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class FastRetrievalReasonerConfigurator {
+public class FastRetrievalReasonerConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -44,6 +44,7 @@
}
/**
+* @param knowledgeSource see knowledgeSource
* @return FastRetrievalReasoner
**/
public static FastRetrievalReasoner getFastRetrievalReasoner(Set<KnowledgeSource> knowledgeSource) {
@@ -54,7 +55,8 @@
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class GPConfigurator {
+public class GPConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -45,6 +45,9 @@
}
/**
+* @param reasoningService see reasoningService
+* @param learningProblem see learningProblem
+* @throws LearningProblemUnsupportedException see
* @return GP
**/
public static GP getGP(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException{
@@ -361,7 +364,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -27,7 +27,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class KBFileConfigurator {
+public class KBFileConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -90,7 +90,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -27,7 +27,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class OWLAPIOntologyConfigurator {
+public class OWLAPIOntologyConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -52,7 +52,8 @@
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class OWLAPIReasonerConfigurator {
+public class OWLAPIReasonerConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -44,6 +44,7 @@
}
/**
+* @param knowledgeSource see knowledgeSource
* @return OWLAPIReasoner
**/
public static OWLAPIReasoner getOWLAPIReasoner(Set<KnowledgeSource> knowledgeSource) {
@@ -72,7 +73,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -27,7 +27,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class OWLFileConfigurator {
+public class OWLFileConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -72,7 +72,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosNegDefinitionLPConfigurator {
+public class PosNegDefinitionLPConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -44,6 +44,7 @@
}
/**
+* @param reasoningService see reasoningService
* @param positiveExamples positive examples
* @param negativeExamples negative examples
* @return PosNegDefinitionLP
@@ -148,7 +149,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosNegDefinitionLPStrictConfigurator {
+public class PosNegDefinitionLPStrictConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -44,6 +44,7 @@
}
/**
+* @param reasoningService see reasoningService
* @param positiveExamples positive examples
* @param negativeExamples negative examples
* @return PosNegDefinitionLPStrict
@@ -202,7 +203,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosNegInclusionLPConfigurator {
+public class PosNegInclusionLPConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -44,6 +44,7 @@
}
/**
+* @param reasoningService see reasoningService
* @param positiveExamples positive examples
* @param negativeExamples negative examples
* @return PosNegInclusionLP
@@ -148,7 +149,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosOnlyDefinitionLPConfigurator {
+public class PosOnlyDefinitionLPConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -44,6 +44,7 @@
}
/**
+* @param reasoningService see reasoningService
* @param positiveExamples positive examples
* @return PosOnlyDefinitionLP
**/
@@ -74,7 +75,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosOnlyInclusionLPConfigurator {
+public class PosOnlyInclusionLPConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -44,6 +44,7 @@
}
/**
+* @param reasoningService see reasoningService
* @param positiveExamples positive examples
* @return PosOnlyInclusionLP
**/
@@ -74,7 +75,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -31,7 +31,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class ROLearnerConfigurator {
+public class ROLearnerConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -46,6 +46,9 @@
}
/**
+* @param reasoningService see reasoningService
+* @param learningProblem see learningProblem
+* @throws LearningProblemUnsupportedException see
* @return ROLearner
**/
public static ROLearner getROLearner(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException{
@@ -510,7 +513,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class RandomGuesserConfigurator {
+public class RandomGuesserConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -45,6 +45,9 @@
}
/**
+* @param reasoningService see reasoningService
+* @param learningProblem see learningProblem
+* @throws LearningProblemUnsupportedException see
* @return RandomGuesser
**/
public static RandomGuesser getRandomGuesser(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException{
@@ -91,7 +94,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class SimpleSuggestionLearningAlgorithmConfigurator {
+public class SimpleSuggestionLearningAlgorithmConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -45,6 +45,9 @@
}
/**
+* @param reasoningService see reasoningService
+* @param learningProblem see learningProblem
+* @throws LearningProblemUnsupportedException see
* @return SimpleSuggestionLearningAlgorithm
**/
public static SimpleSuggestionLearningAlgorithm getSimpleSuggestionLearningAlgorithm(LearningProblem learningProblem, ReasoningService reasoningService) throws LearningProblemUnsupportedException{
@@ -55,7 +58,8 @@
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class SparqlKnowledgeSourceConfigurator {
+public class SparqlKnowledgeSourceConfigurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
@@ -480,7 +480,8 @@
}
/**
-* true, if this component needs reinitializsation
+* true, if this component needs reinitializsation.
+* @return boolean
**/
public boolean isReinitNecessary(){
return reinitNecessary;
Modified: trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -66,7 +66,8 @@
private static final String REINITVAR = "reinitNecessary";
- private static final String REINITGETTER = "/**\n* true, if this component needs reinitializsation\n**/\n"
+ private static final String REINITGETTER = "/**\n* true, if this component needs reinitializsation.\n"
+ + "* @return boolean\n**/\n"
+ "public boolean is"
+ capitalize(REINITVAR)
+ "(){\nreturn "
@@ -115,19 +116,17 @@
public static void main(String[] args) {
Files.backupDirectory(TARGET_DIR);
- // System.exit(0);
+ System.out.println("previous classes were backupped to tmp/+System.currentTimeMillis()");
Files.deleteDir(TARGET_DIR);
ComponentManager cm = ComponentManager.getInstance();
- // configuratorImports.add(ComponentManager.class.getCanonicalName());
COMPONENT_FACTORY_IMPORTS.add(KnowledgeSource.class.getCanonicalName());
- // configuratorImports.add(ReasonerComponent.class.getCanonicalName());
COMPONENT_FACTORY_IMPORTS
.add(ReasoningService.class.getCanonicalName());
COMPONENT_FACTORY_IMPORTS.add(LearningProblem.class.getCanonicalName());
- // componentFactoryImports.add(LearningAlgorithm.class.getCanonicalName());
COMPONENT_FACTORY_IMPORTS.add(LearningProblemUnsupportedException.class
.getCanonicalName());
+ COMPONENT_FACTORY_METHODS.add("private "+COMPONENT_FACTORY+"(){}\n");
for (Class<? extends KnowledgeSource> component : cm
.getKnowledgeSources()) {
@@ -313,11 +312,11 @@
for (String s : additionalMandatoryVars.keySet()) {
parametersWithType.put(s, additionalMandatoryVars.get(s));
parametersNoType.put(s, additionalMandatoryVars.get(s));
+ comments ="* @param "+additionalMandatoryVars.get(s)+" see "+additionalMandatoryVars.get(s)+"\n"+comments;
}
for (String s : mandatoryVars.keySet()) {
parametersWithType.put(s, mandatoryVars.get(s));
- applyConf += fillApplyConfigEntry("component", mandatoryVars.get(s))
- + "";
+ applyConf += fillApplyConfigEntry("component", mandatoryVars.get(s));
}
String parWithType = expandCollection(parametersWithType.keySet(), "",
@@ -329,6 +328,7 @@
if (!getinstanceExceptions.isEmpty()) {
exceptions += "throws ";
exceptions += expandCollection(getinstanceExceptions, "", ", ", 2);
+ comments+=expandCollection(getinstanceExceptions, "* @throws ", " see \n", 0);
}
comments = fillJavaDocComment(comments + "* @return " + className
+ "\n");
@@ -392,7 +392,7 @@
String ret = fillClassTemplate(TARGET_PACKAGE, expandCollection(
COMPONENT_FACTORY_IMPORTS, "import ", ";\n", 0),
COMPONENT_FACTORY, "", expandCollection(
- COMPONENT_FACTORY_METHODS, "", "\n", 0));
+ COMPONENT_FACTORY_METHODS, "", "\n", 0), "final");
Files.createFile(new File(TARGET_DIR + "/" + COMPONENT_FACTORY
+ ".java"), ret);
@@ -462,8 +462,14 @@
return ret;
}
+
private static String fillClassTemplate(String packagE, String imports,
String className, String extendS, String body) {
+ return fillClassTemplate(packagE, imports, className, extendS, body, "");
+ }
+
+ private static String fillClassTemplate(String packagE, String imports,
+ String className, String extendS, String body, String classModifier) {
String comment = "* automatically generated, do not edit manually.\n";
comment += "* run " + ConfigJavaGenerator.class.getCanonicalName()
+ " to update\n";
@@ -473,7 +479,7 @@
ret += imports + "\n";
ret += fillJavaDocComment(comment);
ret += (INCLUDE_UNUSED) ? UNUSED : "";
- ret += "public class " + className + " "
+ ret += "public "+classModifier+" class " + className + " "
+ ((extendS.length() > 0) ? "extends " + extendS : "")
+ " {\n\n";
ret += body + "\n";
Modified: trunk/src/dl-learner/org/dllearner/utilities/Files.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-09-09 09:42:37 UTC (rev 1182)
+++ trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-09-09 11:24:26 UTC (rev 1183)
@@ -157,6 +157,10 @@
}
}
+ /**
+ * copies all files in dir to "tmp/"+System.currentTimeMillis()
+ * @param dir the dir to be backupped
+ */
public static void backupDirectory(String dir){
File f = new File(dir);
String backupDir = "tmp/"+System.currentTimeMillis();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ku...@us...> - 2008-09-09 13:40:55
|
Revision: 1185
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1185&view=rev
Author: kurzum
Date: 2008-09-09 13:40:43 +0000 (Tue, 09 Sep 2008)
Log Message:
-----------
included for all components
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java
trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java
trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java
trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java
trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java
trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java
trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java
trunk/src/dl-learner/org/dllearner/core/Component.java
trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
trunk/src/dl-learner/org/dllearner/kb/KBFile.java
trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java
trunk/src/dl-learner/org/dllearner/kb/OWLFile.java
trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java
trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java
trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java
trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java
trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java
trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java
trunk/src/dl-learner/org/dllearner/learningproblems/RoleLearning.java
trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java
trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java
trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java
trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java
trunk/src/dl-learner/org/dllearner/scripts/NewSample.java
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/RoleLearningConfigurator.java
Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -36,6 +36,7 @@
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.IntegerConfigOption;
import org.dllearner.core.config.InvalidConfigOptionValueException;
+import org.dllearner.core.configurators.BruteForceLearnerConfigurator;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Intersection;
import org.dllearner.core.owl.NamedClass;
@@ -57,6 +58,13 @@
*
*/
public class BruteForceLearner extends LearningAlgorithm {
+
+ private BruteForceLearnerConfigurator configurator;
+ @Override
+ public BruteForceLearnerConfigurator getConfigurator(){
+ return configurator;
+ }
+
private LearningProblem learningProblem;
private ReasoningService rs;
@@ -77,6 +85,7 @@
public BruteForceLearner(LearningProblem learningProblem, ReasoningService rs) {
this.learningProblem = learningProblem;
this.rs = rs;
+ this.configurator = new BruteForceLearnerConfigurator(this);
}
public static String getName() {
Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -36,6 +36,8 @@
import org.dllearner.core.config.DoubleConfigOption;
import org.dllearner.core.config.InvalidConfigOptionValueException;
import org.dllearner.core.config.StringConfigOption;
+import org.dllearner.core.configurators.ComponentFactory;
+import org.dllearner.core.configurators.DBpediaNavigationSuggestorConfigurator;
import org.dllearner.core.owl.Description;
import org.dllearner.learningproblems.PosNegDefinitionLP;
import org.dllearner.learningproblems.PosNegLP;
@@ -53,19 +55,34 @@
*/
public class DBpediaNavigationSuggestor extends LearningAlgorithm {
+ private DBpediaNavigationSuggestorConfigurator configurator;
+ @Override
+ public DBpediaNavigationSuggestorConfigurator getConfigurator(){
+ return configurator;
+ }
+
+
// private ReasoningService rs;
private ExampleBasedROLComponent learner;
private static String defaultSearchTreeFile = "log/searchTree.txt";
public DBpediaNavigationSuggestor(LearningProblem learningProblem, ReasoningService rs) {
// this.rs=rs;
+ this.configurator = new DBpediaNavigationSuggestorConfigurator(this);
+ try{
if(learningProblem instanceof PosNegLP) {
PosNegLP lp = (PosNegLP) learningProblem;
- this.learner=new ExampleBasedROLComponent(lp, rs);
+ this.learner = ComponentFactory.getExampleBasedROLComponent(lp, rs);
+ //this.learner=new ExampleBasedROLComponent(lp, rs);
} else if(learningProblem instanceof PosOnlyDefinitionLP) {
PosOnlyDefinitionLP lp = (PosOnlyDefinitionLP) learningProblem;
- this.learner=new ExampleBasedROLComponent(lp, rs);
+ this.learner = ComponentFactory.getExampleBasedROLComponent(lp, rs);
+ //this.learner=new ExampleBasedROLComponent(lp, rs);
}
+ }catch (Exception e) {
+ System.out.println("this error should never occur"+this.getClass().getCanonicalName());
+ e.printStackTrace();
+ }
}
public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() {
Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -34,10 +34,17 @@
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.IntegerConfigOption;
import org.dllearner.core.config.InvalidConfigOptionValueException;
+import org.dllearner.core.configurators.RandomGuesserConfigurator;
import org.dllearner.core.owl.Description;
public class RandomGuesser extends LearningAlgorithm {
+ private RandomGuesserConfigurator configurator;
+ @Override
+ public RandomGuesserConfigurator getConfigurator(){
+ return configurator;
+ }
+
private Description bestDefinition = null;
private Score bestScore;
private double bestFitness = Double.NEGATIVE_INFINITY;
@@ -51,6 +58,7 @@
public RandomGuesser(LearningProblem learningProblem, ReasoningService rs) {
this.learningProblem = learningProblem;
this.rs = rs;
+ this.configurator = new RandomGuesserConfigurator(this);
}
public static String getName() {
Modified: trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -19,15 +19,21 @@
*/
package org.dllearner.algorithms;
-import java.util.*;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.dllearner.core.EvaluatedDescription;
import org.dllearner.core.LearningAlgorithm;
import org.dllearner.core.ReasoningService;
+import org.dllearner.core.Score;
+import org.dllearner.core.config.ConfigEntry;
+import org.dllearner.core.configurators.SimpleSuggestionLearningAlgorithmConfigurator;
import org.dllearner.core.owl.Description;
-import org.dllearner.core.config.ConfigEntry;
-import org.dllearner.core.Score;
-import org.dllearner.core.owl.*;
+import org.dllearner.core.owl.Individual;
+import org.dllearner.core.owl.ObjectProperty;
+import org.dllearner.core.owl.ObjectSomeRestriction;
+import org.dllearner.core.owl.Thing;
/**
* TODO: Javadoc
@@ -37,7 +43,13 @@
*
*/
public class SimpleSuggestionLearningAlgorithm extends LearningAlgorithm implements Runnable {
-
+
+ private SimpleSuggestionLearningAlgorithmConfigurator configurator;
+ @Override
+ public SimpleSuggestionLearningAlgorithmConfigurator getConfigurator(){
+ return configurator;
+ }
+
// private boolean stop = false;
private Score solutionScore;
private Description bestSollution;
@@ -45,6 +57,7 @@
public SimpleSuggestionLearningAlgorithm() {
// this.learningProblem = learningProblem;
+ this.configurator = new SimpleSuggestionLearningAlgorithmConfigurator(this);
}
@Override
Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -42,6 +42,7 @@
import org.dllearner.core.config.IntegerConfigOption;
import org.dllearner.core.config.InvalidConfigOptionValueException;
import org.dllearner.core.config.StringConfigOption;
+import org.dllearner.core.configurators.GPConfigurator;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Thing;
import org.dllearner.learningproblems.PosNegLP;
@@ -56,6 +57,13 @@
*/
public class GP extends LearningAlgorithm {
+ private GPConfigurator configurator;
+ @Override
+ public GPConfigurator getConfigurator(){
+ return configurator;
+ }
+
+
// NumberFormat f;
DecimalFormat df = new DecimalFormat("0.00");
@@ -140,6 +148,7 @@
public GP(PosNegLP learningProblem, ReasoningService rs) {
this.learningProblem = learningProblem;
this.rs = rs;
+ this.configurator = new GPConfigurator(this);
}
public static String getName() {
Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -82,6 +82,12 @@
*/
public class ExampleBasedROLComponent extends LearningAlgorithm {
+ private ExampleBasedROLComponentConfigurator configurator;
+ @Override
+ public ExampleBasedROLComponentConfigurator getConfigurator(){
+ return configurator;
+ }
+
// actual algorithm
private ExampleBasedROLearner algorithm;
private static Logger logger = Logger
@@ -91,14 +97,7 @@
// learning problem to solve and background knowledge
private ReasoningService rs;
private LearningProblem learningProblem;
-
- private ExampleBasedROLComponentConfigurator configurator;
- public ExampleBasedROLComponentConfigurator getConfigurator(){
- return configurator;
- }
-
-
-
+
// configuration options
private boolean writeSearchTree;
private File searchTreeFile;
Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -27,6 +27,7 @@
import org.dllearner.core.config.DoubleConfigOption;
import org.dllearner.core.config.InvalidConfigOptionValueException;
import org.dllearner.core.config.StringConfigOption;
+import org.dllearner.core.configurators.ROLearnerConfigurator;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Intersection;
import org.dllearner.core.owl.NamedClass;
@@ -44,6 +45,12 @@
public class ROLearner extends LearningAlgorithm {
+ private ROLearnerConfigurator configurator;
+ @Override
+ public ROLearnerConfigurator getConfigurator(){
+ return configurator;
+ }
+
private static Logger logger = Logger
.getLogger(LearningAlgorithm.class);
@@ -194,13 +201,16 @@
public ROLearner(PosNegLP learningProblem, ReasoningService rs) {
this.learningProblem = learningProblem;
this.rs = rs;
+ this.configurator = new ROLearnerConfigurator(this);
posOnly=false;
baseURI = rs.getBaseURI();
+
}
public ROLearner(PosOnlyDefinitionLP learningProblem, ReasoningService rs) {
this.posOnlyLearningProblem = learningProblem;
this.rs = rs;
+ this.configurator = new ROLearnerConfigurator(this);
posOnly=true;
baseURI = rs.getBaseURI();
}
Modified: trunk/src/dl-learner/org/dllearner/core/Component.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/Component.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/Component.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -26,6 +26,7 @@
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.DoubleConfigOption;
import org.dllearner.core.config.InvalidConfigOptionValueException;
+import org.dllearner.core.configurators.Configurator;
/**
* Base class of all components. See also http://dl-learner.org/wiki/Architecture.
@@ -35,12 +36,14 @@
*/
public abstract class Component {
-//protected Configurator configurator;
+protected Configurator configurator;
- //public Configurator<? extends Configurator> getConfigurator(){
+ public abstract Configurator getConfigurator();
//return configurator;
//}
+
+
/**
* Returns the name of this component. By default, "unnamed
* component" is returned, but all implementations of components
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class BruteForceLearnerConfigurator {
+public class BruteForceLearnerConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -41,6 +41,7 @@
import org.dllearner.learningproblems.PosNegInclusionLP;
import org.dllearner.learningproblems.PosOnlyDefinitionLP;
import org.dllearner.learningproblems.PosOnlyInclusionLP;
+import org.dllearner.learningproblems.RoleLearning;
import org.dllearner.reasoning.DIGReasoner;
import org.dllearner.reasoning.FastInstanceChecker;
import org.dllearner.reasoning.FastRetrievalReasoner;
@@ -167,6 +168,16 @@
}
/**
+* @param positiveExamples positive examples
+* @param negativeExamples negative examples
+* @param reasoningService see ReasoningService
+* @return a component ready for initialization RoleLearning
+**/
+public static RoleLearning getRoleLearning(ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) {
+return RoleLearningConfigurator.getRoleLearning(reasoningService, positiveExamples, negativeExamples);
+}
+
+/**
* @param learningProblem see LearningProblem
* @param reasoningService see ReasoningService
* @throws LearningProblemUnsupportedException see
Added: trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -0,0 +1,28 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package org.dllearner.core.configurators;
+
+/**
+* automatically generated, do not edit manually.
+* run org.dllearner.scripts.ConfigJavaGenerator to update
+**/
+public interface Configurator{
+}
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -31,7 +31,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class DBpediaNavigationSuggestorConfigurator {
+public class DBpediaNavigationSuggestorConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class DIGReasonerConfigurator {
+public class DIGReasonerConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -31,7 +31,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class ExampleBasedROLComponentConfigurator {
+public class ExampleBasedROLComponentConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class FastInstanceCheckerConfigurator {
+public class FastInstanceCheckerConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class FastRetrievalReasonerConfigurator {
+public class FastRetrievalReasonerConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class GPConfigurator {
+public class GPConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -27,7 +27,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class KBFileConfigurator {
+public class KBFileConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -27,7 +27,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class OWLAPIOntologyConfigurator {
+public class OWLAPIOntologyConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class OWLAPIReasonerConfigurator {
+public class OWLAPIReasonerConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -27,7 +27,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class OWLFileConfigurator {
+public class OWLFileConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosNegDefinitionLPConfigurator {
+public class PosNegDefinitionLPConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosNegDefinitionLPStrictConfigurator {
+public class PosNegDefinitionLPStrictConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosNegInclusionLPConfigurator {
+public class PosNegInclusionLPConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosOnlyDefinitionLPConfigurator {
+public class PosOnlyDefinitionLPConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -29,7 +29,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class PosOnlyInclusionLPConfigurator {
+public class PosOnlyInclusionLPConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -31,7 +31,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class ROLearnerConfigurator {
+public class ROLearnerConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class RandomGuesserConfigurator {
+public class RandomGuesserConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Added: trunk/src/dl-learner/org/dllearner/core/configurators/RoleLearningConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/RoleLearningConfigurator.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/RoleLearningConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -0,0 +1,160 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package org.dllearner.core.configurators;
+
+import java.util.Set;
+import org.dllearner.core.ComponentManager;
+import org.dllearner.core.ReasoningService;
+import org.dllearner.learningproblems.RoleLearning;
+
+/**
+* automatically generated, do not edit manually.
+* run org.dllearner.scripts.ConfigJavaGenerator to update
+**/
+public class RoleLearningConfigurator implements Configurator {
+
+private boolean reinitNecessary = false;
+@SuppressWarnings("unused")
+
+private RoleLearning roleLearning;
+
+/**
+* @param roleLearning see RoleLearning
+**/
+public RoleLearningConfigurator(RoleLearning roleLearning){
+this.roleLearning = roleLearning;
+}
+
+/**
+* @param reasoningService see reasoningService
+* @param positiveExamples positive examples
+* @param negativeExamples negative examples
+* @return RoleLearning
+**/
+public static RoleLearning getRoleLearning(ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) {
+RoleLearning component = ComponentManager.getInstance().learningProblem(RoleLearning.class, reasoningService);
+ComponentManager.getInstance().applyConfigEntry(component, "positiveExamples", positiveExamples);
+ComponentManager.getInstance().applyConfigEntry(component, "negativeExamples", negativeExamples);
+return component;
+}
+
+/**
+* positiveExamples positive examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+* @return Set(String)
+**/
+@SuppressWarnings("unchecked")
+public Set<String> getPositiveExamples() {
+return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(roleLearning, "positiveExamples") ;
+}
+/**
+* negativeExamples negative examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+* @return Set(String)
+**/
+@SuppressWarnings("unchecked")
+public Set<String> getNegativeExamples() {
+return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(roleLearning, "negativeExamples") ;
+}
+/**
+* useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept..
+* mandatory: false| reinit necessary: true
+* default value: false
+* @return boolean
+**/
+public boolean getUseRetrievalForClassficiation() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(roleLearning, "useRetrievalForClassficiation") ;
+}
+/**
+* percentPerLenghtUnit describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one.
+* mandatory: false| reinit necessary: true
+* default value: 0.05
+* @return double
+**/
+public double getPercentPerLenghtUnit() {
+return (Double) ComponentManager.getInstance().getConfigOptionValue(roleLearning, "percentPerLenghtUnit") ;
+}
+/**
+* useMultiInstanceChecks See UseMultiInstanceChecks enum..
+* mandatory: false| reinit necessary: true
+* default value: twoChecks
+* @return String
+**/
+public String getUseMultiInstanceChecks() {
+return (String) ComponentManager.getInstance().getConfigOptionValue(roleLearning, "useMultiInstanceChecks") ;
+}
+
+/**
+* @param positiveExamples positive examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+**/
+public void setPositiveExamples(Set<String> positiveExamples) {
+ComponentManager.getInstance().applyConfigEntry(roleLearning, "positiveExamples", positiveExamples);
+}
+/**
+* @param negativeExamples negative examples.
+* mandatory: true| reinit necessary: false
+* default value: null
+**/
+public void setNegativeExamples(Set<String> negativeExamples) {
+ComponentManager.getInstance().applyConfigEntry(roleLearning, "negativeExamples", negativeExamples);
+}
+/**
+* @param useRetrievalForClassficiation Specifies whether to use retrieval or instance checks for testing a concept..
+* mandatory: false| reinit necessary: true
+* default value: false
+**/
+public void setUseRetrievalForClassficiation(boolean useRetrievalForClassficiation) {
+ComponentManager.getInstance().applyConfigEntry(roleLearning, "useRetrievalForClassficiation", useRetrievalForClassficiation);
+reinitNecessary = true;
+}
+/**
+* @param percentPerLenghtUnit describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one.
+* mandatory: false| reinit necessary: true
+* default value: 0.05
+**/
+public void setPercentPerLenghtUnit(double percentPerLenghtUnit) {
+ComponentManager.getInstance().applyConfigEntry(roleLearning, "percentPerLenghtUnit", percentPerLenghtUnit);
+reinitNecessary = true;
+}
+/**
+* @param useMultiInstanceChecks See UseMultiInstanceChecks enum..
+* mandatory: false| reinit necessary: true
+* default value: twoChecks
+**/
+public void setUseMultiInstanceChecks(String useMultiInstanceChecks) {
+ComponentManager.getInstance().applyConfigEntry(roleLearning, "useMultiInstanceChecks", useMultiInstanceChecks);
+reinitNecessary = true;
+}
+
+/**
+* true, if this component needs reinitializsation.
+* @return boolean
+**/
+public boolean isReinitNecessary(){
+return reinitNecessary;
+}
+
+
+}
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class SimpleSuggestionLearningAlgorithmConfigurator {
+public class SimpleSuggestionLearningAlgorithmConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -30,7 +30,7 @@
* automatically generated, do not edit manually.
* run org.dllearner.scripts.ConfigJavaGenerator to update
**/
-public class SparqlKnowledgeSourceConfigurator {
+public class SparqlKnowledgeSourceConfigurator implements Configurator {
private boolean reinitNecessary = false;
@SuppressWarnings("unused")
Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -66,6 +66,7 @@
private KB kb;
private KBFileConfigurator configurator;
+ @Override
public KBFileConfigurator getConfigurator(){
return configurator;
}
Modified: trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -7,16 +7,24 @@
import org.dllearner.core.OntologyFormat;
import org.dllearner.core.config.ConfigEntry;
import org.dllearner.core.config.InvalidConfigOptionValueException;
+import org.dllearner.core.configurators.OWLAPIOntologyConfigurator;
import org.dllearner.core.owl.KB;
import org.semanticweb.owl.model.OWLOntology;
public class OWLAPIOntology extends KnowledgeSource {
+ private OWLAPIOntologyConfigurator configurator;
+ @Override
+ public OWLAPIOntologyConfigurator getConfigurator(){
+ return configurator;
+ }
+
private OWLOntology ontology;
public OWLAPIOntology(OWLOntology onto)
{
this.ontology = onto;
+ this.configurator = new OWLAPIOntologyConfigurator(this);
}
@Override
Modified: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -49,7 +49,8 @@
private URL url;
private OWLFileConfigurator configurator ;
- public OWLFileConfigurator getOWLFileConfigurator(){
+ @Override
+ public OWLFileConfigurator getConfigurator(){
return configurator;
}
Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -87,6 +87,7 @@
/**
* @return the configurator for this Knowledgesource
*/
+ @Override
public SparqlKnowledgeSourceConfigurator getConfigurator() {
return configurator;
}
Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -48,7 +48,7 @@
public class PosNegDefinitionLP extends PosNegLP implements DefinitionLP {
private PosNegDefinitionLPConfigurator configurator;
-
+ @Override
public PosNegDefinitionLPConfigurator getConfigurator() {
return configurator;
}
Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -53,7 +53,7 @@
private double errorPenalty = defaultErrorPenalty;
private PosNegDefinitionLPStrictConfigurator configurator;
-
+ @Override
public PosNegDefinitionLPStrictConfigurator getConfigurator(){
return configurator;
}
Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -24,7 +24,6 @@
import org.dllearner.core.ReasoningService;
import org.dllearner.core.Score;
-import org.dllearner.core.config.CommonConfigMappings;
import org.dllearner.core.configurators.ComponentFactory;
import org.dllearner.core.configurators.PosNegInclusionLPConfigurator;
import org.dllearner.core.owl.Description;
@@ -57,6 +56,7 @@
private PosNegDefinitionLP definitionLP;
private PosNegInclusionLPConfigurator configurator;
+ @Override
public PosNegInclusionLPConfigurator getConfigurator(){
return configurator;
}
Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -38,6 +38,7 @@
private PosNegDefinitionLP definitionLP;
private PosOnlyDefinitionLPConfigurator configurator;
+ @Override
public PosOnlyDefinitionLPConfigurator getConfigurator(){
return configurator;
}
@@ -71,7 +72,7 @@
reasoningService,
SetManipulation.indToString(positiveExamples),
SetManipulation.indToString(pseudoNegatives));
- definitionLP = new PosNegDefinitionLP(reasoningService, positiveExamples, pseudoNegatives);
+ //definitionLP = new PosNegDefinitionLP(reasoningService, positiveExamples, pseudoNegatives);
// TODO: we must make sure that the problem also gets the same
// reasoning options (i.e. options are the same up to reversed example sets)
definitionLP.init();
Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -23,6 +23,7 @@
import org.dllearner.core.Score;
import org.dllearner.core.config.ConfigEntry;
import org.dllearner.core.config.InvalidConfigOptionValueException;
+import org.dllearner.core.configurators.PosOnlyInclusionLPConfigurator;
import org.dllearner.core.owl.Description;
/**
@@ -31,8 +32,16 @@
*/
public class PosOnlyInclusionLP extends PosOnlyLP implements InclusionLP {
+ private PosOnlyInclusionLPConfigurator configurator;
+ @Override
+ public PosOnlyInclusionLPConfigurator getConfigurator(){
+ return configurator;
+ }
+
+
public PosOnlyInclusionLP(ReasoningService reasoningService) {
super(reasoningService);
+ this.configurator = new PosOnlyInclusionLPConfigurator(this);
}
/* (non-Javadoc)
Modified: trunk/src/dl-learner/org/dllearner/learningproblems/RoleLearning.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/learningproblems/RoleLearning.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/learningproblems/RoleLearning.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -25,6 +25,7 @@
import org.dllearner.core.ReasoningService;
import org.dllearner.core.Score;
+import org.dllearner.core.configurators.RoleLearningConfigurator;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
import org.dllearner.utilities.datastructures.StringTuple;
@@ -43,6 +44,13 @@
*/
public class RoleLearning extends PosNegLP implements DefinitionLP {
+ private RoleLearningConfigurator configurator;
+ @Override
+ public RoleLearningConfigurator getConfigurator(){
+ return configurator;
+ }
+
+
public RoleLearning(ReasoningService reasoningService) {
super(reasoningService);
}
@@ -51,6 +59,7 @@
SortedSet<Individual> positiveExamples,
SortedSet<Individual> negativeExamples) {
super(reasoningService);
+ this.configurator = new RoleLearningConfigurator(this);
// TODO sets have to be queried
this.positiveExamples = positiveExamples;
this.negativeExamples = negativeExamples;
Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -46,10 +46,11 @@
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.InvalidConfigOptionValueException;
import org.dllearner.core.config.StringConfigOption;
+import org.dllearner.core.configurators.DIGReasonerConfigurator;
+import org.dllearner.core.owl.Description;
+import org.dllearner.core.owl.Individual;
import org.dllearner.core.owl.NamedClass;
import org.dllearner.core.owl.Nothing;
-import org.dllearner.core.owl.Description;
-import org.dllearner.core.owl.Individual;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ObjectPropertyHierarchy;
import org.dllearner.core.owl.SubsumptionHierarchy;
@@ -75,6 +76,13 @@
*
*/
public class DIGReasoner extends ReasonerComponent {
+
+ private DIGReasonerConfigurator configurator;
+ @Override
+ public DIGReasonerConfigurator getConfigurator(){
+ return configurator;
+ }
+
URL reasonerURL;
Set<KnowledgeSource> sources;
@@ -105,7 +113,10 @@
private File digProtocolFile;
private static String defaultDIGProtocolFile = "log/digProtocol.txt";
+
+
public DIGReasoner(Set<KnowledgeSource> sources) {
+ this.configurator = new DIGReasonerConfigurator(this);
this.sources = sources;
try {
reasonerURL = new URL("http://localhost:8081");
Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -92,6 +92,7 @@
private boolean defaultNegation = true;
private FastInstanceCheckerConfigurator configurator;
+ @Override
public FastInstanceCheckerConfigurator getConfigurator (){
return configurator;
}
Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -1,8 +1,8 @@
package org.dllearner.reasoning;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.HashSet;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -13,10 +13,12 @@
import org.dllearner.core.ReasoningService;
import org.dllearner.core.config.ConfigEntry;
import org.dllearner.core.config.InvalidConfigOptionValueException;
-import org.dllearner.core.owl.NamedClass;
+import org.dllearner.core.configurators.ComponentFactory;
+import org.dllearner.core.configurators.FastRetrievalReasonerConfigurator;
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.FlatABox;
import org.dllearner.core.owl.Individual;
+import org.dllearner.core.owl.NamedClass;
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ObjectPropertyHierarchy;
import org.dllearner.core.owl.SubsumptionHierarchy;
@@ -25,6 +27,12 @@
public class FastRetrievalReasoner extends ReasonerComponent {
+ private FastRetrievalReasonerConfigurator configurator;
+ @Override
+ public FastRetrievalReasonerConfigurator getConfigurator(){
+ return configurator;
+ }
+
FlatABox abox;
FastRetrieval fastRetrieval;
Set<NamedClass> atomicConcepts;
@@ -34,8 +42,12 @@
ReasoningService rs;
ReasonerComponent rc;
+
+
public FastRetrievalReasoner(Set<KnowledgeSource> sources) {
- rc = new DIGReasoner(sources);
+ this.configurator = new FastRetrievalReasonerConfigurator(this);
+
+ rc = ComponentFactory.getDIGReasoner(sources);
try {
rc.init();
} catch (ComponentInitException e1) {
@@ -56,6 +68,7 @@
}
public FastRetrievalReasoner(FlatABox abox) {
+ this.configurator = new FastRetrievalReasonerConfigurator(this);
this.abox = abox;
fastRetrieval = new FastRetrieval(abox);
Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -105,6 +105,7 @@
//private String reasonerType = "pellet";
private OWLAPIReasonerConfigurator configurator;
+ @Override
public OWLAPIReasonerConfigurator getConfigurator(){
return configurator;
}
Modified: trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -78,6 +78,8 @@
private static final String CONFIGURATOR = "Configurator";
private static final String COMPONENT_FACTORY = "ComponentFactory";
+ private static final String CLASS_COMMENT = "* automatically generated, do not edit manually.\n"
+ + "* run " + ConfigJavaGenerator.class.getCanonicalName()+ " to update\n";
private static final SortedSet<String> COMPONENT_FACTORY_IMPORTS = new TreeSet<String>();
@@ -194,6 +196,7 @@
}
makeComponentFactory();
+ makeInterface();
System.out.println("Done");
}
@@ -252,13 +255,20 @@
.add(makeGetInstanceForConfigurators(getAllCommentsForOptionList(mandatoryOptions)));
// body.add(makeApplyConfigEntryForOptionList(ComponentManager.getConfigOptions(component)));
-
+
body.add(expandCollection(getters, "", "", 0));
body.add(expandCollection(setters, "", "", 0));
body.add(REINITGETTER);
- String ret = fillClassTemplate(TARGET_PACKAGE, expandCollection(
- imports, "import ", ";\n", 0), className + CONFIGURATOR, "",
- expandCollection(body, "", "\n", 0));
+ String bodytmp = expandCollection(body, "", "\n",0);
+ String importtmp = expandCollection(imports, "import ", ";\n", 0);
+ String ret = fillClassTemplate(
+ TARGET_PACKAGE,
+ importtmp,
+ className + CONFIGURATOR,
+ "",
+ bodytmp ,
+ "",
+ CONFIGURATOR);
// configuratorMethods.add((className, componentType,
// mandatoryOptions));
@@ -270,6 +280,15 @@
.add(makeComponentFactoryMethods(getAllCommentsForOptionList(mandatoryOptions)));
}
+ private static void makeInterface(){
+ String ret ="";
+ ret+= HEADER+"\n";
+ ret+= "package "+TARGET_PACKAGE+";\n\n";
+ ret+= fillJavaDocComment(CLASS_COMMENT);
+ ret+="public interface Configurator{\n}\n";
+ Files.createFile(new File(TARGET_DIR+File.separator+CONFIGURATOR+".java"), ret);
+ }
+
@SuppressWarnings("unused")
private static String makeApplyConfigEntryForOptionList(
List<ConfigOption<?>> options) {
@@ -392,7 +411,7 @@
String ret = fillClassTemplate(TARGET_PACKAGE, expandCollection(
COMPONENT_FACTORY_IMPORTS, "import ", ";\n", 0),
COMPONENT_FACTORY, "", expandCollection(
- COMPONENT_FACTORY_METHODS, "", "\n", 0), "final");
+ COMPONENT_FACTORY_METHODS, "", "\n", 0), "final","");
Files.createFile(new File(TARGET_DIR + "/" + COMPONENT_FACTORY
+ ".java"), ret);
@@ -463,30 +482,28 @@
}
- private static String fillClassTemplate(String packagE, String imports,
- String className, String extendS, String body) {
- return fillClassTemplate(packagE, imports, className, extendS, body, "");
- }
+
private static String fillClassTemplate(String packagE, String imports,
- String className, String extendS, String body, String classModifier) {
- String comment = "* automatically generated, do not edit manually.\n";
- comment += "* run " + ConfigJavaGenerator.class.getCanonicalName()
- + " to update\n";
+ String className, String extendS, String body, String classModifier, String implementS) {
+
String ret = HEADER + "\n";
ret += "package " + packagE + ";\n\n";
ret += imports + "\n";
- ret += fillJavaDocComment(comment);
+ ret += fillJavaDocComment(CLASS_COMMENT);
ret += (INCLUDE_UNUSED) ? UNUSED : "";
ret += "public "+classModifier+" class " + className + " "
+ ((extendS.length() > 0) ? "extends " + extendS : "")
+ + ((implementS.length() > 0) ? "implements " + implementS : "")
+ " {\n\n";
ret += body + "\n";
ret += "}\n";
return ret;
}
+
+
private static String expandCollection(Collection<String> col,
String before, String after, int removeChars) {
Modified: trunk/src/dl-learner/org/dllearner/scripts/NewSample.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/scripts/NewSample.java 2008-09-09 11:38:48 UTC (rev 1184)
+++ trunk/src/dl-learner/org/dllearner/scripts/NewSample.java 2008-09-09 13:40:43 UTC (rev 1185)
@@ -121,7 +121,7 @@
String fileURL = new File(owlFile).toURI().toString();
OWLFile ks = ComponentFactory.getOWLFile( fileURL);
-
+
Set<KnowledgeSource> tmp = new HashSet<KnowledgeSource>();
tmp.add(ks);
// reasoner
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Jen...@us...> - 2008-09-09 13:44:33
|
Revision: 1186
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1186&view=rev
Author: JensLehmann
Date: 2008-09-09 13:44:25 +0000 (Tue, 09 Sep 2008)
Log Message:
-----------
GUI update:
- improved file chooser
- tabs enable/disable appropriately
- status panel for messages
- cleanup
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/gui/AboutWindow.java
trunk/src/dl-learner/org/dllearner/gui/Config.java
trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java
trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java
trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java
trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java
trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java
trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java
trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/gui/ExampleFileChooser.java
trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java
Modified: trunk/src/dl-learner/org/dllearner/gui/AboutWindow.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/AboutWindow.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/gui/AboutWindow.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -1,3 +1,22 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
package org.dllearner.gui;
import java.net.URL;
Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -24,11 +24,11 @@
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.ComponentManager;
import org.dllearner.core.KnowledgeSource;
+import org.dllearner.core.LearningAlgorithm;
import org.dllearner.core.LearningProblem;
import org.dllearner.core.LearningProblemUnsupportedException;
+import org.dllearner.core.ReasonerComponent;
import org.dllearner.core.ReasoningService;
-import org.dllearner.core.LearningAlgorithm;
-import org.dllearner.core.ReasonerComponent;
import org.dllearner.core.config.ConfigEntry;
import org.dllearner.core.config.ConfigOption;
@@ -58,6 +58,10 @@
// have changed configuration options, which require initialisation)
private boolean[] needsInit = new boolean[4];
+ // specifies whether the panel is enabled, i.e. the user
+ // can select it (all mandatory variables in selected components have been choosen)
+ private boolean[] isEnabled = new boolean[4];
+
// learning algorithm status
private boolean threadIsRunning = false;
private Long algorithmRunStartTime = null;
@@ -70,6 +74,8 @@
// none of the components is initialised
for(int i=0; i<4; i++) {
needsInit[i] = true;
+ // TODO there might be knowledge source without mandatory options
+ isEnabled[i] = false;
}
}
@@ -282,6 +288,14 @@
return needsInit[3];
}
+ public boolean needsInit(int tabIndex) {
+ return needsInit[tabIndex];
+ }
+
+ public boolean isEnabled(int tabIndex) {
+ return isEnabled[tabIndex];
+ }
+
/**
* set true if you run LearningAlgorithm.init
*/
@@ -386,6 +400,9 @@
needsInit[1] = true;
needsInit[2] = true;
needsInit[3] = true;
+ if(mandatoryOptionsSpecified(component)) {
+ isEnabled[1] = true;
+ }
} else if(component instanceof ReasonerComponent) {
needsInit[1] = true;
needsInit[2] = true;
@@ -399,6 +416,10 @@
gui.updateTabColors();
}
+ private boolean mandatoryOptionsSpecified(Component component) {
+ return false;
+ }
+
// delegate method for getting config option values
public <T> T getConfigOptionValue(Component component, ConfigOption<T> option) {
return cm.getConfigOptionValue(component, option);
Added: trunk/src/dl-learner/org/dllearner/gui/ExampleFileChooser.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ExampleFileChooser.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/gui/ExampleFileChooser.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -0,0 +1,58 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.gui;
+
+import java.io.File;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+
+/**
+ * Convenience class for choosing files from the example directory with a specific file ending.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public class ExampleFileChooser extends JFileChooser {
+
+ private static final long serialVersionUID = 1566010391199697892L;
+
+ public ExampleFileChooser(final String fileEnding) {
+ super(new File("examples/"));
+
+ FileFilter filter = new FileFilter() {
+ @Override
+ public boolean accept(File f) {
+ if (f.isDirectory())
+ return true;
+ return f.getName().toLowerCase().endsWith("." + fileEnding);
+ }
+
+ @Override
+ public String getDescription() {
+ return fileEnding + " files"; // name for filter
+ }
+ };
+
+ addChoosableFileFilter(filter);
+ setFileFilter(filter);
+ }
+
+}
Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -20,7 +20,6 @@
package org.dllearner.gui;
import java.awt.BorderLayout;
-import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
@@ -29,14 +28,16 @@
import javax.swing.JComboBox;
import javax.swing.JPanel;
-import org.dllearner.core.ComponentInitException;
import org.dllearner.core.KnowledgeSource;
+import org.dllearner.kb.OWLAPIOntology;
+import org.dllearner.kb.OWLFile;
/**
- * KnowledgeSourcePanel, tab 0. Choose Source, change Options and final initiate
- * KnowledgeSource.
+ * Knowledge source panel, tab 0. Choose source, change mandatory options and finally initialise
+ * knowledge source.
*
+ * @author Jens Lehmann
* @author Tilo Hielscher
*/
public class KnowledgeSourcePanel extends JPanel implements ActionListener {
@@ -44,14 +45,14 @@
private static final long serialVersionUID = -7678275020058043937L;
private Config config;
- private StartGUI startGUI;
- private JButton initButton;
+// private StartGUI startGUI;
+// private JButton initButton;
private JButton setButton;
private JButton clearButton;
private String[] kbBoxItems = {};
private JComboBox cb = new JComboBox(kbBoxItems);
private JPanel choosePanel = new JPanel();
- private JPanel initPanel = new JPanel();
+// private JPanel initPanel = new JPanel();
private int choosenClassIndex;
private List<Class<? extends KnowledgeSource>> selectableSources;
private OptionPanel optionPanel;
@@ -60,16 +61,21 @@
super(new BorderLayout());
this.config = config;
- this.startGUI = startGUI;
+// this.startGUI = startGUI;
selectableSources = config.getComponentManager().getKnowledgeSources();
+ // to set a default source, we move it to the beginning of the list
+ selectableSources.remove(OWLFile.class);
+ selectableSources.add(0, OWLFile.class);
+ // OWL API ontology is only useful programmatically (not in the GUI itself)
+ selectableSources.remove(OWLAPIOntology.class);
setButton = new JButton("Set");
setButton.addActionListener(this);
setButton = new JButton("Clear All");
setButton.addActionListener(this);
- initButton = new JButton("Init KnowledgeSource");
- initButton.addActionListener(this);
- initButton.setEnabled(true);
+// initButton = new JButton("Init KnowledgeSource");
+// initButton.addActionListener(this);
+// initButton.setEnabled(true);
// add to comboBox
for (int i = 0; i < selectableSources.size(); i++) {
@@ -90,10 +96,12 @@
add(choosePanel, BorderLayout.PAGE_START);
add(optionPanel, BorderLayout.CENTER);
- add(initPanel, BorderLayout.PAGE_END);
+// add(initPanel, BorderLayout.PAGE_END);
- setSource();
- updateAll();
+ choosenClassIndex = cb.getSelectedIndex();
+
+// setSource();
+// updateAll();
}
public void actionPerformed(ActionEvent e) {
@@ -101,7 +109,10 @@
choosenClassIndex = cb.getSelectedIndex();
// create a new knowledge source component
config.newKnowledgeSource(selectableSources.get(choosenClassIndex));
- updateAll();
+// updateAll();
+ updateOptionPanel();
+
+ System.out.println("update");
// config.setInitKnowledgeSource(false);
// init();
}
@@ -110,9 +121,9 @@
setSource();
}
- if (e.getSource() == initButton) {
- init();
- }
+// if (e.getSource() == initButton) {
+// init();
+// }
if (e.getSource() == clearButton) {
config.reInit();
@@ -132,6 +143,7 @@
/**
* after this, next tab can be used
*/
+ /*
public void init() {
setSource();
if (config.getKnowledgeSource() != null && config.isSetURL()) {
@@ -145,19 +157,21 @@
}
}
}
+ */
/**
* updateAll
*/
public void updateAll() {
- updateComboBox();
+// updateComboBox();
updateOptionPanel();
- updateInitButtonColor();
+// updateInitButtonColor();
}
/**
* set ComboBox to selected class
*/
+ /*
public void updateComboBox() {
if (config.getKnowledgeSource() != null)
for (int i = 0; i < selectableSources.size(); i++)
@@ -166,7 +180,7 @@
cb.setSelectedIndex(i);
}
this.choosenClassIndex = cb.getSelectedIndex();
- }
+ }*/
/**
* update OptionPanel with new selection
@@ -178,11 +192,13 @@
/**
* make init-button red if you have to click
*/
+ /*
public void updateInitButtonColor() {
if (!config.needsInitKnowledgeSource()) {
initButton.setForeground(Color.RED);
} else
initButton.setForeground(Color.BLACK);
}
+ */
}
Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -31,7 +31,6 @@
import org.dllearner.algorithms.DBpediaNavigationSuggestor;
import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent;
-import org.dllearner.core.ComponentInitException;
import org.dllearner.core.LearningAlgorithm;
import org.dllearner.core.LearningProblemUnsupportedException;
@@ -46,8 +45,8 @@
private static final long serialVersionUID = 8721490771860452959L;
private Config config;
- private StartGUI startGUI;
- private List<Class<? extends LearningAlgorithm>> learner;
+// private StartGUI startGUI;
+ private List<Class<? extends LearningAlgorithm>> selectableAlgorithms;
private JPanel choosePanel = new JPanel();
private OptionPanel optionPanel;
private JPanel initPanel = new JPanel();
@@ -60,14 +59,14 @@
super(new BorderLayout());
this.config = config;
- this.startGUI = startGUI;
- learner = config.getComponentManager().getLearningAlgorithms();
+// this.startGUI = startGUI;
+ selectableAlgorithms = config.getComponentManager().getLearningAlgorithms();
// to set a default learning algorithm, we move it to the beginning of the list
- learner.remove(ExampleBasedROLComponent.class);
- learner.add(0, ExampleBasedROLComponent.class);
+ selectableAlgorithms.remove(ExampleBasedROLComponent.class);
+ selectableAlgorithms.add(0, ExampleBasedROLComponent.class);
// we also remove the DBpedia Navigation Suggestor (maybe shouldn't be declared as a learning algorithm at all;
// at least it is not doing anything useful at the moment)
- learner.remove(DBpediaNavigationSuggestor.class);
+ selectableAlgorithms.remove(DBpediaNavigationSuggestor.class);
initButton = new JButton("Init LearingAlgorithm");
initButton.addActionListener(this);
@@ -77,8 +76,8 @@
autoInitButton.addActionListener(this);
// add into comboBox
- for (int i = 0; i < learner.size(); i++) {
- cb.addItem(config.getComponentManager().getComponentName(learner.get(i)));
+ for (int i = 0; i < selectableAlgorithms.size(); i++) {
+ cb.addItem(config.getComponentManager().getComponentName(selectableAlgorithms.get(i)));
}
choosePanel.add(cb);
@@ -87,9 +86,9 @@
LearningAlgorithm la = null;
try {
- la = config.newLearningAlgorithm(learner.get(cb.getSelectedIndex()));
+ la = config.newLearningAlgorithm(selectableAlgorithms.get(cb.getSelectedIndex()));
} catch (LearningProblemUnsupportedException e) {
- // TODO Auto-generated catch block
+ // TODO display message (or avoid selection at all)
e.printStackTrace();
}
optionPanel = new OptionPanel(config, la);
@@ -99,7 +98,7 @@
add(initPanel, BorderLayout.PAGE_END);
choosenClassIndex = cb.getSelectedIndex();
- updateInitButtonColor();
+// updateInitButtonColor();
}
public void actionPerformed(ActionEvent e) {
@@ -124,7 +123,7 @@
if (config.getLearningProblem() != null && config.getReasoningService() != null) {
try {
config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(
- learner.get(choosenClassIndex), config.getLearningProblem(),
+ selectableAlgorithms.get(choosenClassIndex), config.getLearningProblem(),
config.getReasoningService()));
updateOptionPanel();
} catch (LearningProblemUnsupportedException e) {
@@ -165,7 +164,7 @@
*/
public void updateComboBox() {
if (config.getLearningAlgorithm() != null)
- for (int i = 0; i < learner.size(); i++)
+ for (int i = 0; i < selectableAlgorithms.size(); i++)
if (config.getLearningAlgorithm().getClass().equals(
config.getComponentManager().getLearningAlgorithms().get(i))) {
cb.setSelectedIndex(i);
Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -21,7 +21,6 @@
*/
import java.awt.BorderLayout;
-import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
@@ -50,7 +49,7 @@
private JPanel choosePanel = new JPanel();
private OptionPanel optionPanel;
private JPanel initPanel = new JPanel();
- private JButton initButton, setButton;
+ private JButton setButton;
private int choosenClassIndex;
LearningProblemPanel(final Config config, StartGUI startGUI) {
Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -30,7 +30,6 @@
import javax.swing.JComboBox;
import javax.swing.JPanel;
-import org.dllearner.core.ComponentInitException;
import org.dllearner.core.ReasonerComponent;
import org.dllearner.reasoning.OWLAPIReasoner;
@@ -45,7 +44,7 @@
private static final long serialVersionUID = -7678275020058043937L;
private Config config;
- private StartGUI startGUI;
+// private StartGUI startGUI;
private List<Class<? extends ReasonerComponent>> reasoner;
private JPanel choosePanel = new JPanel();
private JPanel initPanel = new JPanel();
@@ -59,7 +58,7 @@
super(new BorderLayout());
this.config = config;
- this.startGUI = startGUI;
+// this.startGUI = startGUI;
reasoner = config.getComponentManager().getReasonerComponents();
// to set a default reasoner, we move it to the beginning of the list
reasoner.remove(OWLAPIReasoner.class);
Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -19,25 +19,32 @@
*/
package org.dllearner.gui;
-import javax.swing.*;
-import javax.swing.event.*;
-
+import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JTabbedPane;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.filechooser.FileFilter;
+
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
-import org.dllearner.core.ComponentInitException;
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.FileWriter;
-import javax.swing.filechooser.FileFilter;
-
/**
* This class builds the basic GUI elements and is used to start the DL-Learner
* GUI.
@@ -71,6 +78,8 @@
private JMenuItem aboutItem = new JMenuItem("About");
private JMenuItem tutorialItem = new JMenuItem("Quick Tutorial");
+ private StatusPanel statusPanel = new StatusPanel();
+
public StartGUI() {
this(null);
}
@@ -111,7 +120,8 @@
menuHelp.add(aboutItem);
aboutItem.addActionListener(this);
- add(tabPane);
+ add(tabPane, BorderLayout.CENTER);
+ add(statusPanel, BorderLayout.SOUTH);
setVisible(true);
updateTabColors();
@@ -177,8 +187,9 @@
// force platform look and feel
try {
UIManager.setLookAndFeel(
- // "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
- UIManager.getSystemLookAndFeelClassName());
+ UIManager.getCrossPlatformLookAndFeelClassName());
+// "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
+// UIManager.getSystemLookAndFeelClassName());
// TODO: currently everything is in bold on Linux (and Win?)
} catch (ClassNotFoundException e) {
e.printStackTrace();
@@ -197,21 +208,7 @@
// open config file
if (e.getSource() == openItem) {
// file dialog
- JFileChooser fc = new JFileChooser(new File("examples/"));
- // FileFilter only *.conf
- fc.addChoosableFileFilter(new FileFilter() {
- @Override
- public boolean accept(File f) {
- if (f.isDirectory())
- return true;
- return f.getName().toLowerCase().endsWith(".conf");
- }
-
- @Override
- public String getDescription() {
- return "*.conf"; // name for filter
- }
- });
+ JFileChooser fc = new ExampleFileChooser("conf");
if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
System.out.println("FILE: " + fc.getSelectedFile());
configLoad.openFile(fc.getSelectedFile());
@@ -264,25 +261,41 @@
* Update colors of tabulators; red should be clicked, black for OK.
*/
public void updateTabColors() {
- if (config.needsInitKnowledgeSource())
- tabPane.setForegroundAt(0, Color.RED);
- else
- tabPane.setForegroundAt(0, Color.BLACK);
- if (config.needsInitReasoner())
- tabPane.setForegroundAt(1, Color.RED);
- else
- tabPane.setForegroundAt(1, Color.BLACK);
- if (config.needsInitLearningProblem())
- tabPane.setForegroundAt(2, Color.RED);
- else
- tabPane.setForegroundAt(2, Color.BLACK);
- if (config.needsInitLearningAlgorithm()) {
- tabPane.setForegroundAt(3, Color.RED);
- tabPane.setForegroundAt(4, Color.RED);
- } else {
- tabPane.setForegroundAt(3, Color.BLACK);
- tabPane.setForegroundAt(4, Color.BLACK);
+ for(int i=0; i<4; i++) {
+ // red = needs init, black = initialised
+ if(config.needsInit(i)) {
+ tabPane.setForegroundAt(i, Color.RED);
+ } else {
+ tabPane.setForegroundAt(i, Color.BLACK);
+ }
+
+ // only enable tabs, which can be selected
+ // (note the i+1: knowledge source always enabled)
+ tabPane.setEnabledAt(i+1, config.isEnabled(i));
}
+
+ // run panel is enabled if all mandatory algorithm parameters have been set
+// tabPane.setEnabledAt(4, config.isEnabled(4));
+
+// if (config.needsInitKnowledgeSource())
+// tabPane.setForegroundAt(0, Color.RED);
+// else
+// tabPane.setForegroundAt(0, Color.BLACK);
+// if (config.needsInitReasoner())
+// tabPane.setForegroundAt(1, Color.RED);
+// else
+// tabPane.setForegroundAt(1, Color.BLACK);
+// if (config.needsInitLearningProblem())
+// tabPane.setForegroundAt(2, Color.RED);
+// else
+// tabPane.setForegroundAt(2, Color.BLACK);
+// if (config.needsInitLearningAlgorithm()) {
+// tabPane.setForegroundAt(3, Color.RED);
+// tabPane.setForegroundAt(4, Color.RED);
+// } else {
+// tabPane.setForegroundAt(3, Color.BLACK);
+// tabPane.setForegroundAt(4, Color.BLACK);
+// }
// commented out as I do not see any reason why the method should update
// everything
@@ -294,4 +307,8 @@
// tab3.updateAll();
}
+
+ public void setStatusMessage(String message) {
+ statusPanel.setStatus(message);
+ }
}
Added: trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -0,0 +1,48 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.gui;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+/**
+ * Status panel showing help messages, exceptions etc.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public class StatusPanel extends JPanel {
+
+ private static final long serialVersionUID = 2426470148153461670L;
+
+ private String initText = "Please fill in the mandatory config options and proceed to the next tab.";
+
+ private JLabel statusLabel = new JLabel(initText);
+
+ public StatusPanel() {
+ super();
+ add(statusLabel);
+ }
+
+ public void setStatus(String message) {
+ statusLabel.setText(message);
+ }
+
+}
Modified: trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -19,6 +19,8 @@
*/
package org.dllearner.gui;
+import java.awt.Dimension;
+
import javax.swing.JFrame;
import javax.swing.JLabel;
@@ -36,7 +38,7 @@
setTitle("Quick Tutorial");
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setLocationByPlatform(true);
- setSize(300, 500);
+ setSize(300, 600);
// display tutorial text
String text = "<html><h2>Quick Tutorial</h2><p align=\"justify\">DL-Learner has a component" +
@@ -50,12 +52,20 @@
"you have to choose and configure all four types of components." +
" The run tab plays a special role: It is used to start the learning algorithm" +
" and display statistical information.</p>" +
+ "<br /><p><i>Tab color explanation:</i> <br />gray = cannot be configured yet (mandatory configuration values missing)<br />" +
+ "red = needs to be initialised<br />black = component has been initialised</p>" +
"<br /><p><i>Further references:</i><br />" +
"Homepage: <a href=\"http://dl-learner.org\">http://dl-learner.org</a><br />" +
"DL-Learner Architecture: <a href=\"http://dl-learner.org/wiki/Architecture\">http://dl-learner.org/wiki/Architecture</a>" +
"</p><br /><p>Please send questions to le...@in....</p></html>";
JLabel label = new JLabel(text);
+ label.setMaximumSize(new Dimension(300,500));
add(label);
+// JScrollPane scrollPane = new JScrollPane(label);
+// scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+// scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+// scrollPane.setPreferredSize(new Dimension(300,500));
+// add(scrollPane);
setVisible(true);
}
Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -21,7 +21,6 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
@@ -29,6 +28,7 @@
import org.dllearner.core.Component;
import org.dllearner.core.config.StringConfigOption;
+import org.dllearner.kb.OWLFile;
/**
* Panel for option String, defined in
@@ -54,9 +54,14 @@
public void actionPerformed(ActionEvent e) {
if (e.getSource() == setButton) {
- if (checkForFilename()) {
- // file dialog
- JFileChooser fc = new JFileChooser(new File("examples/"));
+ if (configOption.getName().equals("filename")) {
+ JFileChooser fc;
+ if(component instanceof OWLFile) {
+ fc = new ExampleFileChooser("owl");
+ } else {
+ fc = new ExampleFileChooser("kb");
+ }
+
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
value = fc.getSelectedFile().toString();
@@ -92,14 +97,6 @@
System.out.println("String: not valid value");
}*/
- /**
- * Widget filename getName() == filename you should open a file dialog in
- * ActionPerformed
- */
- private Boolean checkForFilename() {
- return configOption.getName().equalsIgnoreCase("filename");
- }
-
@Override
public void buildWidgetPanel() {
add(getLabel());
@@ -123,7 +120,8 @@
add(stringField);
add(setButton);
- if (checkForFilename())
+ // special handling for filename option
+ if (configOption.getName().equals("filename"))
setButton.setText("choose local file");
}
Modified: trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java 2008-09-09 13:40:43 UTC (rev 1185)
+++ trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java 2008-09-09 13:44:25 UTC (rev 1186)
@@ -21,12 +21,20 @@
private OWLOntology ontology;
+ public OWLAPIOntology() {
+ this(null);
+ }
+
public OWLAPIOntology(OWLOntology onto)
{
this.ontology = onto;
this.configurator = new OWLAPIOntologyConfigurator(this);
}
+ public static String getName() {
+ return "OWL API Ontology";
+ }
+
@Override
public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-10 05:48:12
|
Revision: 1189
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1189&view=rev
Author: jenslehmann
Date: 2008-09-10 05:48:08 +0000 (Wed, 10 Sep 2008)
Log Message:
-----------
fixed all Eclipse warnings in project
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java
trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java
trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java
trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java
trunk/src/dl-learner/org/dllearner/utilities/datastructures/SetManipulation.java
Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-09 14:27:41 UTC (rev 1188)
+++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-10 05:48:08 UTC (rev 1189)
@@ -21,7 +21,6 @@
import java.awt.BorderLayout;
import java.awt.Color;
-import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
Modified: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-09-09 14:27:41 UTC (rev 1188)
+++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-09-10 05:48:08 UTC (rev 1189)
@@ -31,6 +31,7 @@
import org.dllearner.core.ComponentManager;
import org.dllearner.core.EvaluatedDescription;
import org.dllearner.core.LearningAlgorithm;
+import org.dllearner.core.ReasonerComponent;
import org.dllearner.core.ReasoningService;
import org.dllearner.core.owl.Individual;
import org.dllearner.reasoning.FastInstanceChecker;
@@ -54,7 +55,7 @@
public static String ontologyPath = "examples/semantic_bible/NTNcombined.owl";
//private static Class usedReasoner = FastInstanceChecker.class;
- private static Class usedReasoner = OWLAPIReasoner.class;
+ private static Class<? extends ReasonerComponent> usedReasoner = OWLAPIReasoner.class;
private static boolean allOrExists = true;
private static boolean tenORthirty = true;
@@ -285,7 +286,7 @@
}
- Class tmp = FastInstanceChecker.class;
+ Class<? extends ReasonerComponent> tmp = FastInstanceChecker.class;
if(usedReasoner.equals(tmp)){
lc.maxExecutionTimeInSeconds = 30;
}else{
Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java 2008-09-09 14:27:41 UTC (rev 1188)
+++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java 2008-09-10 05:48:08 UTC (rev 1189)
@@ -34,6 +34,7 @@
import org.dllearner.core.EvaluatedDescription;
import org.dllearner.core.KnowledgeSource;
import org.dllearner.core.LearningAlgorithm;
+import org.dllearner.core.ReasonerComponent;
import org.dllearner.core.ReasoningService;
import org.dllearner.core.owl.Individual;
import org.dllearner.core.owl.NamedClass;
@@ -75,7 +76,7 @@
public static String ontologyPath = "examples/semantic_bible/NTNcombined.owl";
- private static Class usedReasoner = FastInstanceChecker.class;
+ private static Class<? extends ReasonerComponent> usedReasoner = FastInstanceChecker.class;
/**
* @param args
Modified: trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java 2008-09-09 14:27:41 UTC (rev 1188)
+++ trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java 2008-09-10 05:48:08 UTC (rev 1189)
@@ -269,9 +269,9 @@
private static void printIntermediateResults(
- SortedSet fullSet,
- SortedSet correctIndividuals,
- SortedSet wrongIndividuals,
+ SortedSet<String> fullSet,
+ SortedSet<String> correctIndividuals,
+ SortedSet<String> wrongIndividuals,
int numberOfConcepts) {
SetManipulation.printSet("full Individual set: ", fullSet, logger);
Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-09-09 14:27:41 UTC (rev 1188)
+++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-09-10 05:48:08 UTC (rev 1189)
@@ -197,6 +197,7 @@
* returns the edited Components.
* @return Set of OWLDescriptions
*/
+ @Override
public Set<OWLDescription> getEditedObjects() {
if (tabbedPane.getSelectedComponent() == classSelectorPanel) {
return new HashSet<OWLDescription>(classSelectorPanel
@@ -630,6 +631,7 @@
splitPane.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
List<RestrictionCreator> types = new ArrayList<RestrictionCreator>();
types.add(new RestrictionCreator("Some (existential)") {
+ @Override
public void createRestrictions(
Set<OWLObjectProperty> properties,
Set<OWLDescription> fillers, Set<OWLDescription> result) {
@@ -642,6 +644,7 @@
}
});
types.add(new RestrictionCreator("Only (universal)") {
+ @Override
public void createRestrictions(
Set<OWLObjectProperty> properties,
Set<OWLDescription> fillers, Set<OWLDescription> result) {
@@ -663,6 +666,7 @@
});
types.add(new CardinalityRestrictionCreator(
"Min (min cardinality)", cardinalitySpinner) {
+ @Override
public OWLDescription createRestriction(OWLObjectProperty prop,
OWLDescription filler, int card) {
return getDataFactory()
@@ -672,6 +676,7 @@
});
types.add(new CardinalityRestrictionCreator(
"Exactly (exact cardinality)", cardinalitySpinner) {
+ @Override
public OWLDescription createRestriction(OWLObjectProperty prop,
OWLDescription filler, int card) {
return getDataFactory()
@@ -681,6 +686,7 @@
});
types.add(new CardinalityRestrictionCreator(
"Max (max cardinality)", cardinalitySpinner) {
+ @Override
public OWLDescription createRestriction(OWLObjectProperty prop,
OWLDescription filler, int card) {
return getDataFactory()
@@ -744,6 +750,7 @@
this.name = name;
}
+ @Override
public String toString() {
return name;
}
@@ -767,6 +774,7 @@
this.cardinalitySpinner = cardinalitySpinner;
}
+ @Override
public void createRestrictions(Set<OWLObjectProperty> properties,
Set<OWLDescription> fillers, Set<OWLDescription> result) {
for (OWLObjectProperty prop : properties) {
Modified: trunk/src/dl-learner/org/dllearner/utilities/datastructures/SetManipulation.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/datastructures/SetManipulation.java 2008-09-09 14:27:41 UTC (rev 1188)
+++ trunk/src/dl-learner/org/dllearner/utilities/datastructures/SetManipulation.java 2008-09-10 05:48:08 UTC (rev 1189)
@@ -129,7 +129,7 @@
* @param nrElements
* @return returns the list shrunken to size.
*/
- public static List getFirst(List list, int nrElements) {
+ public static <T> List<T> getFirst(List<T> list, int nrElements) {
int size;
while ((size = list.size()) > nrElements) {
list.remove(size - 1);
@@ -153,7 +153,7 @@
return ret;
}
- public static void printSet(String s, SortedSet set, Logger logger) {
+ public static void printSet(String s, SortedSet<String> set, Logger logger) {
if(logger.getLevel().equals(Level.DEBUG)){
logger.info(s +" ["+ set.size()+"]: "+set);
}else{
@@ -162,7 +162,7 @@
}
- public static void printSet(String s, SortedSet set) {
+ public static <T> void printSet(String s, SortedSet<T> set) {
System.out.println(s +" ["+ set.size()+"]: "+set);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-10 10:25:20
|
Revision: 1191
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1191&view=rev
Author: jenslehmann
Date: 2008-09-10 10:25:17 +0000 (Wed, 10 Sep 2008)
Log Message:
-----------
new URL config option type
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java
trunk/src/dl-learner/org/dllearner/gui/ajaxloader.gif
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java
Added: trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java 2008-09-10 10:25:17 UTC (rev 1191)
@@ -0,0 +1,79 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.core.config;
+
+import java.net.URL;
+
+/**
+ * Option which has an URL as value.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public class URLConfigOption extends ConfigOption<URL> {
+
+ public URLConfigOption(String name, String description) {
+ super(name, description);
+ }
+
+ public URLConfigOption(String name, String description, URL defaultValue) {
+ super(name, description, defaultValue);
+ }
+
+ public URLConfigOption(String name, String description, URL defaultValue, boolean mandatory,
+ boolean requiresInit) {
+ super(name, description, defaultValue, mandatory, requiresInit);
+ }
+
+ /* (non-Javadoc)
+ * @see org.dllearner.core.config.ConfigOption#checkType(java.lang.Object)
+ */
+ @Override
+ public boolean checkType(Object object) {
+ return (object instanceof URL);
+ }
+
+ /* (non-Javadoc)
+ * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object, java.lang.Integer)
+ */
+ @Override
+ public String getValueFormatting(URL value) {
+ return value.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString()
+ */
+ @Override
+ public String getValueTypeAsJavaString() {
+ return "URL";
+ }
+
+ /* (non-Javadoc)
+ * @see org.dllearner.core.config.ConfigOption#isValidValue(java.lang.Object)
+ */
+ @Override
+ public boolean isValidValue(URL value) {
+ return true;
+ }
+
+
+
+}
Property changes on: trunk/src/dl-learner/org/dllearner/gui/ajaxloader.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java 2008-09-10 10:25:17 UTC (rev 1191)
@@ -0,0 +1,126 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.gui.widgets;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import org.dllearner.core.Component;
+import org.dllearner.core.config.URLConfigOption;
+import org.dllearner.gui.Config;
+import org.dllearner.gui.ExampleFileChooser;
+import org.dllearner.kb.OWLFile;
+
+/**
+ * Widget panel for URLs.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public class WidgetPanelURL extends AbstractWidgetPanel<URL> implements ActionListener {
+
+ private static final long serialVersionUID = -2169739820989891226L;
+
+ private JButton setButton;
+ private JButton chooseLocalButton;
+
+ private URL value;
+ private JTextField stringField;
+
+ public WidgetPanelURL(Config config, Component component, URLConfigOption configOption) {
+ super(config, component, configOption);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == chooseLocalButton) {
+// String stringValue;
+ JFileChooser fc;
+ if(component instanceof OWLFile) {
+ fc = new ExampleFileChooser("owl");
+ } else {
+ fc = new ExampleFileChooser("kb");
+ }
+
+ int returnVal = fc.showOpenDialog(this);
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+// stringValue = fc.getSelectedFile().toString();
+// stringField.setText(stringValue);
+ try {
+ // get file URI, add it into text field and fire a
+ // value changed event
+ value = fc.getSelectedFile().toURI().toURL();
+ stringField.setText(value.toString());
+ fireValueChanged(value);
+ } catch (MalformedURLException e1) {
+ // should never happen, because an actual file was selected
+ e1.printStackTrace();
+ }
+ }
+ } else if(e.getSource() == setButton) {
+ String stringValue = stringField.getText();
+ try {
+ value = new URL(stringValue);
+ } catch (MalformedURLException e1) {
+ // TODO add error handling
+ e1.printStackTrace();
+ }
+ fireValueChanged(value);
+ }
+ }
+
+ @Override
+ public void buildWidgetPanel() {
+ add(getLabel());
+
+ // get current value of this option for the given component
+ value = config.getConfigOptionValue(component, configOption);
+ // default values can be null, so we interpret this as empty string
+// if (value == null) {
+// value = "";
+// }
+
+ // text field for strings
+ stringField = new JTextField(35);
+ if(value != null)
+ stringField.setText(value.toString());
+ stringField.setToolTipText(configOption.getAllowedValuesDescription());
+
+ // set button (value is only updated when this button is pressed => would better without set)
+ setButton = new JButton("Set");
+ setButton.addActionListener(this);
+
+ chooseLocalButton = new JButton("Choose Local File");
+ chooseLocalButton.addActionListener(this);
+
+ add(stringField);
+ add(setButton);
+ add(new JLabel(" or "));
+ add(chooseLocalButton);
+
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-10 12:17:53
|
Revision: 1193
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1193&view=rev
Author: jenslehmann
Date: 2008-09-10 12:17:50 +0000 (Wed, 10 Sep 2008)
Log Message:
-----------
inits running in separate threads, option panels updated correctly
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java
trunk/src/dl-learner/org/dllearner/gui/Config.java
trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java
trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java
trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java
trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java
trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java
trunk/src/dl-learner/org/dllearner/test/ComponentTest.java
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/gui/InitWorker.java
Modified: trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -1,6 +1,6 @@
package org.dllearner.gui;
-import java.awt.event.ActionEvent;
+import java.awt.LayoutManager;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
@@ -13,12 +13,14 @@
* @author Jens Lehmann
*
*/
-public class ComponentPanel<T extends Component> extends JPanel implements ActionListener {
+public abstract class ComponentPanel<T extends Component> extends JPanel implements ActionListener {
private static final long serialVersionUID = -7678275020058043937L;
- public void actionPerformed(ActionEvent arg0) {
- // TODO Auto-generated method stub
+ public ComponentPanel(LayoutManager layout) {
+ super(layout);
}
-
+
+ // called when panel is active
+ public abstract void panelActivated();
}
Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -20,17 +20,7 @@
package org.dllearner.gui;
-import java.awt.BorderLayout;
-import java.net.URL;
-
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.SwingWorker;
-
-import org.apache.log4j.Logger;
import org.dllearner.core.Component;
-import org.dllearner.core.ComponentInitException;
import org.dllearner.core.ComponentManager;
import org.dllearner.core.KnowledgeSource;
import org.dllearner.core.LearningAlgorithm;
@@ -57,7 +47,7 @@
public class Config {
private ComponentManager cm = ComponentManager.getInstance();
- private static Logger logger = Logger.getLogger(Config.class);
+// private static Logger logger = Logger.getLogger(Config.class);
// the components currently active
private KnowledgeSource source;
@@ -154,6 +144,14 @@
// logger.debug("knowledge source " + clazz + " changed");
// create a new reasoner object using the current class and the selected source
reasoner = cm.reasoner(reasoner.getClass(), source);
+ rs = cm.reasoningService(reasoner);
+ lp = cm.learningProblem(lp.getClass(), rs);
+ try {
+ la = cm.learningAlgorithm(la.getClass(), lp, rs);
+ } catch (LearningProblemUnsupportedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
return source;
}
@@ -182,6 +180,19 @@
return reasoner;
}
+ public ReasonerComponent changeReasoner(Class<? extends ReasonerComponent> clazz) {
+ reasoner = cm.reasoner(clazz, source);
+ rs = cm.reasoningService(reasoner);
+ lp = cm.learningProblem(lp.getClass(), rs);
+ try {
+ la = cm.learningAlgorithm(la.getClass(), lp, rs);
+ } catch (LearningProblemUnsupportedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return reasoner;
+ }
+
/**
* Set ReasoningService.
*
@@ -223,6 +234,17 @@
return lp;
}
+ public LearningProblem changeLearningProblem(Class<? extends LearningProblem> clazz) {
+ lp = cm.learningProblem(clazz, rs);
+ try {
+ la = cm.learningAlgorithm(la.getClass(), lp, rs);
+ } catch (LearningProblemUnsupportedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return lp;
+ }
+
/**
* Set LearningAlgorithm.
*
@@ -246,6 +268,16 @@
return la;
}
+ public LearningAlgorithm changeLearningAlgorithm(Class<? extends LearningAlgorithm> clazz) {
+ try {
+ la = cm.learningAlgorithm(clazz, lp, rs);
+ } catch (LearningProblemUnsupportedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return la;
+ }
+
public boolean tabNeedsInit(int tabIndex) {
return needsInit[tabIndex];
}
@@ -401,114 +433,29 @@
// init the specified component and record which ones where initialised
public void init(int tabIndex) {
- // a thread class for handling inits (GUI has to remain
- // responsive while init process is executed)
- class InitThread extends Thread {
- private Component component;
- public InitThread(Component component) {
- this.component = component;
- }
- @Override
- public void run() {
- gui.disableTabbedPane();
- try {
- component.init();
- } catch (ComponentInitException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- gui.enableTabbedPane();
- }
- }
-
-// final SwingWorker worker = new SwingWorker() {
- class InitWorker extends SwingWorker<Boolean,Boolean> {
- private Component component;
- public InitWorker(Component component) {
- this.component = component;
- }
-
- @Override
- protected Boolean doInBackground() throws Exception {
- gui.getStatusPanel().setStatus("Initialising reasoner ... ");
-// gui.getStatusPanel().repaint();
- gui.disableTabbedPane();
- gui.setEnabled(false);
- JFrame waitFrame = new JFrame();
- waitFrame.setUndecorated(true);
- waitFrame.setSize(200, 200);
- URL imgURL = Config.class.getResource("ajaxloader.gif");
- ImageIcon waitIcon = new ImageIcon(imgURL, "wait");
-// waitFrame.add(new JLabel("Wait!"), waitIcon, SwingConstants.RIGHT);
-// waitFrame.add(new JLabel("Wait"));
- waitFrame.add(new JLabel(waitIcon), BorderLayout.NORTH);
- waitFrame.add(new JLabel("Initialising reasoner. Please wait."), BorderLayout.SOUTH);
- waitFrame.setLocationRelativeTo(gui);
- waitFrame.setVisible(true);
- try {
- component.init();
- } catch (ComponentInitException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- gui.enableTabbedPane();
- gui.setEnabled(true);
- gui.getStatusPanel().extendMessage("done.");
- waitFrame.dispose();
- // TODO Auto-generated method stub
-// return null;
- return true;
- }
- };
-
-
- try {
+// try {
if(tabIndex==0) {
- gui.disableTabbedPane();
- gui.getStatusPanel().setStatus("Initialising knowledge source ... ");
- source.init();
- gui.getStatusPanel().extendMessage("done.");
- gui.enableTabbedPane();
+ InitWorker worker = new InitWorker(source, gui);
+ worker.execute();
} else if(tabIndex==1) {
-// gui.disableTabbedPane();
-// gui.getStatusPanel().setStatus("Initialising reasoner ... ");
-// gui.repaint();
-// Thread initThread = new InitThread(reasoner);
-// initThread.run();
-// SwingWorker worker;
-// try {
-// SwingUtilities.invokeAndWait(initThread);
-// } catch (InterruptedException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch (InvocationTargetException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-
- InitWorker worker = new InitWorker(reasoner);
+ InitWorker worker = new InitWorker(reasoner, gui);
worker.execute();
-
-// reasoner.init();
-// gui.getStatusPanel().extendMessage("done.");
-// gui.enableTabbedPane();
} else if(tabIndex==2) {
- gui.disableTabbedPane();
- gui.getStatusPanel().setStatus("Initialising learning problem ... ");
- lp.init();
- gui.getStatusPanel().extendMessage("done.");
- gui.enableTabbedPane();
+ InitWorker worker = new InitWorker(lp, gui);
+ worker.execute();
} else if(tabIndex == 3) {
- gui.disableTabbedPane();
- gui.getStatusPanel().setStatus("Initialising learning algorithm ... ");
- la.init();
- gui.getStatusPanel().extendMessage("done.");
- gui.enableTabbedPane();
+ InitWorker worker = new InitWorker(la, gui);
+ worker.execute();
+// gui.disableTabbedPane();
+// gui.getStatusPanel().setStatus("Initialising learning algorithm ... ");
+// la.init();
+// gui.getStatusPanel().extendMessage("done.");
+// gui.enableTabbedPane();
}
- } catch (ComponentInitException e) {
- // TODO display message in status bar
- e.printStackTrace();
- }
+// } catch (ComponentInitException e) {
+// // TODO display message in status bar
+// e.printStackTrace();
+// }
needsInit[tabIndex] = false;
System.out.println("component " + tabIndex + " initialised.");
Added: trunk/src/dl-learner/org/dllearner/gui/InitWorker.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/InitWorker.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/gui/InitWorker.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -0,0 +1,117 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.gui;
+
+import java.awt.Color;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.SwingWorker;
+
+import org.dllearner.core.Component;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.ReasonerComponent;
+import org.dllearner.kb.KBFile;
+import org.dllearner.kb.OWLFile;
+
+/**
+ * Class, which is responsible for executing the init method of
+ * a component in a different thread and displaying a "please wait"
+ * message while the initialisation is in process.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public class InitWorker extends SwingWorker<Boolean, Boolean> {
+
+ private Component component;
+ private StartGUI gui;
+ private boolean timeIntensive = true;
+
+ public InitWorker(Component component, StartGUI gui) {
+ this.component = component;
+ this.gui = gui;
+
+ // create a list of components, which do need virtually
+ // no time to initialise (and where displaying a please
+ // wait message is an unnecessary overhead)
+ List<Class<? extends Component>> nonTimeIntensiveComponents = new LinkedList<Class<? extends Component>>();
+ nonTimeIntensiveComponents.add(OWLFile.class);
+ nonTimeIntensiveComponents.add(KBFile.class);
+
+ if(nonTimeIntensiveComponents.contains(component.getClass())) {
+ timeIntensive = false;
+ }
+ }
+
+ @Override
+ protected Boolean doInBackground() throws Exception {
+
+ JFrame waitFrame = null;
+ if(timeIntensive) {
+ // gui.getStatusPanel().setStatus("Initialising reasoner ... ");
+ gui.disableTabbedPane();
+ gui.setEnabled(false);
+ waitFrame = new JFrame();
+ waitFrame.setUndecorated(true);
+ waitFrame.setSize(160, 100);
+ waitFrame.getContentPane().setBackground(Color.WHITE);
+ URL imgURL = Config.class.getResource("ajaxloader.gif");
+ // ImageIcon waitIcon = new ImageIcon(imgURL, "wait");
+ // waitFrame.add(new JLabel("Wait!"), waitIcon, SwingConstants.RIGHT);
+ // waitFrame.add(new JLabel("Wait"));
+ // JLabel iconLabel = new JLabel(waitIcon);
+ // iconLabel.setOpaque(true);
+ // iconLabel.setBackground(Color.RED);
+ // iconLabel.setForeground(Color.RED);
+ // waitFrame.add(iconLabel, BorderLayout.NORTH);
+ waitFrame.add(new JLabel("<html><br /><p align=\"center\"><img src=\"" + imgURL + "\" /><br /> Initialising component.<br />Please wait.</p></html>"));
+ waitFrame.setLocationRelativeTo(gui);
+ waitFrame.setVisible(true);
+ }
+
+ try {
+ component.init();
+ } catch (ComponentInitException e) {
+ gui.getStatusPanel().setExceptionMessage(e.getMessage());
+ e.printStackTrace();
+ }
+
+ if(timeIntensive) {
+ gui.enableTabbedPane();
+ gui.setEnabled(true);
+ // gui.getStatusPanel().extendMessage("done.");
+ waitFrame.dispose();
+ }
+
+ // when the reasoner has been initialised, we need to update
+ // the option panel (such that the user can see the existing
+ // examples, classes etc.)
+ if(component instanceof ReasonerComponent) {
+ gui.tab2.updateOptionPanel();
+ gui.tab3.updateOptionPanel();
+ }
+
+ return true;
+ }
+}
Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -21,7 +21,6 @@
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
@@ -40,7 +39,7 @@
* @author Jens Lehmann
* @author Tilo Hielscher
*/
-public class KnowledgeSourcePanel extends JPanel implements ActionListener {
+public class KnowledgeSourcePanel extends ComponentPanel<KnowledgeSource> {
private static final long serialVersionUID = -7678275020058043937L;
@@ -76,6 +75,7 @@
cb.addActionListener(this);
choosePanel.add(cb);
+// choosePanel.add(new JLabel(" "));
choosePanel.add(clearButton);
choosenClassIndex = cb.getSelectedIndex();
@@ -97,12 +97,7 @@
choosenClassIndex = cb.getSelectedIndex();
// create a new knowledge source component
config.changeKnowledgeSource(selectableSources.get(choosenClassIndex));
-// updateAll();
updateOptionPanel();
-
- System.out.println("update");
-// config.setInitKnowledgeSource(false);
-// init();
}
if (e.getSource() == clearButton) {
@@ -134,4 +129,13 @@
optionPanel.update(config.getKnowledgeSource());
}
+ /* (non-Javadoc)
+ * @see org.dllearner.gui.ComponentPanel#panelActivated()
+ */
+ @Override
+ public void panelActivated() {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -22,7 +22,6 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
@@ -40,7 +39,7 @@
*
* @author Tilo Hielscher
*/
-public class LearningAlgorithmPanel extends JPanel implements ActionListener {
+public class LearningAlgorithmPanel extends ComponentPanel<LearningAlgorithm> {
private static final long serialVersionUID = 8721490771860452959L;
@@ -188,4 +187,13 @@
} else
initButton.setForeground(Color.BLACK);
}
+
+ /* (non-Javadoc)
+ * @see org.dllearner.gui.ComponentPanel#panelActivated()
+ */
+ @Override
+ public void panelActivated() {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -1,5 +1,3 @@
-package org.dllearner.gui;
-
/**
* Copyright (C) 2007-2008, Jens Lehmann
*
@@ -19,25 +17,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+package org.dllearner.gui;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.util.List;
-import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import org.dllearner.core.LearningProblem;
/**
- * LearningProblemPanel tab 2. Choose LearingProblem, change Options and final
- * initiate LearningProblem.
+ * Learning problem panel.
*
+ * @author Jens Lehmann
* @author Tilo Hielscher
*/
-public class LearningProblemPanel extends JPanel implements ActionListener {
+public class LearningProblemPanel extends ComponentPanel<LearningProblem> {
private static final long serialVersionUID = -3819627680918930203L;
@@ -49,7 +46,7 @@
private JPanel choosePanel = new JPanel();
private OptionPanel optionPanel;
private JPanel initPanel = new JPanel();
- private JButton setButton;
+// private JButton setButton;
private int choosenClassIndex;
LearningProblemPanel(final Config config, StartGUI startGUI) {
@@ -59,10 +56,10 @@
// this.startGUI = startGUI;
lpClasses = config.getComponentManager().getLearningProblems();
- setButton = new JButton("Set");
- setButton.addActionListener(this);
+// setButton = new JButton("Set");
+// setButton.addActionListener(this);
choosePanel.add(cb);
- choosePanel.add(setButton);
+// choosePanel.add(setButton);
cb.addActionListener(this);
// add into comboBox
@@ -89,8 +86,8 @@
// read selected LearningProblemClass
if (choosenClassIndex != cb.getSelectedIndex()) {
this.choosenClassIndex = cb.getSelectedIndex();
-// config.setInitLearningProblem(false);
-// init();
+ config.changeLearningProblem(lpClasses.get(choosenClassIndex));
+ updateOptionPanel();
}
// if (e.getSource() == setButton)
@@ -134,15 +131,17 @@
/**
* updateAll
*/
+ /*
public void updateAll() {
updateComboBox();
updateOptionPanel();
// updateInitButtonColor();
- }
+ }*/
/**
* set ComboBox to selected class
*/
+ /*
public void updateComboBox() {
if (config.getLearningProblem() != null)
for (int i = 0; i < lpClasses.size(); i++)
@@ -151,15 +150,24 @@
cb.setSelectedIndex(i);
}
this.choosenClassIndex = cb.getSelectedIndex();
- }
+ }*/
/**
* update OptionPanel with new selection
*/
- private void updateOptionPanel() {
+ public void updateOptionPanel() {
optionPanel.update(config.getLearningProblem());
}
+ /* (non-Javadoc)
+ * @see org.dllearner.gui.ComponentPanel#panelActivated()
+ */
+ @Override
+ public void panelActivated() {
+ // TODO Auto-generated method stub
+
+ }
+
/**
* make init-button red if you have to click
*/
Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -1,5 +1,3 @@
-package org.dllearner.gui;
-
/**
* Copyright (C) 2007-2008, Jens Lehmann
*
@@ -19,11 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+package org.dllearner.gui;
import java.awt.BorderLayout;
-import java.awt.Color;
import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
@@ -34,22 +31,22 @@
import org.dllearner.reasoning.OWLAPIReasoner;
/**
- * ReasonerPanel, tab 1. Choose Resoner, change Options and final initiate
- * Reasoner and ReasoningService.
+ * Panel for configuring reasoner.
*
* @author Tilo Hielscher
+ * @author Jens Lehmann
*/
-public class ReasonerPanel extends JPanel implements ActionListener {
+public class ReasonerPanel extends ComponentPanel<ReasonerComponent> {
private static final long serialVersionUID = -7678275020058043937L;
private Config config;
// private StartGUI startGUI;
- private List<Class<? extends ReasonerComponent>> reasoner;
+ private List<Class<? extends ReasonerComponent>> selectableReasoners;
private JPanel choosePanel = new JPanel();
private JPanel initPanel = new JPanel();
private OptionPanel optionPanel;
- private JButton initButton, setButton;
+ private JButton initButton;
private String[] cbItems = {};
private JComboBox cb = new JComboBox(cbItems);
private int choosenClassIndex;
@@ -59,29 +56,29 @@
this.config = config;
// this.startGUI = startGUI;
- reasoner = config.getComponentManager().getReasonerComponents();
+ selectableReasoners = config.getComponentManager().getReasonerComponents();
// to set a default reasoner, we move it to the beginning of the list
- reasoner.remove(OWLAPIReasoner.class);
- reasoner.add(0, OWLAPIReasoner.class);
+ selectableReasoners.remove(OWLAPIReasoner.class);
+ selectableReasoners.add(0, OWLAPIReasoner.class);
initButton = new JButton("Init Reasoner");
initButton.addActionListener(this);
// initPanel.add(initButton);
initButton.setEnabled(true);
- setButton = new JButton("Set");
- setButton.addActionListener(this);
+// setButton = new JButton("Set");
+// setButton.addActionListener(this);
choosePanel.add(cb);
// add into comboBox
- for (int i = 0; i < reasoner.size(); i++) {
- cb.addItem(config.getComponentManager().getComponentName(reasoner.get(i)));
+ for (int i = 0; i < selectableReasoners.size(); i++) {
+ cb.addItem(config.getComponentManager().getComponentName(selectableReasoners.get(i)));
}
- ReasonerComponent rc = config.newReasoner(reasoner.get(cb.getSelectedIndex()));
+ ReasonerComponent rc = config.newReasoner(selectableReasoners.get(cb.getSelectedIndex()));
optionPanel = new OptionPanel(config, rc);
- choosePanel.add(setButton);
+// choosePanel.add(setButton);
cb.addActionListener(this);
add(choosePanel, BorderLayout.PAGE_START);
@@ -90,7 +87,7 @@
choosenClassIndex = cb.getSelectedIndex();
// setReasoner();
- updateInitButtonColor();
+// updateInitButtonColor();
}
public void actionPerformed(ActionEvent e) {
@@ -98,8 +95,9 @@
// choosenClassIndex = cb.getSelectedIndex();
if (choosenClassIndex != cb.getSelectedIndex()) {
choosenClassIndex = cb.getSelectedIndex();
-// config.setInitReasoner(false);
-// init();
+ // create a new knowledge source component
+ config.changeReasoner(selectableReasoners.get(choosenClassIndex));
+ updateOptionPanel();
}
// if (e.getSource() == setButton) {
@@ -151,24 +149,27 @@
/**
* updateAll
*/
+ /*
public void updateAll() {
updateComboBox();
updateOptionPanel();
updateInitButtonColor();
}
+ */
/**
* set ComboBox to selected class
*/
+ /*
public void updateComboBox() {
if (config.getReasoner() != null)
- for (int i = 0; i < reasoner.size(); i++)
+ for (int i = 0; i < selectableReasoners.size(); i++)
if (config.getReasoner().getClass().equals(
config.getComponentManager().getReasonerComponents().get(i))) {
cb.setSelectedIndex(i);
}
this.choosenClassIndex = cb.getSelectedIndex();
- }
+ }*/
/**
* update OptionPanel with new selection
@@ -177,13 +178,23 @@
optionPanel.update(config.getReasoner());
}
+ /* (non-Javadoc)
+ * @see org.dllearner.gui.ComponentPanel#panelActivated()
+ */
+ @Override
+ public void panelActivated() {
+ // TODO Auto-generated method stub
+
+ }
+
/**
* make init-button red if you have to click
*/
+ /*
public void updateInitButtonColor() {
if (!config.needsInitReasoner()) {
initButton.setForeground(Color.RED);
} else
initButton.setForeground(Color.BLACK);
- }
+ }*/
}
Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -21,6 +21,8 @@
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
@@ -62,11 +64,11 @@
private ConfigLoad configLoad = new ConfigLoad(config, this);
private ConfigSave configSave = new ConfigSave(config, this);
- private KnowledgeSourcePanel tab0;
- private ReasonerPanel tab1;
- private LearningProblemPanel tab2;
- private LearningAlgorithmPanel tab3;
- private RunPanel tab4;
+ protected KnowledgeSourcePanel tab0;
+ protected ReasonerPanel tab1;
+ protected LearningProblemPanel tab2;
+ protected LearningAlgorithmPanel tab3;
+ protected RunPanel tab4;
private JMenuBar menuBar = new JMenuBar();
private JMenu menuFile = new JMenu("File");
@@ -86,9 +88,20 @@
public StartGUI(File file) {
this.setTitle("DL-Learner GUI");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setLocationByPlatform(true);
+// this.setLocationByPlatform(true);
this.setSize(800, 600);
+ // center frame
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension size = getSize();
+ screenSize.height = screenSize.height/2;
+ screenSize.width = screenSize.width/2;
+ size.height = size.height/2;
+ size.width = size.width/2;
+ int y = screenSize.height - size.height;
+ int x = screenSize.width - size.width;
+ setLocation(x, y);
+
// set icon
if (this.getClass().getResource("icon.gif") != null)
setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(
@@ -143,6 +156,14 @@
}
updateTabs();
+
+ // send signals to panels
+ switch(index) {
+ case 0: tab0.panelActivated(); break;
+ case 1: tab1.panelActivated(); break;
+ case 2: tab2.panelActivated(); break;
+ case 3: tab3.panelActivated(); break;
+ }
// new tab => ask user to fill in values
statusPanel.setTabInitMessage();
Modified: trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -40,6 +40,9 @@
private String oldMessage;
+ // specifies whether the message is an exception
+ private boolean isException = false;
+
public StatusPanel() {
super();
add(statusLabel);
@@ -53,11 +56,18 @@
}
public void setStatus(String message) {
- updateMessage(message);
+ if(!isException) {
+ updateMessage(message);
+ }
}
+ public void setExceptionMessage(String message) {
+ updateMessage(message);
+ isException = true;
+ }
+
public void setTabInitMessage() {
-// updateMessage(tabInitText);
+ updateMessage(tabInitText);
}
public void extendMessage(String addition) {
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -225,7 +225,7 @@
gridbag.setConstraints(clearButton, constraints);
widgetPanel.add(clearButton, constraints);
} else {
- System.out.println("SPECIAL OPTION " + configOption.getName());
+// System.out.println("SPECIAL OPTION " + configOption.getName());
// SPECIAL LAYOUT
// ComboBoxList
@@ -245,6 +245,7 @@
System.out.println(ind.getName());
cBL.add(ind.getName());
}
+// cBL.add("Test");
}
// allowedConcepts or ignoredConcepts
if (configOption.getName().equalsIgnoreCase("allowedConcepts")
Modified: trunk/src/dl-learner/org/dllearner/test/ComponentTest.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/test/ComponentTest.java 2008-09-10 10:34:43 UTC (rev 1192)
+++ trunk/src/dl-learner/org/dllearner/test/ComponentTest.java 2008-09-10 12:17:50 UTC (rev 1193)
@@ -20,6 +20,7 @@
package org.dllearner.test;
import java.io.File;
+import java.net.MalformedURLException;
import java.util.Set;
import java.util.TreeSet;
@@ -47,8 +48,9 @@
/**
* @param args
* @throws ComponentInitException
+ * @throws MalformedURLException
*/
- public static void main(String[] args) throws ComponentInitException {
+ public static void main(String[] args) throws ComponentInitException, MalformedURLException {
// get singleton instance of component manager
ComponentManager cm = ComponentManager.getInstance();
@@ -56,11 +58,12 @@
// create knowledge source
KnowledgeSource source = cm.knowledgeSource(OWLFile.class);
String example = "examples/family/uncle.owl";
- cm.applyConfigEntry(source, "url", new File(example).toURI().toString());
+ cm.applyConfigEntry(source, "url", new File(example).toURI().toURL());
source.init();
- // create DIG reasoning service with standard settings
+ // create OWL API reasoning service with standard settings
ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, source);
+
// ReasoningService rs = cm.reasoningService(DIGReasonerNew.class, source);
reasoner.init();
ReasoningService rs = cm.reasoningService(reasoner);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-10 13:41:59
|
Revision: 1194
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1194&view=rev
Author: jenslehmann
Date: 2008-09-10 13:41:56 +0000 (Wed, 10 Sep 2008)
Log Message:
-----------
first partially working GUI version
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java
trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java
trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java
trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-09-10 12:17:50 UTC (rev 1193)
+++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-09-10 13:41:56 UTC (rev 1194)
@@ -26,6 +26,7 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.BorderLayout;
+import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.HashSet;
@@ -43,15 +44,21 @@
private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>();
private GridBagLayout gridbag = new GridBagLayout();
private GridBagConstraints constraints = new GridBagConstraints();
- private WidgetPanelStringSet panel;
+ private WidgetPanelStringSet widgetPanel;
/**
* Make a JPanel with GridBagLayout.
*/
public CheckBoxList(WidgetPanelStringSet panel) {
- this.panel = panel;
+ this.widgetPanel = panel;
checkBoxPanel.setLayout(gridbag);
- add(checkBoxPanel, BorderLayout.CENTER);
+
+ JScrollPane scrollPane = new JScrollPane(checkBoxPanel);
+// scrollPane.setSize(new Dimension(500,100));
+ scrollPane.setPreferredSize(new Dimension(500, 300));
+ scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ add(scrollPane, BorderLayout.CENTER);
+
constraints.anchor = GridBagConstraints.WEST;
}
@@ -74,7 +81,7 @@
*/
public Set<String> getSelections() {
Set<String> selectionSet = new HashSet<String>();
- selectionSet.clear(); // remove all
+// selectionSet.clear(); // remove all
for (int i = 0; i < list.size(); i++) {
if (list.get(i).isSelected())
selectionSet.add(list.get(i).getText());
@@ -123,6 +130,9 @@
}
public void actionPerformed(ActionEvent e) {
- panel.specialSet();
+ Set<String> value = getSelections();
+ widgetPanel.fireValueChanged(value);
+
+// widgetPanel.specialSet();
}
}
\ No newline at end of file
Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-09-10 12:17:50 UTC (rev 1193)
+++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-09-10 13:41:56 UTC (rev 1194)
@@ -20,11 +20,9 @@
*
*/
import java.awt.BorderLayout;
-import java.awt.Color;
import java.awt.event.ActionEvent;
import java.util.List;
-import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
@@ -48,8 +46,8 @@
private List<Class<? extends LearningAlgorithm>> selectableAlgorithms;
private JPanel choosePanel = new JPanel();
private OptionPanel optionPanel;
- private JPanel initPanel = new JPanel();
- private JButton initButton, autoInitButton;
+// private JPanel initPanel = new JPanel();
+// private JButton initButton, autoInitButton;
private String[] cbItems = {};
private JComboBox cb = new JComboBox(cbItems);
private int choosenClassIndex;
@@ -67,12 +65,12 @@
// at least it is not doing anything useful at the moment)
selectableAlgorithms.remove(DBpediaNavigationSuggestor.class);
- initButton = new JButton("Init LearingAlgorithm");
- initButton.addActionListener(this);
+// initButton = new JButton("Init LearingAlgorithm");
+// initButton.addActionListener(this);
// initPanel.add(initButton);
- initButton.setEnabled(true);
- autoInitButton = new JButton("Set");
- autoInitButton.addActionListener(this);
+// initButton.setEnabled(true);
+// autoInitButton = new JButton("Set");
+// autoInitButton.addActionListener(this);
// add into comboBox
for (int i = 0; i < selectableAlgorithms.size(); i++) {
@@ -80,7 +78,7 @@
}
choosePanel.add(cb);
- choosePanel.add(autoInitButton);
+// choosePanel.add(autoInitButton);
cb.addActionListener(this);
LearningAlgorithm la = null;
@@ -94,7 +92,7 @@
add(choosePanel, BorderLayout.PAGE_START);
add(optionPanel, BorderLayout.CENTER);
- add(initPanel, BorderLayout.PAGE_END);
+// add(initPanel, BorderLayout.PAGE_END);
choosenClassIndex = cb.getSelectedIndex();
// updateInitButtonColor();
@@ -104,6 +102,8 @@
// read selected Class
if (choosenClassIndex != cb.getSelectedIndex()) {
choosenClassIndex = cb.getSelectedIndex();
+ config.changeLearningAlgorithm(selectableAlgorithms.get(choosenClassIndex));
+ updateOptionPanel();
// config.setInitLearningAlgorithm(false);
// init();
}
@@ -152,15 +152,17 @@
/**
* updateAll
*/
+ /*
public void updateAll() {
updateComboBox();
updateOptionPanel();
updateInitButtonColor();
- }
+ }*/
/**
* set ComboBox to selected class
*/
+ /*
public void updateComboBox() {
if (config.getLearningAlgorithm() != null)
for (int i = 0; i < selectableAlgorithms.size(); i++)
@@ -169,7 +171,7 @@
cb.setSelectedIndex(i);
}
this.choosenClassIndex = cb.getSelectedIndex();
- }
+ }*/
/**
* update OptionPanel with new selection
@@ -181,12 +183,13 @@
/**
* make init-button red if you have to click
*/
+ /*
public void updateInitButtonColor() {
if (!config.needsInitLearningAlgorithm()) {
initButton.setForeground(Color.RED);
} else
initButton.setForeground(Color.BLACK);
- }
+ }*/
/* (non-Javadoc)
* @see org.dllearner.gui.ComponentPanel#panelActivated()
Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-09-10 12:17:50 UTC (rev 1193)
+++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-09-10 13:41:56 UTC (rev 1194)
@@ -28,7 +28,7 @@
import javax.swing.JPanel;
import org.dllearner.core.ReasonerComponent;
-import org.dllearner.reasoning.OWLAPIReasoner;
+import org.dllearner.reasoning.FastInstanceChecker;
/**
* Panel for configuring reasoner.
@@ -58,8 +58,8 @@
// this.startGUI = startGUI;
selectableReasoners = config.getComponentManager().getReasonerComponents();
// to set a default reasoner, we move it to the beginning of the list
- selectableReasoners.remove(OWLAPIReasoner.class);
- selectableReasoners.add(0, OWLAPIReasoner.class);
+ selectableReasoners.remove(FastInstanceChecker.class);
+ selectableReasoners.add(0, FastInstanceChecker.class);
initButton = new JButton("Init Reasoner");
initButton.addActionListener(this);
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-10 12:17:50 UTC (rev 1193)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-10 13:41:56 UTC (rev 1194)
@@ -115,12 +115,13 @@
/**
* Use this, to set entry for layout 2.
*/
+ /*
public void specialSet() {
if (isSpecial()) {
this.value = cBL.getSelections();
setEntry();
}
- }
+ }*/
public void setEntry() {
StringSetConfigOption specialOption;
@@ -239,13 +240,13 @@
// fill lists
Set<Individual> individualsSet = config.getReasoningService()
.getIndividuals();
- LinkedList<Individual> individuals = new LinkedList<Individual>(
- individualsSet);
- for (Individual ind : individuals) {
- System.out.println(ind.getName());
- cBL.add(ind.getName());
+ if(individualsSet != null) {
+ LinkedList<Individual> individuals = new LinkedList<Individual>(
+ individualsSet);
+ for (Individual ind : individuals) {
+ cBL.add(ind.getName());
+ }
}
-// cBL.add("Test");
}
// allowedConcepts or ignoredConcepts
if (configOption.getName().equalsIgnoreCase("allowedConcepts")
@@ -253,10 +254,12 @@
// fill lists
Set<NamedClass> atomicsSet = config.getReasoningService()
.getNamedClasses();
- LinkedList<NamedClass> atomicConcepts = new LinkedList<NamedClass>(
- atomicsSet);
- for (NamedClass ind : atomicConcepts)
- cBL.add(ind.getName());
+ if(atomicsSet != null) {
+ LinkedList<NamedClass> atomicConcepts = new LinkedList<NamedClass>(
+ atomicsSet);
+ for (NamedClass ind : atomicConcepts)
+ cBL.add(ind.getName());
+ }
}
// allowedRoles or ignoredRoles
if (configOption.getName().equalsIgnoreCase("allowedRoles")
@@ -264,10 +267,12 @@
// fill lists
Set<ObjectProperty> atomicsSet = config.getReasoningService()
.getObjectProperties();
- LinkedList<ObjectProperty> atomicRoles = new LinkedList<ObjectProperty>(
- atomicsSet);
- for (ObjectProperty ind : atomicRoles)
- cBL.add(ind.getName());
+ if(atomicsSet != null) {
+ LinkedList<ObjectProperty> atomicRoles = new LinkedList<ObjectProperty>(
+ atomicsSet);
+ for (ObjectProperty ind : atomicRoles)
+ cBL.add(ind.getName());
+ }
}
// set selections
if (value != null)
Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-10 12:17:50 UTC (rev 1193)
+++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-10 13:41:56 UTC (rev 1194)
@@ -171,6 +171,17 @@
@Override
public void init() throws ComponentInitException {
+ // reset variables (otherwise subsequent initialisation with
+ // different knowledge sources will merge both)
+ atomicConcepts = new TreeSet<NamedClass>(conceptComparator);
+ atomicRoles = new TreeSet<ObjectProperty>(roleComparator);
+ datatypeProperties = new TreeSet<DatatypeProperty>();
+ booleanDatatypeProperties = new TreeSet<DatatypeProperty>();
+ doubleDatatypeProperties = new TreeSet<DatatypeProperty>();
+ intDatatypeProperties = new TreeSet<DatatypeProperty>();
+ individuals = new TreeSet<Individual>();
+
+ // create OWL API ontology manager
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
// it is a bit cumbersome to obtain all classes, because there
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Jen...@us...> - 2008-09-11 09:32:32
|
Revision: 1196
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1196&view=rev
Author: JensLehmann
Date: 2008-09-11 09:32:28 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
- uncommented natural language conversion in EvaluatedDescription - it only works for DBpedia!!
- added URL option to web service interface
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java
trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java
trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java
trunk/src/dl-learner/org/dllearner/server/jaxws/ComponentInitExceptionBean.java
trunk/src/dl-learner/org/dllearner/server/jaxws/ConfigOptionTypeExceptionBean.java
trunk/src/dl-learner/org/dllearner/server/jaxws/LearningProblemUnsupportedExceptionBean.java
trunk/src/dl-learner/org/dllearner/server/jaxws/ParseExceptionBean.java
trunk/src/dl-learner/org/dllearner/server/jaxws/SparqlQueryExceptionBean.java
trunk/src/dl-learner/org/dllearner/server/jaxws/UnknownComponentExceptionBean.java
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/server/jaxws/MalformedURLExceptionBean.java
Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-10 13:46:37 UTC (rev 1195)
+++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -164,7 +164,9 @@
}
public String getNaturalDescription(){
- return NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(description);
+ // TODO only works for DBpedia !! (no DBpedia SPARQL queries should be made to convert the description)
+// return NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(description);
+ return "";
}
/**
Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-09-10 13:46:37 UTC (rev 1195)
+++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -19,6 +19,8 @@
*/
package org.dllearner.server;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
@@ -217,15 +219,16 @@
* Adds a knowledge source.
*
* @return An identifier for the component.
+ * @throws MalformedURLException
*/
@WebMethod
- public int addKnowledgeSource(int id, String component, String url) throws ClientNotKnownException, UnknownComponentException {
+ public int addKnowledgeSource(int id, String component, String url) throws ClientNotKnownException, UnknownComponentException, MalformedURLException {
ClientState state = getState(id);
Class<? extends KnowledgeSource> ksClass = knowledgeSourceMapping.get(component);
if(ksClass == null)
throw new UnknownComponentException(component);
KnowledgeSource ks = cm.knowledgeSource(ksClass);
- cm.applyConfigEntry(ks, "url", url);
+ cm.applyConfigEntry(ks, "url", new URL(url));
return state.addKnowledgeSource(ks);
}
@@ -435,6 +438,13 @@
}
@WebMethod
+ public void applyConfigEntryURL(int sessionID, int componentID, String optionName, String value) throws ClientNotKnownException, UnknownComponentException, MalformedURLException {
+ // URLs are passed as String and then converted
+ URL url = new URL(value);
+ applyConfigEntry(sessionID, componentID,optionName,url);
+ }
+
+ @WebMethod
public void applyConfigEntryStringArray(int sessionID, int componentID, String optionName, String[] value) throws ClientNotKnownException, UnknownComponentException {
Set<String> stringSet = new TreeSet<String>(Arrays.asList(value));
applyConfigEntry(sessionID, componentID,optionName,stringSet);
@@ -462,6 +472,12 @@
}
@WebMethod
+ public String getConfigOptionValueURL(int sessionID, int componentID, String optionName) throws ClientNotKnownException, UnknownComponentException, ConfigOptionTypeException {
+ URL url = getConfigOptionValue(sessionID, componentID, optionName, URL.class);
+ return url.toString();
+ }
+
+ @WebMethod
public Double getConfigOptionValueDouble(int sessionID, int componentID, String optionName) throws ClientNotKnownException, UnknownComponentException, ConfigOptionTypeException {
return getConfigOptionValue(sessionID, componentID, optionName, Double.class);
}
Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java 2008-09-10 13:46:37 UTC (rev 1195)
+++ trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -8,9 +8,9 @@
/**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0_02-b08-fcs
- * Generated source version: 2.0_02
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.1
+ * Generated source version: 2.1.1
*
*/
@XmlRootElement(name = "ClientNotKnownException", namespace = "http://server.dllearner.org/")
Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/ComponentInitExceptionBean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/jaxws/ComponentInitExceptionBean.java 2008-09-10 13:46:37 UTC (rev 1195)
+++ trunk/src/dl-learner/org/dllearner/server/jaxws/ComponentInitExceptionBean.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -8,9 +8,9 @@
/**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0_02-b08-fcs
- * Generated source version: 2.0_02
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.1
+ * Generated source version: 2.1.1
*
*/
@XmlRootElement(name = "ComponentInitException", namespace = "http://server.dllearner.org/")
Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/ConfigOptionTypeExceptionBean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/jaxws/ConfigOptionTypeExceptionBean.java 2008-09-10 13:46:37 UTC (rev 1195)
+++ trunk/src/dl-learner/org/dllearner/server/jaxws/ConfigOptionTypeExceptionBean.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -8,9 +8,9 @@
/**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0_02-b08-fcs
- * Generated source version: 2.0_02
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.1
+ * Generated source version: 2.1.1
*
*/
@XmlRootElement(name = "ConfigOptionTypeException", namespace = "http://server.dllearner.org/")
Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/LearningProblemUnsupportedExceptionBean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/jaxws/LearningProblemUnsupportedExceptionBean.java 2008-09-10 13:46:37 UTC (rev 1195)
+++ trunk/src/dl-learner/org/dllearner/server/jaxws/LearningProblemUnsupportedExceptionBean.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -8,9 +8,9 @@
/**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0_02-b08-fcs
- * Generated source version: 2.0_02
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.1
+ * Generated source version: 2.1.1
*
*/
@XmlRootElement(name = "LearningProblemUnsupportedException", namespace = "http://server.dllearner.org/")
Added: trunk/src/dl-learner/org/dllearner/server/jaxws/MalformedURLExceptionBean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/jaxws/MalformedURLExceptionBean.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/server/jaxws/MalformedURLExceptionBean.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -0,0 +1,41 @@
+
+package org.dllearner.server.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.1
+ * Generated source version: 2.1.1
+ *
+ */
+@XmlRootElement(name = "MalformedURLException", namespace = "http://server.dllearner.org/")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "MalformedURLException", namespace = "http://server.dllearner.org/")
+public class MalformedURLExceptionBean {
+
+ private String message;
+
+ /**
+ *
+ * @return
+ * returns String
+ */
+ public String getMessage() {
+ return this.message;
+ }
+
+ /**
+ *
+ * @param message
+ * the value for the message property
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/ParseExceptionBean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/jaxws/ParseExceptionBean.java 2008-09-10 13:46:37 UTC (rev 1195)
+++ trunk/src/dl-learner/org/dllearner/server/jaxws/ParseExceptionBean.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -8,9 +8,9 @@
/**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0_02-b08-fcs
- * Generated source version: 2.0_02
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.1
+ * Generated source version: 2.1.1
*
*/
@XmlRootElement(name = "ParseException", namespace = "http://server.dllearner.org/")
Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/SparqlQueryExceptionBean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/jaxws/SparqlQueryExceptionBean.java 2008-09-10 13:46:37 UTC (rev 1195)
+++ trunk/src/dl-learner/org/dllearner/server/jaxws/SparqlQueryExceptionBean.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -8,9 +8,9 @@
/**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0_02-b08-fcs
- * Generated source version: 2.0_02
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.1
+ * Generated source version: 2.1.1
*
*/
@XmlRootElement(name = "SparqlQueryException", namespace = "http://server.dllearner.org/")
Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/UnknownComponentExceptionBean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/jaxws/UnknownComponentExceptionBean.java 2008-09-10 13:46:37 UTC (rev 1195)
+++ trunk/src/dl-learner/org/dllearner/server/jaxws/UnknownComponentExceptionBean.java 2008-09-11 09:32:28 UTC (rev 1196)
@@ -8,9 +8,9 @@
/**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0_02-b08-fcs
- * Generated source version: 2.0_02
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.1
+ * Generated source version: 2.1.1
*
*/
@XmlRootElement(name = "UnknownComponentException", namespace = "http://server.dllearner.org/")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ku...@us...> - 2008-09-11 17:13:56
|
Revision: 1197
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1197&view=rev
Author: kurzum
Date: 2008-09-11 17:13:52 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
fxed bug, integrated url option inti sparqlknowledgesource
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java
trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java
trunk/src/dl-learner/org/dllearner/test/TestGetExampleBug.java
trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-11 09:32:28 UTC (rev 1196)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-11 17:13:52 UTC (rev 1197)
@@ -84,7 +84,7 @@
* @param instances relevant instances e.g. positive and negative examples in a learning problem
* @return a component ready for initialization SparqlKnowledgeSource
**/
-public static SparqlKnowledgeSource getSparqlKnowledgeSource(String url, Set<String> instances) {
+public static SparqlKnowledgeSource getSparqlKnowledgeSource(URL url, Set<String> instances) {
return SparqlKnowledgeSourceConfigurator.getSparqlKnowledgeSource(url, instances);
}
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-11 09:32:28 UTC (rev 1196)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-11 17:13:52 UTC (rev 1197)
@@ -20,6 +20,7 @@
package org.dllearner.core.configurators;
+import java.net.URL;
import java.util.List;
import java.util.Set;
import org.dllearner.core.ComponentManager;
@@ -49,7 +50,7 @@
* @param instances relevant instances e.g. positive and negative examples in a learning problem
* @return SparqlKnowledgeSource
**/
-public static SparqlKnowledgeSource getSparqlKnowledgeSource(String url, Set<String> instances) {
+public static SparqlKnowledgeSource getSparqlKnowledgeSource(URL url, Set<String> instances) {
SparqlKnowledgeSource component = ComponentManager.getInstance().knowledgeSource(SparqlKnowledgeSource.class);
ComponentManager.getInstance().applyConfigEntry(component, "url", url);
ComponentManager.getInstance().applyConfigEntry(component, "instances", instances);
@@ -60,10 +61,10 @@
* url URL of SPARQL Endpoint.
* mandatory: true| reinit necessary: true
* default value: null
-* @return String
+* @return URL
**/
-public String getUrl() {
-return (String) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "url") ;
+public URL getUrl() {
+return (URL) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "url") ;
}
/**
* cacheDir dir of cache.
@@ -276,7 +277,7 @@
* mandatory: true| reinit necessary: true
* default value: null
**/
-public void setUrl(String url) {
+public void setUrl(URL url) {
ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "url", url);
reinitNecessary = true;
}
Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-11 09:32:28 UTC (rev 1196)
+++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-11 17:13:52 UTC (rev 1197)
@@ -21,7 +21,6 @@
import java.io.File;
import java.io.FileWriter;
-import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
@@ -42,6 +41,7 @@
import org.dllearner.core.config.StringConfigOption;
import org.dllearner.core.config.StringSetConfigOption;
import org.dllearner.core.config.StringTupleListConfigOption;
+import org.dllearner.core.config.URLConfigOption;
import org.dllearner.core.configurators.SparqlKnowledgeSourceConfigurator;
import org.dllearner.core.owl.KB;
import org.dllearner.kb.aquisitors.SparqlTupleAquisitor;
@@ -132,7 +132,7 @@
*/
public static Collection<ConfigOption<?>> createConfigOptions() {
Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>();
- options.add(new StringConfigOption("url", "URL of SPARQL Endpoint",
+ options.add(new URLConfigOption("url", "URL of SPARQL Endpoint",
null, true, true));
options.add(new StringConfigOption("cacheDir", "dir of cache", "cache",
false, true));
@@ -226,14 +226,9 @@
SimpleClock totalTime = new SimpleClock();
SimpleClock extractionTime = new SimpleClock();
- try {
- url = new URL(configurator.getUrl());
- } catch (MalformedURLException e) {
- logger.error(e.getMessage());
- //throw new InvalidConfigOptionValueException(entry.getOption(),
- // entry.getValue(), "malformed URL " + s);
- }
-
+ logger.trace(getURL());
+ logger.trace(getSparqlEndpoint());
+ logger.trace(configurator.getInstances());
Manager m = new Manager();
// get Options for Manipulator
@@ -342,12 +337,22 @@
* @return the URL of the used sparql endpoint
*/
public URL getURL() {
- if(url == null && endpoint!=null){
+ if(endpoint == null){
+ if(url==null){
+ if(configurator.getPredefinedEndpoint() == null){
+ url = configurator.getUrl();
+ return url;
+ }else{
+ return getSparqlEndpoint().getURL();
+ }
+
+ }else{
+ return url;
+ }
+ }else {
return endpoint.getURL();
}
- else{
- return url;
- }
+
}
public String[] getOntArray() {
@@ -362,7 +367,7 @@
public SparqlEndpoint getSparqlEndpoint(){
if(endpoint==null) {
if (configurator.getPredefinedEndpoint() == null) {
- endpoint = new SparqlEndpoint(url, new LinkedList<String>(
+ endpoint = new SparqlEndpoint(getURL(), new LinkedList<String>(
configurator.getDefaultGraphURIs()),
new LinkedList<String>(configurator.getNamedGraphURIs()));
} else {
Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-09-11 09:32:28 UTC (rev 1196)
+++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-09-11 17:13:52 UTC (rev 1197)
@@ -37,6 +37,7 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
+import org.apache.log4j.Logger;
import org.dllearner.Info;
import org.dllearner.algorithms.BruteForceLearner;
import org.dllearner.algorithms.DBpediaNavigationSuggestor;
@@ -86,6 +87,10 @@
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class DLLearnerWS {
+ @SuppressWarnings("unused")
+ private static Logger logger = Logger
+ .getLogger(DLLearnerWS.class);
+
private Map<Integer, ClientState> clients = new TreeMap<Integer,ClientState>();
private Random rand=new Random();
private static ComponentManager cm = ComponentManager.getInstance();
@@ -330,7 +335,11 @@
String json = "{";
int count = 1;
for(EvaluatedDescription description : descriptions) {
+ //FIXME this is not a general method, but specific to dbpedia
+ // the mehtod name schould mention, that the return String is in JSON
+ // also it throws errors
json += "\"solution" + count + "\" : " + description.asJSON();
+
count++;
}
return json;
Modified: trunk/src/dl-learner/org/dllearner/test/TestGetExampleBug.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/test/TestGetExampleBug.java 2008-09-11 09:32:28 UTC (rev 1196)
+++ trunk/src/dl-learner/org/dllearner/test/TestGetExampleBug.java 2008-09-11 17:13:52 UTC (rev 1197)
@@ -27,12 +27,18 @@
//Logger.getLogger(SparqlQuery.class).setLevel(Level.DEBUG);
try {
- String OntowikiUrl="http://localhost/ontowiki-0.8.5/service/sparql";
+ String OntowikiUrl="http://localhost/ontowiki/service/sparql";
- String posExamples = "http://3ba.se/conferences/FMILeipzig";
+
+
SortedSet<String> positiveSet = new TreeSet<String>();
- positiveSet.add(posExamples);
- SPARQLTasks st = new SPARQLTasks(new SparqlEndpoint(new URL(OntowikiUrl)));
+ positiveSet.add("http://3ba.se/conferences/JensLehmann");
+ positiveSet.add("http://3ba.se/conferences/MuhammadAhtishamAslam");
+ positiveSet.add("http://3ba.se/conferences/SebastianDietzold");
+ positiveSet.add("http://3ba.se/conferences/ThomasRiechert");
+ //positiveSet.add("http://3ba.se/conferences/FMILeipzig");
+
+ SPARQLTasks st = new SPARQLTasks(new SparqlEndpoint(new URL(OntowikiUrl)));
AutomaticNegativeExampleFinderSPARQL ane =
new AutomaticNegativeExampleFinderSPARQL(positiveSet,st);
SortedSet<String> negExamples = new TreeSet<String>();
Modified: trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java 2008-09-11 09:32:28 UTC (rev 1196)
+++ trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java 2008-09-11 17:13:52 UTC (rev 1197)
@@ -185,6 +185,7 @@
try{
classes.addAll(sparqltasks.getClassesForInstance(instance, sparqlResultLimit));
}catch (Exception e) {
+ e.printStackTrace();
logger.warn("ignoring SPARQLQuery failure, see log/sparql.txt");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-12 10:52:19
|
Revision: 1199
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1199&view=rev
Author: jenslehmann
Date: 2008-09-12 10:52:14 +0000 (Fri, 12 Sep 2008)
Log Message:
-----------
fixed bug related to URL config option and commandline interface
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/cli/Start.java
trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java
trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java
trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java
trunk/src/dl-learner/org/dllearner/gui/Config.java
trunk/src/dl-learner/org/dllearner/gui/InitWorker.java
trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java
trunk/src/dl-learner/org/dllearner/kb/KBFile.java
trunk/src/dl-learner/org/dllearner/kb/OWLFile.java
Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -198,7 +198,7 @@
// configuration option "url"), so this may need to be changed in
// the
// future
- cm.applyConfigEntry(ks, "url", entry.getKey().toString());
+ cm.applyConfigEntry(ks, "url", entry.getKey());
sources.add(ks);
configureComponent(cm, ks, componentPrefixMapping, parser);
Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -141,6 +141,8 @@
}
/**
+ * TODO Method should be removed and a mapping table in ConfigJavaGenerator
+ * created instead.
* gets java imports
* @return
*/
Modified: trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -31,6 +31,8 @@
*/
public class URLConfigOption extends ConfigOption<URL> {
+ private boolean refersToFile = false;
+
public URLConfigOption(String name, String description) {
super(name, description);
}
@@ -44,6 +46,24 @@
super(name, description, defaultValue, mandatory, requiresInit);
}
+ /**
+ * Returns whether the URI can refer to a file or not, e.g. the
+ * URL of an OWL knowledge source does refer to a file whereas
+ * the URL of a SPARQL endpoint cannot refer to a file. The distinction
+ * can be useful in GUIs (e.g. they may offer to choose a local file).
+ * @return the refersToFile
+ */
+ public boolean refersToFile() {
+ return refersToFile;
+ }
+
+ /**
+ * @param refersToFile Set whether this option can refer to a file.
+ */
+ public void setRefersToFile(boolean refersToFile) {
+ this.refersToFile = refersToFile;
+ }
+
/* (non-Javadoc)
* @see org.dllearner.core.config.ConfigOption#checkType(java.lang.Object)
*/
Modified: trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -21,8 +21,6 @@
/**
* Class displaying a component (and its options).
*
- * @param <T> The type of the panel (KnowledgeSource, ReasonerComponent,
- * LearningProblem, LearningAlgorithm).
* @author Jens Lehmann
*
*/
Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -20,6 +20,10 @@
package org.dllearner.gui;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
import org.dllearner.core.Component;
import org.dllearner.core.ComponentManager;
import org.dllearner.core.KnowledgeSource;
@@ -47,7 +51,7 @@
public class Config {
private ComponentManager cm = ComponentManager.getInstance();
-// private static Logger logger = Logger.getLogger(Config.class);
+ private static Logger logger = Logger.getLogger(Config.class);
// the components currently active
private KnowledgeSource source;
@@ -425,9 +429,23 @@
// algorithmRunStopTime = null;
// }
+
+
// init the specified component and record which ones where initialised
- public void init(int tabIndex) {
+ public void init(List<Integer> tabIndex) {
+ List<Component> components = new LinkedList<Component>();
+ for(int i : tabIndex) {
+ switch(i) {
+ case 0: components.add(source); needsInit[i] = false; break;
+ case 1: components.add(reasoner); needsInit[i] = false; break;
+ case 2: components.add(lp); needsInit[i] = false; break;
+ case 3: components.add(la); needsInit[i] = false; break;
+ }
+ }
+ InitWorker worker = new InitWorker (components, gui);
+ worker.execute();
+ /*
// try {
if(tabIndex==0) {
InitWorker worker = new InitWorker(source, gui);
@@ -451,9 +469,14 @@
// // TODO display message in status bar
// e.printStackTrace();
// }
+ */
- needsInit[tabIndex] = false;
- System.out.println("component " + tabIndex + " initialised.");
+ if(tabIndex.size() == 1) {
+ logger.info("Component " + tabIndex.get(0) + " initialised.");
+ } else if(tabIndex.size() > 1) {
+ logger.info("Components " + tabIndex + " initialised.");
+ }
+
}
// applies a configuration option - used as delegate method, which invalidates components
Modified: trunk/src/dl-learner/org/dllearner/gui/InitWorker.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/InitWorker.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/gui/InitWorker.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -44,12 +44,12 @@
*/
public class InitWorker extends SwingWorker<Boolean, Boolean> {
- private Component component;
+ private List<Component> components;
private StartGUI gui;
- private boolean timeIntensive = true;
+ private boolean timeIntensive;
- public InitWorker(Component component, StartGUI gui) {
- this.component = component;
+ public InitWorker(List<Component> components, StartGUI gui) {
+ this.components = components;
this.gui = gui;
// create a list of components, which do need virtually
@@ -59,9 +59,14 @@
nonTimeIntensiveComponents.add(OWLFile.class);
nonTimeIntensiveComponents.add(KBFile.class);
- if(nonTimeIntensiveComponents.contains(component.getClass())) {
- timeIntensive = false;
+ // we check if any of the components is time-intensive
+ timeIntensive = false;
+ for(Component component : components) {
+ if(!nonTimeIntensiveComponents.contains(component.getClass())) {
+ timeIntensive = true;
+ }
}
+
}
@Override
@@ -91,7 +96,9 @@
}
try {
- component.init();
+ for(Component component : components) {
+ component.init();
+ }
} catch (ComponentInitException e) {
gui.getStatusPanel().setExceptionMessage(e.getMessage());
e.printStackTrace();
@@ -107,7 +114,7 @@
// when the reasoner has been initialised, we need to update
// the option panel (such that the user can see the existing
// examples, classes etc.)
- if(component instanceof ReasonerComponent) {
+ if(components instanceof ReasonerComponent) {
gui.panels[2].updateOptionPanel();
gui.panels[3].updateOptionPanel();
}
Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -179,14 +179,19 @@
int index = tabPane.getSelectedIndex();
// System.out.println(index);
+ // a list of all components (0 = knowledge source,
+ // 1 = reasoner etc.) which have to be initialised;
+ // the user can init several components at once
+ List<Integer> componentsToInit = new LinkedList<Integer>();
// check whether we need to initialise components
if (index != 0 && config.tabNeedsInit(index - 1)) {
for (int i = 0; i < index; i++) {
if(config.tabNeedsInit(i)) {
- config.init(i);
+ componentsToInit.add(i);
}
}
}
+ config.init(componentsToInit);
updateTabs();
@@ -227,7 +232,7 @@
Logger logger = Logger.getRootLogger();
logger.removeAllAppenders();
logger.addAppender(consoleAppender);
- logger.setLevel(Level.DEBUG);
+ logger.setLevel(Level.TRACE);
File file = null;
if (args.length > 0)
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -243,8 +243,14 @@
if(individualsSet != null) {
LinkedList<Individual> individuals = new LinkedList<Individual>(
individualsSet);
+// int i = 0;
for (Individual ind : individuals) {
cBL.add(ind.getName());
+// i++;
+ // do not display more than 200 examples (freezes GUI)
+// if(i == 200) {
+// break;
+// }
}
}
}
Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -33,7 +33,6 @@
import org.dllearner.core.config.ConfigEntry;
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.InvalidConfigOptionValueException;
-import org.dllearner.core.config.StringConfigOption;
import org.dllearner.core.config.URLConfigOption;
import org.dllearner.core.configurators.KBFileConfigurator;
import org.dllearner.core.owl.KB;
@@ -63,7 +62,7 @@
.getLogger(KBFile.class);
// private File file;
- private URL url;
+// private URL url;
private KB kb;
private KBFileConfigurator configurator;
@@ -98,8 +97,10 @@
public static Collection<ConfigOption<?>> createConfigOptions() {
Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>();
- options.add(new StringConfigOption("filename", "pointer to the KB file on local file system",null, true, true));
- options.add(new URLConfigOption("url", "URL pointer to the KB file",null, false, true));
+// 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;
}
@@ -118,25 +119,26 @@
public void init() throws ComponentInitException {
//URL url = null;
try {
- String filename = configurator.getFilename();
- String urlString = configurator.getUrl().toString();
- if(filename!=null){
- url = new File(filename).toURI().toURL();
- }else if(urlString!=null){
- url = new URL(urlString);
- }
+// String filename = configurator.getFilename();
+// String urlString = configurator.getUrl().toString();
+// if(filename!=null){
+// url = new File(filename).toURI().toURL();
+// }else if(urlString!=null){
+// url = new URL(urlString);
+// }
+//
+// if(url != null) {
+// kb = KBParser.parseKBFile(url);
+// }
+ kb = KBParser.parseKBFile(configurator.getUrl());
- if(url != null) {
- kb = KBParser.parseKBFile(url);
- }
-
} catch (MalformedURLException e) {
logger.error(e.getMessage());
//throw new InvalidConfigOptionValueException(entry.getOption(),entry.getValue());
} catch (IOException e) {
- throw new ComponentInitException("KB file " + url + " could not be read.", e);
+ throw new ComponentInitException("KB file " + configurator.getUrl() + " could not be read.", e);
} catch (ParseException e) {
- throw new ComponentInitException("KB file " + url + " could not be parsed correctly.", e);
+ throw new ComponentInitException("KB file " + configurator.getUrl() + " could not be parsed correctly.", e);
}
}
@@ -206,7 +208,7 @@
}
public URL getURL() {
- return url;
+ return configurator.getUrl();
}
@Override
Modified: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-12 09:52:17 UTC (rev 1198)
+++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-12 10:52:14 UTC (rev 1199)
@@ -65,7 +65,9 @@
public static Collection<ConfigOption<?>> createConfigOptions() {
Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>();
- options.add(new URLConfigOption("url", "URL pointing to the OWL file", null, true, true));
+ URLConfigOption urlOption = new URLConfigOption("url", "URL pointing to the OWL file", null, true, true);
+ urlOption.setRefersToFile(true);
+ options.add(urlOption);
return options;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-12 12:35:13
|
Revision: 1200
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1200&view=rev
Author: jenslehmann
Date: 2008-09-12 12:35:09 +0000 (Fri, 12 Sep 2008)
Log Message:
-----------
added change methods to components such that underlying components can be replaced
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java
trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java
trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java
trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java
trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java
trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java
trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java
trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java
trunk/src/dl-learner/org/dllearner/core/LearningProblem.java
trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java
trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java
trunk/src/dl-learner/org/dllearner/gui/Config.java
trunk/src/dl-learner/org/dllearner/gui/InitWorker.java
trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java
trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java
trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java
trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -83,6 +83,7 @@
private Map<Integer,List<Description>> generatedDefinitions = new HashMap<Integer,List<Description>>();
public BruteForceLearner(LearningProblem learningProblem, ReasoningService rs) {
+ super(learningProblem, rs);
this.learningProblem = learningProblem;
this.rs = rs;
this.configurator = new BruteForceLearnerConfigurator(this);
Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -67,6 +67,7 @@
private static String defaultSearchTreeFile = "log/searchTree.txt";
public DBpediaNavigationSuggestor(LearningProblem learningProblem, ReasoningService rs) {
+ super(learningProblem, rs);
// this.rs=rs;
this.configurator = new DBpediaNavigationSuggestorConfigurator(this);
try{
@@ -96,10 +97,12 @@
}
public DBpediaNavigationSuggestor(PosOnlyDefinitionLP learningProblem, ReasoningService rs) {
+ super(learningProblem, rs);
System.out.println("test1");
}
public DBpediaNavigationSuggestor(PosNegDefinitionLP learningProblem, ReasoningService rs) {
+ super(learningProblem, rs);
System.out.println("test2");
}
Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -56,6 +56,7 @@
private static Logger logger = Logger.getLogger(RandomGuesser.class);
public RandomGuesser(LearningProblem learningProblem, ReasoningService rs) {
+ super(learningProblem, rs);
this.learningProblem = learningProblem;
this.rs = rs;
this.configurator = new RandomGuesserConfigurator(this);
Modified: trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -56,7 +56,7 @@
private Set<Description> simpleSuggestions;
public SimpleSuggestionLearningAlgorithm() {
- // this.learningProblem = learningProblem;
+ super(null, null);
this.configurator = new SimpleSuggestionLearningAlgorithmConfigurator(this);
}
Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -131,12 +131,9 @@
private Score bestScore;
private Description bestConcept;
- private PosNegLP learningProblem;
-
// private GeneticRefinementOperator psi;
private Psi psi;
- private ReasoningService rs;
/**
* Creates an algorithm object. By default a steady state algorithm with
@@ -146,8 +143,7 @@
*
*/
public GP(PosNegLP learningProblem, ReasoningService rs) {
- this.learningProblem = learningProblem;
- this.rs = rs;
+ super(learningProblem, rs);
this.configurator = new GPConfigurator(this);
}
@@ -276,14 +272,14 @@
*/
@Override
public void init() {
- rs.prepareSubsumptionHierarchy();
- rs.prepareRoleHierarchy();
+ reasoningService.prepareSubsumptionHierarchy();
+ reasoningService.prepareRoleHierarchy();
}
@Override
public void start() {
// falls refinement-Wahrscheinlichkeit größer 0, dann erzeuge psi
- psi = new Psi(learningProblem, rs);
+ psi = new Psi((PosNegLP)learningProblem, reasoningService);
System.out.println();
System.out.println("Starting Genetic Programming Learner");
@@ -446,11 +442,11 @@
i++;
// mutation
} else if(rand >= crossoverBoundary && rand < mutationBoundary) {
- newIndividuals[i] = GPUtilities.mutation(learningProblem, rs, individuals[selectedIndividuals[i]]);
+ newIndividuals[i] = GPUtilities.mutation(learningProblem, reasoningService, individuals[selectedIndividuals[i]]);
// hill climbing
} else if(rand >= mutationBoundary && rand < hillClimbingBoundary) {
// System.out.println("hill climbing");
- newIndividuals[i] = GPUtilities.hillClimbing(learningProblem, rs, individuals[selectedIndividuals[i]]);
+ newIndividuals[i] = GPUtilities.hillClimbing(learningProblem, reasoningService, individuals[selectedIndividuals[i]]);
// refinement operator
} else if(rand >= hillClimbingBoundary && rand < refinementBoundary) {
newIndividuals[i] = psi.applyOperator(individuals[selectedIndividuals[i]]);
@@ -624,9 +620,9 @@
// int depth = rand.nextInt(initMaxDepth-initMinDepth)+initMinDepth;
if(grow)
- individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem, rs, depth, adc);
+ individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem, reasoningService, depth, adc);
else
- individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, rs, depth, adc);
+ individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, reasoningService, depth, adc);
}
/*
Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -92,11 +92,7 @@
private ExampleBasedROLearner algorithm;
private static Logger logger = Logger
.getLogger(ExampleBasedROLearner.class);
- private String logLevel = CommonConfigOptions.logLevelDefault;
-
- // learning problem to solve and background knowledge
- private ReasoningService rs;
- private LearningProblem learningProblem;
+ private String logLevel = CommonConfigOptions.logLevelDefault;
// configuration options
private boolean writeSearchTree;
@@ -150,15 +146,13 @@
// soll später einen Operator und eine Heuristik entgegennehmen
// public ROLearner(LearningProblem learningProblem, LearningProblem learningProblem2) {
- public ExampleBasedROLComponent(PosNegLP learningProblem, ReasoningService rs) {
- this.learningProblem = learningProblem;
- this.rs = rs;
+ public ExampleBasedROLComponent(PosNegLP learningProblem, ReasoningService reasoningService) {
+ super(learningProblem, reasoningService);
this.configurator = new ExampleBasedROLComponentConfigurator(this);
}
- public ExampleBasedROLComponent(PosOnlyDefinitionLP learningProblem, ReasoningService rs) {
- this.learningProblem = learningProblem;
- this.rs = rs;
+ public ExampleBasedROLComponent(PosOnlyDefinitionLP learningProblem, ReasoningService reasoningService) {
+ super(learningProblem, reasoningService);
this.configurator = new ExampleBasedROLComponentConfigurator(this);
}
@@ -290,7 +284,7 @@
public void init() throws ComponentInitException {
// exit with a ComponentInitException if the reasoner is unsupported for this learning algorithm
- if(rs.getReasonerType() == ReasonerType.DIG) {
+ if(reasoningService.getReasonerType() == ReasonerType.DIG) {
throw new ComponentInitException("DIG does not support the inferences needed in the selected learning algorithm component: " + getName());
}
@@ -327,38 +321,38 @@
// concepts/roles
if(allowedConcepts != null) {
// sanity check to control if no non-existing concepts are in the list
- Helper.checkConcepts(rs, allowedConcepts);
+ Helper.checkConcepts(reasoningService, allowedConcepts);
usedConcepts = allowedConcepts;
} else if(ignoredConcepts != null) {
- usedConcepts = Helper.computeConceptsUsingIgnoreList(rs, ignoredConcepts);
+ usedConcepts = Helper.computeConceptsUsingIgnoreList(reasoningService, ignoredConcepts);
} else {
- usedConcepts = Helper.computeConcepts(rs);
+ usedConcepts = Helper.computeConcepts(reasoningService);
}
if(allowedRoles != null) {
- Helper.checkRoles(rs, allowedRoles);
+ Helper.checkRoles(reasoningService, allowedRoles);
usedRoles = allowedRoles;
} else if(ignoredRoles != null) {
- Helper.checkRoles(rs, ignoredRoles);
- usedRoles = Helper.difference(rs.getObjectProperties(), ignoredRoles);
+ Helper.checkRoles(reasoningService, ignoredRoles);
+ usedRoles = Helper.difference(reasoningService.getObjectProperties(), ignoredRoles);
} else {
- usedRoles = rs.getObjectProperties();
+ usedRoles = reasoningService.getObjectProperties();
}
// prepare subsumption and role hierarchies, because they are needed
// during the run of the algorithm
- rs.prepareSubsumptionHierarchy(usedConcepts);
+ reasoningService.prepareSubsumptionHierarchy(usedConcepts);
if(improveSubsumptionHierarchy)
- rs.getSubsumptionHierarchy().improveSubsumptionHierarchy();
- rs.prepareRoleHierarchy(usedRoles);
+ reasoningService.getSubsumptionHierarchy().improveSubsumptionHierarchy();
+ reasoningService.prepareRoleHierarchy(usedRoles);
// prepare datatype hierarchy only if necessary
- if(rs.hasDatatypeSupport())
- rs.prepareDatatypePropertyHierarchy();
+ if(reasoningService.hasDatatypeSupport())
+ reasoningService.prepareDatatypePropertyHierarchy();
// create a refinement operator and pass all configuration
// variables to it
RhoDRDown operator = new RhoDRDown(
- rs,
+ reasoningService,
applyAllFilter,
applyExistsFilter,
useAllConstructor,
@@ -374,7 +368,7 @@
// options to it
algorithm = new ExampleBasedROLearner(
learningProblem,
- rs,
+ reasoningService,
operator,
algHeuristic,
startClass,
Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -103,8 +103,6 @@
private boolean stop = false;
private boolean isRunning = false;
- private ReasoningService rs;
-
private Comparator<Node> nodeComparator;
private NodeComparatorStable nodeComparatorStable = new NodeComparatorStable();
private ConceptComparator conceptComparator = new ConceptComparator();
@@ -198,21 +196,21 @@
// soll später einen Operator und eine Heuristik entgegennehmen
// public ROLearner(LearningProblem learningProblem, LearningProblem learningProblem2) {
- public ROLearner(PosNegLP learningProblem, ReasoningService rs) {
+ public ROLearner(PosNegLP learningProblem, ReasoningService reasoningService) {
+ super(learningProblem, reasoningService);
this.learningProblem = learningProblem;
- this.rs = rs;
this.configurator = new ROLearnerConfigurator(this);
posOnly=false;
- baseURI = rs.getBaseURI();
+ baseURI = reasoningService.getBaseURI();
}
- public ROLearner(PosOnlyDefinitionLP learningProblem, ReasoningService rs) {
+ public ROLearner(PosOnlyDefinitionLP learningProblem, ReasoningService reasoningService) {
+ super(learningProblem, reasoningService);
this.posOnlyLearningProblem = learningProblem;
- this.rs = rs;
this.configurator = new ROLearnerConfigurator(this);
posOnly=true;
- baseURI = rs.getBaseURI();
+ baseURI = reasoningService.getBaseURI();
}
public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() {
@@ -348,7 +346,7 @@
}
// this.learningProblem2 = learningProblem2;
- operator = new RhoDown(rs, applyAllFilter, applyExistsFilter, useAllConstructor, useExistsConstructor, useNegation, useBooleanDatatypes);
+ operator = new RhoDown(reasoningService, applyAllFilter, applyExistsFilter, useAllConstructor, useExistsConstructor, useNegation, useBooleanDatatypes);
// candidate sets entsprechend der gewählten Heuristik initialisieren
candidates = new TreeSet<Node>(nodeComparator);
@@ -356,30 +354,30 @@
if(allowedConcepts != null) {
// sanity check to control if no non-existing concepts are in the list
- Helper.checkConcepts(rs, allowedConcepts);
+ Helper.checkConcepts(reasoningService, allowedConcepts);
usedConcepts = allowedConcepts;
} else if(ignoredConcepts != null) {
- usedConcepts = Helper.computeConceptsUsingIgnoreList(rs, ignoredConcepts);
+ usedConcepts = Helper.computeConceptsUsingIgnoreList(reasoningService, ignoredConcepts);
} else {
- usedConcepts = Helper.computeConcepts(rs);
+ usedConcepts = Helper.computeConcepts(reasoningService);
}
if(allowedRoles != null) {
- Helper.checkRoles(rs, allowedRoles);
+ Helper.checkRoles(reasoningService, allowedRoles);
usedRoles = allowedRoles;
} else if(ignoredRoles != null) {
- Helper.checkRoles(rs, ignoredRoles);
- usedRoles = Helper.difference(rs.getObjectProperties(), ignoredRoles);
+ Helper.checkRoles(reasoningService, ignoredRoles);
+ usedRoles = Helper.difference(reasoningService.getObjectProperties(), ignoredRoles);
} else {
- usedRoles = rs.getObjectProperties();
+ usedRoles = reasoningService.getObjectProperties();
}
// prepare subsumption and role hierarchies, because they are needed
// during the run of the algorithm
- rs.prepareSubsumptionHierarchy(usedConcepts);
+ reasoningService.prepareSubsumptionHierarchy(usedConcepts);
if(improveSubsumptionHierarchy)
- rs.getSubsumptionHierarchy().improveSubsumptionHierarchy();
- rs.prepareRoleHierarchy(usedRoles);
+ reasoningService.getSubsumptionHierarchy().improveSubsumptionHierarchy();
+ reasoningService.prepareRoleHierarchy(usedRoles);
}
public static String getName() {
@@ -763,7 +761,7 @@
if(toEvaluateConcepts.size()>0) {
// Test aller Konzepte auf properness (mit DIG in nur einer Anfrage)
long propCalcReasoningStart = System.nanoTime();
- improperConcepts = rs.subsumes(toEvaluateConcepts, concept);
+ improperConcepts = reasoningService.subsumes(toEvaluateConcepts, concept);
propernessTestsReasoner+=toEvaluateConcepts.size();
// boolean isProper = !learningProblem.getReasoningService().subsumes(refinement, concept);
propernessCalcReasoningTimeNs += System.nanoTime() - propCalcReasoningStart;
@@ -988,19 +986,19 @@
// System.out.println("properness max recursion depth: " + maxRecDepth);
// System.out.println("max. number of one-step refinements: " + maxNrOfRefinements);
// System.out.println("max. number of children of a node: " + maxNrOfChildren);
- logger.debug("subsumption time: " + Helper.prettyPrintNanoSeconds(rs.getSubsumptionReasoningTimeNs()));
- logger.debug("instance check time: " + Helper.prettyPrintNanoSeconds(rs.getInstanceCheckReasoningTimeNs()));
+ logger.debug("subsumption time: " + Helper.prettyPrintNanoSeconds(reasoningService.getSubsumptionReasoningTimeNs()));
+ logger.debug("instance check time: " + Helper.prettyPrintNanoSeconds(reasoningService.getInstanceCheckReasoningTimeNs()));
}
if(showBenchmarkInformation) {
- long reasoningTime = rs.getOverallReasoningTimeNs();
+ long reasoningTime = reasoningService.getOverallReasoningTimeNs();
double reasoningPercentage = 100 * reasoningTime/(double)algorithmRuntime;
long propWithoutReasoning = propernessCalcTimeNs-propernessCalcReasoningTimeNs;
double propPercentage = 100 * propWithoutReasoning/(double)algorithmRuntime;
double deletionPercentage = 100 * childConceptsDeletionTimeNs/(double)algorithmRuntime;
- long subTime = rs.getSubsumptionReasoningTimeNs();
+ long subTime = reasoningService.getSubsumptionReasoningTimeNs();
double subPercentage = 100 * subTime/(double)algorithmRuntime;
double refinementPercentage = 100 * refinementCalcTimeNs/(double)algorithmRuntime;
double redundancyCheckPercentage = 100 * redundancyCheckTimeNs/(double)algorithmRuntime;
Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -45,6 +45,56 @@
public abstract class LearningAlgorithm extends Component {
/**
+ * The learning problem variable, which must be used by
+ * all learning algorithm implementations.
+ */
+ protected LearningProblem learningProblem;
+
+ /**
+ * The reasoning service variable, which must be used by
+ * all learning algorithm implementations.
+ */
+ protected ReasoningService reasoningService;
+
+ /**
+ * Each learning algorithm gets a learning problem and
+ * a reasoner as input.
+ * @param learningProblem The learning problem to solve.
+ * @param reasoningService The reasoner connecting to the
+ * underlying knowledge base.
+ */
+ public LearningAlgorithm(LearningProblem learningProblem, ReasoningService reasoningService) {
+ this.learningProblem = learningProblem;
+ this.reasoningService = reasoningService;
+ }
+
+ /**
+ * Call this when you want to change the learning problem, but
+ * leave everything else as is. Method can be used to apply
+ * a configured algorithm to different learning problems.
+ * Implementations, which do not only use the provided learning
+ * algorithm variable, must make sure that a call to this method
+ * indeed changes the learning problem.
+ * @param learningProblem The new learning problem.
+ */
+ public void changeLearningProblem(LearningProblem learningProblem) {
+ this.learningProblem = learningProblem;
+ }
+
+ /**
+ * Call this when you want to change the reasoning service, but
+ * leave everything else as is. Method can be used to use
+ * a configured algorithm with different reasoners.
+ * Implementations, which do not only use the provided reasoning
+ * service class variable, must make sure that a call to this method
+ * indeed changes the reasoning service.
+ * @param reasoningService The new reasoning service.
+ */
+ public void changeReasoningService(ReasoningService reasoningService) {
+ this.reasoningService = reasoningService;
+ }
+
+ /**
* This is the maximum number of results, which the learning
* algorithms need to keep. (Often algorithms do not need
* to store any results except the best one, so this limit
Modified: trunk/src/dl-learner/org/dllearner/core/LearningProblem.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -60,6 +60,18 @@
}
/**
+ * Method to exchange the reasoner underlying the learning
+ * problem.
+ * Implementations, which do not only use the provided reasoning
+ * service class variable, must make sure that a call to this method
+ * indeed changes the reasoning service.
+ * @param reasoningService New reasoning service.
+ */
+ public void changeReasoningService(ReasoningService reasoningService) {
+ this.reasoningService = reasoningService;
+ }
+
+ /**
* Computes the <code>Score</code> of a given class description
* with respect to this learning problem.
* This can (but does not need to) be used by learning algorithms
Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -40,11 +40,38 @@
import org.dllearner.utilities.datastructures.SortedSetTuple;
/**
+ * Component representing a reasoner.
+ *
* @author Jens Lehmann
*
*/
public abstract class ReasonerComponent extends Component implements Reasoner {
+ protected Set<KnowledgeSource> sources;
+
+ public ReasonerComponent(Set<KnowledgeSource> sources) {
+ this.sources = sources;
+ }
+
+ /**
+ * @return the sources
+ */
+ public Set<KnowledgeSource> getSources() {
+ return sources;
+ }
+
+ /**
+ * Method to exchange the reasoner underlying the learning
+ * problem.
+ * Implementations, which do not only use the provided sources
+ * class variable, must make sure that a call to this method
+ * indeed changes them.
+ * @param The new knowledge sources.
+ */
+ public void changeSources(Set<KnowledgeSource> sources) {
+ this.sources = sources;
+ }
+
public abstract boolean hasDatatypeSupport();
public boolean subsumes(Description superConcept, Description subConcept)
@@ -258,4 +285,5 @@
public Set<NamedClass> getInconsistentClasses() throws ReasoningMethodUnsupportedException{
throw new ReasoningMethodUnsupportedException();
}
+
}
Modified: trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -1,7 +1,6 @@
package org.dllearner.gui;
import java.awt.BorderLayout;
-import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
@@ -39,10 +38,6 @@
private JButton clearButton;
private JComboBox comboBox = new JComboBox();
- public ComponentPanel(LayoutManager layout) {
- super(layout);
- }
-
ComponentPanel(final Config config, StartGUI startGUI, Class<? extends Component> panelClass, Class<? extends Component> defaultComponent) {
this(config, startGUI, panelClass, defaultComponent,null);
}
Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -20,8 +20,10 @@
package org.dllearner.gui;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
import org.apache.log4j.Logger;
import org.dllearner.core.Component;
@@ -145,17 +147,20 @@
*/
public KnowledgeSource changeKnowledgeSource(Class<? extends KnowledgeSource> clazz) {
source = cm.knowledgeSource(clazz);
+ Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>();
+ sources.add(source);
+ reasoner.changeSources(sources);
// logger.debug("knowledge source " + clazz + " changed");
// create a new reasoner object using the current class and the selected source
- reasoner = cm.reasoner(reasoner.getClass(), source);
- rs = cm.reasoningService(reasoner);
- lp = cm.learningProblem(lp.getClass(), rs);
- try {
- la = cm.learningAlgorithm(la.getClass(), lp, rs);
- } catch (LearningProblemUnsupportedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+// reasoner = cm.reasoner(reasoner.getClass(), source);
+// rs = cm.reasoningService(reasoner);
+// lp = cm.learningProblem(lp.getClass(), rs);
+// try {
+// la = cm.learningAlgorithm(la.getClass(), lp, rs);
+// } catch (LearningProblemUnsupportedException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
return source;
}
@@ -187,13 +192,15 @@
public ReasonerComponent changeReasoner(Class<? extends ReasonerComponent> clazz) {
reasoner = cm.reasoner(clazz, source);
rs = cm.reasoningService(reasoner);
- lp = cm.learningProblem(lp.getClass(), rs);
- try {
- la = cm.learningAlgorithm(la.getClass(), lp, rs);
- } catch (LearningProblemUnsupportedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ lp.changeReasoningService(rs);
+ la.changeReasoningService(rs);
+// lp = cm.learningProblem(lp.getClass(), rs);
+// try {
+// la = cm.learningAlgorithm(la.getClass(), lp, rs);
+// } catch (LearningProblemUnsupportedException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
return reasoner;
}
@@ -240,12 +247,13 @@
public LearningProblem changeLearningProblem(Class<? extends LearningProblem> clazz) {
lp = cm.learningProblem(clazz, rs);
- try {
- la = cm.learningAlgorithm(la.getClass(), lp, rs);
- } catch (LearningProblemUnsupportedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ la.changeLearningProblem(lp);
+// try {
+// la = cm.learningAlgorithm(la.getClass(), lp, rs);
+// } catch (LearningProblemUnsupportedException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
return lp;
}
Modified: trunk/src/dl-learner/org/dllearner/gui/InitWorker.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/InitWorker.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/gui/InitWorker.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -98,6 +98,14 @@
try {
for(Component component : components) {
component.init();
+
+ // when the reasoner has been initialised, we need to update
+ // the option panel (such that the user can see the existing
+ // examples, classes etc.)
+ if(component instanceof ReasonerComponent) {
+ gui.panels[2].updateOptionPanel();
+ gui.panels[3].updateOptionPanel();
+ }
}
} catch (ComponentInitException e) {
gui.getStatusPanel().setExceptionMessage(e.getMessage());
@@ -111,14 +119,6 @@
waitFrame.dispose();
}
- // when the reasoner has been initialised, we need to update
- // the option panel (such that the user can see the existing
- // examples, classes etc.)
- if(components instanceof ReasonerComponent) {
- gui.panels[2].updateOptionPanel();
- gui.panels[3].updateOptionPanel();
- }
-
return true;
}
}
Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -85,7 +85,6 @@
URL reasonerURL;
- Set<KnowledgeSource> sources;
// Variablen für Reasoner
DIGHTTPConnector connector;
@@ -116,8 +115,8 @@
public DIGReasoner(Set<KnowledgeSource> sources) {
+ super(sources);
this.configurator = new DIGReasonerConfigurator(this);
- this.sources = sources;
try {
reasonerURL = new URL("http://localhost:8081");
} catch (MalformedURLException e) {
Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -107,7 +107,6 @@
// private ReasoningService rs;
private OWLAPIReasoner rc;
- private Set<KnowledgeSource> sources;
// we use sorted sets (map indices) here, because they have only log(n)
// complexity for checking whether an element is contained in them
@@ -127,7 +126,7 @@
private Map<DatatypeProperty, Map<Individual, SortedSet<Integer>>> id = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Integer>>>();
public FastInstanceChecker(Set<KnowledgeSource> sources) {
- this.sources = sources;
+ super(sources);
this.configurator = new FastInstanceCheckerConfigurator(this);
}
Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -45,6 +45,7 @@
public FastRetrievalReasoner(Set<KnowledgeSource> sources) {
+ super(sources);
this.configurator = new FastRetrievalReasonerConfigurator(this);
rc = ComponentFactory.getDIGReasoner(sources);
@@ -68,10 +69,11 @@
}
public FastRetrievalReasoner(FlatABox abox) {
+ super(null);
this.configurator = new FastRetrievalReasonerConfigurator(this);
this.abox = abox;
fastRetrieval = new FastRetrieval(abox);
-
+
// atomare Konzepte und Rollen initialisieren
atomicConcepts = new HashSet<NamedClass>();
for(String concept : abox.concepts) {
Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-12 10:52:14 UTC (rev 1199)
+++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-12 12:35:09 UTC (rev 1200)
@@ -110,7 +110,6 @@
return configurator;
}
- private Set<KnowledgeSource> sources;
private OWLReasoner reasoner;
// the data factory is used to generate OWL API objects
private OWLDataFactory factory;
@@ -141,9 +140,8 @@
private List<OWLOntology> owlAPIOntologies = new LinkedList<OWLOntology>();
public OWLAPIReasoner(Set<KnowledgeSource> sources) {
- this.sources = sources;
+ super(sources);
this.configurator = new OWLAPIReasonerConfigurator(this);
-
}
public static String getName() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-12 16:51:31
|
Revision: 1201
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1201&view=rev
Author: jenslehmann
Date: 2008-09-12 16:51:26 +0000 (Fri, 12 Sep 2008)
Log Message:
-----------
fixed tricky multi-threading issue when querying currently best class descriptions
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java
trunk/src/dl-learner/org/dllearner/gui/RunPanel.java
trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionSet.java
trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java
Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-12 12:35:09 UTC (rev 1200)
+++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-12 16:51:26 UTC (rev 1201)
@@ -21,6 +21,7 @@
import java.io.File;
import java.text.DecimalFormat;
+import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
@@ -30,9 +31,11 @@
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
+import java.util.concurrent.ConcurrentSkipListSet;
import org.apache.log4j.Logger;
import org.dllearner.core.EvaluatedDescription;
+import org.dllearner.core.LearningAlgorithm;
import org.dllearner.core.LearningProblem;
import org.dllearner.core.ReasoningService;
import org.dllearner.core.Score;
@@ -51,6 +54,7 @@
import org.dllearner.utilities.owl.ConceptComparator;
import org.dllearner.utilities.owl.ConceptTransformation;
import org.dllearner.utilities.owl.EvaluatedDescriptionComparator;
+import org.dllearner.utilities.owl.EvaluatedDescriptionSet;
import com.jamonapi.Monitor;
@@ -160,9 +164,13 @@
// an ordering which does not change during the run of the algorithm
private NodeComparatorStable nodeComparatorStable = new NodeComparatorStable();
// stable candidate set; it has no functional part in the algorithm,
- // but is a list of the currently best concepts found
- private TreeSet<ExampleBasedNode> candidatesStable = new TreeSet<ExampleBasedNode>(
+ // but is a list of the currently best concepts found;
+ // it is very important to use a concurrent set here as other threads will
+ // access it (usual iterating is likely to throw a ConcurrentModificationException)
+ private NavigableSet<ExampleBasedNode> candidatesStable = new ConcurrentSkipListSet<ExampleBasedNode>(
nodeComparatorStable);
+ // evaluated descriptions
+// private EvaluatedDescriptionSet evaluatedDescriptions = new EvaluatedDescriptionSet(LearningAlgorithm.MAX_NR_OF_RESULTS);
// comparator used to create ordered sets of concepts
private ConceptComparator conceptComparator = new ConceptComparator();
@@ -1191,12 +1199,13 @@
}
return best;
}
-
+
public SortedSet<EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions() {
+ Iterator<ExampleBasedNode> it = candidatesStable.descendingIterator();
int count = 0;
- SortedSet<ExampleBasedNode> rev = candidatesStable.descendingSet();
SortedSet<EvaluatedDescription> cbd = new TreeSet<EvaluatedDescription>(edComparator);
- for (ExampleBasedNode eb : rev) {
+ while(it.hasNext()) {
+ ExampleBasedNode eb = it.next();
cbd.add(new EvaluatedDescription(eb.getConcept(), getScore(eb.getConcept())));
// return a maximum of 200 elements (we need a maximum, because the
// candidate set can be very large)
Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-09-12 12:35:09 UTC (rev 1200)
+++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-09-12 16:51:26 UTC (rev 1201)
@@ -170,6 +170,7 @@
* Show Statistics.
*/
public void showStats() {
+ System.out.println("stat update " + System.currentTimeMillis());
Long algorithmRunTime = null;
Long overallReasoningTime = null;
Long instanceCheckReasoningTime = null;
@@ -178,7 +179,7 @@
infoArea.setText("");
// best solutions
- if (config.getLearningAlgorithm().getCurrentlyBestDescriptions() != null) {
+ if (config.getLearningAlgorithm().getCurrentlyBestDescription() != null) {
infoArea.append("Best class descriptions in Manchester OWL Syntax: \n\n"
+ getSolutionString(config.getLearningAlgorithm().getCurrentlyBestEvaluatedDescriptions(10)) + "\n");
}
Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-12 12:35:09 UTC (rev 1200)
+++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-12 16:51:26 UTC (rev 1201)
@@ -232,7 +232,7 @@
Logger logger = Logger.getRootLogger();
logger.removeAllAppenders();
logger.addAppender(consoleAppender);
- logger.setLevel(Level.TRACE);
+ logger.setLevel(Level.DEBUG);
File file = null;
if (args.length > 0)
Added: trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionSet.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionSet.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionSet.java 2008-09-12 16:51:26 UTC (rev 1201)
@@ -0,0 +1,71 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.utilities.owl;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.dllearner.core.owl.Description;
+
+/**
+ * A set of descriptions, which is bound by a maximum
+ * size. Can be used by algorithms to store the most promising
+ * n class descriptions.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public class DescriptionSet {
+
+ private ConceptComparator comp = new ConceptComparator();
+
+ private SortedSet<Description> set = new TreeSet<Description>(comp);
+
+ private int maxSize;
+
+ public DescriptionSet(int maxSize) {
+ this.maxSize = maxSize;
+ }
+
+ public void add(Description ed) {
+ set.add(ed);
+ if(set.size()>maxSize) {
+ Iterator<Description> it = set.iterator();
+ it.next();
+ it.remove();
+ }
+ }
+
+ public void addAll(Collection<Description> eds) {
+ for(Description ed : eds) {
+ add(ed);
+ }
+ }
+
+ /**
+ * @return the set
+ */
+ public SortedSet<Description> getSet() {
+ return set;
+ }
+
+}
Added: trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java 2008-09-12 16:51:26 UTC (rev 1201)
@@ -0,0 +1,71 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.utilities.owl;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.dllearner.core.EvaluatedDescription;
+
+/**
+ * A set of evaluated descriptions, which is bound by a maximum
+ * size. Can be used by algorithms to store the most promising
+ * n class descriptions.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public class EvaluatedDescriptionSet {
+
+ private EvaluatedDescriptionComparator comp = new EvaluatedDescriptionComparator();
+
+ private SortedSet<EvaluatedDescription> set = new TreeSet<EvaluatedDescription>(comp);
+
+ private int maxSize;
+
+ public EvaluatedDescriptionSet(int maxSize) {
+ this.maxSize = maxSize;
+ }
+
+ public void add(EvaluatedDescription ed) {
+ set.add(ed);
+ if(set.size()>maxSize) {
+ Iterator<EvaluatedDescription> it = set.iterator();
+ it.next();
+ it.remove();
+ }
+ }
+
+ public void addAll(Collection<EvaluatedDescription> eds) {
+ for(EvaluatedDescription ed : eds) {
+ add(ed);
+ }
+ }
+
+ /**
+ * @return the set
+ */
+ public SortedSet<EvaluatedDescription> getSet() {
+ return set;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ku...@us...> - 2008-09-15 07:50:04
|
Revision: 1205
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1205&view=rev
Author: kurzum
Date: 2008-09-15 07:50:00 +0000 (Mon, 15 Sep 2008)
Log Message:
-----------
small changes
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java
trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java
Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-15 07:43:31 UTC (rev 1204)
+++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-15 07:50:00 UTC (rev 1205)
@@ -124,8 +124,11 @@
ComponentManager cm =ComponentManager.getInstance();
try{
-
+ int i=0;
for (File f : confs) {
+ if(i!=80){
+ i++; continue;
+ }
Cache.getDefaultCache().clearCache();
String fileContent = Files.readFile(f);
@@ -396,7 +399,7 @@
"sparql.predefinedEndpoint = \"LOCALJOSEKIBIBLE\";\n"+
"sparql.getPropertyInformation = true;\n"+
"refexamples.maxExecutionTimeInSeconds = "+sparqllMaxExecution+";\n"+
- "import(\"lalala\",\"SPARQL\");\n"+
+ "import(\"http://localhost:2020/bible\",\"SPARQL\");\n"+
getCombinedOptions()+
"";
return s;
Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java 2008-09-15 07:43:31 UTC (rev 1204)
+++ trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java 2008-09-15 07:50:00 UTC (rev 1205)
@@ -21,6 +21,7 @@
package org.dllearner.utilities.owl;
import java.io.File;
+import java.net.URL;
import java.util.List;
import org.dllearner.core.ComponentManager;
@@ -69,7 +70,7 @@
// knowledge source
KnowledgeSource ks = cm.knowledgeSource(OWLFile.class);
- String fileURL = new File(ontologyFile).toURI().toString();
+ URL fileURL = new File(ontologyFile).toURI().toURL();
cm.applyConfigEntry(ks, "url", fileURL);
ks.init();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-15 11:19:43
|
Revision: 1210
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1210&view=rev
Author: jenslehmann
Date: 2008-09-15 11:19:37 +0000 (Mon, 15 Sep 2008)
Log Message:
-----------
improved starting and stopping algorithms in GUI
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java
trunk/src/dl-learner/org/dllearner/gui/Config.java
trunk/src/dl-learner/org/dllearner/gui/RunPanel.java
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java
Removed Paths:
-------------
trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java
trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java
Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-15 09:20:10 UTC (rev 1209)
+++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-15 11:19:37 UTC (rev 1210)
@@ -283,6 +283,7 @@
}
public void start() {
+ stop = false;
isRunning = true;
runtime = System.currentTimeMillis();
Monitor totalLearningTime = JamonMonitorLogger.getTimeMonitor(ExampleBasedROLComponent.class, "totalLearningTime")
Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-15 09:20:10 UTC (rev 1209)
+++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-15 11:19:37 UTC (rev 1210)
@@ -72,9 +72,9 @@
private boolean[] isEnabled = new boolean[4];
// learning algorithm status
- private boolean threadIsRunning = false;
- private Long algorithmRunStartTime = null;
- private Long algorithmRunStopTime = null;
+// private boolean threadIsRunning = false;
+// private Long algorithmRunStartTime = null;
+// private Long algorithmRunStopTime = null;
private StartGUI gui;
@@ -409,6 +409,7 @@
*
* @param isThreadRunning
*/
+ /*
public void setThreadIsRunning(Boolean isThreadRunning) {
if (isThreadRunning)
algorithmRunStartTime = System.nanoTime();
@@ -416,16 +417,17 @@
if (algorithmRunStartTime < System.nanoTime())
algorithmRunStopTime = System.nanoTime();
this.threadIsRunning = isThreadRunning;
- }
+ }*/
/**
* Get true if algorithm has started, false if not.
*
* @return true if algorithm is running, false if not.
*/
+ /*
public Boolean getThreadIsRunning() {
return this.threadIsRunning;
- }
+ }*/
/**
* Get time in ns for run of algorithm. If algorithm is still running return
@@ -433,6 +435,7 @@
*
* @return time in ns
*/
+ /*
public Long getAlgorithmRunTime() {
if (algorithmRunStartTime != null)
if (algorithmRunStopTime != null) {
@@ -441,7 +444,7 @@
} else
return System.nanoTime() - algorithmRunStartTime;
return null;
- }
+ }*/
/**
* It is necessary for init LearningProblem.
Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-09-15 09:20:10 UTC (rev 1209)
+++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-09-15 11:19:37 UTC (rev 1210)
@@ -45,9 +45,9 @@
private JButton runButton, stopButton, treeButton;
private JTextArea infoArea;
private Config config;
- //private StartGUI startGUI;
+ private StartGUI startGUI;
- private ThreadRun thread;
+ private long algorithmStartTime = 0;
private GridBagLayout gridbag = new GridBagLayout();
private GridBagConstraints constraints = new GridBagConstraints();
@@ -67,16 +67,19 @@
private JLabel[] time = new JLabel[5];
private JLabel[] percent = new JLabel[5];
+
+
RunPanel(Config config, StartGUI startGUI) {
super(new BorderLayout());
this.config = config;
- //this.startGUI = startGUI;
+ this.startGUI = startGUI;
runButton = new JButton("Run");
runButton.addActionListener(this);
showPanel.add(runButton);
stopButton = new JButton("Stop");
+ stopButton.setEnabled(false);
stopButton.addActionListener(this);
showPanel.add(stopButton);
treeButton = new JButton("Tree");
@@ -147,17 +150,35 @@
public void actionPerformed(ActionEvent e) {
// start
- if (e.getSource() == runButton && config.getLearningAlgorithm() != null
- && !config.getThreadIsRunning()) {
- thread = new ThreadRun(config);
+ if (e.getSource() == runButton) {
+
+ // separate thread for learning algorithm
+ Thread algorithmThread = new Thread() {
+ @Override
+ public void run() {
+ setPriority(Thread.MIN_PRIORITY);
+ config.getLearningAlgorithm().start();
+ }
+ };
+
config.getReasoningService().resetStatistics();
- thread.start();
- ThreadStatistics threadStatistics = new ThreadStatistics(config, this);
+ algorithmThread.start();
+ algorithmStartTime = System.nanoTime();
+ StatisticsThread threadStatistics = new StatisticsThread(config, this);
threadStatistics.start();
+ runButton.setEnabled(false);
+ stopButton.setEnabled(true);
+ // disable other panes (we do not want changes while
+ // algorithm is running)
+ startGUI.disableTabbedPane();
}
// stop
- if (e.getSource() == stopButton && config.getLearningAlgorithm() != null) {
- thread.exit();
+ if (e.getSource() == stopButton) {
+ config.getLearningAlgorithm().stop();
+ runButton.setEnabled(true);
+ stopButton.setEnabled(false);
+ // enable panels
+ startGUI.enableTabbedPane();
}
// tree
if (e.getSource() == treeButton) {
@@ -170,12 +191,11 @@
* Show Statistics.
*/
public void showStats() {
- System.out.println("stat update " + System.currentTimeMillis());
- Long algorithmRunTime = null;
- Long overallReasoningTime = null;
- Long instanceCheckReasoningTime = null;
- Long retrievalReasoningTime = null;
- Long subsumptionReasoningTime = null;
+// System.out.println("stat update " + System.currentTimeMillis());
+ long overallReasoningTime = 0; // = null;
+ long instanceCheckReasoningTime = 0; // = null;
+ long retrievalReasoningTime = 0; // = null;
+ long subsumptionReasoningTime = 0; // = null;
infoArea.setText("");
// best solutions
@@ -189,19 +209,18 @@
// + config.getLearningAlgorithm().getSolutionScore().toString()
// + "\n\n");
- // reasoner statistics
- if (config.getAlgorithmRunTime() != null) {
- algorithmRunTime = config.getAlgorithmRunTime();
- bar[0].update(1.0);
- time[0].setText(makeTime(algorithmRunTime));
- percent[0].setText("100%");
- }
- if (config.getReasoningService() != null) {
+ // update algorith runtime
+ long algorithmRunTime = System.nanoTime() - algorithmStartTime;
+ bar[0].update(1.0);
+ time[0].setText(makeTime(algorithmRunTime));
+ percent[0].setText("100%");
+
+ // update overall reasoning time
overallReasoningTime = config.getReasoningService().getOverallReasoningTimeNs();
bar[1].update((double) overallReasoningTime / (double) algorithmRunTime);
time[1].setText(makeTime(overallReasoningTime));
percent[1].setText(Percent(overallReasoningTime, algorithmRunTime));
- }
+
if (config.getReasoningService().getNrOfInstanceChecks() > 0) {
instanceCheckReasoningTime = config.getReasoningService()
.getInstanceCheckReasoningTimeNs();
Copied: trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java (from rev 1208, trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java)
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java 2008-09-15 11:19:37 UTC (rev 1210)
@@ -0,0 +1,61 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.gui;
+
+/**
+ * This thread is responsible for sending update events to the GUI.
+ * In regular intervals it tests whether the learning algorithm is
+ * running and calls methods to update the statistics in the run
+ * panel.
+ *
+ * @author Tilo Hielscher
+ * @author Jens Lehmann
+ */
+public class StatisticsThread extends Thread {
+
+ private Config config;
+ private RunPanel runPanel;
+
+ public StatisticsThread(Config config, RunPanel runPanel) {
+ this.config = config;
+ this.runPanel = runPanel;
+ }
+
+ /**
+ * Calls {@link RunPanel#showStats()} in regular intervals.
+ */
+ @Override
+ public void run() {
+ try {
+ // initial delay of one second
+ sleep(1000);
+ while (config.getLearningAlgorithm().isRunning()) {
+ // update statistics every 3 seconds
+ runPanel.showStats();
+ sleep(3000);
+ }
+ // show final stats
+ runPanel.showStats();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
Deleted: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-09-15 09:20:10 UTC (rev 1209)
+++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-09-15 11:19:37 UTC (rev 1210)
@@ -1,58 +0,0 @@
-package org.dllearner.gui;
-
-/**
- * Copyright (C) 2007-2008, Jens Lehmann
- *
- * This file is part of DL-Learner.
- *
- * DL-Learner is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * DL-Learner is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * Start algorithm in a new thread.
- *
- * @author Tilo Hielscher
- */
-public class ThreadRun extends Thread {
-
- Config config;
-
- public ThreadRun(Config config) {
- this.config = config;
- }
-
- /**
- * method to start thread
- */
- @Override
- public void run() {
- if (config.getLearningAlgorithm() != null) {
- config.setThreadIsRunning(true);
- this.setPriority(Thread.MIN_PRIORITY);
- config.getLearningAlgorithm().start();
- config.setThreadIsRunning(false);
- }
- }
-
- /**
- * stop thread
- */
- public void exit() {
- if (config.getLearningAlgorithm() != null)
- config.getLearningAlgorithm().stop();
- config.setThreadIsRunning(false);
- System.out.println("stop run");
- }
-}
Deleted: trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-09-15 09:20:10 UTC (rev 1209)
+++ trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-09-15 11:19:37 UTC (rev 1210)
@@ -1,60 +0,0 @@
-/**
- * Copyright (C) 2007-2008, Jens Lehmann
- *
- * This file is part of DL-Learner.
- *
- * DL-Learner is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * DL-Learner is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.dllearner.gui;
-
-/**
- * Start statistics in a new thread.
- *
- * @author Tilo Hielscher
- */
-public class ThreadStatistics extends Thread {
-
- private Config config;
- private RunPanel runPanel;
-
- public ThreadStatistics(Config config, RunPanel runPanel) {
- this.config = config;
- this.runPanel = runPanel;
- }
-
- /**
- * method to start thread
- */
- @Override
- public void run() {
- //this.setPriority(4);
- if (config.getThreadIsRunning()) {
- try {
- sleep(1000); // sleep 1 second
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- while (config.getThreadIsRunning()) {
- try {
- runPanel.showStats();
- sleep(3000); // sleep 3 seconds
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- runPanel.showStats();
- }
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-15 13:18:02
|
Revision: 1212
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1212&view=rev
Author: jenslehmann
Date: 2008-09-15 13:17:51 +0000 (Mon, 15 Sep 2008)
Log Message:
-----------
large number of GUI fixes and improvements
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/cli/Start.java
trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java
trunk/src/dl-learner/org/dllearner/gui/Config.java
trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringTupleList.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/gui/tutorial.html
Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -328,7 +328,7 @@
* this way the CLI will automatically support any configuration options
* supported by the component
*/
- public static void configureComponent(ComponentManager cm, Component component,
+ private static void configureComponent(ComponentManager cm, Component component,
ConfParser parser) {
String prefix = confMapper.getComponentString(component.getClass());
if (prefix != null)
Modified: trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -28,7 +28,7 @@
private static final long serialVersionUID = -7678275020058043937L;
private Config config;
-// private StartGUI startGUI;
+ private StartGUI startGUI;
private List<Class<? extends Component>> selectableComponents;
private OptionPanel optionPanel;
private Class<? extends Component> panelClass;
@@ -46,7 +46,7 @@
super(new BorderLayout());
this.config = config;
-// this.startGUI = startGUI;
+ this.startGUI = startGUI;
this.panelClass = panelClass;
// get all classes of the correct type
@@ -99,11 +99,14 @@
public void actionPerformed(ActionEvent e) {
if(e.getSource() == comboBox) {
- System.out.println("TESTzz");
// change component and update option panel
Class<? extends Component> c = selectableComponents.get(comboBox.getSelectedIndex());
currentComponent = changeInstance(c);
updateOptionPanel();
+ // if the component does not have mandatory values, we can
+ // enable the following tabs
+ config.enableComponentsIfPossible();
+ startGUI.updateTabs();
} else if (e.getSource() == clearButton) {
// clearing everything corresponds to changing to an unconfigured
// component of the same type
Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -40,6 +40,7 @@
import org.dllearner.core.config.ConfigOption;
import org.dllearner.kb.KBFile;
import org.dllearner.kb.OWLFile;
+import org.dllearner.kb.sparql.SparqlKnowledgeSource;
import org.dllearner.learningproblems.PosNegLP;
/**
@@ -530,7 +531,7 @@
cm.applyConfigEntry(component, entry);
// enable tabs if setting the value completed mandatory settings
- enableTabsIfPossible();
+ enableComponentsIfPossible();
// invalidate components
if(component instanceof KnowledgeSource) {
needsInit[0] = true;
@@ -563,22 +564,49 @@
gui.updateTabs();
}
- private void enableTabsIfPossible() {
- if(mandatoryOptionsSpecified(source)) {
- isEnabled[0] = true;
- }
- if(mandatoryOptionsSpecified(reasoner) && isEnabled[0]) {
- isEnabled[1] = true;
- }
- if(mandatoryOptionsSpecified(lp) && isEnabled[1]) {
- isEnabled[2] = true;
- }
- if(mandatoryOptionsSpecified(la) && isEnabled[1] && isEnabled[2]) {
- isEnabled[3] = true;
+ // note it can also happend that components become
+ // disabled if mandatory fields are cleared
+ public void enableComponentsIfPossible() {
+ // 0: reasoner
+ // 1: problem
+ // 2: algorithm
+ // 3: run
+
+ isEnabled[0] = mandatoryOptionsSpecified(source);
+ isEnabled[1] = isEnabled[0] && mandatoryOptionsSpecified(reasoner);
+ isEnabled[2] = isEnabled[0] && isEnabled[1] && mandatoryOptionsSpecified(lp);
+ isEnabled[3] = isEnabled[0] && isEnabled[1] && isEnabled[2] && mandatoryOptionsSpecified(la);
+
+
+ /*
+ // enable reasoner iff source has all options
+ isEnabled[0] = mandatoryOptionsSpecified(source);
+
+ // enable problem if reasoner has all options
+ if(isEnabled[0]) {
+ isEnabled[1] = mandatoryOptionsSpecified(reasoner);
+ } else {
+ isEnabled[1] = false;
}
+
+ // enable algorithm if reasoner enabled and problem
+ // has all options
+ if(isEnabled[0]) {
+ isEnabled[2] = mandatoryOptionsSpecified(lp);
+ } else {
+ isEnabled[2] = false;
+ }
+
+ // enable run panel if al
+ isEnabled[3] = mandatoryOptionsSpecified(la);
+
+ if(isEnabled[1] && isEnabled[2]) {
+ isEnabled[3] = mandatoryOptionsSpecified(la);
+ }*/
}
// TODO use specification of mandatory variables
+ @SuppressWarnings("unchecked")
public boolean mandatoryOptionsSpecified(Component component) {
// System.out.println("check mandatory options for " + component.getClass().getName());
if(component instanceof OWLFile) {
@@ -590,10 +618,17 @@
return false;
}
} else if(component instanceof PosNegLP) {
- if(cm.getConfigOptionValue(component, "positiveExamples")==null || cm.getConfigOptionValue(component, "negativeExamples") == null) {
+ if(cm.getConfigOptionValue(component, "positiveExamples")==null || cm.getConfigOptionValue(component, "negativeExamples") == null
+ || ((Set<String>)cm.getConfigOptionValue(component, "positiveExamples")).size()==0
+ || ((Set<String>)cm.getConfigOptionValue(component, "negativeExamples")).size()==0) {
return false;
}
+ } else if(component instanceof SparqlKnowledgeSource) {
+ if(cm.getConfigOptionValue(component, "instances")==null || ((Set<String>)cm.getConfigOptionValue(component, "instances")).size()==0) {
+ return false;
+ }
}
+
return true;
}
Modified: trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -19,16 +19,20 @@
*/
package org.dllearner.gui;
-import java.awt.Dimension;
+import java.awt.BorderLayout;
+import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextPane;
+import javax.swing.SwingWorker;
/**
* Window displaying a tutorial for the DL-Learner GUI.
*
* @author Jens Lehmann
- *
+ *
*/
public class TutorialWindow extends JFrame {
@@ -39,35 +43,74 @@
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLocationByPlatform(true);
setSize(300, 600);
+ setVisible(true);
+
+ getContentPane().setLayout(new BorderLayout());
+ final JLabel label = new JLabel("Loading HTML help page.");
+ add(label, BorderLayout.NORTH);
+ final JTextPane tp = new JTextPane();
+ JScrollPane js = new JScrollPane();
+ js.getViewport().add(tp);
+ add(js, BorderLayout.CENTER);
+
+ SwingWorker<Boolean, Boolean> worker = new SwingWorker<Boolean, Boolean>() {
+ @Override
+ public Boolean doInBackground() {
+
+ try {
+ URL url = getClass().getResource("tutorial.html");
+ tp.setPage(url);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+// label.setText("Displaying tutorial.html.");
+ remove(label);
+ repaint();
+
+ return true;
+ }
+ };
+ worker.execute();
+
// display tutorial text
- String text = "<html><h2>Quick Tutorial</h2><p align=\"justify\">DL-Learner has a component" +
- " based design to make it easier to extend and use. There are four " +
- "components corresponding to the tabs you see: knowledge source, " +
- "reasoner, learning problem, and learning algorithm. There are various " +
- "components available of each type (selectable at the top of each tab). " +
- "Each component has configuration options associated with it (middle of the" +
- " tab, scrollable), which you can use to specify the settings for the component.</p>" +
- "<br /><p align=\"justify\">In order to create a learning problem, " +
- "you have to choose and configure all four types of components." +
- " The run tab plays a special role: It is used to start the learning algorithm" +
- " and display statistical information.</p>" +
- "<br /><p><i>Tab color explanation:</i> <br />gray = cannot be configured yet (mandatory configuration values missing)<br />" +
- "red = needs to be initialised<br />black = component has been initialised</p>" +
- "<br /><p><i>Further references:</i><br />" +
- "Homepage: <a href=\"http://dl-learner.org\">http://dl-learner.org</a><br />" +
- "DL-Learner Architecture: <a href=\"http://dl-learner.org/wiki/Architecture\">http://dl-learner.org/wiki/Architecture</a>" +
- "</p><br /><p>Please send questions to le...@in....</p></html>";
- JLabel label = new JLabel(text);
- label.setMaximumSize(new Dimension(300,500));
- add(label);
-// JScrollPane scrollPane = new JScrollPane(label);
-// scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
-// scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
-// scrollPane.setPreferredSize(new Dimension(300,500));
-// add(scrollPane);
-
- setVisible(true);
- }
-
+ // String text = "<html><h2>Quick Tutorial</h2><p
+ // align=\"justify\">DL-Learner has a component" +
+ // " based design to make it easier to extend and use. There are four "
+ // +
+ // "components corresponding to the tabs you see: knowledge source, " +
+ // "reasoner, learning problem, and learning algorithm. There are
+ // various " +
+ // "components available of each type (selectable at the top of each
+ // tab). " +
+ // "Each component has configuration options associated with it (middle
+ // of the" +
+ // " tab, scrollable), which you can use to specify the settings for the
+ // component.</p>" +
+ // "<br /><p align=\"justify\">In order to create a learning problem, "
+ // +
+ // "you have to choose and configure all four types of components." +
+ // " The run tab plays a special role: It is used to start the learning
+ // algorithm" +
+ // " and display statistical information.</p>" +
+ // "<br /><p><i>Tab color explanation:</i> <br />gray = cannot be
+ // configured yet (mandatory configuration values missing)<br />" +
+ // "red = needs to be initialised<br />black = component has been
+ // initialised</p>" +
+ // "<br /><p><i>Further references:</i><br />" +
+ // "Homepage: <a
+ // href=\"http://dl-learner.org\">http://dl-learner.org</a><br />" +
+ // "DL-Learner Architecture: <a
+ // href=\"http://dl-learner.org/wiki/Architecture\">http://dl-learner.org/wiki/Architecture</a>"
+ // +
+ // "</p><br /><p>Please send questions to
+ // le...@in....</p></html>";
+ // JLabel label = new JLabel(text);
+ // label.setMaximumSize(new Dimension(300,500));
+ // add(label);
+
+ // setVisible(true);
+ }
+
}
Added: trunk/src/dl-learner/org/dllearner/gui/tutorial.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/tutorial.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/gui/tutorial.html 2008-09-15 13:17:51 UTC (rev 1212)
@@ -0,0 +1,42 @@
+<html>
+ <head>
+ <title>Quick Tutorial for DL-Learner GUI</title>
+ </head>
+ <body style="font-family: Verdana">
+
+<h2>Quick Tutorial</h2>
+
+<p align=\"justify\">
+DL-Learner has a component based design to make it easier to
+extend and use. There are four components corresponding to the
+tabs you see: knowledge source, reasoner, learning problem, and
+learning algorithm. There are various components available of
+each type (selectable at the top of each tab). Each component
+has configuration options associated with it (middle of the tab,
+scrollable), which you can use to specify the settings for the
+component.
+</p><br />
+
+<p align=\"justify\">
+In order to create a learning problem, you have to choose and
+configure all four types of components. The run tab plays a
+special role: It is used to start the learning algorithm
+and display statistical information.
+</p><br />
+
+<p>
+<i>Tab heads explanation:</i><br />
+gray/disabled = cannot be configured yet (mandatory configuration values missing)<br />
+red = needs to be initialised<br />
+black = component has been initialised
+</p><br />
+
+<p><i>Further references:</i><br />
+Homepage: <a href="http://dl-learner.org">http://dl-learner.org</a><br />
+DL-Learner Architecture: <a href="http://dl-learner.org/wiki/Architecture">http://dl-learner.org/wiki/Architecture</a>
+</p><br />
+
+<p>Please send questions to le...@in....</p>
+
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -26,8 +26,6 @@
import org.dllearner.core.Component;
import org.dllearner.core.config.BooleanConfigOption;
-import org.dllearner.core.config.ConfigEntry;
-import org.dllearner.core.config.InvalidConfigOptionValueException;
import org.dllearner.gui.Config;
/**
@@ -55,39 +53,10 @@
else
value = true;
- BooleanConfigOption specialOption;
- specialOption = (BooleanConfigOption) config.getComponentManager().getConfigOption(
- component.getClass(), configOption.getName());
- if (specialOption.isValidValue(value)) {
- try {
- ConfigEntry<Boolean> specialEntry = new ConfigEntry<Boolean>(specialOption, value);
- config.getComponentManager().applyConfigEntry(component, specialEntry);
- // System.out.println("set Boolean: " + configOption.getName() +
- // " = " + value);
- } catch (InvalidConfigOptionValueException s) {
- s.printStackTrace();
- }
- } else
- System.out.println("Boolean: not valid value");
+ fireValueChanged(value);
+
}
- public void setEntry() {
- BooleanConfigOption specialOption;
- specialOption = (BooleanConfigOption) config.getComponentManager().getConfigOption(
- component.getClass(), configOption.getName());
- if (specialOption.isValidValue(value)) {
- try {
- ConfigEntry<Boolean> specialEntry = new ConfigEntry<Boolean>(specialOption, value);
- config.getComponentManager().applyConfigEntry(component, specialEntry);
- // System.out.println("set Boolean: " + configOption.getName() +
- // " = " + value);
- } catch (InvalidConfigOptionValueException s) {
- s.printStackTrace();
- }
- } else
- System.out.println("Boolean: not valid value");
- }
-
@Override
public void buildWidgetPanel() {
add(getLabel());
@@ -96,8 +65,8 @@
if (value == null)
value = false;
- else
- setEntry();
+// else
+// setEntry();
// set cb-index
String[] kbBoxItems = { "false", "true" };
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -20,16 +20,16 @@
*
*/
+import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
+import javax.swing.JLabel;
import javax.swing.JTextField;
import org.dllearner.core.Component;
-import org.dllearner.core.config.ConfigEntry;
import org.dllearner.core.config.DoubleConfigOption;
-import org.dllearner.core.config.InvalidConfigOptionValueException;
import org.dllearner.gui.Config;
/**
@@ -44,6 +44,7 @@
private static final long serialVersionUID = 5238903690721116289L;
private JButton setButton = new JButton("Set");
+ private JLabel problemLabel;
// private Class<? extends Component> componentOption;
@@ -56,31 +57,23 @@
public void actionPerformed(ActionEvent e) {
if (e.getSource() == setButton) {
- setEntry();
+ // TODO need better way for double parsing than throwing an
+ // exception
+ try {
+ double value = Integer.valueOf(doubleField.getText());
+ fireValueChanged(value);
+ problemLabel.setText("");
+ } catch(NumberFormatException e1) {
+ problemLabel.setText("Please enter a valid double value.");
+ }
}
}
- public void setEntry() {
- DoubleConfigOption specialOption;
- value = Double.parseDouble(doubleField.getText()); // get from input
- specialOption = (DoubleConfigOption) config.getComponentManager().getConfigOption(
- component.getClass(), configOption.getName());
- if (specialOption.isValidValue(value)) {
- try {
- ConfigEntry<Double> specialEntry = new ConfigEntry<Double>(specialOption, value);
- config.getComponentManager().applyConfigEntry(component, specialEntry);
- // System.out.println("set Double: " + configOption.getName() +
- // " = " + value);
- } catch (InvalidConfigOptionValueException s) {
- s.printStackTrace();
- }
- } else
- System.out.println("Double: not valid value");
- }
-
@Override
public void buildWidgetPanel() {
add(getLabel());
+ problemLabel = new JLabel();
+ problemLabel.setForeground(Color.RED);
value = config.getConfigOptionValue(component, configOption);
@@ -90,7 +83,7 @@
value = 0.0;
else {
doubleField.setText(value.toString());
- setEntry();
+// setEntry();
}
doubleField.setText(value.toString());
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -20,16 +20,16 @@
*
*/
+import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
+import javax.swing.JLabel;
import javax.swing.JTextField;
import org.dllearner.core.Component;
-import org.dllearner.core.config.ConfigEntry;
import org.dllearner.core.config.IntegerConfigOption;
-import org.dllearner.core.config.InvalidConfigOptionValueException;
import org.dllearner.gui.Config;
/**
@@ -37,16 +37,18 @@
* org.dllearner.core.config.IntegerConfigOption.
*
* @author Tilo Hielscher
+ * @author Jens Lehmann
*
*/
public class WidgetPanelInteger extends AbstractWidgetPanel<Integer> implements ActionListener {
private static final long serialVersionUID = -1802111225835164644L;
- private JButton setButton = new JButton("Set");
+ private JButton setButton; // = new JButton("Set");
+ private JLabel problemLabel ; //= new JLabel();
private Integer value;
- private JTextField integerField = new JTextField(3);
+ private JTextField integerField; // = new JTextField(3);
public WidgetPanelInteger(Config config, Component component, IntegerConfigOption configOption) {
super(config, component, configOption);
@@ -54,31 +56,24 @@
public void actionPerformed(ActionEvent e) {
if (e.getSource() == setButton) {
- setEntry();
- }
- }
- public void setEntry() {
- IntegerConfigOption specialOption;
- value = Integer.parseInt(integerField.getText()); // get from input
- specialOption = (IntegerConfigOption) config.getComponentManager().getConfigOption(
- component.getClass(), configOption.getName());
- if (specialOption.isValidValue(value)) {
+ // TODO need better way for integer parsing than throwing an
+ // exception
try {
- ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value);
- config.getComponentManager().applyConfigEntry(component, specialEntry);
- // System.out.println("set Integer: " + configOption.getName() +
- // " = " + value);
- } catch (InvalidConfigOptionValueException s) {
- s.printStackTrace();
+ int value = Integer.valueOf(integerField.getText());
+ fireValueChanged(value);
+ problemLabel.setText("");
+ } catch(NumberFormatException e1) {
+ problemLabel.setText("Please enter a valid integer value.");
}
- } else
- System.out.println("Integer: not valid value");
+ }
}
@Override
public void buildWidgetPanel() {
add(getLabel());
+ problemLabel = new JLabel();
+ problemLabel.setForeground(Color.RED);
value = config.getConfigOptionValue(component, configOption);
@@ -88,13 +83,14 @@
value = 0;
else {
integerField.setText(value.toString());
- setEntry();
+// setEntry();
}
integerField.setText(value.toString());
integerField.setToolTipText(configOption.getAllowedValuesDescription());
setButton.addActionListener(this);
add(integerField);
- add(setButton);
+ add(setButton);
+ add(problemLabel);
}
}
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -23,14 +23,11 @@
import java.awt.event.ActionListener;
import javax.swing.JButton;
-import javax.swing.JFileChooser;
import javax.swing.JTextField;
import org.dllearner.core.Component;
import org.dllearner.core.config.StringConfigOption;
import org.dllearner.gui.Config;
-import org.dllearner.gui.ExampleFileChooser;
-import org.dllearner.kb.OWLFile;
/**
* Panel for option String, defined in
@@ -44,11 +41,10 @@
private static final long serialVersionUID = -2169739820989891226L;
-// private JPanel widgetPanel = new JPanel();
- private JButton setButton; // = new JButton("Set");
+ private JButton setButton;
private String value;
- private JTextField stringField; // = new JTextField(35);
+ private JTextField stringField;
public WidgetPanelString(Config config, Component component, StringConfigOption configOption) {
super(config, component, configOption);
@@ -56,49 +52,12 @@
public void actionPerformed(ActionEvent e) {
if (e.getSource() == setButton) {
- if (configOption.getName().equals("filename") || configOption.getName().equals("url")) {
- JFileChooser fc;
- if(component instanceof OWLFile) {
- fc = new ExampleFileChooser("owl");
- } else {
- fc = new ExampleFileChooser("kb");
- }
-
- int returnVal = fc.showOpenDialog(this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- value = fc.getSelectedFile().toString();
- stringField.setText(value);
- }
- }
+ // fire value changed event
value = stringField.getText();
fireValueChanged(value);
-// setEntry();
- // if url and value not ""
- // necessary for init knowledge source
- if (configOption.getName().equalsIgnoreCase("url") && !value.equalsIgnoreCase("")) {
- }
}
}
- /*
- public void setEntry() {
- StringConfigOption specialOption;
- value = stringField.getText(); // get from input
- specialOption = (StringConfigOption) config.getComponentManager().getConfigOption(
- componentOption, configOption.getName());
- if (specialOption.isValidValue(value)) {
- try {
- ConfigEntry<String> specialEntry = new ConfigEntry<String>(specialOption, value);
- config.getComponentManager().applyConfigEntry(component, specialEntry);
- // System.out.println("set String: " + configOption.getName() +
- // " = " + value);
- } catch (InvalidConfigOptionValueException s) {
- s.printStackTrace();
- }
- } else
- System.out.println("String: not valid value");
- }*/
-
@Override
public void buildWidgetPanel() {
add(getLabel());
@@ -108,24 +67,25 @@
// default values can be null, so we interpret this as empty string
if (value == null) {
value = "";
- }
-
+ }
+
// text field for strings
stringField = new JTextField(35);
stringField.setText(value);
stringField.setToolTipText(configOption.getAllowedValuesDescription());
-
- // set button (value is only updated when this button is pressed => would better without set)
+
+ // set button (value is only updated when this button is pressed =>
+ // would better without set)
setButton = new JButton("Set");
setButton.addActionListener(this);
-
+
add(stringField);
add(setButton);
-
+
// special handling for filename option
if (configOption.getName().equals("filename"))
setButton.setText("choose local file");
-
+
}
}
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -38,8 +38,6 @@
import javax.swing.JTextField;
import org.dllearner.core.Component;
-import org.dllearner.core.config.ConfigEntry;
-import org.dllearner.core.config.InvalidConfigOptionValueException;
import org.dllearner.core.config.StringSetConfigOption;
import org.dllearner.core.owl.Individual;
import org.dllearner.core.owl.NamedClass;
@@ -55,6 +53,7 @@
* options. Second layout shows a list of JCheckBox's.
*
* @author Tilo Hielscher
+ * @author Jens Lehmann
*
*/
public class WidgetPanelStringSet extends AbstractWidgetPanel<Set<String>> implements ActionListener {
@@ -64,17 +63,17 @@
private GridBagLayout gridbag = new GridBagLayout();
private GridBagConstraints constraints = new GridBagConstraints();
- private JPanel widgetPanel = new JPanel();
- private JButton addButton = new JButton("add");
- private JButton removeButton = new JButton("remove");
- private JButton clearButton = new JButton("clear");
- private JTextField stringField = new JTextField(30);
+ private JPanel widgetPanel; // = new JPanel();
+ private JButton addButton; // = new JButton("add");
+ private JButton removeButton; // = new JButton("remove");
+ private JButton clearButton; // = new JButton("clear");
+ private JTextField stringField; // = new JTextField(30);
private Set<String> value = new HashSet<String>();
- private JList stringList = new JList();
- private DefaultListModel listModel = new DefaultListModel();
+ private JList stringList; // = new JList();
+ private DefaultListModel listModel; // = new DefaultListModel();
- private CheckBoxList cBL = new CheckBoxList(this);
+ private CheckBoxList cBL; // = new CheckBoxList(this);
public WidgetPanelStringSet(Config config, Component component, StringSetConfigOption configOption) {
super(config, component, configOption);
@@ -86,6 +85,7 @@
Set<String> exampleSet = new HashSet<String>();
// add to list
if (e.getSource() == addButton && !listModel.contains(stringField.getText())) {
+ System.out.println("add event");
listModel.addElement(stringField.getText());
}
// remove selection
@@ -108,41 +108,12 @@
}
// set entry
value = exampleSet;
- setEntry();
+// setEntry();
+ fireValueChanged(value);
}
}
/**
- * Use this, to set entry for layout 2.
- */
- /*
- public void specialSet() {
- if (isSpecial()) {
- this.value = cBL.getSelections();
- setEntry();
- }
- }*/
-
- public void setEntry() {
- StringSetConfigOption specialOption;
- specialOption = (StringSetConfigOption) config.getComponentManager().getConfigOption(
- component.getClass(), configOption.getName());
- if (specialOption.isValidValue(value)) {
- try {
- ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>(specialOption,
- value);
- config.getComponentManager().applyConfigEntry(component, specialEntry);
- // System.out.println("set StringSet: " + configOption.getName()
- // + " = " + value);
- } catch (InvalidConfigOptionValueException s) {
- s.printStackTrace();
- }
- } else
- System.out.println("StringSet: not valid value");
-
- }
-
- /**
* Define GridBagConstraints
*/
private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx,
@@ -183,7 +154,7 @@
listModel = new DefaultListModel();
// fill list
if (value != null) {
- setEntry();
+// setEntry();
for (Iterator<String> iterator = value.iterator(); iterator.hasNext();) {
String item = iterator.next();
listModel.addElement(item);
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringTupleList.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringTupleList.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringTupleList.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -39,8 +39,6 @@
import javax.swing.JTextField;
import org.dllearner.core.Component;
-import org.dllearner.core.config.ConfigEntry;
-import org.dllearner.core.config.InvalidConfigOptionValueException;
import org.dllearner.core.config.StringTupleListConfigOption;
import org.dllearner.gui.Config;
import org.dllearner.utilities.datastructures.StringTuple;
@@ -58,19 +56,19 @@
private GridBagLayout gridbag = new GridBagLayout();
private GridBagConstraints constraints = new GridBagConstraints();
- private JPanel widgetPanel = new JPanel();
- private JButton addButton = new JButton("add");
- private JButton removeButton = new JButton("remove");
- private JButton clearButton = new JButton("clear");
- private JTextField stringFieldA = new JTextField(10);
- private JTextField stringFieldB = new JTextField(10);
- private List<StringTuple> exampleList = new LinkedList<StringTuple>();
+ private JPanel widgetPanel; // = new JPanel();
+ private JButton addButton; // = new JButton("add");
+ private JButton removeButton; // = new JButton("remove");
+ private JButton clearButton; // = new JButton("clear");
+ private JTextField stringFieldA; // = new JTextField(10);
+ private JTextField stringFieldB; // = new JTextField(10);
+ private List<StringTuple> exampleList; // = new LinkedList<StringTuple>();
- private List<StringTuple> value = new LinkedList<StringTuple>();
- private JList stringList = new JList();
- private DefaultListModel listModel = new DefaultListModel();
+ private List<StringTuple> value; // = new LinkedList<StringTuple>();
+ private JList stringList; // = new JList();
+ private DefaultListModel listModel; // = new DefaultListModel();
- private JButton setButton = new JButton("set");
+ private JButton setButton; // = new JButton("set");
public WidgetPanelStringTupleList(Config config, Component component, StringTupleListConfigOption configOption) {
super(config, component, configOption);
@@ -102,9 +100,11 @@
}
// set entry
value = exampleList;
- setEntry();
+// setEntry();
+ fireValueChanged(value);
}
+ /*
public void setEntry() {
StringTupleListConfigOption specialOption;
specialOption = (StringTupleListConfigOption) config.getComponentManager().getConfigOption(
@@ -121,7 +121,7 @@
}
} else
System.out.println("StringTupleList: not valid value");
- }
+ }*/
/**
* Define GridBagConstraints
@@ -162,7 +162,7 @@
value = config.getConfigOptionValue(component, configOption);
if (value != null) {
- setEntry();
+// setEntry();
exampleList = value;
}
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java 2008-09-15 11:53:03 UTC (rev 1211)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java 2008-09-15 13:17:51 UTC (rev 1212)
@@ -113,14 +113,18 @@
setButton = new JButton("Set");
setButton.addActionListener(this);
- chooseLocalButton = new JButton("Choose Local File");
- chooseLocalButton.addActionListener(this);
-
add(stringField);
- add(setButton);
- add(new JLabel(" or "));
- add(chooseLocalButton);
+ add(setButton);
+ // if the URL can refer to a file, we add the possibility to
+ // choose a local file
+ if(((URLConfigOption)configOption).refersToFile()) {
+ chooseLocalButton = new JButton("Choose Local File");
+ chooseLocalButton.addActionListener(this);
+ add(new JLabel(" or "));
+ add(chooseLocalButton);
+ }
+
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sk...@us...> - 2008-09-16 00:08:40
|
Revision: 1215
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1215&view=rev
Author: sknappe
Date: 2008-09-16 07:08:33 +0000 (Tue, 16 Sep 2008)
Log Message:
-----------
Changed the Evaluated Description, so that the NaturalDescription is not automatically generated with it, instead a seperate webservice is now used to generate it.
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java
trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java
trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java
Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-15 17:28:02 UTC (rev 1214)
+++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-16 07:08:33 UTC (rev 1215)
@@ -23,6 +23,7 @@
import org.dllearner.core.owl.Description;
import org.dllearner.core.owl.Individual;
+import org.dllearner.kb.sparql.NaturalLanguageDescriptionConvertVisitor;
import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor;
import org.dllearner.learningproblems.ScoreTwoValued;
import org.dllearner.reasoning.OWLAPIDescriptionConvertVisitor;
@@ -162,12 +163,6 @@
return SparqlQueryDescriptionConvertVisitor.getSparqlQuery(description, limit);
}
- public String getNaturalDescription(){
- // TODO only works for DBpedia !! (no DBpedia SPARQL queries should be made to convert the description)
-// return NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(description);
- return "";
- }
-
/**
* This convenience method can be used to store and exchange evaluated
* descriptions by transforming them to a JSON string.
@@ -179,8 +174,8 @@
object.put("descriptionManchesterSyntax", description.toManchesterSyntaxString(null, null));
OWLDescription d = OWLAPIDescriptionConvertVisitor.getOWLDescription(description);
object.put("descriptionOWLXML", OWLAPIRenderers.toOWLXMLSyntax(d));
+ object.put("descriptionKBSyntax", description.toKBSyntaxString());
object.put("accuracy", score.getAccuracy());
- object.put("NaturalLanguage", getNaturalDescription());
object.put("coveredPositives", getJSONArray(score.getCoveredPositives()));
object.put("coveredNegatives", getJSONArray(score.getCoveredNegatives()));
object.put("notCoveredPositives", getJSONArray(score.getNotCoveredPositives()));
Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-09-15 17:28:02 UTC (rev 1214)
+++ trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-09-16 07:08:33 UTC (rev 1215)
@@ -68,7 +68,7 @@
return ret;
}
- public static String getSparqlQuery(String descriptionKBSyntax) throws ParseException
+ public static String getNaturalLanguageDescription(String descriptionKBSyntax) throws ParseException
{
Description d = KBParser.parseConcept(descriptionKBSyntax);
NaturalLanguageDescriptionConvertVisitor visitor=new NaturalLanguageDescriptionConvertVisitor();
@@ -98,7 +98,7 @@
s.add("NOT \"http://dbpedia.org/class/yago/Person100007846\"");
s.add("(\"http://dbpedia.org/class/yago/HeadOfState110164747\" AND (\"http://dbpedia.org/class/yago/Negotiator110351874\" AND \"http://dbpedia.org/class/yago/Representative110522035\"))");
for (String kbsyntax : s) {
- result.put(kbsyntax,NaturalLanguageDescriptionConvertVisitor.getSparqlQuery(kbsyntax));
+ result.put(kbsyntax,NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(kbsyntax));
}
System.out.println("************************");
for (String string : result.keySet()) {
Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-09-15 17:28:02 UTC (rev 1214)
+++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-09-16 07:08:33 UTC (rev 1215)
@@ -61,6 +61,7 @@
import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.kb.OWLFile;
import org.dllearner.kb.sparql.Cache;
+import org.dllearner.kb.sparql.NaturalLanguageDescriptionConvertVisitor;
import org.dllearner.kb.sparql.SPARQLTasks;
import org.dllearner.kb.sparql.SparqlKnowledgeSource;
import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor;
@@ -707,6 +708,12 @@
}
@WebMethod
+ public String getNaturalDescription(String conceptString) throws ParseException {
+ // call parser to parse concept
+ return NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(conceptString);
+ }
+
+ @WebMethod
public String[] getNegativeExamples(int sessionID, int componentID,String[] positives, int results, String namespace) throws ClientNotKnownException
{
int sparqlResultSetLimit = 500;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-16 23:20:55
|
Revision: 1223
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1223&view=rev
Author: jenslehmann
Date: 2008-09-17 06:20:53 +0000 (Wed, 17 Sep 2008)
Log Message:
-----------
changed learning algorithm call in Prot?\195?\169g?\195?\169 plugin
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java
trunk/src/dl-learner/org/dllearner/test/ComponentTest.java
trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java
trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java
Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-17 05:30:32 UTC (rev 1222)
+++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-17 06:20:53 UTC (rev 1223)
@@ -247,6 +247,9 @@
}
if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed.getDescription())) {
+ // before we add the description we replace EXISTS r.TOP with
+ // EXISTS r.range(r) if range(r) is atomic
+// ConceptTransformation.replaceRange(ed.getDescription(), reasoningService);
returnList.add(ed);
}
Modified: trunk/src/dl-learner/org/dllearner/test/ComponentTest.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/test/ComponentTest.java 2008-09-17 05:30:32 UTC (rev 1222)
+++ trunk/src/dl-learner/org/dllearner/test/ComponentTest.java 2008-09-17 06:20:53 UTC (rev 1223)
@@ -98,7 +98,7 @@
// start the algorithm and print the best concept found
la.start();
- System.out.println(la.getCurrentlyBestEvaluatedDescriptions());
+ System.out.println(la.getCurrentlyBestEvaluatedDescriptions(10, 0.8, true));
}
}
Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-09-17 05:30:32 UTC (rev 1222)
+++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-09-17 06:20:53 UTC (rev 1223)
@@ -112,7 +112,9 @@
// This is the count of Concepts which you get after learning
- private static final int ANZAHL = 6;
+ // TODO make those configurable via user interface
+ private static final int nrOfDisplayedDescriptions = 6;
+ private static final double minAccuracy = 0.8;
// A Array of Concepts which the DL-Learner suggested
@@ -205,7 +207,7 @@
// This is a List of evaluated descriptions to get more information of the
// suggested concept
- private List<EvaluatedDescription> evalDescription;
+ private List<EvaluatedDescription> evalDescriptions;
/**
* This is the constructor for DL-Learner model.
@@ -263,10 +265,9 @@
* This method adds the solutions from the DL-Learner to the List Model.
*/
private void addToListModel() {
- evalDescription = la.getCurrentlyBestEvaluatedDescriptions(ANZAHL);
- for (int j = 0; j < la.getCurrentlyBestEvaluatedDescriptions(ANZAHL).size(); j++) {
- suggestModel.add(j, la
- .getCurrentlyBestEvaluatedDescriptions(ANZAHL).get(j)
+ evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(nrOfDisplayedDescriptions, minAccuracy, true);
+ for (int j = 0; j < evalDescriptions.size(); j++) {
+ suggestModel.add(j, evalDescriptions.get(j)
.getDescription().toManchesterSyntaxString(
editor.getOWLModelManager().getActiveOntology()
.getURI().toString()
@@ -317,7 +318,7 @@
* @return list of evaluated descriptions
*/
public List<EvaluatedDescription> getEvaluatedDescriptionList() {
- return evalDescription;
+ return evalDescriptions;
}
/**
@@ -403,7 +404,7 @@
// start the algorithm and print the best concept found
la.start();
description = new Description[la.getCurrentlyBestEvaluatedDescriptions(
- ANZAHL).size()];
+ nrOfDisplayedDescriptions).size()];
addToListModel();
// renders the errormessage
view.renderErrorMessage(error);
Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2008-09-17 05:30:32 UTC (rev 1222)
+++ trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2008-09-17 06:20:53 UTC (rev 1223)
@@ -28,10 +28,12 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import org.dllearner.core.ReasoningService;
import org.dllearner.core.owl.ObjectAllRestriction;
import org.dllearner.core.owl.NamedClass;
import org.dllearner.core.owl.Nothing;
import org.dllearner.core.owl.Description;
+import org.dllearner.core.owl.ObjectProperty;
import org.dllearner.core.owl.ObjectSomeRestriction;
import org.dllearner.core.owl.Intersection;
import org.dllearner.core.owl.Union;
@@ -443,4 +445,22 @@
return false;
}
+ // replaces EXISTS hasChild.TOP with EXISTS hasChild.Person,
+ // i.e. TOP is replaced by the range of the property;
+ // this is semantically equivalent, but easier to read for some people
+ public static void replaceRange(Description description, ReasoningService rs) {
+ if(description instanceof ObjectSomeRestriction && description.getChild(0) instanceof Thing) {
+ ObjectPropertyExpression p = ((ObjectSomeRestriction)description).getRole();
+ if(p instanceof ObjectProperty) {
+ // replace TOP with range of propery
+ description.removeChild(description.getChild(0));
+ description.addChild(rs.getRange((ObjectProperty)p));
+ }
+ }
+
+ for(Description child : description.getChildren()) {
+ replaceRange(child, rs);
+ }
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-22 08:04:53
|
Revision: 1235
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1235&view=rev
Author: jenslehmann
Date: 2008-09-22 08:04:33 +0000 (Mon, 22 Sep 2008)
Log Message:
-----------
- GUI fixes
- added maxClassDescriptionTests as option to ExampleBasedROLComponent
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java
trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java
trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java
trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java
trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java
trunk/src/dl-learner/org/dllearner/gui/Config.java
trunk/src/dl-learner/org/dllearner/gui/RunPanel.java
trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java
Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -134,6 +134,7 @@
private int maxExecutionTimeInSeconds = CommonConfigOptions.maxExecutionTimeInSecondsDefault;
private int minExecutionTimeInSeconds = CommonConfigOptions.minExecutionTimeInSecondsDefault;
private int guaranteeXgoodDescriptions = CommonConfigOptions.guaranteeXgoodDescriptionsDefault;
+ private int maxClassDescriptionTests = CommonConfigOptions.maxClassDescriptionTestsDefault;
// Variablen zur Einstellung der Protokollierung
// boolean quiet = false;
@@ -196,6 +197,7 @@
options.add(CommonConfigOptions.maxExecutionTimeInSeconds());
options.add(CommonConfigOptions.minExecutionTimeInSeconds());
options.add(CommonConfigOptions.guaranteeXgoodDescriptions());
+ options.add(CommonConfigOptions.maxClassDescriptionTests());
options.add(CommonConfigOptions.getLogLevel());
options.add(new BooleanConfigOption("usePropernessChecks", "specifies whether to check for equivalence (i.e. discard equivalent refinements)",usePropernessChecksDefault));
options.add(new IntegerConfigOption("maxPosOnlyExpansion", "specifies how often a node in the search tree of a posonly learning problem needs to be expanded before it is" +
@@ -274,6 +276,8 @@
minExecutionTimeInSeconds = (Integer) entry.getValue();
}else if(name.equals("guaranteeXgoodDescriptions")) {
guaranteeXgoodDescriptions = (Integer) entry.getValue();
+ } else if(name.equals("maxClassDescriptionTests")) {
+ maxClassDescriptionTests = (Integer) entry.getValue();
} else if(name.equals("logLevel")) {
logLevel = ((String)entry.getValue()).toUpperCase();
} else if(name.equals("forceRefinementLengthIncrease")) {
@@ -390,6 +394,7 @@
maxExecutionTimeInSeconds,
minExecutionTimeInSeconds,
guaranteeXgoodDescriptions,
+ maxClassDescriptionTests,
forceRefinementLengthIncrease
);
// note: used concepts and roles do not need to be passed
Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -119,6 +119,7 @@
private boolean minExecutionTimeShown = false;
private int guaranteeXgoodDescriptions = 1;
private boolean guaranteeXgoodShown = false;
+ private int maxClassDescriptionTests;
// if set to false we do not test properness; this may seem wrong
// but the disadvantage of properness testing are additional reasoner
@@ -242,7 +243,7 @@
boolean useTooWeakList, boolean useOverlyGeneralList,
boolean useShortConceptConstruction, boolean usePropernessChecks,
int maxPosOnlyExpansion, int maxExecutionTimeInSeconds, int minExecutionTimeInSeconds,
- int guaranteeXgoodDescriptions, boolean forceRefinementLengthIncrease) {
+ int guaranteeXgoodDescriptions, int maxClassDescriptionTests, boolean forceRefinementLengthIncrease) {
if (learningProblem instanceof PosNegLP) {
PosNegLP lp = (PosNegLP) learningProblem;
@@ -287,6 +288,7 @@
this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
this.minExecutionTimeInSeconds = minExecutionTimeInSeconds;
this.guaranteeXgoodDescriptions = guaranteeXgoodDescriptions;
+ this.maxClassDescriptionTests = maxClassDescriptionTests;
this.forceRefinementLengthIncrease = forceRefinementLengthIncrease;
// logger.setLevel(Level.DEBUG);
@@ -296,6 +298,29 @@
stop = false;
isRunning = true;
runtime = System.currentTimeMillis();
+
+ // reset values (algorithms may be started several times)
+ candidates.clear();
+ candidatesStable.clear();
+ newCandidates.clear();
+ solutionFound = false;
+ solutions.clear();
+ maxExecutionTimeShown = false;
+ minExecutionTimeShown = false;
+ guaranteeXgoodShown = false;
+ propernessTestsReasoner = 0;
+ propernessTestsAvoidedByShortConceptConstruction = 0;
+ propernessTestsAvoidedByTooWeakList = 0;
+ conceptTestsTooWeakList = 0;
+ conceptTestsOverlyGeneralList = 0;
+ propernessCalcTimeNs = 0;
+ propernessCalcReasoningTimeNs = 0;
+ childConceptsDeletionTimeNs = 0;
+ refinementCalcTimeNs = 0;
+ redundancyCheckTimeNs = 0;
+ evaluateSetCreationTimeNs = 0;
+ improperConceptsRemovalTimeNs = 0;
+
Monitor totalLearningTime = JamonMonitorLogger.getTimeMonitor(ExampleBasedROLComponent.class, "totalLearningTime")
.start();
// TODO: write a JUnit test for this problem (long-lasting or infinite
@@ -1327,6 +1352,10 @@
if (solutions.size() > 0)
solutionFound = true;
}
+ if(!solutionFound && maxClassDescriptionTests != 0) {
+ int conceptTests = conceptTestsReasoner + conceptTestsTooWeakList + conceptTestsOverlyGeneralList;
+ solutionFound = (conceptTests >= maxClassDescriptionTests);
+ }
}
private boolean guaranteeXgoodDescriptions() {
Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -83,6 +83,15 @@
}
/**
+ * Used for rewriting (simplification, beautification) of
+ * evaluated descriptions returned by the learning algorithm.
+ * @param description The description to set.
+ */
+ public void setDescription(Description description) {
+ this.description = description;
+ }
+
+ /**
* @see org.dllearner.core.owl.Description#getLength()
* @return Length of the description.
*/
@@ -202,4 +211,5 @@
}
return j;
}
+
}
Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -249,7 +249,13 @@
if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed.getDescription())) {
// before we add the description we replace EXISTS r.TOP with
// EXISTS r.range(r) if range(r) is atomic
- ConceptTransformation.replaceRange(ed.getDescription(), reasoningService);
+ // (we need to clone, otherwise we change descriptions which could
+ // be in the search of the learning algorith, which leads to
+ // unpredictable behaviour)
+ Description d = ed.getDescription().clone();
+ ConceptTransformation.replaceRange(d, reasoningService);
+ ed.setDescription(d);
+
returnList.add(ed);
}
Modified: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -47,6 +47,7 @@
public static int maxExecutionTimeInSecondsDefault = 0;
public static int minExecutionTimeInSecondsDefault = 0;
public static int guaranteeXgoodDescriptionsDefault = 1;
+ public static int maxClassDescriptionTestsDefault = 0;
public static String logLevelDefault = "DEBUG";
//public static double noisePercentageDefault = 0.0;
@@ -128,6 +129,11 @@
return new IntegerConfigOption("guaranteeXgoodDescriptions", "algorithm will run until X good (100%) concept descritpions are found",guaranteeXgoodDescriptionsDefault);
}
+ public static IntegerConfigOption maxClassDescriptionTests() {
+ return new IntegerConfigOption("maxClassDescriptionTests", "The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. " +
+ "(The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.)",maxClassDescriptionTestsDefault);
+ }
+
public static StringConfigOption getLogLevel() {
return new StringConfigOption("logLevel", "determines the logLevel for this component, can be {TRACE, DEBUG, INFO}",logLevelDefault);
}
Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -194,6 +194,10 @@
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
+ needsInit[0] = true;
+ needsInit[1] = true;
+ needsInit[2] = true;
+ needsInit[3] = true;
return source;
}
@@ -236,6 +240,9 @@
rs = cm.reasoningService(reasoner);
lp.changeReasoningService(rs);
la.changeReasoningService(rs);
+ needsInit[1] = true;
+ needsInit[2] = true;
+ needsInit[3] = true;
return reasoner;
}
@@ -276,6 +283,8 @@
public LearningProblem changeLearningProblem(Class<? extends LearningProblem> clazz) {
lp = cm.learningProblem(clazz, rs);
la.changeLearningProblem(lp);
+ needsInit[2] = true;
+ needsInit[3] = true;
return lp;
}
@@ -313,6 +322,7 @@
public LearningAlgorithm changeLearningAlgorithm(Class<? extends LearningAlgorithm> clazz)
throws LearningProblemUnsupportedException {
la = cm.learningAlgorithm(clazz, lp, rs);
+ needsInit[3] = true;
return la;
}
Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -66,7 +66,7 @@
private Config config;
private StartGUI startGUI;
- private long algorithmStartTime = 0;
+// private long algorithmStartTime = 0;
private GridBagLayout gridbag = new GridBagLayout();
private GridBagConstraints constraints = new GridBagConstraints();
@@ -86,8 +86,53 @@
private JLabel[] time = new JLabel[5];
private JLabel[] percent = new JLabel[5];
-
+ private class AlgorithmThread extends Thread {
+ private long startTime;
+ private long endTime;
+
+ @Override
+ public void run() {
+ startTime = System.nanoTime();
+// setPriority(Thread.MIN_PRIORITY);
+ config.getLearningAlgorithm().start();
+ endTime = System.nanoTime();
+ }
+
+ public long getRuntimeNanos() {
+ if(isAlive()) {
+ System.out.println("ALIVE");
+ return System.nanoTime() - startTime;
+ } else {
+ System.out.println("NOT ALIVE");
+ return endTime - startTime;
+ }
+ }
+ }
+ AlgorithmThread algorithmThread;
+ // separate thread for learning algorithm
+// Thread algorithmThread = new Thread() {
+//
+// private long startTime;
+// private long endTime;
+//
+// @Override
+// public void run() {
+// startTime = System.nanoTime();
+//// setPriority(Thread.MIN_PRIORITY);
+// config.getLearningAlgorithm().start();
+// endTime = System.nanoTime();
+// }
+//
+// public long getRuntimeNanos() {
+// if(isAlive()) {
+// return System.nanoTime() - startTime;
+// } else {
+// return endTime - startTime;
+// }
+// }
+// };
+
RunPanel(Config config, StartGUI startGUI) {
super(new BorderLayout());
@@ -172,19 +217,11 @@
public void actionPerformed(ActionEvent e) {
// start
if (e.getSource() == runButton) {
-
- // separate thread for learning algorithm
- Thread algorithmThread = new Thread() {
- @Override
- public void run() {
- setPriority(Thread.MIN_PRIORITY);
- config.getLearningAlgorithm().start();
- }
- };
-
+ algorithmThread = new AlgorithmThread();
config.getReasoningService().resetStatistics();
algorithmThread.start();
- algorithmStartTime = System.nanoTime();
+// algorithmStartTime = System.nanoTime();
+// algorithmThread.
StatisticsThread threadStatistics = new StatisticsThread(config, this);
threadStatistics.start();
runButton.setEnabled(false);
@@ -230,8 +267,9 @@
// + config.getLearningAlgorithm().getSolutionScore().toString()
// + "\n\n");
- // update algorith runtime
- long algorithmRunTime = System.nanoTime() - algorithmStartTime;
+ // update algorithm runtime
+// long algorithmRunTime = System.nanoTime() - algorithmStartTime;
+ long algorithmRunTime = algorithmThread.getRuntimeNanos();
bar[0].update(1.0);
time[0].setText(makeTime(algorithmRunTime));
percent[0].setText("100%");
Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -253,7 +253,7 @@
Logger rootLogger = Logger.getRootLogger();
rootLogger.removeAllAppenders();
rootLogger.addAppender(consoleAppender);
- rootLogger.setLevel(Level.DEBUG);
+ rootLogger.setLevel(Level.TRACE);
File file = null;
if (args.length > 0)
@@ -308,10 +308,17 @@
}
});
if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
- logger.info("Saving current configuration to " + fc.getSelectedFile() + ".");
+ File file = fc.getSelectedFile();
+ // returns name without path to it
+ String name= file.getName();
+ // if there is no extension, we append .conf
+ if(!name.contains(".")) {
+ file = new File(file.getAbsolutePath() + ".conf");
+ }
+ logger.info("Saving current configuration to " + file + ".");
ConfigSave save = new ConfigSave(config);
try {
- save.saveFile(fc.getSelectedFile());
+ save.saveFile(file);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Modified: trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -49,7 +49,7 @@
while (config.getLearningAlgorithm().isRunning()) {
// update statistics every 3 seconds
runPanel.showStats();
- sleep(3000);
+ sleep(2000);
}
// show final stats
runPanel.showStats();
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java 2008-09-21 12:50:24 UTC (rev 1234)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java 2008-09-22 08:04:33 UTC (rev 1235)
@@ -71,7 +71,7 @@
// set cb-index
String[] kbBoxItems = { "true", "false" };
cb = new JComboBox(kbBoxItems);
- if (!value) {
+ if (value) {
cb.setSelectedIndex(0);
} else {
cb.setSelectedIndex(1);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-22 14:51:04
|
Revision: 1236
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1236&view=rev
Author: jenslehmann
Date: 2008-09-22 14:50:35 +0000 (Mon, 22 Sep 2008)
Log Message:
-----------
- code improvements
- string options with a fixed set of possible values now shown as combo boxes in GUI
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java
trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java
trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java
trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java
Modified: trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2007, Jens Lehmann
+ * Copyright (C) 2007-2008, Jens Lehmann
*
* This file is part of DL-Learner.
*
@@ -21,27 +21,27 @@
/**
+ * A configuration option representing a boolean value.
+ *
* @author Jens Lehmann
*
*/
public class BooleanConfigOption extends ConfigOption<Boolean> {
-
-
- public BooleanConfigOption(String name, String description, Boolean defaultValue, boolean mandatory, boolean requiresInit) {
- super(name, description, defaultValue, mandatory, requiresInit);
+ public BooleanConfigOption(String name, String description) {
+ super(name, description);
}
-
+
public BooleanConfigOption(String name, String description, Boolean defaultValue) {
super(name, description, defaultValue);
- }
-
- public BooleanConfigOption(String name, String description) {
- super(name, description);
+ }
+
+ public BooleanConfigOption(String name, String description, Boolean defaultValue, boolean mandatory, boolean requiresInit) {
+ super(name, description, defaultValue, mandatory, requiresInit);
- }
+ }
/* (non-Javadoc)
* @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString()
Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -102,10 +102,18 @@
this.requiresInit = requiresInit;
}
+ /**
+ *
+ * @return The name of this option.
+ */
public String getName() {
return name;
}
+ /**
+ *
+ * @return The textual description of this option.
+ */
public String getDescription() {
return description;
}
@@ -125,16 +133,20 @@
}
/**
- * says, if this option is mandatory for the component
- * @return
+ * Specifies whether this option is mandatory for the component.
+ * (Mandatory means that this component cannot be initialised
+ * without setting a value for this option.)
+ * @return True if option is mandatory for component, false otherwise.
*/
public boolean isMandatory() {
return mandatory;
}
/**
- * says, if this option requires that the componnent is reinitialized with init()
- * @return
+ * Specifies whether setting this option requires that the
+ * component or any components depending on this component
+ * need to be (re-)initialised.
+ * @return True if option requires init, false otherwise.
*/
public boolean requiresInit() {
return requiresInit;
@@ -161,6 +173,13 @@
*/
public abstract boolean checkType(Object object);
+ /**
+ * Checks whether the value is valid, e.g. passing 1985 as
+ * integer value for an option, which requires values between
+ * 0 and 1, is not valid.
+ * @param value A value for the option.
+ * @return True if the value is valid and false otherwise.
+ */
public abstract boolean isValidValue(T value);
public abstract String getValueTypeAsJavaString();
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
@@ -42,7 +42,6 @@
import org.dllearner.learningproblems.PosNegInclusionLP;
import org.dllearner.learningproblems.PosOnlyDefinitionLP;
import org.dllearner.learningproblems.PosOnlyInclusionLP;
-import org.dllearner.learningproblems.RoleLearning;
import org.dllearner.reasoning.DIGReasoner;
import org.dllearner.reasoning.FastInstanceChecker;
import org.dllearner.reasoning.FastRetrievalReasoner;
@@ -57,11 +56,10 @@
private ComponentFactory(){}
/**
-* @param filename pointer to the KB file on local file system
* @return a component ready for initialization KBFile
**/
-public static KBFile getKBFile(String filename) {
-return KBFileConfigurator.getKBFile(filename);
+public static KBFile getKBFile() {
+return KBFileConfigurator.getKBFile();
}
/**
@@ -169,16 +167,6 @@
}
/**
-* @param positiveExamples positive examples
-* @param negativeExamples negative examples
-* @param reasoningService see ReasoningService
-* @return a component ready for initialization RoleLearning
-**/
-public static RoleLearning getRoleLearning(ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) {
-return RoleLearningConfigurator.getRoleLearning(reasoningService, positiveExamples, negativeExamples);
-}
-
-/**
* @param learningProblem see LearningProblem
* @param reasoningService see ReasoningService
* @throws LearningProblemUnsupportedException see
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
@@ -294,6 +294,15 @@
public String getStartClass() {
return (String) ComponentManager.getInstance().getConfigOptionValue(dBpediaNavigationSuggestor, "startClass") ;
}
+/**
+* forceRefinementLengthIncrease specifies whether nodes should be expanded until only longer refinements are reached.
+* mandatory: false| reinit necessary: true
+* default value: null
+* @return boolean
+**/
+public boolean getForceRefinementLengthIncrease() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(dBpediaNavigationSuggestor, "forceRefinementLengthIncrease") ;
+}
/**
* @param writeSearchTree specifies whether to write a search tree.
@@ -529,6 +538,15 @@
ComponentManager.getInstance().applyConfigEntry(dBpediaNavigationSuggestor, "startClass", startClass);
reinitNecessary = true;
}
+/**
+* @param forceRefinementLengthIncrease specifies whether nodes should be expanded until only longer refinements are reached.
+* mandatory: false| reinit necessary: true
+* default value: null
+**/
+public void setForceRefinementLengthIncrease(boolean forceRefinementLengthIncrease) {
+ComponentManager.getInstance().applyConfigEntry(dBpediaNavigationSuggestor, "forceRefinementLengthIncrease", forceRefinementLengthIncrease);
+reinitNecessary = true;
+}
/**
* true, if this component needs reinitializsation.
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
@@ -277,6 +277,15 @@
return (Integer) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "guaranteeXgoodDescriptions") ;
}
/**
+* maxClassDescriptionTests The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. (The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.).
+* mandatory: false| reinit necessary: true
+* default value: 0
+* @return int
+**/
+public int getMaxClassDescriptionTests() {
+return (Integer) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "maxClassDescriptionTests") ;
+}
+/**
* logLevel determines the logLevel for this component, can be {TRACE, DEBUG, INFO}.
* mandatory: false| reinit necessary: true
* default value: DEBUG
@@ -321,6 +330,15 @@
public String getStartClass() {
return (String) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "startClass") ;
}
+/**
+* forceRefinementLengthIncrease specifies whether nodes should be expanded until only longer refinements are reached.
+* mandatory: false| reinit necessary: true
+* default value: null
+* @return boolean
+**/
+public boolean getForceRefinementLengthIncrease() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "forceRefinementLengthIncrease") ;
+}
/**
* @param writeSearchTree specifies whether to write a search tree.
@@ -539,6 +557,15 @@
reinitNecessary = true;
}
/**
+* @param maxClassDescriptionTests The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. (The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.).
+* mandatory: false| reinit necessary: true
+* default value: 0
+**/
+public void setMaxClassDescriptionTests(int maxClassDescriptionTests) {
+ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "maxClassDescriptionTests", maxClassDescriptionTests);
+reinitNecessary = true;
+}
+/**
* @param logLevel determines the logLevel for this component, can be {TRACE, DEBUG, INFO}.
* mandatory: false| reinit necessary: true
* default value: DEBUG
@@ -583,6 +610,15 @@
ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "startClass", startClass);
reinitNecessary = true;
}
+/**
+* @param forceRefinementLengthIncrease specifies whether nodes should be expanded until only longer refinements are reached.
+* mandatory: false| reinit necessary: true
+* default value: null
+**/
+public void setForceRefinementLengthIncrease(boolean forceRefinementLengthIncrease) {
+ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "forceRefinementLengthIncrease", forceRefinementLengthIncrease);
+reinitNecessary = true;
+}
/**
* true, if this component needs reinitializsation.
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
@@ -61,6 +61,15 @@
public String getReasonerType() {
return (String) ComponentManager.getInstance().getConfigOptionValue(fastInstanceChecker, "reasonerType") ;
}
+/**
+* defaultNegation Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class..
+* mandatory: false| reinit necessary: true
+* default value: true
+* @return boolean
+**/
+public boolean getDefaultNegation() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fastInstanceChecker, "defaultNegation") ;
+}
/**
* @param reasonerType FaCT++ or Pellet to dematerialize.
@@ -71,6 +80,15 @@
ComponentManager.getInstance().applyConfigEntry(fastInstanceChecker, "reasonerType", reasonerType);
reinitNecessary = true;
}
+/**
+* @param defaultNegation Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class..
+* mandatory: false| reinit necessary: true
+* default value: true
+**/
+public void setDefaultNegation(boolean defaultNegation) {
+ComponentManager.getInstance().applyConfigEntry(fastInstanceChecker, "defaultNegation", defaultNegation);
+reinitNecessary = true;
+}
/**
* true, if this component needs reinitializsation.
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
@@ -43,25 +43,14 @@
}
/**
-* @param filename pointer to the KB file on local file system
* @return KBFile
**/
-public static KBFile getKBFile(String filename) {
+public static KBFile getKBFile() {
KBFile component = ComponentManager.getInstance().knowledgeSource(KBFile.class);
-ComponentManager.getInstance().applyConfigEntry(component, "filename", filename);
return component;
}
/**
-* filename pointer to the KB file on local file system.
-* mandatory: true| reinit necessary: true
-* default value: null
-* @return String
-**/
-public String getFilename() {
-return (String) ComponentManager.getInstance().getConfigOptionValue(kBFile, "filename") ;
-}
-/**
* url URL pointer to the KB file.
* mandatory: false| reinit necessary: true
* default value: null
@@ -72,15 +61,6 @@
}
/**
-* @param filename pointer to the KB file on local file system.
-* mandatory: true| reinit necessary: true
-* default value: null
-**/
-public void setFilename(String filename) {
-ComponentManager.getInstance().applyConfigEntry(kBFile, "filename", filename);
-reinitNecessary = true;
-}
-/**
* @param url URL pointer to the KB file.
* mandatory: false| reinit necessary: true
* default value: null
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -23,6 +23,7 @@
import java.awt.event.ActionListener;
import javax.swing.JButton;
+import javax.swing.JComboBox;
import javax.swing.JTextField;
import org.dllearner.core.Component;
@@ -45,6 +46,7 @@
private String value;
private JTextField stringField;
+ private JComboBox comboBox;
/**
* Provides a widget for string options.
@@ -62,6 +64,9 @@
// fire value changed event
value = stringField.getText();
fireValueChanged(value);
+ } else if(e.getSource() == comboBox) {
+ value = (String) comboBox.getSelectedItem();
+ fireValueChanged(value);
}
}
@@ -76,18 +81,30 @@
value = "";
}
- // text field for strings
- stringField = new JTextField(35);
- stringField.setText(value);
- stringField.setToolTipText(configOption.getAllowedValuesDescription());
-
- // set button (value is only updated when this button is pressed =>
- // would better without set)
- setButton = new JButton("Set");
- setButton.addActionListener(this);
-
- add(stringField);
- add(setButton);
+ StringConfigOption option = (StringConfigOption) configOption;
+ if(option.getAllowedValues().size() == 0) {
+
+ // text field for strings
+ stringField = new JTextField(35);
+ stringField.setText(value);
+ stringField.setToolTipText(configOption.getAllowedValuesDescription());
+
+ // set button (value is only updated when this button is pressed =>
+ // would better without set)
+ setButton = new JButton("Set");
+ setButton.addActionListener(this);
+
+ add(stringField);
+ add(setButton);
+
+ // if there is a fixed set of strings available as options, we
+ // only offer those
+ } else {
+ comboBox = new JComboBox(option.getAllowedValues().toArray());
+ comboBox.setSelectedItem(option.getDefaultValue());
+ comboBox.addActionListener(this);
+ add(comboBox);
+ }
}
}
Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-22 08:04:33 UTC (rev 1235)
+++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-22 14:50:35 UTC (rev 1236)
@@ -35,6 +35,7 @@
import org.dllearner.core.KnowledgeSource;
import org.dllearner.core.ReasonerComponent;
import org.dllearner.core.ReasoningMethodUnsupportedException;
+import org.dllearner.core.config.BooleanConfigOption;
import org.dllearner.core.config.ConfigEntry;
import org.dllearner.core.config.ConfigOption;
import org.dllearner.core.config.InvalidConfigOptionValueException;
@@ -89,14 +90,15 @@
private static Logger logger = Logger.getLogger(FastInstanceChecker.class);
- private boolean defaultNegation = true;
-
+// private boolean defaultNegation = true;
+
private FastInstanceCheckerConfigurator configurator;
+
@Override
- public FastInstanceCheckerConfigurator getConfigurator (){
+ public FastInstanceCheckerConfigurator getConfigurator() {
return configurator;
}
-
+
private Set<NamedClass> atomicConcepts;
private Set<ObjectProperty> atomicRoles;
private SortedSet<DatatypeProperty> datatypeProperties;
@@ -105,7 +107,7 @@
private SortedSet<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>();
private SortedSet<Individual> individuals;
-// private ReasoningService rs;
+ // private ReasoningService rs;
private OWLAPIReasoner rc;
// we use sorted sets (map indices) here, because they have only log(n)
@@ -125,22 +127,30 @@
private Map<DatatypeProperty, Map<Individual, SortedSet<Double>>> dd = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Double>>>();
private Map<DatatypeProperty, Map<Individual, SortedSet<Integer>>> id = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Integer>>>();
+ /**
+ * Creates an instance of the fast instance checker.
+ * @param sources The knowledge sources used as input.
+ */
public FastInstanceChecker(Set<KnowledgeSource> sources) {
super(sources);
this.configurator = new FastInstanceCheckerConfigurator(this);
}
-
+ /**
+ * @return The options of this component.
+ */
public static Collection<ConfigOption<?>> createConfigOptions() {
Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>();
- StringConfigOption type = new StringConfigOption("reasonerType", "FaCT++ or Pellet to dematerialize", "pellet", false, true);
- type.setAllowedValues(new String[] {"fact", "pellet"});
+ StringConfigOption type = new StringConfigOption("reasonerType",
+ "FaCT++ or Pellet to dematerialize", "pellet", false, true);
+ type.setAllowedValues(new String[] { "fact", "pellet" });
// closure option? see:
// http://owlapi.svn.sourceforge.net/viewvc/owlapi/owl1_1/trunk/tutorial/src/main/java/uk/ac/manchester/owl/tutorial/examples/ClosureAxiomsExample.java?view=markup
options.add(type);
+ options.add(new BooleanConfigOption("defaultNegation", "Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class.", true, false, true));
return options;
- }
-
+ }
+
/*
* (non-Javadoc)
*
@@ -150,10 +160,12 @@
public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException {
}
+ /**
+ * @return The name of this component.
+ */
public static String getName() {
return "fast instance checker";
- }
-
+ }
/*
* (non-Javadoc)
@@ -162,7 +174,7 @@
*/
@Override
public void init() throws ComponentInitException {
- //rc = new OWLAPIReasoner(sources);
+ // rc = new OWLAPIReasoner(sources);
rc = ComponentFactory.getOWLAPIReasoner(sources);
rc.getConfigurator().setReasonerType(configurator.getReasonerType());
rc.init();
@@ -176,7 +188,7 @@
atomicRoles = rc.getAtomicRoles();
individuals = rc.getIndividuals();
-// rs = new ReasoningService(rc);
+ // rs = new ReasoningService(rc);
// TODO: some code taken from Helper.createFlatABox, but pasted here
// because additional things need to
@@ -185,46 +197,47 @@
long dematStartTime = System.currentTimeMillis();
logger.debug("dematerialising concepts");
-
- for (NamedClass atomicConcept : rc.getAtomicConcepts()) {
-
+
+ for (NamedClass atomicConcept : rc.getAtomicConcepts()) {
+
SortedSet<Individual> pos = rc.retrieval(atomicConcept);
classInstancesPos.put(atomicConcept, pos);
-
- if(defaultNegation) {
- classInstancesNeg.put(atomicConcept, Helper.difference(individuals,pos));
+
+ if (configurator.getDefaultNegation()) {
+ classInstancesNeg.put(atomicConcept, Helper.difference(individuals, pos));
} else {
- // Pellet needs approximately infinite time to answer negated queries
- // on the carcinogenesis data set (and probably others), so we have to
+ // Pellet needs approximately infinite time to answer
+ // negated queries
+ // on the carcinogenesis data set (and probably others), so
+ // we have to
// be careful here
Negation negatedAtomicConcept = new Negation(atomicConcept);
classInstancesNeg.put(atomicConcept, rc.retrieval(negatedAtomicConcept));
}
-
}
logger.debug("dematerialising object properties");
-
+
for (ObjectProperty atomicRole : atomicRoles) {
opPos.put(atomicRole, rc.getRoleMembers(atomicRole));
}
logger.debug("dematerialising datatype properties");
-
+
for (DatatypeProperty dp : booleanDatatypeProperties) {
bdPos.put(dp, rc.getTrueDatatypeMembers(dp));
bdNeg.put(dp, rc.getFalseDatatypeMembers(dp));
}
-
+
for (DatatypeProperty dp : intDatatypeProperties) {
id.put(dp, rc.getIntDatatypeMembers(dp));
- }
-
+ }
+
for (DatatypeProperty dp : doubleDatatypeProperties) {
dd.put(dp, rc.getDoubleDatatypeMembers(dp));
}
-
+
long dematDuration = System.currentTimeMillis() - dematStartTime;
logger.debug("TBox dematerialised in " + dematDuration + " ms");
@@ -237,9 +250,9 @@
@Override
public boolean instanceCheck(Description description, Individual individual)
throws ReasoningMethodUnsupportedException {
-
-// System.out.println(description + " " + individual);
-
+
+ // System.out.println(description + " " + individual);
+
if (description instanceof NamedClass) {
return classInstancesPos.get((NamedClass) description).contains(individual);
} else if (description instanceof Negation) {
@@ -260,8 +273,9 @@
// the union, we return true
List<Description> children = description.getChildren();
for (Description child : children) {
- if (instanceCheck(child, individual))
+ if (instanceCheck(child, individual)) {
return true;
+ }
}
return false;
} else if (description instanceof Intersection) {
@@ -269,59 +283,67 @@
// the union, we return true
List<Description> children = description.getChildren();
for (Description child : children) {
- if (!instanceCheck(child, individual))
+ if (!instanceCheck(child, individual)) {
return false;
+ }
}
return true;
} else if (description instanceof ObjectSomeRestriction) {
ObjectPropertyExpression ope = ((ObjectSomeRestriction) description).getRole();
- if (!(ope instanceof ObjectProperty))
+ if (!(ope instanceof ObjectProperty)) {
throw new ReasoningMethodUnsupportedException("Instance check for description "
+ description + " unsupported. Inverse object properties not supported.");
+ }
ObjectProperty op = (ObjectProperty) ope;
Description child = description.getChild(0);
Map<Individual, SortedSet<Individual>> mapping = opPos.get(op);
- ;
+
if (mapping == null) {
logger.warn("Instance check of a description with an undefinied property (" + op
+ ").");
return false;
}
SortedSet<Individual> roleFillers = opPos.get(op).get(individual);
- if (roleFillers == null)
+ if (roleFillers == null) {
return false;
+ }
for (Individual roleFiller : roleFillers) {
- if (instanceCheck(child, roleFiller))
+ if (instanceCheck(child, roleFiller)) {
return true;
+ }
}
return false;
} else if (description instanceof ObjectAllRestriction) {
ObjectPropertyExpression ope = ((ObjectAllRestriction) description).getRole();
- if (!(ope instanceof ObjectProperty))
+ if (!(ope instanceof ObjectProperty)) {
throw new ReasoningMethodUnsupportedException("Instance check for description "
+ description + " unsupported. Inverse object properties not supported.");
+ }
ObjectProperty op = (ObjectProperty) ope;
Description child = description.getChild(0);
Map<Individual, SortedSet<Individual>> mapping = opPos.get(op);
- ;
+
if (mapping == null) {
logger.warn("Instance check of a description with an undefinied property (" + op
+ ").");
return true;
}
SortedSet<Individual> roleFillers = opPos.get(op).get(individual);
- if (roleFillers == null)
+ if (roleFillers == null) {
return true;
+ }
for (Individual roleFiller : roleFillers) {
- if (!instanceCheck(child, roleFiller))
+ if (!instanceCheck(child, roleFiller)) {
return false;
+ }
}
return true;
} else if (description instanceof ObjectMinCardinalityRestriction) {
ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole();
- if (!(ope instanceof ObjectProperty))
+ if (!(ope instanceof ObjectProperty)) {
throw new ReasoningMethodUnsupportedException("Instance check for description "
+ description + " unsupported. Inverse object properties not supported.");
+ }
ObjectProperty op = (ObjectProperty) ope;
Description child = description.getChild(0);
Map<Individual, SortedSet<Individual>> mapping = opPos.get(op);
@@ -331,38 +353,44 @@
+ ").");
return true;
}
-
+
int number = ((ObjectCardinalityRestriction) description).getNumber();
- int nrOfFillers = 0;
-
+ int nrOfFillers = 0;
+
SortedSet<Individual> roleFillers = opPos.get(op).get(individual);
// special case: there are always at least zero fillers
- if(number == 0)
+ if (number == 0) {
return true;
+ }
// return false if there are none or not enough role fillers
- if (roleFillers == null || roleFillers.size() < number)
+ if (roleFillers == null || roleFillers.size() < number) {
return false;
-
+ }
+
int index = 0;
for (Individual roleFiller : roleFillers) {
index++;
if (instanceCheck(child, roleFiller)) {
nrOfFillers++;
- if(nrOfFillers == number)
+ if (nrOfFillers == number) {
return true;
- // earyl abort: e.g. >= 10 hasStructure.Methyl;
- // if there are 11 fillers and 2 are not Methyl, the result is false
+ }
+ // earyl abort: e.g. >= 10 hasStructure.Methyl;
+ // if there are 11 fillers and 2 are not Methyl, the result
+ // is false
} else {
- if(roleFillers.size() - index < number)
+ if (roleFillers.size() - index < number) {
return false;
+ }
}
}
return false;
} else if (description instanceof ObjectMaxCardinalityRestriction) {
ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole();
- if (!(ope instanceof ObjectProperty))
+ if (!(ope instanceof ObjectProperty)) {
throw new ReasoningMethodUnsupportedException("Instance check for description "
+ description + " unsupported. Inverse object properties not supported.");
+ }
ObjectProperty op = (ObjectProperty) ope;
Description child = description.getChild(0);
Map<Individual, SortedSet<Individual>> mapping = opPos.get(op);
@@ -372,38 +400,42 @@
+ ").");
return true;
}
-
+
int number = ((ObjectCardinalityRestriction) description).getNumber();
- int nrOfFillers = 0;
-
+ int nrOfFillers = 0;
+
SortedSet<Individual> roleFillers = opPos.get(op).get(individual);
// return true if there are none or not enough role fillers
- if (roleFillers == null || roleFillers.size() < number)
+ if (roleFillers == null || roleFillers.size() < number) {
return true;
-
-// System.out.println(description + " " + individual);
-
+ }
+
int index = 0;
for (Individual roleFiller : roleFillers) {
index++;
if (instanceCheck(child, roleFiller)) {
nrOfFillers++;
- if(nrOfFillers > number)
+ if (nrOfFillers > number) {
return false;
- // earyl abort: e.g. <= 5 hasStructure.Methyl;
- // if there are 6 fillers and 2 are not Methyl, the result is true
+ }
+ // early abort: e.g. <= 5 hasStructure.Methyl;
+ // if there are 6 fillers and 2 are not Methyl, the result
+ // is true
} else {
- if(roleFillers.size() - index <= number)
+ if (roleFillers.size() - index <= number) {
return true;
+ }
}
}
return true;
} else if (description instanceof BooleanValueRestriction) {
- DatatypeProperty dp = ((BooleanValueRestriction)description).getRestrictedPropertyExpresssion();
- boolean value = ((BooleanValueRestriction)description).getBooleanValue();
-
- if(value) {
- // check whether the individual is in the set of individuals mapped
+ DatatypeProperty dp = ((BooleanValueRestriction) description)
+ .getRestrictedPropertyExpresssion();
+ boolean value = ((BooleanValueRestriction) description).getBooleanValue();
+
+ if (value) {
+ // check whether the individual is in the set of individuals
+ // mapped
// to true by this datatype property
return bdPos.get(dp).contains(individual);
} else {
@@ -414,23 +446,18 @@
DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression();
DataRange dr = dsr.getDataRange();
SortedSet<Double> values = dd.get(dp).get(individual);
-
+
// if there is no filler for this individual and property we
// need to return false
- if(values == null)
+ if (values == null) {
return false;
-
- if(dr instanceof DoubleMaxValue) {
- if(values.first() <= ((DoubleMaxValue)dr).getValue())
- return true;
- else
- return false;
- } else if(dr instanceof DoubleMinValue) {
- if(values.last() >= ((DoubleMinValue)dr).getValue())
- return true;
- else
- return false;
}
+
+ if (dr instanceof DoubleMaxValue) {
+ return (values.first() <= ((DoubleMaxValue) dr).getValue());
+ } else if (dr instanceof DoubleMinValue) {
+ return (values.last() >= ((DoubleMinValue) dr).getValue());
+ }
}
throw new ReasoningMethodUnsupportedException("Instance check for description "
@@ -438,40 +465,46 @@
}
@Override
- public SortedSet<Individual> retrieval(Description concept) throws ReasoningMethodUnsupportedException {
- if(concept instanceof NamedClass)
- return classInstancesPos.get((NamedClass)concept);
- else if(concept instanceof Negation && concept.getChild(0) instanceof NamedClass)
- return classInstancesNeg.get((NamedClass)concept.getChild(0));
+ public SortedSet<Individual> retrieval(Description concept)
+ throws ReasoningMethodUnsupportedException {
+ if (concept instanceof NamedClass) {
+ return classInstancesPos.get((NamedClass) concept);
+ } else if (concept instanceof Negation && concept.getChild(0) instanceof NamedClass) {
+ return classInstancesNeg.get((NamedClass) concept.getChild(0));
+ }
-// return rs.retrieval(concept);
+ // return rs.retrieval(concept);
SortedSet<Individual> inds = new TreeSet<Individual>();
- for(Individual i : individuals) {
- if(instanceCheck(concept,i))
+ for (Individual i : individuals) {
+ if (instanceCheck(concept, i)) {
inds.add(i);
+ }
}
return inds;
- }
-
+ }
+
/*
* (non-Javadoc)
*
* @see org.dllearner.core.Reasoner#getAtomicConcepts()
*/
+ @Override
public Set<NamedClass> getAtomicConcepts() {
return atomicConcepts;
}
@Override
- public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException {
+ public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(
+ DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException {
return rc.getDoubleDatatypeMembers(datatypeProperty);
}
-
+
/*
* (non-Javadoc)
*
* @see org.dllearner.core.Reasoner#getAtomicRoles()
*/
+ @Override
public Set<ObjectProperty> getAtomicRoles() {
return atomicRoles;
}
@@ -501,6 +534,7 @@
*
* @see org.dllearner.core.Reasoner#getIndividuals()
*/
+ @Override
public SortedSet<Individual> getIndividuals() {
return individuals;
}
@@ -510,6 +544,7 @@
*
* @see org.dllearner.core.Reasoner#getReasonerType()
*/
+ @Override
public ReasonerType getReasonerType() {
return ReasonerType.FAST_INSTANCE_CHECKER;
}
@@ -519,6 +554,7 @@
*
* @see org.dllearner.core.Reasoner#prepareSubsumptionHierarchy(java.util.Set)
*/
+ @Override
public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) {
rc.prepareSubsumptionHierarchy(allowedConcepts);
}
@@ -547,7 +583,7 @@
public DatatypePropertyHierarchy getDatatypePropertyHierarchy() {
return rc.getDatatypePropertyHierarchy();
}
-
+
@Override
public boolean subsumes(Description superConcept, Description subConcept) {
// Negation neg = new Negation(subConcept);
@@ -561,9 +597,9 @@
*
* @param args
* No arguments supported.
- * @throws ComponentInitException
- * @throws ParseException
- * @throws ReasoningMethodUnsupportedException
+ * @throws ComponentInitException Component cannot be initialised.
+ * @throws ParseException File cannot be parsed.
+ * @throws ReasoningMethodUnsupportedException Reasoning method not supported.
*/
public static void main(String[] args) throws ComponentInitException, ParseException,
ReasoningMethodUnsupportedException {
@@ -584,16 +620,22 @@
System.out.println(reasoner.instanceCheck(d, i));
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.dllearner.core.Reasoner#getBaseURI()
*/
+ @Override
public String getBaseURI() {
return rc.getBaseURI();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.dllearner.core.Reasoner#getPrefixes()
*/
+ @Override
public Map<String, String> getPrefixes() {
return rc.getPrefixes();
}
@@ -602,38 +644,35 @@
public Description getDomain(ObjectProperty objectProperty) {
return rc.getDomain(objectProperty);
}
-
+
@Override
public Description getDomain(DatatypeProperty datatypeProperty) {
return rc.getDomain(datatypeProperty);
}
-
+
@Override
public Description getRange(ObjectProperty objectProperty) {
return rc.getRange(objectProperty);
}
@Override
- public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) {
+ public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) {
return opPos.get(atomicRole);
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.dllearner.core.ReasonerComponent#releaseKB()
*/
@Override
public void releaseKB() {
rc.releaseKB();
- }
-
- /*public void setReasonerType(String type){
- configurator.setReasonerType(type);
- }*/
+ }
-
@Override
public boolean hasDatatypeSupport() {
return true;
}
-
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ku...@us...> - 2008-09-23 23:06:50
|
Revision: 1243
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1243&view=rev
Author: kurzum
Date: 2008-09-23 23:06:40 +0000 (Tue, 23 Sep 2008)
Log Message:
-----------
switched SparqlKnowledgeSource output to RDF/XML.
This will be necessary to include blanknodes.
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
trunk/src/dl-learner/org/dllearner/kb/aquisitors/SparqlTupleAquisitor.java
trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java
trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java
trunk/src/dl-learner/org/dllearner/kb/extraction/DatatypePropertyNode.java
trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java
trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java
trunk/src/dl-learner/org/dllearner/kb/extraction/LiteralNode.java
trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java
trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java
trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java
trunk/src/dl-learner/org/dllearner/kb/manipulator/DBPediaNavigatorCityLocatorRule.java
trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java
trunk/src/dl-learner/org/dllearner/scripts/NT2RDF.java
trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java
trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java
trunk/src/dl-learner/org/dllearner/utilities/datastructures/RDFNodeTuple.java
trunk/src/dl-learner/org/dllearner/utilities/owl/OWLVocabulary.java
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/kb/aquisitors/BlankNodeCollector.java
trunk/src/dl-learner/org/dllearner/kb/aquisitors/RDFBlankNode.java
trunk/src/dl-learner/org/dllearner/kb/extraction/BlankNode.java
trunk/src/dl-learner/org/dllearner/kb/extraction/OWLAPIOntologyCollector.java
trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
@@ -42,6 +42,7 @@
import org.dllearner.learningproblems.PosNegInclusionLP;
import org.dllearner.learningproblems.PosOnlyDefinitionLP;
import org.dllearner.learningproblems.PosOnlyInclusionLP;
+import org.dllearner.learningproblems.RoleLearning;
import org.dllearner.reasoning.DIGReasoner;
import org.dllearner.reasoning.FastInstanceChecker;
import org.dllearner.reasoning.FastRetrievalReasoner;
@@ -167,6 +168,16 @@
}
/**
+* @param positiveExamples positive examples
+* @param negativeExamples negative examples
+* @param reasoningService see ReasoningService
+* @return a component ready for initialization RoleLearning
+**/
+public static RoleLearning getRoleLearning(ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) {
+return RoleLearningConfigurator.getRoleLearning(reasoningService, positiveExamples, negativeExamples);
+}
+
+/**
* @param learningProblem see LearningProblem
* @param reasoningService see ReasoningService
* @throws LearningProblemUnsupportedException see
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
+ */
package org.dllearner.core.configurators;
Added: trunk/src/dl-learner/org/dllearner/kb/aquisitors/BlankNodeCollector.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/aquisitors/BlankNodeCollector.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/kb/aquisitors/BlankNodeCollector.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -0,0 +1,93 @@
+package org.dllearner.kb.aquisitors;
+
+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.utilities.datastructures.RDFNodeTuple;
+
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSetRewindable;
+
+public class BlankNodeCollector {
+
+ private static int globalBNodeId = 0;
+ public static synchronized int getNextGlobalBNodeId(){
+ int ret = globalBNodeId;
+ globalBNodeId++;
+ return ret;
+ }
+
+ private static Map<Integer, SortedSet<RDFNodeTuple>> blankNodes = new HashMap<Integer, SortedSet<RDFNodeTuple>>();
+
+ public static void addBlankNode(int id, RDFNodeTuple t){
+ if(blankNodes.get(id)==null){
+ blankNodes.put(id, new TreeSet<RDFNodeTuple>());
+ }
+ blankNodes.get(id).add(t);
+ }
+
+ public static SortedSet<RDFNodeTuple> getBlankNode(int id){
+ return blankNodes.get(id);
+ }
+
+ public static Map<Integer, SortedSet<RDFNodeTuple>> getBlankNodeMap(){
+ return blankNodes;
+ }
+
+
+ public static boolean testResultSet(ResultSetRewindable rsw, int depth){
+ List<String> vars = new ArrayList<String>();
+ vars.add("o0");
+ for (int i = 1; i <= depth; i++) {
+ vars.add("o"+i);
+ }
+
+ while (rsw.hasNext()){
+ QuerySolution q = rsw.nextSolution();
+ if(!q.get("o0").isAnon()){
+ continue;
+ }else{
+ if(!testOneQuerySolution(vars, q)){
+ rsw.reset();
+ return false;
+ }
+
+ }
+ }
+ rsw.reset();
+ return true;
+ }
+ private static boolean testOneQuerySolution(List<String> vars, QuerySolution q){
+ for (String v : vars) {
+ if(!q.get(v).isAnon()){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static String makeQuery(String uri, String predicate, int maxDepth){
+ int currentDepth = 0;
+ StringBuffer sq = new StringBuffer();
+ String init = "SELECT * WHERE { "+
+ "<"+uri+"> <"+predicate+"> ?o"+currentDepth+". ";
+
+ sq.append(init);
+
+ for (; currentDepth < maxDepth; currentDepth++) {
+ String currentO = "?o"+currentDepth;
+ String nextP = "?p"+(currentDepth+1);
+ String nextO = "?o"+(currentDepth+1);
+ sq.append(" { OPTIONAL { "+currentO+" "+nextP+" "+nextO+". }}");
+ }
+
+
+ sq.append(" } ");
+ return sq.toString();
+ }
+
+}
Added: trunk/src/dl-learner/org/dllearner/kb/aquisitors/RDFBlankNode.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/aquisitors/RDFBlankNode.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/kb/aquisitors/RDFBlankNode.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -0,0 +1,104 @@
+/**
+ * Copyright (C) 2007-2008, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.kb.aquisitors;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.RDFVisitor;
+
+/**
+ * This class is used to save disambiguated information for a blankNode in an RDF
+ * Graph. It is used to silently transport the info to the layer above.
+ *
+ * @author Sebastian Hellmann
+ *
+ */
+public class RDFBlankNode implements RDFNode {
+
+
+ private RDFNode blankNode;
+ private int bNodeId;
+
+ public RDFBlankNode(int id, RDFNode blankNode) {
+ super();
+ this.bNodeId = id;
+ this.blankNode = blankNode;
+ }
+
+ public int getBNodeId(){
+ return bNodeId;
+ }
+ //RBC
+ public String toString(){
+ //RBC
+ return "I'm a blank node with id: "+bNodeId+"||"+blankNode;
+ }
+
+ // overidden Functions
+
+ public RDFNode as(Class view) {
+
+ return blankNode.as(view);
+ }
+
+ public boolean canAs(Class view) {
+
+ return blankNode.canAs(view);
+ }
+
+ public RDFNode inModel(Model m) {
+
+ return blankNode.inModel(m);
+ }
+
+ public boolean isAnon() {
+
+ return blankNode.isAnon();
+ }
+
+ public boolean isLiteral() {
+
+ return blankNode.isLiteral();
+ }
+
+ public boolean isResource() {
+
+ return blankNode.isResource();
+ }
+
+ public boolean isURIResource() {
+
+ return blankNode.isURIResource();
+ }
+
+ public Object visitWith(RDFVisitor rv) {
+
+ return blankNode.visitWith(rv);
+ }
+
+ public Node asNode() {
+
+ return blankNode.asNode();
+ }
+
+
+
+}
Modified: trunk/src/dl-learner/org/dllearner/kb/aquisitors/SparqlTupleAquisitor.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/aquisitors/SparqlTupleAquisitor.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/aquisitors/SparqlTupleAquisitor.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -19,6 +19,8 @@
*/
package org.dllearner.kb.aquisitors;
+import java.util.ArrayList;
+import java.util.List;
import java.util.SortedSet;
import org.apache.log4j.Logger;
@@ -26,6 +28,10 @@
import org.dllearner.kb.sparql.SparqlQueryMaker;
import org.dllearner.utilities.datastructures.RDFNodeTuple;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSetRewindable;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+
/**
* Can execute different queries.
*
@@ -42,6 +48,7 @@
protected SparqlQueryMaker sparqlQueryMaker;
protected SPARQLTasks sparqlTasks;
+ //RBC
@@ -55,21 +62,107 @@
public SortedSet<RDFNodeTuple> retrieveTupel(String uri){
// getQuery
String sparqlQueryString = sparqlQueryMaker.makeSubjectQueryUsingFilters(uri);
- return sparqlTasks.queryAsRDFNodeTuple(sparqlQueryString, PREDICATE, OBJECT);
-
+ SortedSet<RDFNodeTuple> ret = sparqlTasks.queryAsRDFNodeTuple(sparqlQueryString, PREDICATE, OBJECT);
+ disambiguateBlankNodes(uri, ret);
+ return ret;
}
@Override
public SortedSet<RDFNodeTuple> retrieveClassesForInstances(String uri){
// getQuery
String sparqlQueryString = sparqlQueryMaker.makeClassQueryUsingFilters(uri);
- return sparqlTasks.queryAsRDFNodeTuple(sparqlQueryString, PREDICATE, OBJECT);
+ SortedSet<RDFNodeTuple> ret = sparqlTasks.queryAsRDFNodeTuple(sparqlQueryString, PREDICATE, OBJECT);
+ return ret;
}
@Override
public SortedSet<RDFNodeTuple> retrieveTuplesForClassesOnly(String uri){
- return retrieveTupel(uri);
+ SortedSet<RDFNodeTuple> ret = retrieveTupel(uri);
+ return ret;
}
+
+ private void disambiguateBlankNodes(String uri, SortedSet<RDFNodeTuple> resultSet){
+ try{
+ for (RDFNodeTuple tuple : resultSet) {
+ if(tuple.b.isAnon()){
+ int currentId = BlankNodeCollector.getNextGlobalBNodeId();
+ tuple.b = new RDFBlankNode(currentId, tuple.b);
+ System.out.println(uri+" replaced blanknode "+tuple.b);
+ dissolveBlankNodes(currentId, uri, tuple);
+ System.out.println(BlankNodeCollector.getBlankNodeMap());
+
+ }
+ }
+ }catch (Exception e) {
+ e.printStackTrace();
+ System.exit(0);
+ }
+ }
+
+ private void dissolveBlankNodes(int currentId, String uri, RDFNodeTuple tuple){
+ int currentDepth = 1;
+ int lastDepth = 1;
+ ResultSetRewindable rsw=null;
+ do{
+ String q = BlankNodeCollector.makeQuery(uri, tuple.a.toString(), currentDepth);
+
+ rsw = sparqlTasks.queryAsResultSet(q);
+ lastDepth = currentDepth;
+ }while (!BlankNodeCollector.testResultSet(rsw, currentDepth++));
+
+ assignIds( currentId, rsw, lastDepth);
+
+ }
+
+ private void assignIds(int currentId, ResultSetRewindable rsw, int lastDepth){
+ List<String> vars = new ArrayList<String>();
+ vars.add("o0");
+ for (int i = 1; i <= lastDepth; i++) {
+ vars.add("p"+i);
+ vars.add("o"+i);
+ }
+
+ final List<String> tmpVars = new ArrayList<String>();
+
+ while (rsw.hasNext()){
+ tmpVars.clear();
+ tmpVars.addAll(vars);
+ QuerySolution q = rsw.nextSolution();
+
+ if(!q.get("o0").isAnon()){
+ continue;
+ }else{
+ tmpVars.remove(0);
+ assignIdRec(currentId, q, tmpVars);
+ }
+
+
+ }
+ rsw.reset();
+
+ }
+
+ private void assignIdRec(int currentId, QuerySolution q, List<String> vars ){
+ if(vars.isEmpty()){return;}
+ String pvar = vars.remove(0);
+ String ovar = vars.remove(0);
+
+ RDFNode n = q.get(ovar);
+ if(n.isAnon()){
+ int nextId = BlankNodeCollector.getNextGlobalBNodeId();
+ RDFNodeTuple tuple = new RDFNodeTuple(q.get(pvar), new RDFBlankNode(nextId,n));
+ BlankNodeCollector.addBlankNode(currentId, tuple);
+ assignIdRec(nextId, q, vars);
+ }else{
+ BlankNodeCollector.addBlankNode(currentId, new RDFNodeTuple(q.get(pvar), n));
+ }
+
+
+ }
+
+
+
+
Added: trunk/src/dl-learner/org/dllearner/kb/extraction/BlankNode.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/BlankNode.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/BlankNode.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -0,0 +1,75 @@
+package org.dllearner.kb.extraction;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.dllearner.kb.aquisitors.BlankNodeCollector;
+import org.dllearner.kb.aquisitors.RDFBlankNode;
+import org.dllearner.kb.aquisitors.TupleAquisitor;
+import org.dllearner.kb.manipulator.Manipulator;
+import org.dllearner.utilities.datastructures.RDFNodeTuple;
+
+public class BlankNode extends Node {
+
+ RDFBlankNode bNode;
+
+ private List<ObjectPropertyNode> objectProperties = new ArrayList<ObjectPropertyNode>();
+ private List<DatatypePropertyNode> datatypeProperties = new ArrayList<DatatypePropertyNode>();
+
+
+ public BlankNode(RDFBlankNode bNode){
+ super("_:internal_"+bNode.getBNodeId());
+ this.bNode=bNode;
+ }
+
+
+
+ @Override
+ public List<Node> expand(TupleAquisitor TupelAquisitor,
+ Manipulator manipulator) {
+ List<Node> newNodes = new ArrayList<Node>();
+ SortedSet<RDFNodeTuple> s = BlankNodeCollector.getBlankNode(bNode.getBNodeId());
+ for (RDFNodeTuple tuple : s) {
+ if(tuple.b.isLiteral()) {
+ datatypeProperties.add(new DatatypePropertyNode(tuple.a.toString(), this, new LiteralNode(tuple.b) ));
+ }else if(tuple.b.isAnon()){
+
+ BlankNode tmp = new BlankNode( (RDFBlankNode)tuple.b);
+ objectProperties.add(new ObjectPropertyNode(tuple.a.toString(), this, tmp ));
+ newNodes.add(tmp);
+ }else{
+ objectProperties.add(new ObjectPropertyNode(tuple.a.toString(), this, new ClassNode(tuple.b.toString()) ));
+ }
+ }
+ return newNodes;
+ }
+
+ @Override
+ public void expandProperties(TupleAquisitor TupelAquisitor,
+ Manipulator manipulator) {
+ }
+
+ @Override
+ public SortedSet<String> toNTriple() {
+ SortedSet<String> returnSet = new TreeSet<String>();
+ String subject = getNTripleForm();
+ for (ObjectPropertyNode one : objectProperties) {
+ returnSet.add(subject + one.getNTripleForm() + one.getBPart().getNTripleForm()+" . ");
+ returnSet.addAll(one.getBPart().toNTriple());
+ }
+ return returnSet;
+ }
+
+ @Override
+ public String getNTripleForm(){
+ return " "+uri+" ";
+ }
+
+ @Override
+ public void toOWLOntology( OWLAPIOntologyCollector owlAPIOntologyCollector){
+ //FIXME
+ }
+
+}
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -25,10 +25,15 @@
import java.util.TreeSet;
import org.apache.log4j.Logger;
+import org.dllearner.kb.aquisitors.RDFBlankNode;
import org.dllearner.kb.aquisitors.TupleAquisitor;
import org.dllearner.kb.manipulator.Manipulator;
import org.dllearner.utilities.datastructures.RDFNodeTuple;
import org.dllearner.utilities.owl.OWLVocabulary;
+import org.semanticweb.owl.model.OWLClass;
+import org.semanticweb.owl.model.OWLCommentAnnotation;
+import org.semanticweb.owl.model.OWLDataFactory;
+import org.semanticweb.owl.model.OWLLabelAnnotation;
/**
* Is a node in the graph, that is a class.
@@ -66,7 +71,7 @@
return newNodes;
}
- public Node processTuple( RDFNodeTuple tuple) {
+ private Node processTuple( RDFNodeTuple tuple) {
try {
String property = tuple.a.toString();
if(tuple.b.isLiteral()) {
@@ -74,6 +79,12 @@
return null;
}else if(tuple.b.isAnon()){
logger.warn("blanknodes not supported as of now "+ this +" in tuple" + tuple);
+ RDFBlankNode n = (RDFBlankNode) tuple.b;
+ //SortedSet<RDFNodeTuple> bNodeTuples = BlankNodeCollector.getBlankNode(n.getBNodeId());
+ //BlankNode tmp = new BlankNode(n);
+ //add it to the graph
+ //classProperties.add(new ObjectPropertyNode( tuple.a.toString(), this, tmp));
+ //return tmp;
return null;
// substitute rdf:type with owl:subclassof
}else if (property.equals(OWLVocabulary.RDF_TYPE) ||
@@ -110,21 +121,60 @@
@Override
public SortedSet<String> toNTriple() {
SortedSet<String> returnSet = new TreeSet<String>();
- returnSet.add("<" + this.uri + "><" + OWLVocabulary.RDF_TYPE + "><" + OWLVocabulary.OWL_CLASS + ">.");
+ String subject = getNTripleForm();
+ returnSet.add(subject+"<" + OWLVocabulary.RDF_TYPE + "><" + OWLVocabulary.OWL_CLASS + ">.");
for (ObjectPropertyNode one : classProperties) {
- returnSet.add("<" + this.uri + "><" + one.getURI() + "><"
- + one.getB().getURI() + ">.");
- returnSet.addAll(one.getB().toNTriple());
+ returnSet.add(subject + one.getNTripleForm() +
+ one.getBPart().getNTripleForm()+" .");
+ returnSet.addAll(one.getBPart().toNTriple());
}
for (DatatypePropertyNode one : datatypeProperties) {
- returnSet.add("<" + uri + "><" + one.getURI() + "> " + one.getNTripleFormOfB()
+ returnSet.add(subject+ one.getNTripleForm() + one.getNTripleFormOfB()
+ " .");
}
return returnSet;
}
-
+ @Override
+ public void toOWLOntology( OWLAPIOntologyCollector owlAPIOntologyCollector){
+ try{
+ OWLDataFactory factory = owlAPIOntologyCollector.getFactory();
+ OWLClass me =factory.getOWLClass(getURI());
+ for (ObjectPropertyNode one : classProperties) {
+ OWLClass c = factory.getOWLClass(one.getBPart().getURI());
+ if(OWLVocabulary.isStringSubClassVocab(one.getURIString())){
+ owlAPIOntologyCollector.addAxiom(factory.getOWLSubClassAxiom(me, c));
+ }else if(one.getURIString().equals(OWLVocabulary.OWL_DISJOINT_WITH)){
+ owlAPIOntologyCollector.addAxiom(factory.getOWLDisjointClassesAxiom(me, c));
+ }else if(one.getURIString().equals(OWLVocabulary.OWL_EQUIVALENT_CLASS)){
+ owlAPIOntologyCollector.addAxiom(factory.getOWLEquivalentClassesAxiom(me, c));
+ }else {
+ logger.warn("missing : " +one.getURIString());
+ }
+ one.getBPart().toOWLOntology(owlAPIOntologyCollector);
+ }
+ for (DatatypePropertyNode one : datatypeProperties) {
+ //FIXME add languages
+ // watch for tail
+ if(one.getURIString().equals(OWLVocabulary.RDFS_COMMENT)){
+ OWLCommentAnnotation comment = factory.getCommentAnnotation(one.getBPart().getLiteral().getString());
+ owlAPIOntologyCollector.addAxiom(factory.getOWLEntityAnnotationAxiom(me, comment));
+
+ }else if(one.getURIString().equals(OWLVocabulary.RDFS_LABEL)) {
+ OWLLabelAnnotation label = factory.getOWLLabelAnnotation(one.getBPart().getLiteral().getString());
+ owlAPIOntologyCollector.addAxiom(factory.getOWLEntityAnnotationAxiom(me, label));
+ }else {
+ logger.warn("missing : " +one.getURIString());
+ }
+
+ }
+ }catch (Exception e) {
+ System.out.println("aaa"+getURIString());
+ e.printStackTrace();
+ }
+ }
+
}
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -25,34 +25,36 @@
/**
* Stores all configuration settings. this class collects all configuration
* information see the other classes, which are used as attributes here
- *
+ *
* @author Sebastian Hellmann
*/
public class Configuration {
-
+ private OWLAPIOntologyCollector owlAPIOntologyCollector;
+
private Manipulator manipulator;
+
private TupleAquisitor tupelAquisitor;
-
+
// the following needs to be moved to
// class extraction algorithm or manipulator
private boolean optimizeForDLLearner = true;
+
private int recursiondepth;
+
private boolean getAllSuperClasses = true;
+
private boolean closeAfterRecursion = true;
+
private boolean getPropertyInformation = false;
+
private int breakSuperClassesAfter = 200;
+ public Configuration(TupleAquisitor tupelAquisitor,
+ Manipulator manipulator, int recursiondepth,
+ boolean getAllSuperClasses, boolean closeAfterRecursion,
+ boolean getPropertyInformation, int breakSuperClassesAfter) {
- public Configuration(
- TupleAquisitor tupelAquisitor,
- Manipulator manipulator,
- int recursiondepth,
- boolean getAllSuperClasses,
- boolean closeAfterRecursion,
- boolean getPropertyInformation,
- int breakSuperClassesAfter) {
-
this.tupelAquisitor = tupelAquisitor;
this.manipulator = manipulator;
this.recursiondepth = recursiondepth;
@@ -61,51 +63,54 @@
this.getPropertyInformation = getPropertyInformation;
this.breakSuperClassesAfter = breakSuperClassesAfter;
+ this.owlAPIOntologyCollector = new OWLAPIOntologyCollector();
}
+ public Configuration(TupleAquisitor tupelAquisitor,
+ Manipulator manipulator, int recursiondepth,
+ boolean getAllSuperClasses, boolean closeAfterRecursion,
+ boolean getPropertyInformation, int breakSuperClassesAfter,
+ OWLAPIOntologyCollector owlAPIOntologyCollector) {
+ this(tupelAquisitor, manipulator, recursiondepth, getAllSuperClasses,
+ closeAfterRecursion, getAllSuperClasses, breakSuperClassesAfter);
+ this.owlAPIOntologyCollector = owlAPIOntologyCollector;
+ }
public int getBreakSuperClassesAfter() {
return breakSuperClassesAfter;
}
-
public boolean isCloseAfterRecursion() {
return closeAfterRecursion;
}
-
public boolean isGetAllSuperClasses() {
return getAllSuperClasses;
}
-
public Manipulator getManipulator() {
return manipulator;
}
-
public int getRecursiondepth() {
return recursiondepth;
}
-
public TupleAquisitor getTupelAquisitor() {
return tupelAquisitor;
}
-
public boolean isOptimizeForDLLearner() {
return optimizeForDLLearner;
}
-
public boolean isGetPropertyInformation() {
return getPropertyInformation;
}
+ public OWLAPIOntologyCollector getOwlAPIOntologyCollector() {
+ return owlAPIOntologyCollector;
+ }
-
-
-
}
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/DatatypePropertyNode.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/DatatypePropertyNode.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/DatatypePropertyNode.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -34,18 +34,10 @@
*
*/
-public class DatatypePropertyNode extends Node {
+public class DatatypePropertyNode extends PropertyNode {
- // the a and b part of a property
- private Node a;
- private LiteralNode b;
-
-
public DatatypePropertyNode(String uri, Node a, LiteralNode b) {
- super(uri);
- // this.type = "property";
- this.a = a;
- this.b = b;
+ super(uri, a, b);
}
// Property Nodes are normally not expanded,
@@ -60,15 +52,10 @@
public void expandProperties(TupleAquisitor tupelAquisitor, Manipulator manipulator) {
}
-
-
- public Node getA() {
- return a;
+ @Override
+ public LiteralNode getBPart(){
+ return (LiteralNode)b;
}
-
- public Node getB() {
- return b;
- }
public String getNTripleFormOfB() {
return b.getNTripleForm();
@@ -77,12 +64,17 @@
@Override
public SortedSet<String> toNTriple() {
SortedSet<String> s = new TreeSet<String>();
- s.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><"
+ s.add(getNTripleForm()+"<" + OWLVocabulary.RDF_TYPE + "><"
+ OWLVocabulary.OWL_DATATYPPROPERTY + ">.");
return s;
}
-
+ @Override
+ public void toOWLOntology( OWLAPIOntologyCollector owlAPIOntologyCollector){
+
+ }
+
+
}
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -59,6 +59,7 @@
for (String oneURI : uris) {
nodeList.add(expandNode(oneURI, tupelAquisitor));
}
+
return nodeList;
}
@@ -135,14 +136,32 @@
List<ObjectPropertyNode> l = getObjectPropertyNodes(collectNodes);
for (ObjectPropertyNode node : l) {
+ //FIXME has to be transported to the next step
node.expandProperties(tupleAquisitor, configuration.getManipulator());
}
}
+
+ expandBlankNodes(getBlankNodes(collectNodes),tupleAquisitor);
+
return seedNode;
}
+ private List<Node> expandBlankNodes(List<BlankNode> blankNodes, TupleAquisitor tupelAquisitor) {
+ List<Node> newNodes = new ArrayList<Node>();
+ while (!blankNodes.isEmpty()) {
+ Node next = blankNodes.remove(0);
+ List<Node> l = next.expand(tupelAquisitor, configuration.getManipulator());
+ for (Node node : l) {
+ blankNodes.add((BlankNode) node);
+ }
+
+ }
+ return newNodes;
+ }
+
+
private List<Node> expandCloseAfterRecursion(List<InstanceNode> instanceNodes, TupleAquisitor tupelAquisitor) {
List<Node> newNodes = new ArrayList<Node>();
@@ -179,9 +198,9 @@
Node next = newClasses.remove(0);
logger.trace("Getting Superclasses for: " + next);
- if (!alreadyQueriedSuperClasses.contains(next.getURI().toString())) {
+ if (!alreadyQueriedSuperClasses.contains(next.getURIString().toString())) {
logger.trace("" + next+" not in cache retrieving");
- alreadyQueriedSuperClasses.add(next.getURI().toString());
+ alreadyQueriedSuperClasses.add(next.getURIString().toString());
tupelAquisitor.setNextTaskToClassInformation();
newClasses.addAll(next.expand(tupelAquisitor, configuration.getManipulator()));
@@ -226,6 +245,18 @@
return retList;
}
+ public static List<BlankNode> getBlankNodes(List<Node> l ){
+ List<BlankNode> retList = new ArrayList<BlankNode>();
+ for (Node node : l) {
+ if (node instanceof BlankNode) {
+ retList.add( (BlankNode) node);
+
+ }
+
+ }
+ return retList;
+ }
+
public static List<ObjectPropertyNode> getObjectPropertyNodes(List<Node> l ){
List<ObjectPropertyNode> properties = new ArrayList<ObjectPropertyNode>();
for (Node node : l) {
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -24,12 +24,22 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import org.apache.commons.collections.list.TypedList;
import org.apache.log4j.Logger;
+import org.dllearner.kb.aquisitors.RDFBlankNode;
import org.dllearner.kb.aquisitors.TupleAquisitor;
import org.dllearner.kb.manipulator.Manipulator;
import org.dllearner.utilities.datastructures.RDFNodeTuple;
import org.dllearner.utilities.owl.OWLVocabulary;
+import org.semanticweb.owl.expression.OWLExpressionParser;
+import org.semanticweb.owl.model.OWLClass;
+import org.semanticweb.owl.model.OWLDataFactory;
+import org.semanticweb.owl.model.OWLDataProperty;
+import org.semanticweb.owl.model.OWLIndividual;
+import org.semanticweb.owl.model.OWLObjectProperty;
+import com.hp.hpl.jena.rdf.model.Literal;
+
/**
* A node in the graph that is an instance.
*
@@ -47,10 +57,8 @@
private List<ObjectPropertyNode> objectProperties = new ArrayList<ObjectPropertyNode>();
private List<DatatypePropertyNode> datatypeProperties = new ArrayList<DatatypePropertyNode>();
-
public InstanceNode(String uri) {
super(uri);
-
}
// expands all directly connected nodes
@@ -80,6 +88,9 @@
datatypeProperties.add(new DatatypePropertyNode(tuple.a.toString(), this, new LiteralNode(tuple.b) ));
return null;
}else if(tuple.b.isAnon()){
+ RDFBlankNode n = (RDFBlankNode) tuple.b;
+ System.out.println(n.getBNodeId());
+ System.exit(0);
logger.warn("blanknodes not supported as of now"+ this +"in tuple" + tuple);
return null;
@@ -115,30 +126,85 @@
SortedSet<String> returnSet = new TreeSet<String>();
returnSet.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" + OWLVocabulary.OWL_THING + ">.");
for (ClassNode one : classes) {
- returnSet.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" + one.getURI() + ">.");
+ returnSet.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" + one.getURIString() + ">.");
returnSet.addAll(one.toNTriple());
}
for (ObjectPropertyNode one : objectProperties) {
- returnSet.add("<" + uri + "><" + one.getURI() + "><" + one.getB().getURI()
+ returnSet.add("<" + uri + "><" + one.getURIString() + "><" + one.getBPart().getURIString()
+ ">.");
returnSet.addAll(one.toNTriple());
- returnSet.addAll(one.getB().toNTriple());
+ returnSet.addAll(one.getBPart().toNTriple());
}
for (DatatypePropertyNode one : datatypeProperties) {
- returnSet.add("<" + uri + "><" + one.getURI() + "> " + one.getNTripleFormOfB()
+ returnSet.add("<" + uri + "><" + one.getURIString() + "> " + one.getNTripleFormOfB()
+ " .");
}
return returnSet;
}
+
+ @Override
+ public void toOWLOntology( OWLAPIOntologyCollector owlAPIOntologyCollector){
+ OWLDataFactory factory = owlAPIOntologyCollector.getFactory();
+
+
+ OWLIndividual me = factory.getOWLIndividual(getURI());
+ for (ClassNode one : classes) {
+ OWLClass c = factory.getOWLClass(one.getURI());
+ owlAPIOntologyCollector.addAxiom(factory.getOWLClassAssertionAxiom(me, c));
+ one.toOWLOntology(owlAPIOntologyCollector);
+ }
+ for (ObjectPropertyNode one : objectProperties) {
+ OWLIndividual o = factory.getOWLIndividual(one.getBPart().getURI());
+ OWLObjectProperty p = factory.getOWLObjectProperty(one.getURI());
+ factory.getOWLObjectPropertyAssertionAxiom(me, p, o);
+ one.toOWLOntology(owlAPIOntologyCollector);
+ one.getBPart().toOWLOntology(owlAPIOntologyCollector);
+ }
+
+ for (DatatypePropertyNode one : datatypeProperties) {
+ OWLDataProperty p = factory.getOWLDataProperty(one.getURI());
+ Literal ln = one.getBPart().getLiteral();
+ try{
+
+
+ if(one.getBPart().isString()){
+ owlAPIOntologyCollector.addAxiom(
+ factory.getOWLDataPropertyAssertionAxiom(me, p, ln.getString()));
+ } else if(one.getBPart().isDouble()){
+ owlAPIOntologyCollector.addAxiom(
+ factory.getOWLDataPropertyAssertionAxiom(me, p, ln.getDouble()));
+ } else if(one.getBPart().isFloat()){
+ owlAPIOntologyCollector.addAxiom(
+ factory.getOWLDataPropertyAssertionAxiom(me, p, ln.getFloat()));
+ } else if(one.getBPart().isInt()){
+ owlAPIOntologyCollector.addAxiom(
+ factory.getOWLDataPropertyAssertionAxiom(me, p, ln.getInt()));
+ } else if(one.getBPart().isBoolean()){
+ owlAPIOntologyCollector.addAxiom(
+ factory.getOWLDataPropertyAssertionAxiom(me, p, ln.getBoolean()));
+ } else {
+ logger.warn("missing : "+one.getURIString());
+ }
+
+
+ }catch (Exception e) {
+ e.printStackTrace();
+ System.exit(0);
+ }
+
+ //factory.getOWLDataPropertyAssertionAxiom()
+ //returnSet.add("<" + uri + "><" + one.getURI() + "> " + one.getNTripleFormOfB()
+ // + " .");
+ }
+ }
+
public List<ObjectPropertyNode> getObjectProperties() {
return objectProperties;
}
-
-
}
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/LiteralNode.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/LiteralNode.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/LiteralNode.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -48,14 +48,17 @@
public LiteralNode(String uri) {
super(uri);
- // this.type = "instance";
-
+
}
public LiteralNode(RDFNode node) {
super(node.toString());
l = (Literal) node;
}
+
+ public Literal getLiteral(){
+ return l;
+ }
// expands all directly connected nodes
@Override
@@ -77,7 +80,7 @@
-
+ @Override
public String getNTripleForm() {
String quote = "\\\"";
quote = """;
@@ -92,5 +95,59 @@
}
}
+
+ @Override
+ public void toOWLOntology( OWLAPIOntologyCollector owlAPIOntologyCollector){
+
+ }
+
+ public boolean isDouble(){
+ try{
+ l.getDouble();
+ return true;
+ }catch (Exception e) {
+ return false;
+ }
+ }
+
+ public boolean isFloat(){
+ try{
+ l.getFloat();
+ return true;
+ }catch (Exception e) {
+ return false;
+ }
+ }
+
+ public boolean isInt(){
+ try{
+ l.getInt();
+ return true;
+ }catch (Exception e) {
+ return false;
+ }
+ }
+
+ public boolean isBoolean(){
+ try{
+ l.getBoolean();
+ return true;
+ }catch (Exception e) {
+ return false;
+ }
+ }
+
+ public boolean isString(){
+ try{
+ l.getString();
+ return true;
+ }catch (Exception e) {
+ return false;
+ }
+ }
+
+
+
+
}
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -19,11 +19,16 @@
*/
package org.dllearner.kb.extraction;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.log4j.Logger;
+import org.semanticweb.owl.model.OWLOntology;
/**
* An object of this class encapsulates everything.
@@ -36,54 +41,73 @@
private Configuration configuration;
private ExtractionAlgorithm extractionAlgorithm;
private int nrOfExtractedTriples = 0;
+ private List<Node> seedNodes = new ArrayList<Node>();
private static Logger logger = Logger
.getLogger(Manager.class);
public void useConfiguration(Configuration configuration) {
-
this.configuration = configuration;
- //System.out.println(this.configuration);
-
this.extractionAlgorithm = new ExtractionAlgorithm(configuration);
-
}
- public String extract(String uri) {
+ public Node extractOneURI(String uri) {
- logger.info("Start extracting");
-
+ logger.info("Start extracting: "+uri);
Node n = extractionAlgorithm.expandNode(uri, configuration.getTupelAquisitor());
- SortedSet<String> s = n.toNTriple();
- logger.info("number of triples: "+s.size());
- StringBuffer nt = new StringBuffer(33000);
- for (String str : s) {
- nt.append(str + "\n");
- }
- logger.info("sizeofStringBuffer"+nt.length());
- return nt.toString();
+ logger.info("Finished extracting: "+uri );
+ seedNodes.add(n);
+ return n;
}
+
+
- public String extract(Set<String> instances) {
- // this.TypedSparqlQuery.query(uri);
- // System.out.println(ExtractionAlgorithm.getFirstNode(uri));
- logger.info("Start extracting");
- SortedSet<String> tripleCollector = new TreeSet<String>();
+ public List<Node> extract(Set<String> instances) {
+ List<Node> allExtractedNodes = new ArrayList<Node>();
+ logger.info("Start extracting "+instances.size() + " instances ");
int progress=0;
for (String one : instances) {
progress++;
- //if(progress % 10 == 0) {
- logger.info("Progress: "+progress+" of "+instances.size()+" finished: "+one);
- //}
+ logger.info("Progress: "+progress+" of "+instances.size()+" finished: "+one);
try {
Node n = extractionAlgorithm.expandNode(one, configuration.getTupelAquisitor());
- tripleCollector.addAll(n.toNTriple());
+ seedNodes.add(n);
+ allExtractedNodes.add(n);
} catch (Exception e) {
+ logger.warn("extraction failed for: "+one);
e.printStackTrace();
+
}
}
- logger.info("Finished extracting, start conversion");
+ logger.info("Finished extraction");
+ return allExtractedNodes;
+
+ }
+
+ public OWLOntology getOWLAPIOntologyForNodes(List<Node> nodes){
+ for (Node n : nodes) {
+ n.toOWLOntology(configuration.getOwlAPIOntologyCollector());
+ }
+ configuration.getOwlAPIOntologyCollector().saveOntology();
+ return configuration.getOwlAPIOntologyCollector().getCurrentOntology();
+ }
+
+ public URL getPhysicalOntologyURL()throws MalformedURLException{
+ return configuration.getOwlAPIOntologyCollector().getPhysicalURI().toURL();
+
+ }
+
+ public String getNTripleForAllExtractedNodes(){
+ return getNTripleForNodes(seedNodes);
+ }
+
+ public String getNTripleForNodes(List<Node> nodes){
+ SortedSet<String> tripleCollector = new TreeSet<String>();
+ for (Node n : nodes) {
+ tripleCollector.addAll(n.toNTriple());
+ }
+ logger.info("Converting to NTriple");
StringBuffer nt = new StringBuffer(100000);
Object[] arr = tripleCollector.toArray();
nrOfExtractedTriples = arr.length;
@@ -93,11 +117,6 @@
logger.info(i + " of " + arr.length + " triples done");
}
logger.info(arr.length + " of " + arr.length + " triples done");
- /*
- * String tmp=""; while ( ret.size() > 0) { tmp=ret.first(); nt+=tmp;
- * ret.remove(tmp); System.out.println(ret.size()); } /*for (String str :
- * ret) { nt += str + "\n"; }
- */
logger.info("Ontology String size = " + nt.length());
return nt.toString();
}
@@ -107,6 +126,7 @@
return configuration;
}
+ @Deprecated
public int getNrOfExtractedTriples() {
return nrOfExtractedTriples;
}
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -19,6 +19,7 @@
*/
package org.dllearner.kb.extraction;
+import java.net.URI;
import java.util.List;
import java.util.SortedSet;
@@ -73,17 +74,34 @@
*/
public abstract SortedSet<String> toNTriple();
+ public abstract void toOWLOntology( OWLAPIOntologyCollector owlAPIOntologyCollector);
+
+ /*
+
+ @Override
+ public void toOWLOntology( OWLAPIOntologyCollector owlAPIOntologyCollector){
+
+ }
+ */
+
@Override
public String toString() {
return "Node: " + uri + ":" + this.getClass().getSimpleName();
}
- public String getURI() {
+ public String getURIString() {
return uri;
}
+ public URI getURI() {
+ return URI.create(uri);
+ }
+ public String getNTripleForm(){
+ return "<"+uri+"> ";
+ }
+
Added: trunk/src/dl-learner/org/dllearner/kb/extraction/OWLAPIOntologyCollector.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/OWLAPIOntologyCollector.java (rev 0)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/OWLAPIOntologyCollector.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -0,0 +1,80 @@
+package org.dllearner.kb.extraction;
+
+import java.io.File;
+import java.net.URI;
+
+import org.apache.log4j.Logger;
+import org.semanticweb.owl.apibinding.OWLManager;
+import org.semanticweb.owl.model.AddAxiom;
+import org.semanticweb.owl.model.OWLAxiom;
+import org.semanticweb.owl.model.OWLDataFactory;
+import org.semanticweb.owl.model.OWLOntology;
+import org.semanticweb.owl.model.OWLOntologyChangeException;
+import org.semanticweb.owl.model.OWLOntologyCreationException;
+import org.semanticweb.owl.model.OWLOntologyManager;
+import org.semanticweb.owl.util.SimpleURIMapper;
+
+public class OWLAPIOntologyCollector {
+
+ private static Logger logger = Logger.getLogger(OWLAPIOntologyCollector.class);
+
+ private OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
+ private OWLDataFactory factory;
+ private OWLOntology currentOntology;
+ private URI ontologyURI;
+ private URI physicalURI;
+
+
+
+ public OWLAPIOntologyCollector(){
+ this("http://www.fragment.org/fragment", "cache/"+System.currentTimeMillis()+".owl");
+ }
+
+ public OWLAPIOntologyCollector(String ontologyURI, String physicalURI){
+ this.ontologyURI = URI.create(ontologyURI);
+ this.physicalURI = new File(physicalURI).toURI();
+ SimpleURIMapper mapper = new SimpleURIMapper(this.ontologyURI, this.physicalURI);
+ this.manager.addURIMapper(mapper);
+ try{
+ this.currentOntology = manager.createOntology(this.ontologyURI);
+ }catch(OWLOntologyCreationException e){
+ logger.error("FATAL failed to create Ontology " + this.ontologyURI);
+ e.printStackTrace();
+ }
+ this.factory = manager.getOWLDataFactory();
+ }
+
+ public void addAxiom(OWLAxiom axiom){
+ AddAxiom addAxiom = new AddAxiom(currentOntology, axiom);
+ try{
+ manager.applyChange(addAxiom);
+ }catch (OWLOntologyChangeException e) {
+ //TODO
+ e.printStackTrace();
+ }
+ }
+
+ public OWLDataFactory getFactory() {
+ return factory;
+ }
+
+ public void saveOntology(){
+ try{
+ manager.saveOntology(currentOntology);
+ }catch (Exception e) {
+ e.printStackTrace();
+
+ }
+ }
+
+ public OWLOntology getCurrentOntology() {
+ return currentOntology;
+ }
+
+ public URI getPhysicalURI() {
+ return physicalURI;
+ }
+
+
+
+}
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java 2008-09-23 18:35:57 UTC (rev 1242)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java 2008-09-23 23:06:40 UTC (rev 1243)
@@ -23,11 +23,12 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import org.apache.log4j.Logger;
import org.dllearner.kb.aquisitors.TupleAquisitor;
import org.dllearner.kb.manipulator.Manipulator;
import org.dllearner.utilities.datastructures.RDFNodeTuple;
import org.dllearner.utilities.owl.OWLVocabulary;
+import org.semanticweb.owl.model.OWLDataFactory;
+import org.semanticweb.owl.model.OWLObjectProperty;
@@ -38,24 +39,16 @@
*
*/
-public class ObjectPropertyNode extends Node {
+public class ObjectPropertyNode extends PropertyNode {
- public static Logger logger = Logger.getLogger(ObjectPropertyNode.class);
- // the a and b part of a property
- private Node a;
- private Node b;
// specialtypes like owl:symmetricproperty
private SortedSet<String> specialTypes = new TreeSet<String>();
@SuppressWarnings("unused")
private SortedSet<RDFNodeTuple> propertyInformation = new TreeSet<RDFNodeTuple>();
- public ObjectPropertyNode(String uri, Node a, Node b) {
- super(uri);
- // this.type = "property";
- this.a = a;
- this.b = b;
-
+ public ObjectPropertyNode(String propertyURI, Node a, Node b) {
+ super(propertyURI, a, b);
}
// Property Nodes are normally not expanded,
@@ -88,24 +81,13 @@
}
-
-
-
- public Node getA() {
- return a;
- }
-
- public Node getB() {
- return b;
- }
-
@Override
public SortedSet<String> toNTriple() {
SortedSet<String> s = new TreeSet<String>();
- s.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><"
+ s.add(getNTripleForm()+"<" + OWLVocabulary.RDF_TYPE + "><"
+ OWLVocabulary.OWL_OBJECTPROPERTY + ">.");
for (String one : specialTypes) {
- s.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><"
+ s.add(getNTripleForm()+"<" + OWLVocabulary.RDF_TYPE + "><"
+ one + ">.");
}
@@ -115,6 +97,28 @@
return s;
}
+
+ @Override
+ public void toOWLOntology( OWLAPIOntologyCollector owlAPIOntologyCollector){
+ //FIXME Property information
+ OWLDataFactory factory = owlAPIOntologyCollector.getFactory();
+ OWLObjectProperty me =factory.getOWLObjectPro...
[truncated message content] |
|
From: <ku...@us...> - 2008-09-23 23:24:43
|
Revision: 1244
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1244&view=rev
Author: kurzum
Date: 2008-09-23 23:24:34 +0000 (Tue, 23 Sep 2008)
Log Message:
-----------
added function getOWLAPIOntology to SparqlKnowledgeSource
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java
trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-23 23:24:34 UTC (rev 1244)
@@ -76,6 +76,15 @@
return (String) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "cacheDir") ;
}
/**
+* useCache If true a Cache is used.
+* mandatory: false| reinit necessary: true
+* default value: true
+* @return boolean
+**/
+public boolean getUseCache() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "useCache") ;
+}
+/**
* instances relevant instances e.g. positive and negative examples in a learning problem.
* mandatory: true| reinit necessary: true
* default value: null
@@ -142,60 +151,15 @@
return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "objList") ;
}
/**
-* format N-TRIPLES or KB format.
+* saveExtractedFragment Specifies whether the extracted ontology is written to a file or not..
* mandatory: false| reinit necessary: true
-* default value: N-TRIPLES
-* @return String
-**/
-public String getFormat() {
-return (String) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "format") ;
-}
-/**
-* dumpToFile Specifies whether the extracted ontology is written to a file or not..
-* mandatory: false| reinit necessary: true
* default value: true
* @return boolean
**/
-public boolean getDumpToFile() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "dumpToFile") ;
+public boolean getSaveExtractedFragment() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "saveExtractedFragment") ;
}
/**
-* convertNT2RDF Specifies whether the extracted NTriples are converted to RDF and deleted..
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getConvertNT2RDF() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "convertNT2RDF") ;
-}
-/**
-* useLits use Literals in SPARQL query.
-* mandatory: false| reinit necessary: true
-* default value: true
-* @return boolean
-**/
-public boolean getUseLits() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "useLits") ;
-}
-/**
-* getAllSuperClasses If true then all superclasses are retrieved until the most general class (owl:Thing) is reached..
-* mandatory: false| reinit necessary: true
-* default value: true
-* @return boolean
-**/
-public boolean getGetAllSuperClasses() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "getAllSuperClasses") ;
-}
-/**
-* useCache If true a Cache is used.
-* mandatory: false| reinit necessary: true
-* default value: true
-* @return boolean
-**/
-public boolean getUseCache() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "useCache") ;
-}
-/**
* replacePredicate rule for replacing predicates.
* mandatory: false| reinit necessary: true
* default value: []
@@ -225,6 +189,24 @@
return (Integer) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "breakSuperClassRetrievalAfter") ;
}
/**
+* useLits use Literals in SPARQL query.
+* mandatory: false| reinit necessary: true
+* default value: true
+* @return boolean
+**/
+public boolean getUseLits() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "useLits") ;
+}
+/**
+* getAllSuperClasses If true then all superclasses are retrieved until the most general class (owl:Thing) is reached..
+* mandatory: false| reinit necessary: true
+* default value: true
+* @return boolean
+**/
+public boolean getGetAllSuperClasses() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "getAllSuperClasses") ;
+}
+/**
* closeAfterRecursion gets all classes for all instances.
* mandatory: false| reinit necessary: true
* default value: true
@@ -291,6 +273,15 @@
reinitNecessary = true;
}
/**
+* @param useCache If true a Cache is used.
+* mandatory: false| reinit necessary: true
+* default value: true
+**/
+public void setUseCache(boolean useCache) {
+ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "useCache", useCache);
+reinitNecessary = true;
+}
+/**
* @param instances relevant instances e.g. positive and negative examples in a learning problem.
* mandatory: true| reinit necessary: true
* default value: null
@@ -354,60 +345,15 @@
reinitNecessary = true;
}
/**
-* @param format N-TRIPLES or KB format.
+* @param saveExtractedFragment Specifies whether the extracted ontology is written to a file or not..
* mandatory: false| reinit necessary: true
-* default value: N-TRIPLES
-**/
-public void setFormat(String format) {
-ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "format", format);
-reinitNecessary = true;
-}
-/**
-* @param dumpToFile Specifies whether the extracted ontology is written to a file or not..
-* mandatory: false| reinit necessary: true
* default value: true
**/
-public void setDumpToFile(boolean dumpToFile) {
-ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "dumpToFile", dumpToFile);
+public void setSaveExtractedFragment(boolean saveExtractedFragment) {
+ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "saveExtractedFragment", saveExtractedFragment);
reinitNecessary = true;
}
/**
-* @param convertNT2RDF Specifies whether the extracted NTriples are converted to RDF and deleted..
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setConvertNT2RDF(boolean convertNT2RDF) {
-ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "convertNT2RDF", convertNT2RDF);
-reinitNecessary = true;
-}
-/**
-* @param useLits use Literals in SPARQL query.
-* mandatory: false| reinit necessary: true
-* default value: true
-**/
-public void setUseLits(boolean useLits) {
-ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "useLits", useLits);
-reinitNecessary = true;
-}
-/**
-* @param getAllSuperClasses If true then all superclasses are retrieved until the most general class (owl:Thing) is reached..
-* mandatory: false| reinit necessary: true
-* default value: true
-**/
-public void setGetAllSuperClasses(boolean getAllSuperClasses) {
-ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "getAllSuperClasses", getAllSuperClasses);
-reinitNecessary = true;
-}
-/**
-* @param useCache If true a Cache is used.
-* mandatory: false| reinit necessary: true
-* default value: true
-**/
-public void setUseCache(boolean useCache) {
-ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "useCache", useCache);
-reinitNecessary = true;
-}
-/**
* @param replacePredicate rule for replacing predicates.
* mandatory: false| reinit necessary: true
* default value: []
@@ -435,6 +381,24 @@
reinitNecessary = true;
}
/**
+* @param useLits use Literals in SPARQL query.
+* mandatory: false| reinit necessary: true
+* default value: true
+**/
+public void setUseLits(boolean useLits) {
+ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "useLits", useLits);
+reinitNecessary = true;
+}
+/**
+* @param getAllSuperClasses If true then all superclasses are retrieved until the most general class (owl:Thing) is reached..
+* mandatory: false| reinit necessary: true
+* default value: true
+**/
+public void setGetAllSuperClasses(boolean getAllSuperClasses) {
+ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "getAllSuperClasses", getAllSuperClasses);
+reinitNecessary = true;
+}
+/**
* @param closeAfterRecursion gets all classes for all instances.
* mandatory: false| reinit necessary: true
* default value: true
Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-23 23:06:40 UTC (rev 1243)
+++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-23 23:24:34 UTC (rev 1244)
@@ -96,27 +96,26 @@
this.configurator = new SparqlKnowledgeSourceConfigurator(this);
}
- // ConfigOptions
+ // these are saved for further reference
private URL url;
+ private SparqlEndpoint endpoint = null;
//private String format = "N-TRIPLES";
- private String format = "RDF/XML";
+ //private String format = "RDF/XML";
- private boolean dumpToFile = true;
+ private URL ontologyFragmentURL;
+
-
- private URL dumpFile;
-
private OWLOntology fragment;
- private SparqlEndpoint endpoint = null;
+
// received ontology as array, used if format=Array(an element of the
// array consists of the subject, predicate and object separated by '<'
- private String[] ontArray;
+ //private String[] ontArray;
// received ontology as KB, the internal format
- private KB kb;
+ //private KB kb;
// mainly used for statistic
private int nrOfExtractedTriples = 0;
@@ -140,6 +139,8 @@
null, true, true));
options.add(new StringConfigOption("cacheDir", "dir of cache", "cache",
false, true));
+ options.add(new BooleanConfigOption("useCache",
+ "If true a Cache is used", true, false, true));
options
.add(new StringSetConfigOption(
"instances",
@@ -166,27 +167,14 @@
"list of all ignored roles", new TreeSet<String>(), false, true));
options.add(new StringSetConfigOption("objList",
"list of all ignored objects", new TreeSet<String>(), false, true));
- options.add(new StringConfigOption("format", "N-TRIPLES or KB format",
- "N-TRIPLES", false, true));
options
.add(new BooleanConfigOption(
- "dumpToFile",
+ "saveExtractedFragment",
"Specifies whether the extracted ontology is written to a file or not.",
true, false, true));
- options
- .add(new BooleanConfigOption(
- "convertNT2RDF",
- "Specifies whether the extracted NTriples are converted to RDF and deleted.",
- false, false, true));
- options.add(new BooleanConfigOption("useLits",
- "use Literals in SPARQL query", true, false, true));
- options
- .add(new BooleanConfigOption(
- "getAllSuperClasses",
- "If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.",
- true, false, true));
- options.add(new BooleanConfigOption("useCache",
- "If true a Cache is used", true, false, true));
+
+
+
options.add(new StringTupleListConfigOption("replacePredicate",
"rule for replacing predicates", new ArrayList<StringTuple>(), false, true));
options.add(new StringTupleListConfigOption("replaceObject",
@@ -194,6 +182,14 @@
options.add(new IntegerConfigOption("breakSuperClassRetrievalAfter",
"stops a cyclic hierarchy after specified number of classes",
1000, false, true));
+
+ options.add(new BooleanConfigOption("useLits",
+ "use Literals in SPARQL query", true, false, true));
+ options
+ .add(new BooleanConfigOption(
+ "getAllSuperClasses",
+ "If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.",
+ true, false, true));
options.add(new BooleanConfigOption("closeAfterRecursion",
"gets all classes for all instances", true, false, true));
options.add(new BooleanConfigOption("getPropertyInformation",
@@ -264,7 +260,7 @@
extractionTime.printAndSet("extraction needed");
logger.info("Finished collecting Fragment");
- dumpFile = m.getPhysicalOntologyURL();
+ ontologyFragmentURL = m.getPhysicalOntologyURL();
/*
if (dumpToFile) {
@@ -322,12 +318,13 @@
*/
@Override
public String toDIG(URI kbURI) {
- if (format.equals("RDF/XML")){
- return JenaOWLDIGConverter.getTellsString(dumpFile,
+ //if (format.equals("RDF/XML")){
+ return JenaOWLDIGConverter.getTellsString(ontologyFragmentURL,
OntologyFormat.RDF_XML, kbURI);
- }else {
- return DIGConverter.getDIGString(kb, kbURI).toString();
- }
+ //}else {
+ //throw new Error("KB Format not supported any more");
+ //return DIGConverter.getDIGString(kb, kbURI).toString();
+ //}
}
/*
@@ -366,9 +363,9 @@
}
- public String[] getOntArray() {
+ /*public String[] getOntArray() {
return ontArray;
- }
+ }*/
public SparqlQuery sparqlQuery(String query) {
return new SparqlQuery(query, getSparqlEndpoint());
@@ -456,12 +453,16 @@
@Override
public KB toKB() {
// TODO Does this work?
- return kb;
+ return new KB();
}
- public URL getNTripleURL() {
- return dumpFile;
+ public URL getOntologyFragmentURL() {
+ return ontologyFragmentURL;
}
+
+ public OWLOntology getOWLAPIOntology() {
+ return fragment;
+ }
public boolean isUseCache() {
return configurator.getUseCache();
Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-23 23:06:40 UTC (rev 1243)
+++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-23 23:24:34 UTC (rev 1244)
@@ -206,7 +206,7 @@
url = ((OWLFile)source).getURL();
}
else if(source instanceof SparqlKnowledgeSource) {
- url=((SparqlKnowledgeSource)source).getNTripleURL();
+ url=((SparqlKnowledgeSource)source).getOntologyFragmentURL();
}
try {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-24 06:10:56
|
Revision: 1245
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1245&view=rev
Author: jenslehmann
Date: 2008-09-24 06:10:45 +0000 (Wed, 24 Sep 2008)
Log Message:
-----------
removed unresolved import
Modified Paths:
--------------
trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java
trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java
trunk/src/dl-learner/org/dllearner/scripts/NT2RDF.java
Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-09-23 23:24:34 UTC (rev 1244)
+++ trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-09-24 06:10:45 UTC (rev 1245)
@@ -24,14 +24,12 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import org.apache.commons.collections.list.TypedList;
import org.apache.log4j.Logger;
import org.dllearner.kb.aquisitors.RDFBlankNode;
import org.dllearner.kb.aquisitors.TupleAquisitor;
import org.dllearner.kb.manipulator.Manipulator;
import org.dllearner.utilities.datastructures.RDFNodeTuple;
import org.dllearner.utilities.owl.OWLVocabulary;
-import org.semanticweb.owl.expression.OWLExpressionParser;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLDataFactory;
import org.semanticweb.owl.model.OWLDataProperty;
Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-23 23:24:34 UTC (rev 1244)
+++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-24 06:10:45 UTC (rev 1245)
@@ -54,7 +54,6 @@
import org.dllearner.kb.manipulator.ObjectReplacementRule;
import org.dllearner.kb.manipulator.PredicateReplacementRule;
import org.dllearner.kb.manipulator.Rule.Months;
-import org.dllearner.reasoning.DIGConverter;
import org.dllearner.reasoning.JenaOWLDIGConverter;
import org.dllearner.utilities.Files;
import org.dllearner.utilities.JamonMonitorLogger;
Modified: trunk/src/dl-learner/org/dllearner/scripts/NT2RDF.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/scripts/NT2RDF.java 2008-09-23 23:24:34 UTC (rev 1244)
+++ trunk/src/dl-learner/org/dllearner/scripts/NT2RDF.java 2008-09-24 06:10:45 UTC (rev 1245)
@@ -16,6 +16,7 @@
* 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.scripts;
+
import java.io.File;
import java.net.URI;
@@ -24,50 +25,45 @@
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyManager;
-import com.hp.hpl.jena.rdf.arp.NTriple;
public class NT2RDF {
-
- public static void main(String[] args) {
-
- //String ontopath=args[0];
- String ontopath = "examples/semantic_bible/NTNcombined.nt";
- //String ontopath = "examples/semantic_bible/test.nt";
- convertNT2RDF(ontopath);
-
-
- }
-
-
- /**
- * converts .nt file to rdf, same file name, different ending
- * @param ontopath path to nt file
- */
- public static void convertNT2RDF(String ontopath){
-
- try {
- URI inputURI = new File(ontopath).toURI();
- System.out.println(inputURI);
- // outputURI
- String ending = ontopath.substring(ontopath.lastIndexOf(".") + 1);
- System.out.println(ending);
- ontopath = ontopath.replace("." + ending, ".rdf" );
- URI outputURI = new File(ontopath).toURI();
+ public static void main(String[] args) {
- OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
- OWLOntology ontology = manager.loadOntologyFromPhysicalURI(inputURI);
- manager.saveOntology(ontology, new RDFXMLOntologyFormat(), outputURI);
- //manager.saveOntology(ontology, new NTriple(), outputURI);
- // Remove the ontology from the manager
- manager.removeOntology(ontology.getURI());
- }
- catch (Exception e) {
- System.out.println("The ontology could not be created: " + e.getMessage());
- e.printStackTrace();
- }
-
- }
-
+ // String ontopath=args[0];
+ String ontopath = "examples/semantic_bible/NTNcombined.nt";
+ // String ontopath = "examples/semantic_bible/test.nt";
+ convertNT2RDF(ontopath);
+
}
+ /**
+ * converts .nt file to rdf, same file name, different ending
+ *
+ * @param ontopath
+ * path to nt file
+ */
+ public static void convertNT2RDF(String ontopath) {
+ try {
+ URI inputURI = new File(ontopath).toURI();
+ System.out.println(inputURI);
+ // outputURI
+ String ending = ontopath.substring(ontopath.lastIndexOf(".") + 1);
+ System.out.println(ending);
+ ontopath = ontopath.replace("." + ending, ".rdf");
+ URI outputURI = new File(ontopath).toURI();
+
+ OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
+ OWLOntology ontology = manager.loadOntologyFromPhysicalURI(inputURI);
+ manager.saveOntology(ontology, new RDFXMLOntologyFormat(), outputURI);
+ // manager.saveOntology(ontology, new NTriple(), outputURI);
+ // Remove the ontology from the manager
+ manager.removeOntology(ontology.getURI());
+ } catch (Exception e) {
+ System.out.println("The ontology could not be created: " + e.getMessage());
+ e.printStackTrace();
+ }
+
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2008-09-24 08:09:53
|
Revision: 1246
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1246&view=rev
Author: jenslehmann
Date: 2008-09-24 08:09:38 +0000 (Wed, 24 Sep 2008)
Log Message:
-----------
added package.html files for various packages
Added Paths:
-----------
trunk/src/dl-learner/org/dllearner/core/configurators/package.html
trunk/src/dl-learner/org/dllearner/gui/widgets/package.html
trunk/src/dl-learner/org/dllearner/tools/ore/package.html
trunk/src/dl-learner/org/dllearner/tools/protege/package.html
trunk/src/dl-learner/org/dllearner/utilities/datastructures/package.html
trunk/src/dl-learner/org/dllearner/utilities/examples/package.html
trunk/src/dl-learner/org/dllearner/utilities/learn/package.html
trunk/src/dl-learner/org/dllearner/utilities/owl/package.html
trunk/src/dl-learner/org/dllearner/utilities/statistics/package.html
Added: trunk/src/dl-learner/org/dllearner/core/configurators/package.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/core/configurators/package.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/core/configurators/package.html 2008-09-24 08:09:38 UTC (rev 1246)
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+<p>Automatically generated classes, which enable programmatically setting
+and getting configuration options of components.</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/src/dl-learner/org/dllearner/gui/widgets/package.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/gui/widgets/package.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/gui/widgets/package.html 2008-09-24 08:09:38 UTC (rev 1246)
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+<p>Widgets for displaying and setting values of configuration options.</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/src/dl-learner/org/dllearner/tools/ore/package.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/tools/ore/package.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/tools/ore/package.html 2008-09-24 08:09:38 UTC (rev 1246)
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+<p>The ontology repair and enrichment tool.</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/src/dl-learner/org/dllearner/tools/protege/package.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/tools/protege/package.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/tools/protege/package.html 2008-09-24 08:09:38 UTC (rev 1246)
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+<p>The Protege DL-Learner plugin, which enables learning
+class descriptions in the Protege ontology editor.</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/src/dl-learner/org/dllearner/utilities/datastructures/package.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/datastructures/package.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/utilities/datastructures/package.html 2008-09-24 08:09:38 UTC (rev 1246)
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+<p>Utility classesfor manipulating general data structures. Note that
+OWL related datastructures have their own package.</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/src/dl-learner/org/dllearner/utilities/examples/package.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/examples/package.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/utilities/examples/package.html 2008-09-24 08:09:38 UTC (rev 1246)
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+<p>Utility classes related to finding/modifying examples of
+learning problems.</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/src/dl-learner/org/dllearner/utilities/learn/package.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/learn/package.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/utilities/learn/package.html 2008-09-24 08:09:38 UTC (rev 1246)
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+<p>Reusable learnings tasks.</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/src/dl-learner/org/dllearner/utilities/owl/package.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/owl/package.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/utilities/owl/package.html 2008-09-24 08:09:38 UTC (rev 1246)
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+<p>OWL utility classes (file manipulation, converting
+between different formats, orderings on OWL structures etc.).</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/src/dl-learner/org/dllearner/utilities/statistics/package.html
===================================================================
--- trunk/src/dl-learner/org/dllearner/utilities/statistics/package.html (rev 0)
+++ trunk/src/dl-learner/org/dllearner/utilities/statistics/package.html 2008-09-24 08:09:38 UTC (rev 1246)
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+<p>Utility classes for capturing statistics.</p>
+</body>
+</html>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|