From: <jen...@us...> - 2008-06-30 08:56:15
|
Revision: 992 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=992&view=rev Author: jenslehmann Date: 2008-06-30 01:56:11 -0700 (Mon, 30 Jun 2008) Log Message: ----------- - added convenience method to get SPARQL query for evaluated description - fixed all warnings (you should now have zero errors, zero warnings, zero notices) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.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/PropertyNode.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-06-30 08:56:11 UTC (rev 992) @@ -53,12 +53,12 @@ */ public class DBpediaNavigationSuggestor extends LearningAlgorithm { - private ReasoningService rs; +// private ReasoningService rs; private ExampleBasedROLComponent learner; private static String defaultSearchTreeFile = "log/searchTree.txt"; public DBpediaNavigationSuggestor(LearningProblem learningProblem, ReasoningService rs) { - this.rs=rs; +// this.rs=rs; if(learningProblem instanceof PosNegLP) { PosNegLP lp = (PosNegLP) learningProblem; this.learner=new ExampleBasedROLComponent(lp, rs); Modified: trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-06-30 08:56:11 UTC (rev 992) @@ -38,7 +38,7 @@ */ public class SimpleSuggestionLearningAlgorithm extends LearningAlgorithm implements Runnable { - private boolean stop = false; +// private boolean stop = false; private Score solutionScore; private Description bestSollution; private Set<Description> simpleSuggestions; @@ -59,7 +59,7 @@ @Override public void stop() { - stop = true; +// stop = true; } @Override Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-06-30 08:56:11 UTC (rev 992) @@ -23,6 +23,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; +import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; import org.dllearner.learningproblems.ScoreTwoValued; /** @@ -41,11 +42,24 @@ private Description description; private Score score; + /** + * Constructs an evaluated description using its score. + * @param description The description, which was evaluated. + * @param score The score of the description. + */ public EvaluatedDescription(Description description, Score score) { this.description = description; this.score = score; } + /** + * Constructs an evaluated description using example coverage. + * @param description The description, which was evaluated. + * @param posAsPos Positive examples classified as positive by (i.e. instance of) the description. + * @param posAsNeg Positive examples classified as negative by (i.e. not instance of) the description. + * @param negAsPos Negative examples classified as positive by (i.e. instance of) the description. + * @param negAsNeg Negative examples classified as negative by (i.e. not instance of) the description. + */ public EvaluatedDescription(Description description, Set<Individual> posAsPos, Set<Individual> posAsNeg, Set<Individual> negAsPos, Set<Individual> negAsNeg) { this.description = description; // usually core methods should not depend on methods outside of the core package (except utilities) @@ -53,20 +67,29 @@ score = new ScoreTwoValued(posAsPos, posAsNeg, negAsPos, negAsNeg); } + /** + * Gets the description, which was evaluated. + * @return The underlying description. + */ public Description getDescription() { return description; } + /** + * @see org.dllearner.core.owl.Description#getLength() + */ public int getDescriptionLength() { return description.getLength(); } + /** + * @see org.dllearner.core.owl.Description#getDepth() + */ public int getDescriptionDepth() { return description.getDepth(); } /** - * @return * @see org.dllearner.core.Score#getAccuracy() */ public double getAccuracy() { @@ -74,7 +97,6 @@ } /** - * @return * @see org.dllearner.core.Score#getCoveredNegatives() */ public Set<Individual> getCoveredNegatives() { @@ -82,7 +104,6 @@ } /** - * @return * @see org.dllearner.core.Score#getCoveredPositives() */ public Set<Individual> getCoveredPositives() { @@ -90,7 +111,6 @@ } /** - * @return * @see org.dllearner.core.Score#getNotCoveredNegatives() */ public Set<Individual> getNotCoveredNegatives() { @@ -98,11 +118,24 @@ } /** - * @return * @see org.dllearner.core.Score#getNotCoveredPositives() */ public Set<Individual> getNotCoveredPositives() { return score.getNotCoveredPositives(); } + /** + * Returns a SPARQL query to get instances of this description + * from a SPARQL endpoint. Of course, results may be incomplete, + * because no inference is done. The SPARQL query is a straightforward + * translation without any attempts to perform e.g. subclass + * inferencing. + * + * @param limit The maximum number of results. Corresponds to LIMIT + * in SPARQL. + * @return A SPARQL query of the underlying description. + */ + public String getSparqlQuery(int limit) { + return SparqlQueryDescriptionConvertVisitor.getSparqlQuery(description, limit); + } } Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-06-30 08:56:11 UTC (rev 992) @@ -38,7 +38,6 @@ import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.utilities.datastructures.SortedSetTuple; -import org.semanticweb.owl.model.OWLClass; /** * @author Jens Lehmann Modified: trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java 2008-06-30 08:56:11 UTC (rev 992) @@ -20,6 +20,7 @@ this.ontology = onto; } + @Override public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { @@ -30,21 +31,25 @@ return ontology; } + @Override public KB toKB() { throw new Error("OWL -> KB conversion not implemented yet."); } + @Override public void init() { } + @Override public void export(File file, OntologyFormat format) { } + @Override public String toDIG(URI kbURI) { return null; Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java 2008-06-30 08:56:11 UTC (rev 992) @@ -52,9 +52,9 @@ StringTuple t = (StringTuple) it.next(); try { // substitute rdf:type with owl:subclassof - if (t.a.equals(m.type) || t.a.equals(m.subclass)) { + if (t.a.equals(Manipulators.type) || t.a.equals(Manipulators.subclass)) { ClassNode tmp = new ClassNode(new URI(t.b)); - properties.add(new PropertyNode(new URI(m.subclass), this, + properties.add(new PropertyNode(new URI(Manipulators.subclass), this, tmp)); Nodes.add(tmp); } else { @@ -67,9 +67,9 @@ // if o is a blank node expand further // TODO this needs a lot more work - if (t.b.startsWith(m.blankNodeIdentifier)) { + if (t.b.startsWith(Manipulators.blankNodeIdentifier)) { tmp.expand(tsq, m); - System.out.println(m.blankNodeIdentifier); + System.out.println(Manipulators.blankNodeIdentifier); System.out.println("XXXXX" + t.b); } // Nodes.add(tmp); Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java 2008-06-30 08:56:11 UTC (rev 992) @@ -131,7 +131,7 @@ Node next = instances.remove(0); logger.trace("Getting classes for: " + next); classes.addAll(next.expand(tsqc, manipulator)); - if (classes.size() >= manipulator.breakSuperClassRetrievalAfter) { + if (classes.size() >= Manipulators.breakSuperClassRetrievalAfter) { break; } } @@ -155,7 +155,7 @@ // if(i % 50==0)System.out.println("got "+i+" extra classes, // max: "+manipulator.breakSuperClassRetrievalAfter); i++; - if (i >= manipulator.breakSuperClassRetrievalAfter) { + if (i >= Manipulators.breakSuperClassRetrievalAfter) { break; } } Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-06-30 08:56:11 UTC (rev 992) @@ -64,7 +64,7 @@ // basically : if p is rdf:type then o is a class // else it is an instance try { - if (t.a.equals(m.type)) { + if (t.a.equals(Manipulators.type)) { ClassNode tmp = new ClassNode(new URI(t.b)); classes.add(tmp); Nodes.add(tmp); Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java 2008-06-30 08:56:11 UTC (rev 992) @@ -67,7 +67,7 @@ while (it.hasNext()) { StringTuple t = (StringTuple) it.next(); try { - if (t.a.equals(m.type)) { + if (t.a.equals(Manipulators.type)) { specialTypes.add(t.b); } } catch (Exception e) { Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java 2008-06-30 08:56:11 UTC (rev 992) @@ -1,6 +1,24 @@ +/** + * 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.sparql; - import java.util.HashMap; import java.util.SortedSet; import java.util.Stack; @@ -34,7 +52,9 @@ /** * Converter from DL-Learner descriptions to a corresponding SPARQL query * to get all instances that are described by this description. + * * @author Sebastian Knappe + * @author Sebastian Hellmann * */ public class SparqlQueryDescriptionConvertVisitor implements DescriptionVisitor{ Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-06-30 08:56:11 UTC (rev 992) @@ -83,7 +83,7 @@ String prim="http://dbpedia.org/resource/Category:Prime_Ministers_of_the_United_Kingdom"; - String award=("http://dbpedia.org/resource/Category:Best_Actor_Academy_Award_winners"); +// String award=("http://dbpedia.org/resource/Category:Best_Actor_Academy_Award_winners"); SKOS7030 s= new SKOS7030(); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java 2008-06-28 07:28:11 UTC (rev 991) +++ trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java 2008-06-30 08:56:11 UTC (rev 992) @@ -22,7 +22,6 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; -import org.dllearner.reasoning.OWLAPIReasoner; import org.semanticweb.owl.model.OWLOntologyChange; import org.semanticweb.owl.model.RemoveAxiom; @@ -49,17 +48,17 @@ private ORE ore; private Individual ind; - private OWLAPIReasoner reasoner; +// private OWLAPIReasoner reasoner; private Description actualDesc; private Description newDesc; - private Individual object; +// private Individual object; public NegExampleRepairDialog(Individual ind, JDialog dialog, ORE ore){ super(dialog, "Repair negative example", true); this.ind = ind; this.ore = ore; - this.reasoner = ore.reasoner2; +// this.reasoner = ore.reasoner2; init(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |