From: <lor...@us...> - 2011-01-18 12:25:36
|
Revision: 2619 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2619&view=rev Author: lorenz_b Date: 2011-01-18 12:25:29 +0000 (Tue, 18 Jan 2011) Log Message: ----------- Added 2 methods to cache which have a max execution time for SPARQL queries. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-01-18 10:22:55 UTC (rev 2618) +++ trunk/components-core/pom.xml 2011-01-18 12:25:29 UTC (rev 2619) @@ -164,6 +164,11 @@ <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> + + <dependency> + <groupId>org.aksw.commons</groupId> + <artifactId>commons</artifactId> + </dependency> </dependencies> </project> Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2011-01-18 10:22:55 UTC (rev 2618) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2011-01-18 12:25:29 UTC (rev 2619) @@ -32,13 +32,13 @@ import java.sql.SQLException; import java.sql.Statement; +import org.aksw.commons.jena.ExtendedQueryEngineHTTP; import org.dllearner.utilities.Helper; import com.hp.hpl.jena.query.ResultSetFactory; import com.hp.hpl.jena.query.ResultSetRewindable; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; -import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; @@ -99,6 +99,10 @@ } public Model executeConstructQuery(SparqlEndpoint endpoint, String query) throws SQLException, UnsupportedEncodingException { + return executeConstructQuery(endpoint, query, 0); + } + + public Model executeConstructQuery(SparqlEndpoint endpoint, String query, int maxExecutionTimeInSeconds) throws SQLException, UnsupportedEncodingException { mon.start(); byte[] md5 = md5(query); // Timestamp currTS = new Timestamp(new java.util.Date().getTime()); @@ -128,7 +132,8 @@ // System.out.println("Posing new query"); // String endpoint = "http://139.18.2.37:8890/sparql"; - QueryEngineHTTP queryExecution = new QueryEngineHTTP(endpoint.getURL().toString(), query); + ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(endpoint.getURL().toString(), query); + queryExecution.setTimeOut(maxExecutionTimeInSeconds * 1000); for (String dgu : endpoint.getDefaultGraphURIs()) { queryExecution.addDefaultGraph(dgu); } @@ -164,6 +169,10 @@ } public String executeSelectQuery(SparqlEndpoint endpoint, String query) { + return executeSelectQuery(endpoint, query, 0); + } + + public String executeSelectQuery(SparqlEndpoint endpoint, String query, int maxExecutionTimeInSeconds) { try { @@ -182,7 +191,8 @@ return clob.getSubString(1, (int) clob.length()); } else { // System.out.println("no-cache"); - QueryEngineHTTP queryExecution = new QueryEngineHTTP(endpoint.getURL().toString(), query); + ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(endpoint.getURL().toString(), query); + queryExecution.setTimeOut(maxExecutionTimeInSeconds * 1000); for (String dgu : endpoint.getDefaultGraphURIs()) { queryExecution.addDefaultGraph(dgu); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ji...@us...> - 2011-05-02 14:56:57
|
Revision: 2778 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2778&view=rev Author: jialva Date: 2011-05-02 14:56:50 +0000 (Mon, 02 May 2011) Log Message: ----------- New update of fuzzyDL-Learner Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest.java Added Paths: ----------- trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains.java trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_noFuzzyTrains.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-04-28 17:44:44 UTC (rev 2777) +++ trunk/components-core/pom.xml 2011-05-02 14:56:50 UTC (rev 2778) @@ -201,7 +201,7 @@ <version>1.0</version> </dependency> - <dependency> + <dependency> <groupId>fuzzydll</groupId> <artifactId>fuzzyowl2fuzzydlparser</artifactId> <version>1.0</version> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java 2011-04-28 17:44:44 UTC (rev 2777) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java 2011-05-02 14:56:50 UTC (rev 2778) @@ -54,6 +54,7 @@ import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.learningproblems.fuzzydll.FuzzyPosNegLP; import org.dllearner.learningproblems.fuzzydll.FuzzyPosNegLPStandard; import org.dllearner.refinementoperators.OperatorInverter; import org.dllearner.refinementoperators.RefinementOperator; @@ -308,9 +309,13 @@ } } else if(learningProblem instanceof PosOnlyLP) { examples = ((PosOnlyLP)learningProblem).getPositiveExamples(); - } else if(learningProblem instanceof PosNegLP) { + // changed by Josue + } else if (learningProblem instanceof PosNegLP) { examples = Helper.union(((PosNegLP)learningProblem).getPositiveExamples(),((PosNegLP)learningProblem).getNegativeExamples()); + } else if (learningProblem instanceof FuzzyPosNegLP) { + examples = Helper.union(((FuzzyPosNegLP)learningProblem).getPositiveExamples(),((FuzzyPosNegLP)learningProblem).getNegativeExamples()); } + } @Override Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java 2011-04-28 17:44:44 UTC (rev 2777) +++ trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java 2011-05-02 14:56:50 UTC (rev 2778) @@ -73,6 +73,8 @@ private boolean useOldDIGOptions = false; private HeuristicType heuristic = HeuristicType.PRED_ACC; + + private int errorIndex = 0; @Override public FuzzyPosNegLPStandardConfigurator getConfigurator() { @@ -506,10 +508,10 @@ * @see org.dllearner.core.LearningProblem#getAccuracyOrTooWeak(org.dllearner.core.owl.Description, double) */ public double getPredAccuracyOrTooWeakExact(Description description, double noise) { - + double crispAccuracy = crispAccuracy(description, noise); // if I erase next line, fuzzy reasoning fails - // if (crispAccuracy == -1) return -1; + if (crispAccuracy == -1) return -1; // BEGIN // added by Josue @@ -527,27 +529,17 @@ double fuzzyAccuracy = descriptionMembership / (double)fuzzyExamples.size(); - // double fuzzyAccuracy = (posMembership + (negativeExamples.size() - negMembership)) / (double) allExamples.size(); - // END - -// if(useFMeasure) { -// double recall = (positiveExamples.size() - notCoveredPos) / (double) positiveExamples.size(); -// double precision = (positiveExamples.size() - notCoveredPos) / (double) (allExamples.size() - notCoveredPos - notCoveredNeg); -// return getFMeasure(recall, precision); -// } else { - // double crispAccuracy = crispAccuracy(description, noise); -// } - - crispAccuracy = fuzzyAccuracy; - if (crispAccuracy != fuzzyAccuracy) { System.err.println("***********************************************"); - System.err.println("* (crispAccuracy[" + crispAccuracy + "] != fuzzyAccuracy)[" + fuzzyAccuracy + "] *"); + System.err.println("* " + (errorIndex++)); + System.err.println("* (crispAccuracy[" + crispAccuracy + "] != fuzzyAccuracy[" + fuzzyAccuracy + "])"); + System.err.println("* DESC: " + description); System.err.println("***********************************************"); - Scanner sc = new Scanner(System.in); - sc.nextLine(); } +// Scanner sc = new Scanner(System.in); +// sc.nextLine(); + } - return crispAccuracy; + return fuzzyAccuracy; } // added by Josue @@ -581,6 +573,7 @@ double totalMembershipDegree = 0; double invertedCoveredMembershipDegree = 0; + // TODO to optimize for (FuzzyIndividual ind: fuzzyExamples) { coveredMembershipDegree += reasoner.hasTypeFuzzyMembership(description, ind) * ind.getBeliefDegree(); totalMembershipDegree += ind.getBeliefDegree(); @@ -620,7 +613,7 @@ // return getFMeasure(recall, precision); double crispFmeasure = Heuristics.getFScore(recall, precision); - crispFmeasure = fuzzyFmeasure; + // crispFmeasure = fuzzyFmeasure; if (crispFmeasure != fuzzyFmeasure) { System.err.println("************************"); @@ -631,7 +624,7 @@ sc.nextLine(); } - return crispFmeasure; + return fuzzyFmeasure; } // instead of using the standard operation, we use optimisation Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2011-04-28 17:44:44 UTC (rev 2777) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2011-05-02 14:56:50 UTC (rev 2778) @@ -1,9 +1,8 @@ package org.dllearner.reasoning.fuzzydll; import java.io.FileInputStream; -import java.util.ArrayList; +import java.util.Iterator; import java.util.Scanner; - import org.semanticweb.owlapi.model.OWLClassExpression; import org.semanticweb.owlapi.model.OWLEntity; import org.semanticweb.owlapi.model.OWLIndividual; @@ -12,40 +11,37 @@ import fuzzydl.exception.FuzzyOntologyException; import fuzzydl.milp.Solution; import fuzzydl.parser.*; -import fuzzydll.fuzzyowl2fuzzydlparser.FuzzyOwl2toFuzzyDL; +import fuzzydll.fuzzyowl2fuzzydlparser.*; public class FuzzyDLReasonerManager { private static final String CHANGING_JUST_HIERARCHI_PROBLEM = "/Users/josue/Documents/PhD/AKSW/fuzzySemanticTools/FuzzyDLMacOSX/FuzzyDL/examples/output/fuzzyOWL2fuzzyDLparserOutput_manual.fuzzyDL.txt"; private static final String FUZZYOWL2FUZZYDLPARSEROUTPUT = "/Users/josue/Documents/PhD/AKSW/fuzzySemanticTools/FuzzyDLMacOSX/FuzzyDL/examples/output/fuzzyOWL2fuzzyDLparserOutput.fuzzyDL.txt"; private static String CONFIG_FILENAME = "/Users/josue/Documents/PhD/AKSW/fuzzySemanticTools/FuzzyDLMacOSX/FuzzyDL/CONFIG"; - + private Solution queryResult; private KnowledgeBase fuzzyKB; private Parser parser; private SimpleShortFormProvider shortFormParser; - - // private OWLAPI2fuzzyDLConvertVisitor converter; - - private FuzzyOwl2toFuzzyDL fuzzyParser; - + + private FuzzyOwl2toFuzzyDL fuzzyFileParser; + private int auxCounter = 0; + public FuzzyDLReasonerManager(String ontologyFile) throws Exception { queryResult = null; parser = null; - + shortFormParser = new SimpleShortFormProvider(); - // converter = new OWLAPI2fuzzyDLConvertVisitor(); - + ConfigReader.loadParameters(CONFIG_FILENAME, new String[0]); - - fuzzyKB = parseOWLontologyToFuzzyDLsyntax(ontologyFile); + fuzzyKB = parseOWLontologyToFuzzyDLsyntax(ontologyFile); +// fuzzyFileParser.setBaseKB(fuzzyKB); + OWLAPI_fuzzyDLObjectParser.setParsingFuzzyKB(fuzzyFileParser, fuzzyKB); + solveKB(); - - // testAux(); - } - + private void solveKB() { try { fuzzyKB.solveKB(); @@ -54,71 +50,67 @@ } } - private void testAux() { - // query stored in the KB - ArrayList <Query> queries = parser.getQueries(); - Query q1 = queries.get(0); - System.out.println(q1); - - try { - queryResult = q1.solve(fuzzyKB); - } catch (FuzzyOntologyException e) { - e.printStackTrace(); - } - - if (queryResult.isConsistentKB()) - System.out.println(q1.toString() + queryResult.getSolution()); - else - System.out.println("KB is inconsistent"); - } - private KnowledgeBase parseOWLontologyToFuzzyDLsyntax(String ontologyFile) throws Exception { // TODO added by Josue: we may use an in-memory file in the future and not a HD one // As the parser doesn't work at 100% a manually-edited fuzzyDL-file is used - - // String fuzzyOnt = "/Users/josue/Documents/PhD/AKSW/ontologies/foodItems_v1.1.owl"; - - fuzzyParser = new FuzzyOwl2toFuzzyDL(ontologyFile, FUZZYOWL2FUZZYDLPARSEROUTPUT); - fuzzyParser.translateOwl2Ontology(); - // return Parser.getKB(FUZZYOWL2FUZZYDLPARSEROUTPUT); - - // ontologyFile = CHANGING_JUST_HIERARCHI_PROBLEM; - - parser = new Parser(new FileInputStream(FUZZYOWL2FUZZYDLPARSEROUTPUT)); + fuzzyFileParser = new FuzzyOwl2toFuzzyDL(ontologyFile, FUZZYOWL2FUZZYDLPARSEROUTPUT); + fuzzyFileParser.translateOwl2Ontology(); + + System.err.println("WARNING: you're using a particular fuzzy ontology"); + parser = new Parser(new FileInputStream(CHANGING_JUST_HIERARCHI_PROBLEM)); + // parser = new Parser(new FileInputStream(FUZZYOWL2FUZZYDLPARSEROUTPUT)); + parser.Start(); return parser.getKB(); } // added by Josue - // TODO use beliefDegree - public double getFuzzyMembership(OWLClassExpression oce, OWLIndividual i, double beliefDegree) { - - Individual fIndividual = fuzzyKB.getIndividual(shortFormParser.getShortForm((OWLEntity) i)); - Concept fConcept = fuzzyParser.getFuzzyDLExpresion(oce); - - // Concept auxfConcept = Concept.l_or(new Concept("Item"), new Concept("MediumSizeItem")); - - Query q = new MinInstanceQuery(fConcept, fIndividual); - - try { - KnowledgeBase clonedFuzzyKB = fuzzyKB.clone(); - queryResult = q.solve(clonedFuzzyKB); - if (!queryResult.isConsistentKB()){ - System.err.println("Fuzzy KB is inconsistent."); - System.err.println("This may be a fuzzyDL reasoner bug. Press enter to continue."); - System.err.println("concept: " + fConcept + " individual: " + fIndividual); - Scanner sc = new Scanner(System.in); - sc.nextLine(); - // System.exit(0); + public double getFuzzyMembership(OWLClassExpression oce, OWLIndividual i, double truthDegree) { + + Individual fIndividual = fuzzyKB.getIndividual(shortFormParser.getShortForm((OWLEntity) i)); + Concept fConcept = OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(oce); + + // added by Josue + // this if is to jump a fuzyDL's bug + if (!fConcept.toString().equalsIgnoreCase("SOME_hasCar_SOME_hasLoad_*top*") && + !fConcept.toString().equalsIgnoreCase("SOME_hasCar_ALL_hasLoad_*top*") && + !fConcept.toString().equalsIgnoreCase("SOME_hasCar_(LongCar)_OR_(ShortCar)") && + !fConcept.toString().equalsIgnoreCase("(Car)_OR_(SOME_hasCar_*top*)") && + !fConcept.toString().equalsIgnoreCase("(Load)_OR_(SOME_hasCar_*top*)") && + !fConcept.toString().equalsIgnoreCase("(Train)_OR_(SOME_hasCar_*top*)") && + !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_SOME_hasLoad_*top*)") && + !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_ALL_hasLoad_*top*)") && + !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_LongCar)") && + !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_(LongCar)_OR_(ShortCar))") && + !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_*top*)") && + !fConcept.toString().equalsIgnoreCase("SOME_hasCar_LongCar")) { + + System.err.println(fConcept); + + Query q = new MinInstanceQuery(fConcept, fIndividual); + + try { + KnowledgeBase clonedFuzzyKB = fuzzyKB.clone(); + queryResult = q.solve(clonedFuzzyKB); + if (!queryResult.isConsistentKB()){ + System.err.println("Fuzzy KB is inconsistent."); + System.err.println("This may be a fuzzyDL reasoner bug. Press enter to continue."); + System.err.println("concept: " + fConcept + " individual: " + fIndividual); + Scanner sc = new Scanner(System.in); + sc.nextLine(); + // System.exit(0); + } + } catch (FuzzyOntologyException e) { + e.printStackTrace(); } - } catch (FuzzyOntologyException e) { - e.printStackTrace(); + + return (1 - Math.abs(truthDegree - queryResult.getSolution())); } - - return (1 - Math.abs(beliefDegree - queryResult.getSolution())); + System.err.println("* " + fConcept); + return 0; } - + public KnowledgeBase getFuzzyKB() { return fuzzyKB; } Modified: trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest.java 2011-04-28 17:44:44 UTC (rev 2777) +++ trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest.java 2011-05-02 14:56:50 UTC (rev 2778) @@ -20,36 +20,20 @@ * */ -import java.io.File; import java.io.IOException; import java.net.URL; -import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; - -import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.algorithms.fuzzydll.FuzzyCELOE; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.LearningProblemUnsupportedException; -import org.dllearner.core.OntologyFormat; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.configurators.CELOEConfigurator; import org.dllearner.core.options.fuzzydll.FuzzyExample; import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.EquivalentClassesAxiom; -import org.dllearner.core.owl.Individual; -import org.dllearner.core.owl.KB; -import org.dllearner.core.owl.NamedClass; import org.dllearner.kb.OWLFile; -import org.dllearner.kb.sparql.SparqlKnowledgeSource; -import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.learningproblems.fuzzydll.FuzzyPosNegLPStandard; -import org.dllearner.reasoning.FastInstanceChecker; -import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner; -import org.dllearner.utilities.datastructures.Datastructures; -import org.dllearner.utilities.datastructures.SortedSetTuple; /** * A script, which learns definitions / super classes of classes in the DBpedia ontology. @@ -98,7 +82,7 @@ ComponentManager cm = ComponentManager.getInstance(); OWLFile ks = cm.knowledgeSource(OWLFile.class); - ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/fuzzyFoodItems_v1.owl")); + ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/foodItems_v1.owl")); ks.init(); //ReasonerComponent rc = cm.reasoner(OWLAPIReasoner.class, ks); @@ -120,9 +104,10 @@ // Set<String> aaaaaaaaaa = new TreeSet<String>(); // aaaaaaaaaa.add("Nothing"); // fc.getConfigurator().setIgnoredConcepts(aaaaaaaaaa); - fc.getConfigurator().setMaxClassDescriptionTests(50); + fc.getConfigurator().setMaxClassDescriptionTests(1000); fc.getConfigurator().setMaxExecutionTimeInSeconds(0); fc.getConfigurator().setUseDoubleDatatypes(false); + fc.getConfigurator().setUseCardinalityRestrictions(false); fc.init(); fc.start(); Added: trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains.java 2011-05-02 14:56:50 UTC (rev 2778) @@ -0,0 +1,118 @@ +package org.dllearner.test; + +/** + * Copyright (C) 2007-2011, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import java.io.IOException; +import java.net.URL; +import java.util.SortedSet; +import java.util.TreeSet; +import org.dllearner.algorithms.fuzzydll.FuzzyCELOE; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.options.fuzzydll.FuzzyExample; +import org.dllearner.core.owl.Description; +import org.dllearner.kb.OWLFile; +import org.dllearner.learningproblems.fuzzydll.FuzzyPosNegLPStandard; +import org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner; + +/** + * A script, which learns definitions / super classes of classes in the DBpedia ontology. + * + * @author Jens Lehmann + * + */ +public class FuzzyDLLTest_Trains { + + String[] posEx = { + "http://www.example.com/fuzzyTrains.owl#east1" + }; + String[] negEx = { + "http://www.example.com/fuzzyTrains.owl#west6" + }; + + public Description learn() throws LearningProblemUnsupportedException, IOException, ComponentInitException { + + // + // positive and negative examples + // + SortedSet<String> positiveExamples = new TreeSet<String>(); + SortedSet<String> negativeExamples = new TreeSet<String>(); + for (int i=0; i<posEx.length; i++) { + positiveExamples.add(posEx[i]); + } + for (int i=0; i<negEx.length; i++) { + negativeExamples.add(negEx[i]); + } + + // + // fuzzy examples + // + SortedSet<Object> fuzzyExamples = new TreeSet<Object>(); + for (int i=0; i<posEx.length; i++) { + fuzzyExamples.add(new FuzzyExample(posEx[i],1.0)); + } + for (int i=0; i<negEx.length; i++) { + fuzzyExamples.add(new FuzzyExample(negEx[i],0.0)); + } + + ComponentManager cm = ComponentManager.getInstance(); + + OWLFile ks = cm.knowledgeSource(OWLFile.class); + ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/fuzzyTrains/noFuzzyTrains_v1.2.owl")); + ks.init(); + + //ReasonerComponent rc = cm.reasoner(OWLAPIReasoner.class, ks); + ReasonerComponent rc = cm.reasoner(FuzzyOWLAPIReasoner.class, ks); + rc.init(); + + FuzzyPosNegLPStandard lp = cm.learningProblem(FuzzyPosNegLPStandard.class, rc); + //PosNegLPStandard lp = cm.learningProblem(PosNegLPStandard.class, rc); + lp.getConfigurator().setPositiveExamples(positiveExamples); + lp.getConfigurator().setNegativeExamples(negativeExamples); + lp.getConfigurator().setFuzzyExamples(fuzzyExamples); + lp.init(); + + FuzzyCELOE fc = cm.learningAlgorithm(FuzzyCELOE.class, lp, rc); + //CELOE fc = cm.learningAlgorithm(CELOE.class, lp, rc); +// Set<String> kkkkkkkkkk = new TreeSet<String>(); +// kkkkkkkkkk.add("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); +// fc.getConfigurator().setAllowedConcepts(kkkkkkkkkk); +// Set<String> aaaaaaaaaa = new TreeSet<String>(); +// aaaaaaaaaa.add("Nothing"); +// fc.getConfigurator().setIgnoredConcepts(aaaaaaaaaa); + fc.getConfigurator().setMaxClassDescriptionTests(1000); + fc.getConfigurator().setMaxExecutionTimeInSeconds(0); + fc.getConfigurator().setUseDoubleDatatypes(false); + fc.getConfigurator().setUseCardinalityRestrictions(false); + fc.init(); + fc.start(); + + return fc.getCurrentlyBestDescription(); + } + + public static void main(String args[]) throws LearningProblemUnsupportedException, IOException, ComponentInitException { + FuzzyDLLTest_Trains test = new FuzzyDLLTest_Trains(); + test.learn(); + } + +} \ No newline at end of file Added: trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_noFuzzyTrains.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_noFuzzyTrains.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_noFuzzyTrains.java 2011-05-02 14:56:50 UTC (rev 2778) @@ -0,0 +1,123 @@ +package org.dllearner.test; + +/** + * Copyright (C) 2007-2011, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import java.io.IOException; +import java.net.URL; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.algorithms.fuzzydll.FuzzyCELOE; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.options.fuzzydll.FuzzyExample; +import org.dllearner.core.owl.Description; +import org.dllearner.kb.OWLFile; +import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.learningproblems.fuzzydll.FuzzyPosNegLPStandard; +import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner; + +/** + * A script, which learns definitions / super classes of classes in the DBpedia ontology. + * + * @author Jens Lehmann + * + */ +public class FuzzyDLLTest_noFuzzyTrains { + + String[] posEx = { + "http://www.example.com/fuzzyTrains.owl#east1" + }; + String[] negEx = { + "http://www.example.com/fuzzyTrains.owl#west6" + }; + + public Description learn() throws LearningProblemUnsupportedException, IOException, ComponentInitException { + + // + // positive and negative examples + // + SortedSet<String> positiveExamples = new TreeSet<String>(); + SortedSet<String> negativeExamples = new TreeSet<String>(); + for (int i=0; i<posEx.length; i++) { + positiveExamples.add(posEx[i]); + } + for (int i=0; i<negEx.length; i++) { + negativeExamples.add(negEx[i]); + } + + // + // fuzzy examples + // + SortedSet<Object> fuzzyExamples = new TreeSet<Object>(); + for (int i=0; i<posEx.length; i++) { + fuzzyExamples.add(new FuzzyExample(posEx[i],1.0)); + } + for (int i=0; i<negEx.length; i++) { + fuzzyExamples.add(new FuzzyExample(negEx[i],0.0)); + } + + ComponentManager cm = ComponentManager.getInstance(); + + OWLFile ks = cm.knowledgeSource(OWLFile.class); + // ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/fuzzyTrains/fuzzyTrains_v1.0.owl")); + ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/fuzzyTrains/noFuzzyTrains_v1.2.owl")); + ks.init(); + + ReasonerComponent rc = cm.reasoner(OWLAPIReasoner.class, ks); + //ReasonerComponent rc = cm.reasoner(FuzzyOWLAPIReasoner.class, ks); + rc.init(); + + //FuzzyPosNegLPStandard lp = cm.learningProblem(FuzzyPosNegLPStandard.class, rc); + PosNegLPStandard lp = cm.learningProblem(PosNegLPStandard.class, rc); + lp.getConfigurator().setPositiveExamples(positiveExamples); + lp.getConfigurator().setNegativeExamples(negativeExamples); + //lp.getConfigurator().setFuzzyExamples(fuzzyExamples); + lp.init(); + + //FuzzyCELOE fc = cm.learningAlgorithm(FuzzyCELOE.class, lp, rc); + CELOE fc = cm.learningAlgorithm(CELOE.class, lp, rc); +// Set<String> kkkkkkkkkk = new TreeSet<String>(); +// kkkkkkkkkk.add("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); +// fc.getConfigurator().setAllowedConcepts(kkkkkkkkkk); +// Set<String> aaaaaaaaaa = new TreeSet<String>(); +// aaaaaaaaaa.add("Nothing"); +// fc.getConfigurator().setIgnoredConcepts(aaaaaaaaaa); + fc.getConfigurator().setMaxClassDescriptionTests(1000); + fc.getConfigurator().setMaxExecutionTimeInSeconds(0); + fc.getConfigurator().setUseDoubleDatatypes(false); + fc.getConfigurator().setUseCardinalityRestrictions(false); + fc.init(); + fc.start(); + + return fc.getCurrentlyBestDescription(); + } + + public static void main(String args[]) throws LearningProblemUnsupportedException, IOException, ComponentInitException { + FuzzyDLLTest_noFuzzyTrains test = new FuzzyDLLTest_noFuzzyTrains(); + test.learn(); + } + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ji...@us...> - 2011-05-03 14:57:32
|
Revision: 2780 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2780&view=rev Author: jialva Date: 2011-05-03 14:57:22 +0000 (Tue, 03 May 2011) Log Message: ----------- New update of fuzzyDL-Learner Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-05-03 14:22:29 UTC (rev 2779) +++ trunk/components-core/pom.xml 2011-05-03 14:57:22 UTC (rev 2780) @@ -200,12 +200,12 @@ <artifactId>fuzzydl</artifactId> <version>1.0</version> </dependency> - + <dependency> <groupId>fuzzydll</groupId> <artifactId>fuzzyowl2fuzzydlparser</artifactId> <version>1.0</version> </dependency> - + </dependencies> </project> Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java 2011-05-03 14:22:29 UTC (rev 2779) +++ trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java 2011-05-03 14:57:22 UTC (rev 2780) @@ -511,7 +511,10 @@ double crispAccuracy = crispAccuracy(description, noise); // if I erase next line, fuzzy reasoning fails - if (crispAccuracy == -1) return -1; + if (crispAccuracy == -1) { + System.out.println("crisp return -1"); + // return -1; + } // BEGIN // added by Josue @@ -520,15 +523,20 @@ // double negMembership = 0; double descriptionMembership = 0; - //System.out.println("d: " + description); - //System.out.println(); + System.out.println("noise = " + noise); + int individualCounter = fuzzyExamples.size(); for (FuzzyIndividual fuzzyExample : fuzzyExamples) { descriptionMembership += reasoner.hasTypeFuzzyMembership(description, fuzzyExample); + individualCounter--; + if ((descriptionMembership + individualCounter) / fuzzyExamples.size() < noise) + return -1; } double fuzzyAccuracy = descriptionMembership / (double)fuzzyExamples.size(); + + if (crispAccuracy != fuzzyAccuracy) { System.err.println("***********************************************"); System.err.println("* " + (errorIndex++)); Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2011-05-03 14:22:29 UTC (rev 2779) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2011-05-03 14:57:22 UTC (rev 2780) @@ -1,6 +1,9 @@ package org.dllearner.reasoning.fuzzydll; import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.Iterator; import java.util.Scanner; import org.semanticweb.owlapi.model.OWLClassExpression; @@ -26,6 +29,7 @@ private FuzzyOwl2toFuzzyDL fuzzyFileParser; private int auxCounter = 0; + private FileOutputStream errorFile; public FuzzyDLReasonerManager(String ontologyFile) throws Exception { queryResult = null; @@ -40,6 +44,8 @@ OWLAPI_fuzzyDLObjectParser.setParsingFuzzyKB(fuzzyFileParser, fuzzyKB); solveKB(); + + errorFile = new FileOutputStream("errorFile.txt"); } private void solveKB() { @@ -71,21 +77,25 @@ Individual fIndividual = fuzzyKB.getIndividual(shortFormParser.getShortForm((OWLEntity) i)); Concept fConcept = OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(oce); - // added by Josue - // this if is to jump a fuzyDL's bug - if (!fConcept.toString().equalsIgnoreCase("SOME_hasCar_SOME_hasLoad_*top*") && - !fConcept.toString().equalsIgnoreCase("SOME_hasCar_ALL_hasLoad_*top*") && - !fConcept.toString().equalsIgnoreCase("SOME_hasCar_(LongCar)_OR_(ShortCar)") && - !fConcept.toString().equalsIgnoreCase("(Car)_OR_(SOME_hasCar_*top*)") && - !fConcept.toString().equalsIgnoreCase("(Load)_OR_(SOME_hasCar_*top*)") && - !fConcept.toString().equalsIgnoreCase("(Train)_OR_(SOME_hasCar_*top*)") && - !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_SOME_hasLoad_*top*)") && - !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_ALL_hasLoad_*top*)") && - !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_LongCar)") && - !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_(LongCar)_OR_(ShortCar))") && - !fConcept.toString().equalsIgnoreCase("(Train)_AND_(SOME_hasCar_*top*)") && - !fConcept.toString().equalsIgnoreCase("SOME_hasCar_LongCar")) { - + try { + errorFile.write(fConcept.toString().getBytes()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + +// try { +// fuzzyKB.saveToFile("file.txt"); +// Parser parser = new Parser(new FileInputStream("file.txt")); +// parser.Start(); +// fuzzyKB = parser.getKB(); +// } catch (Exception e1) { +// e1.printStackTrace(); +// } + + if (fConcept.toString().equalsIgnoreCase("SOME_hasFirstCar_SOME_inFrontOf_LongCar")) + System.err.println(fConcept); + System.err.println(fConcept); Query q = new MinInstanceQuery(fConcept, fIndividual); @@ -101,14 +111,24 @@ sc.nextLine(); // System.exit(0); } - } catch (FuzzyOntologyException e) { + } catch (Exception e) { e.printStackTrace(); + try { + errorFile.write(" 1".getBytes()); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } } - + + try { + errorFile.write("\n".getBytes()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return (1 - Math.abs(truthDegree - queryResult.getSolution())); - } - System.err.println("* " + fConcept); - return 0; } public KnowledgeBase getFuzzyKB() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ji...@us...> - 2011-05-10 12:31:46
|
Revision: 2788 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2788&view=rev Author: jialva Date: 2011-05-10 12:31:35 +0000 (Tue, 10 May 2011) Log Message: ----------- New update of fuzzyDL-Learner Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains.java trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_noFuzzyTrains.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-05-09 13:37:35 UTC (rev 2787) +++ trunk/components-core/pom.xml 2011-05-10 12:31:35 UTC (rev 2788) @@ -195,11 +195,13 @@ <artifactId>h2</artifactId> </dependency> + <!-- <dependency> <groupId>fuzzydll</groupId> <artifactId>fuzzydl</artifactId> <version>1.0</version> </dependency> + --> <dependency> <groupId>fuzzydll</groupId> Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java 2011-05-09 13:37:35 UTC (rev 2787) +++ trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java 2011-05-10 12:31:35 UTC (rev 2788) @@ -508,12 +508,14 @@ * @see org.dllearner.core.LearningProblem#getAccuracyOrTooWeak(org.dllearner.core.owl.Description, double) */ public double getPredAccuracyOrTooWeakExact(Description description, double noise) { - + + System.out.println(errorIndex++); + double crispAccuracy = crispAccuracy(description, noise); // if I erase next line, fuzzy reasoning fails if (crispAccuracy == -1) { - System.out.println("crisp return -1"); - // return -1; +// System.out.println("crisp return -1"); + return -1; } // BEGIN @@ -523,7 +525,7 @@ // double negMembership = 0; double descriptionMembership = 0; - System.out.println("noise = " + noise); +// System.out.println("noise = " + noise); int individualCounter = fuzzyExamples.size(); for (FuzzyIndividual fuzzyExample : fuzzyExamples) { @@ -535,11 +537,12 @@ double fuzzyAccuracy = descriptionMembership / (double)fuzzyExamples.size(); + System.err.println("crispAccuracy = fuzzyAccuracy"); + crispAccuracy = fuzzyAccuracy; - if (crispAccuracy != fuzzyAccuracy) { System.err.println("***********************************************"); - System.err.println("* " + (errorIndex++)); + //System.err.println("* " + (errorIndex++)); System.err.println("* (crispAccuracy[" + crispAccuracy + "] != fuzzyAccuracy[" + fuzzyAccuracy + "])"); System.err.println("* DESC: " + description); System.err.println("***********************************************"); Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2011-05-09 13:37:35 UTC (rev 2787) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2011-05-10 12:31:35 UTC (rev 2788) @@ -4,6 +4,9 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.Iterator; import java.util.Scanner; import org.semanticweb.owlapi.model.OWLClassExpression; @@ -18,7 +21,7 @@ public class FuzzyDLReasonerManager { - // private static final String CHANGING_JUST_HIERARCHI_PROBLEM = "/Users/josue/Documents/PhD/AKSW/fuzzySemanticTools/FuzzyDLMacOSX/FuzzyDL/examples/output/fuzzyOWL2fuzzyDLparserOutput_manual.fuzzyDL.txt"; + private static final String CHANGING_JUST_HIERARCHI_PROBLEM = "/Users/josue/Documents/PhD/AKSW/fuzzySemanticTools/FuzzyDLMacOSX/FuzzyDL/examples/output/fuzzyOWL2fuzzyDLparserOutput_manual.fuzzyDL.txt"; private static final String FUZZYOWL2FUZZYDLPARSEROUTPUT = "fuzzyOWL2fuzzyDLparserOutput.fuzzyDL.txt"; private static String CONFIG_FILENAME = "/Users/josue/Documents/PhD/AKSW/fuzzySemanticTools/FuzzyDLMacOSX/FuzzyDL/CONFIG"; @@ -45,7 +48,7 @@ solveKB(); - errorFile = new FileOutputStream("errorFile.txt"); + errorFile = new FileOutputStream("errorFile.txt"); } private void solveKB() { @@ -77,27 +80,6 @@ Individual fIndividual = fuzzyKB.getIndividual(shortFormParser.getShortForm((OWLEntity) i)); Concept fConcept = OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(oce); - try { - errorFile.write(fConcept.toString().getBytes()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - -// try { -// fuzzyKB.saveToFile("file.txt"); -// Parser parser = new Parser(new FileInputStream("file.txt")); -// parser.Start(); -// fuzzyKB = parser.getKB(); -// } catch (Exception e1) { -// e1.printStackTrace(); -// } - - if (fConcept.toString().equalsIgnoreCase("SOME_hasFirstCar_SOME_inFrontOf_LongCar")) - System.err.println(fConcept); - - System.err.println(fConcept); - Query q = new MinInstanceQuery(fConcept, fIndividual); try { @@ -112,26 +94,35 @@ // System.exit(0); } } catch (Exception e) { - e.printStackTrace(); + // e.printStackTrace(); try { - errorFile.write(" 1".getBytes()); + errorFile.write(fIndividual.toString().getBytes()); + errorFile.write("\n".getBytes()); + errorFile.write(fConcept.toString().getBytes()); + errorFile.write("\n".getBytes()); + errorFile.write(getStackTrace(e).getBytes()); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } +// Scanner sc = new Scanner(System.in); +// sc.nextLine(); } - try { - errorFile.write("\n".getBytes()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return (1 - Math.abs(truthDegree - queryResult.getSolution())); } public KnowledgeBase getFuzzyKB() { return fuzzyKB; } + + public static String getStackTrace(Throwable t) + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw, true); + t.printStackTrace(pw); + pw.flush(); + sw.flush(); + return sw.toString(); + } } Modified: trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains.java 2011-05-09 13:37:35 UTC (rev 2787) +++ trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains.java 2011-05-10 12:31:35 UTC (rev 2788) @@ -44,10 +44,12 @@ public class FuzzyDLLTest_Trains { String[] posEx = { - "http://www.example.com/fuzzyTrains.owl#east1" + "http://www.example.com/fuzzyTrains.owl#east1", + "http://www.example.com/fuzzyTrains.owl#east2" }; String[] negEx = { - "http://www.example.com/fuzzyTrains.owl#west6" + "http://www.example.com/fuzzyTrains.owl#west6", + "http://www.example.com/fuzzyTrains.owl#west7" }; public Description learn() throws LearningProblemUnsupportedException, IOException, ComponentInitException { @@ -78,7 +80,7 @@ ComponentManager cm = ComponentManager.getInstance(); OWLFile ks = cm.knowledgeSource(OWLFile.class); - ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/fuzzyTrains/fuzzyTrains_v1.2.owl")); + ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/fuzzyTrains/fuzzyTrains_v1.3.owl")); ks.init(); //ReasonerComponent rc = cm.reasoner(OWLAPIReasoner.class, ks); Modified: trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_noFuzzyTrains.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_noFuzzyTrains.java 2011-05-09 13:37:35 UTC (rev 2787) +++ trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_noFuzzyTrains.java 2011-05-10 12:31:35 UTC (rev 2788) @@ -48,10 +48,12 @@ public class FuzzyDLLTest_noFuzzyTrains { String[] posEx = { - "http://www.example.com/fuzzyTrains.owl#east1" + "http://www.example.com/fuzzyTrains.owl#east1", + "http://www.example.com/fuzzyTrains.owl#east2" }; String[] negEx = { - "http://www.example.com/fuzzyTrains.owl#west6" + "http://www.example.com/fuzzyTrains.owl#west6", + "http://www.example.com/fuzzyTrains.owl#west7" }; public Description learn() throws LearningProblemUnsupportedException, IOException, ComponentInitException { @@ -83,7 +85,7 @@ OWLFile ks = cm.knowledgeSource(OWLFile.class); // ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/fuzzyTrains/fuzzyTrains_v1.0.owl")); - ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/fuzzyTrains/noFuzzyTrains_v1.2.owl")); + ks.getConfigurator().setUrl(new URL("file:///Users/josue/Documents/PhD/AKSW/ontologies/fuzzyTrains/noFuzzyTrains_v1.3.owl")); ks.init(); ReasonerComponent rc = cm.reasoner(OWLAPIReasoner.class, ks); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ji...@us...> - 2011-06-03 17:02:48
|
Revision: 2849 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2849&view=rev Author: jialva Date: 2011-06-03 17:02:41 +0000 (Fri, 03 Jun 2011) Log Message: ----------- New update of fuzzyDL-Learner Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyOWLAPIReasoner.java Added Paths: ----------- trunk/components-core/log/ Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java 2011-06-03 14:57:18 UTC (rev 2848) +++ trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java 2011-06-03 17:02:41 UTC (rev 2849) @@ -513,10 +513,11 @@ double crispAccuracy = crispAccuracy(description, noise); // if I erase next line, fuzzy reasoning fails - if (crispAccuracy == -1) { -// System.out.println("crisp return -1"); - // return -1; - } +// if (crispAccuracy == -1) { +// System.out.print(description); +// System.out.println(); +// // return -1; +// } // BEGIN // added by Josue @@ -524,6 +525,10 @@ // double posMembership = 0; // double negMembership = 0; double descriptionMembership = 0; + double singleMembership = 0; + // double accumulatedSingleMembership = 0; + double nonAccumulativeDescriptionMembership = 0; + double accumulativeDescriptionMembership = 0; // System.out.println("noise = " + noise); @@ -531,15 +536,15 @@ // int individualCounter = fuzzyExamples.size(); double individualCounter = totalTruth; for (FuzzyIndividual fuzzyExample : fuzzyExamples) { - descriptionMembership += reasoner.hasTypeFuzzyMembership(description, fuzzyExample); - // individualCounter--; - if (individualCounter >= 1) individualCounter -= fuzzyExample.getTruthDegree(); // before it was individual--; - // before -// if ((descriptionMembership + individualCounter) / fuzzyExamples.size() < noise) -// return -1; - // after (to match the noise management of the crisp part) - if ((descriptionMembership + individualCounter) < ((1 - noise) * totalTruth)) + singleMembership = reasoner.hasTypeFuzzyMembership(description, fuzzyExample); + // accumulatedSingleMembership += singleMembership; + nonAccumulativeDescriptionMembership = 1 - Math.abs(fuzzyExample.getTruthDegree() - singleMembership); + descriptionMembership += nonAccumulativeDescriptionMembership; + individualCounter -= fuzzyExample.getTruthDegree(); + if ((accumulativeDescriptionMembership + (nonAccumulativeDescriptionMembership * fuzzyExample.getTruthDegree()) + individualCounter) < ((1 - noise) * totalTruth)) return -1; + accumulativeDescriptionMembership += nonAccumulativeDescriptionMembership * fuzzyExample.getTruthDegree(); + } double fuzzyAccuracy = descriptionMembership / (double)fuzzyExamples.size(); @@ -590,12 +595,14 @@ double coveredMembershipDegree = 0; double totalMembershipDegree = 0; double invertedCoveredMembershipDegree = 0; + double lastMembershipDegree = 0; // TODO to optimize for (FuzzyIndividual ind: fuzzyExamples) { - coveredMembershipDegree += reasoner.hasTypeFuzzyMembership(description, ind) * ind.getTruthDegree(); + lastMembershipDegree = (1 - Math.abs(ind.getTruthDegree() - reasoner.hasTypeFuzzyMembership(description, ind))); + coveredMembershipDegree += lastMembershipDegree * ind.getTruthDegree(); totalMembershipDegree += ind.getTruthDegree(); - invertedCoveredMembershipDegree += (1 - ind.getTruthDegree()) * (1 - reasoner.hasTypeFuzzyMembership(description, ind)); + invertedCoveredMembershipDegree += (1 - ind.getTruthDegree()) * (1 - lastMembershipDegree); } double fuzzyRecall = totalMembershipDegree == 0 ? 0 :coveredMembershipDegree/totalMembershipDegree; // TODO this is like this??? not sure Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2011-06-03 14:57:18 UTC (rev 2848) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2011-06-03 17:02:41 UTC (rev 2849) @@ -143,7 +143,7 @@ } // added by Josue - public double getFuzzyMembership(OWLClassExpression oce, OWLIndividual i, double truthDegree) { + public double getFuzzyMembership(OWLClassExpression oce, OWLIndividual i) { Individual fIndividual = fuzzyKB.getIndividual(shortFormParser.getShortForm((OWLEntity) i)); Concept fConcept = OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(oce); @@ -177,7 +177,8 @@ // sc.nextLine(); } - return (1 - Math.abs(truthDegree - queryResult.getSolution())); + // return (1 - Math.abs(truthDegree - queryResult.getSolution())); + return queryResult.getSolution(); } public KnowledgeBase getFuzzyKB() { Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyOWLAPIReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyOWLAPIReasoner.java 2011-06-03 14:57:18 UTC (rev 2848) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyOWLAPIReasoner.java 2011-06-03 17:02:41 UTC (rev 2849) @@ -624,7 +624,7 @@ // return crispReasonerOutput; // added by Josue to make be fuzzyDL and not Pellet to answer this method - double fuzzyReasonerOutput = ((FuzzyDLReasonerManager) reasoner).getFuzzyMembership(d, i, 1); + double fuzzyReasonerOutput = ((FuzzyDLReasonerManager) reasoner).getFuzzyMembership(d, i); return fuzzyReasonerOutput == 0 ? false : true; } @@ -1138,7 +1138,7 @@ OWLClassExpression desc = OWLAPIDescriptionConvertVisitor.getOWLClassExpression(description); OWLIndividual ind = factory.getOWLNamedIndividual(IRI.create(individual.getName())); - double fuzzyReasonerOutput = ((FuzzyDLReasonerManager) reasoner).getFuzzyMembership(desc, ind, individual.getTruthDegree()); + double fuzzyReasonerOutput = ((FuzzyDLReasonerManager) reasoner).getFuzzyMembership(desc, ind); // System.out.println("- d: " + d); // System.out.println("- i: " + i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sha...@us...> - 2011-07-27 04:46:49
|
Revision: 2968 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2968&view=rev Author: shadowtm Date: 2011-07-27 04:46:43 +0000 (Wed, 27 Jul 2011) Log Message: ----------- Added example showing how to use annotations for fields which were not of a basic type. Modified Paths: -------------- trunk/components-core/pom.xml Added Paths: ----------- trunk/components-core/src/test/java/org/dllearner/examples/ trunk/components-core/src/test/java/org/dllearner/examples/AnnotationExample.java trunk/components-core/src/test/java/org/dllearner/examples/ConfigOption.java trunk/components-core/src/test/java/org/dllearner/examples/ConfiguredObject.java trunk/components-core/src/test/java/org/dllearner/examples/ObjectPropertyEditor.java trunk/components-core/src/test/java/org/dllearner/examples/OurStringTrimmerEditor.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-07-26 11:37:49 UTC (rev 2967) +++ trunk/components-core/pom.xml 2011-07-27 04:46:43 UTC (rev 2968) @@ -247,5 +247,11 @@ <version>1.0</version> </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>3.0.5.RELEASE</version> + <scope>test</scope> + </dependency> </dependencies> </project> Added: trunk/components-core/src/test/java/org/dllearner/examples/AnnotationExample.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/examples/AnnotationExample.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/examples/AnnotationExample.java 2011-07-27 04:46:43 UTC (rev 2968) @@ -0,0 +1,58 @@ +package org.dllearner.examples; + + +import javax.xml.transform.Source; +import java.beans.PropertyEditor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 7/26/11 + * Time: 9:03 PM + * <p/> + * An example showing the use of Annotations with non basic types/classes. + */ +public class AnnotationExample { + + + public static void main(String[] args) throws Exception { + + /** The Configuration map comes in from somewhere - The keys here correspond to the configuration options in ConfiguredObject*/ + Map<String, String> propertiesMap = new HashMap<String, String>(); + propertiesMap.put("initString", "My Initialization String"); + propertiesMap.put("objectProperty", "My Object Property"); + + /** Here's my new configured object */ + ConfiguredObject obj = new ConfiguredObject(); + + Method[] methods = obj.getClass().getMethods(); + for (Method method : methods) { + ConfigOption option = method.getAnnotation(ConfigOption.class); + /** If Annotated with Config Option*/ + if (option != null) { + + /** Retrieve the actual String value from the properties map */ + String configValue = propertiesMap.get(option.name()); + + /** Might be a good idea to catch a class cast exception here if we're wrong */ + PropertyEditor editor = (PropertyEditor) option.propertyEditorClass().newInstance(); + + /** This line causes the property editors to convert the string to the object*/ + editor.setAsText(configValue); + + /** This line grabs the object we want and invokes the method we're currently working on - with this scheme, only annotations should go on set methods */ + method.invoke(obj, editor.getValue()); + } + } + + /** Now show that we actually stored the objects on the ConfiguredObject itself */ + System.out.println("Information on Configured Object:"); + System.out.println("Initialization String: " + obj.getInitializationString()); + System.out.println("ObjectProperty: " + obj.getObjectProperty().getName()); + + } +} Added: trunk/components-core/src/test/java/org/dllearner/examples/ConfigOption.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/examples/ConfigOption.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/examples/ConfigOption.java 2011-07-27 04:46:43 UTC (rev 2968) @@ -0,0 +1,36 @@ +package org.dllearner.examples; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 7/26/11 + * Time: 8:55 PM + * + * This is an example annotation class allowing one to configure a field with a name, description, and corresponding property editor. + * + * Note: Only put this on Setters that take the actual object you want to end up with as the example expects it to be on the setter + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface ConfigOption { + + /** + * The name of this config option. + * @return The name of this config option. + */ + String name(); + + /** + * The description of this config option + * @return + */ + String description(); + + /** + * An implementation of the Property Editor to use + * @return + */ + Class propertyEditorClass(); +} Added: trunk/components-core/src/test/java/org/dllearner/examples/ConfiguredObject.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/examples/ConfiguredObject.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/examples/ConfiguredObject.java 2011-07-27 04:46:43 UTC (rev 2968) @@ -0,0 +1,59 @@ +package org.dllearner.examples; + +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.examples.ConfigOption; +import org.springframework.beans.propertyeditors.StringTrimmerEditor; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 7/26/11 + * Time: 8:57 PM + * + * In this example, this is the object that is actually getting configured. It has the fields that we want to define + * configuration on and hence that's why we use the annotations. + */ +public class ConfiguredObject { + + + + + /** Two options that can be configured for this object */ + private String initializationString; + private ObjectProperty objectProperty; + + + /** + * Default constructor + */ + public ConfiguredObject() { + + } + + + /** + * Get the Initialization String. + * @return The Initialization String + */ + public String getInitializationString() { + return initializationString; + } + + /** + * Set the Initialization String + * @param initializationString + */ + @ConfigOption(name="initString", description = "An Initialization String", propertyEditorClass = OurStringTrimmerEditor.class) + public void setInitializationString(String initializationString) { + this.initializationString = initializationString; + } + + /** Corresponds with the name above */ + public ObjectProperty getObjectProperty() { + return objectProperty; + } + @ConfigOption(name="objectProperty", description = "Some Object Property", propertyEditorClass = ObjectPropertyEditor.class) + public void setObjectProperty(ObjectProperty objectProperty) { + this.objectProperty = objectProperty; + } +} Added: trunk/components-core/src/test/java/org/dllearner/examples/ObjectPropertyEditor.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/examples/ObjectPropertyEditor.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/examples/ObjectPropertyEditor.java 2011-07-27 04:46:43 UTC (rev 2968) @@ -0,0 +1,88 @@ +package org.dllearner.examples; + +import org.dllearner.core.owl.ObjectProperty; + +import java.awt.*; +import java.beans.PropertyChangeListener; +import java.beans.PropertyEditor; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 7/26/11 + * Time: 9:42 PM + * <p/> + * Basic Property Editor for the Object Property DL-Learner class. Doesn't have GUI support yet but we could add that later if we wanted. + */ +public class ObjectPropertyEditor implements PropertyEditor { + + + private ObjectProperty value; + + @Override + public void setValue(Object value) { + this.value = (ObjectProperty) value; + } + + @Override + public Object getValue() { + return value; + } + + @Override + public boolean isPaintable() { + /** Not right now, we're doing non gui work */ + return false; + } + + @Override + public void paintValue(Graphics gfx, Rectangle box) { + + } + + @Override + public String getJavaInitializationString() { + /** This returns the value needed to reconstitute the object from a string */ + return value.getName(); + } + + @Override + public String getAsText() { + /** Get the text value of this object - for displaying in GUIS, etc */ + return value.getName(); + } + + @Override + public void setAsText(String text) throws IllegalArgumentException { + value = new ObjectProperty(text); + } + + @Override + public String[] getTags() { + /** If there was a known set of values it had to have, we could add that list here */ + return new String[0]; + } + + @Override + public Component getCustomEditor() { + /** GUI stuff, if you wanted to edit it a custom way */ + return null; + } + + @Override + public boolean supportsCustomEditor() { + /** We don't support this right now, but maybe later */ + return false; + + } + + @Override + public void addPropertyChangeListener(PropertyChangeListener listener) { + /** More gui stuff, we don't need this for our basic example */ + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener listener) { + /** More gui stuff, we don't need this for our basic example */ + } +} Added: trunk/components-core/src/test/java/org/dllearner/examples/OurStringTrimmerEditor.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/examples/OurStringTrimmerEditor.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/examples/OurStringTrimmerEditor.java 2011-07-27 04:46:43 UTC (rev 2968) @@ -0,0 +1,22 @@ +package org.dllearner.examples; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 7/26/11 + * Time: 10:17 PM + * <p/> + * Making a basic extension so I can get a default constructor so that using reflection is simpler. + * + * I'm extending a Spring provided class for this. + */ +public class OurStringTrimmerEditor extends org.springframework.beans.propertyeditors.StringTrimmerEditor { + + + /** + * Default Constructor + */ + public OurStringTrimmerEditor() { + super(true); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-08-02 10:53:03
|
Revision: 2973 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2973&view=rev Author: lorenz_b Date: 2011-08-02 10:52:56 +0000 (Tue, 02 Aug 2011) Log Message: ----------- Changed dependency scope. Extended reasoner. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/reasoning/ProtegeReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-07-28 13:02:01 UTC (rev 2972) +++ trunk/components-core/pom.xml 2011-08-02 10:52:56 UTC (rev 2973) @@ -251,7 +251,6 @@ <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.0.5.RELEASE</version> - <scope>test</scope> </dependency> </dependencies> </project> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-07-28 13:02:01 UTC (rev 2972) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/PropertyDomainAxiomLearner.java 2011-08-02 10:52:56 UTC (rev 2973) @@ -1,33 +1,80 @@ package org.dllearner.algorithms.properties; +import java.beans.PropertyEditor; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; import org.dllearner.core.AxiomLearningAlgorithm; import org.dllearner.core.Component; import org.dllearner.core.ComponentInitException; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.IntegerEditor; +import org.dllearner.core.config.ObjectPropertyEditor; import org.dllearner.core.configurators.Configurator; import org.dllearner.core.owl.Axiom; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; import org.dllearner.kb.SparqlEndpointKS; +import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.reasoning.SPARQLReasoner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; + public class PropertyDomainAxiomLearner extends Component implements AxiomLearningAlgorithm { - private String propertyToDescribe; + private static final Logger logger = LoggerFactory.getLogger(PropertyDomainAxiomLearner.class); - public String getPropertyToDescribe() { + @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class) + private ObjectProperty propertyToDescribe; + @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class) + private int maxExecutionTimeInSeconds; + + private SPARQLReasoner reasoner; + private SparqlEndpointKS ks; + + public PropertyDomainAxiomLearner(SparqlEndpointKS ks){ + this.ks = ks; + } + + public int getMaxExecutionTimeInSeconds() { + return maxExecutionTimeInSeconds; + } + + public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) { + this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds; + } + + public ObjectProperty getPropertyToDescribe() { return propertyToDescribe; } - public void setPropertyToDescribe(String propertyToDescribe) { + public void setPropertyToDescribe(ObjectProperty propertyToDescribe) { this.propertyToDescribe = propertyToDescribe; } - - public PropertyDomainAxiomLearner(SparqlEndpointKS ks){ - - } @Override public void start() { - // TODO Auto-generated method stub + //get existing domains + Description existingDomain = reasoner.getDomain(propertyToDescribe); + logger.debug("Existing domain: " + existingDomain); + + //get subjects with types + Map<Individual, Set<NamedClass>> individual2Types = getSubjectsWithTypes(); + + //get subjects of property + Map<Individual, SortedSet<Individual>> members = reasoner.getPropertyMembers(propertyToDescribe); + } @@ -45,8 +92,76 @@ @Override public void init() throws ComponentInitException { - // TODO Auto-generated method stub + reasoner = new SPARQLReasoner(ks); } + + private Map<Individual, Set<NamedClass>> getSubjectsWithTypes(){ + Map<Individual, Set<NamedClass>> individual2Types = new HashMap<Individual, Set<NamedClass>>(); + int limit = 1000; + int offset = 135000; + boolean executeAgain = true; + + while(executeAgain){ + String query = String.format("SELECT ?ind ?type WHERE {?ind %s ?o. ?ind a ?type.} LIMIT %d OFFSET %d", inAngleBrackets(propertyToDescribe.getURI().toString()), limit, offset); + ResultSet rs = executeQuery(query); + QuerySolution qs; + Individual ind; + Set<NamedClass> types; + executeAgain = rs.hasNext(); + while(executeAgain && rs.hasNext()){ + qs = rs.next(); + ind = new Individual(qs.getResource("ind").getURI()); + types = individual2Types.get(ind); + if(types == null){ + types = new HashSet<NamedClass>(); + } + types.add(new NamedClass(qs.getResource("type").getURI())); + } + offset += 1000; + } + + return individual2Types; + } + + private String inAngleBrackets(String s){ + return "<" + s + ">"; + } + + private ResultSet executeQuery(String query){ + logger.info("Sending query \n {}", query); + + QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query); + for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) { + queryExecution.addDefaultGraph(dgu); + } + for (String ngu : ks.getEndpoint().getNamedGraphURIs()) { + queryExecution.addNamedGraph(ngu); + } + ResultSet resultSet = queryExecution.execSelect(); + return resultSet; + } + + public static void main(String[] args) throws Exception{ + Map<String, String> propertiesMap = new HashMap<String, String>(); + propertiesMap.put("propertyToDescribe", "http://dbpedia.org/ontology/league"); + propertiesMap.put("maxExecutionTimeInSeconds", "20"); + + PropertyDomainAxiomLearner l = new PropertyDomainAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia())); + + Field[] fields = l.getClass().getDeclaredFields(); + for(Field f : fields){ + ConfigOption option = f.getAnnotation(ConfigOption.class); + if(option != null){ + String configValue = propertiesMap.get(option.name()); + PropertyEditor editor = (PropertyEditor) option.propertyEditorClass().newInstance(); + editor.setAsText(configValue); + f.set(l, editor.getValue()); + } + } + + l.init(); + l.start(); + } } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-07-28 13:02:01 UTC (rev 2972) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubPropertyOfAxiomLearner.java 2011-08-02 10:52:56 UTC (rev 2973) @@ -3,8 +3,10 @@ import java.beans.PropertyEditor; import java.lang.reflect.Field; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.dllearner.core.AxiomLearningAlgorithm; import org.dllearner.core.Component; @@ -17,8 +19,12 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.kb.SparqlEndpointKS; import org.dllearner.kb.sparql.SparqlEndpoint; -import org.springframework.beans.propertyeditors.CustomNumberEditor; +import org.dllearner.reasoning.SPARQLReasoner; +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; + public class SubPropertyOfAxiomLearner extends Component implements AxiomLearningAlgorithm { @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class) @@ -26,7 +32,7 @@ @ConfigOption(name="maxExecutionTimeInSeconds", description="", propertyEditorClass=IntegerEditor.class) private int maxExecutionTimeInSeconds; - + private SPARQLReasoner reasoner; private SparqlEndpointKS ks; public SubPropertyOfAxiomLearner(SparqlEndpointKS ks){ @@ -35,8 +41,17 @@ @Override public void start() { - // TODO Auto-generated method stub - + //get + Set<ObjectProperty> properties = new HashSet<ObjectProperty>(); + String query = String.format("SELECT ?p ?p1 WHERE {?s %s ?o. ?s ?p ?o1. ?s1 ?p1 ?o.}", inAngleBrackets(propertyToDescribe.getURI().toString())); + ResultSet rs = executeQuery(query); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + properties.add(new ObjectProperty(qs.getResource("p").getURI())); + properties.add(new ObjectProperty(qs.getResource("p1").getURI())); + } + System.out.println(properties); } @Override @@ -53,8 +68,7 @@ @Override public void init() throws ComponentInitException { - // TODO Auto-generated method stub - + reasoner = new SPARQLReasoner(ks); } public int getMaxExecutionTimeInSeconds() { @@ -73,9 +87,26 @@ this.propertyToDescribe = propertyToDescribe; } + private String inAngleBrackets(String s){ + return "<" + s + ">"; + } + + private ResultSet executeQuery(String query){ + System.out.println(query); + QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query); + for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) { + queryExecution.addDefaultGraph(dgu); + } + for (String ngu : ks.getEndpoint().getNamedGraphURIs()) { + queryExecution.addNamedGraph(ngu); + } + ResultSet resultset = queryExecution.execSelect(); + return resultset; + } + public static void main(String[] args) throws Exception{ Map<String, String> propertiesMap = new HashMap<String, String>(); - propertiesMap.put("propertyToDescribe", "http://dbpedia.org/ontology/locatedIn"); + propertiesMap.put("propertyToDescribe", "http://dbpedia.org/ontology/league"); propertiesMap.put("maxExecutionTimeInSeconds", "20"); SubPropertyOfAxiomLearner l = new SubPropertyOfAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW())); @@ -91,8 +122,9 @@ } } - System.out.println(l.getPropertyToDescribe()); - System.out.println(l.getMaxExecutionTimeInSeconds()); + l.init(); + l.start(); + } } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/ProtegeReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/ProtegeReasoner.java 2011-07-28 13:02:01 UTC (rev 2972) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/ProtegeReasoner.java 2011-08-02 10:52:56 UTC (rev 2973) @@ -748,7 +748,9 @@ Set<OWLNamedIndividual> individuals = reasoner.getInstances(d, false).getFlattened(); SortedSet<Individual> inds = new TreeSet<Individual>(); for(OWLNamedIndividual ind : individuals) - inds.add(new Individual(ind.toStringID())); + if(ind != null){ + inds.add(new Individual(ind.toStringID())); + } return inds; } @@ -1280,8 +1282,16 @@ } // take one element from the set and ignore the rest // (TODO: we need to make sure we always ignore the same concepts) - OWLObjectPropertyExpression property = node.getRepresentativeElement(); - roles.add(new ObjectProperty(property.asOWLObjectProperty().toStringID())); + + for(OWLObjectPropertyExpression property : node.getEntities()){ + if(!property.isAnonymous()){ + roles.add(new ObjectProperty(property.asOWLObjectProperty().toStringID())); + break; + } + } + //TODO: We get a problem when the returned representative element is anonymous, so we now use the code above +// OWLObjectPropertyExpression property = node.getRepresentativeElement(); +// roles.add(new ObjectProperty(property.asOWLObjectProperty().toStringID())); } roles.remove(new ObjectProperty(factory.getOWLTopObjectProperty().toStringID())); roles.remove(new ObjectProperty(factory.getOWLBottomObjectProperty().toStringID())); Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2011-07-28 13:02:01 UTC (rev 2972) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2011-08-02 10:52:56 UTC (rev 2973) @@ -9,6 +9,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.algorithms.properties.PropertyDomainAxiomLearner; import org.dllearner.core.IndividualReasoner; import org.dllearner.core.SchemaReasoner; import org.dllearner.core.owl.ClassHierarchy; @@ -25,6 +26,8 @@ import org.dllearner.kb.SparqlEndpointKS; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.utilities.datastructures.SortedSetTuple; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.clarkparsia.owlapiv3.XSD; import com.hp.hpl.jena.query.QuerySolution; @@ -36,6 +39,8 @@ public class SPARQLReasoner implements SchemaReasoner, IndividualReasoner{ + private static final Logger logger = LoggerFactory.getLogger(PropertyDomainAxiomLearner.class); + private SparqlEndpointKS ks; public SPARQLReasoner(SparqlEndpointKS ks) { @@ -117,7 +122,7 @@ @Override public Map<ObjectProperty, Set<Individual>> getObjectPropertyRelationships(Individual individual) { Map<ObjectProperty, Set<Individual>> prop2individuals = new HashMap<ObjectProperty, Set<Individual>>(); - String query = String.format("select ?prop ?ind WHERE {" + + String query = String.format("SELECT ?prop ?ind WHERE {" + "%s ?prop ?ind." + " FILTER(isIRI(?ind) && ?prop != %s && ?prop != %s)}", inAngleBrackets(individual.getName()), inAngleBrackets(RDF.type.getURI()), inAngleBrackets(OWL.sameAs.getURI())); @@ -145,7 +150,7 @@ @Override public Map<Individual, SortedSet<Individual>> getPropertyMembers(ObjectProperty objectProperty) { Map<Individual, SortedSet<Individual>> subject2objects = new HashMap<Individual, SortedSet<Individual>>(); - String query = String.format("select ?s ?o WHERE {" + + String query = String.format("SELECT ?s ?o WHERE {" + "?s %s ?o." + " FILTER(isIRI(?o))}", inAngleBrackets(objectProperty.getName())); @@ -179,7 +184,7 @@ @Override public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) { Map<Individual, SortedSet<Double>> subject2objects = new HashMap<Individual, SortedSet<Double>>(); - String query = String.format("select ?s ?o WHERE {" + + String query = String.format("SELECT ?s ?o WHERE {" + "?s %s ?o." + " FILTER(DATATYPE(?o) = %s)}", inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.DOUBLE.toStringID())); @@ -207,7 +212,7 @@ @Override public Map<Individual, SortedSet<Integer>> getIntDatatypeMembers(DatatypeProperty datatypeProperty) { Map<Individual, SortedSet<Integer>> subject2objects = new HashMap<Individual, SortedSet<Integer>>(); - String query = String.format("select ?s ?o WHERE {" + + String query = String.format("SELECT ?s ?o WHERE {" + "?s %s ?o." + " FILTER(DATATYPE(?o) = %s)}", inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.INT.toStringID())); @@ -235,7 +240,7 @@ @Override public Map<Individual, SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty) { Map<Individual, SortedSet<Boolean>> subject2objects = new HashMap<Individual, SortedSet<Boolean>>(); - String query = String.format("select ?s ?o WHERE {" + + String query = String.format("SELECT ?s ?o WHERE {" + "?s %s ?o." + " FILTER(DATATYPE(?o) = %s)}", inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.BOOLEAN.toStringID())); @@ -263,7 +268,7 @@ @Override public SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) { SortedSet<Individual> members = new TreeSet<Individual>(); - String query = String.format("select ?ind WHERE {" + + String query = String.format("SELECT ?ind WHERE {" + "?ind %s ?o." + " FILTER(isLiteral(?o) && DATATYPE(?o) = %s && ?o=%s)}", inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.BOOLEAN.toStringID()), @@ -282,7 +287,7 @@ @Override public SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) { SortedSet<Individual> members = new TreeSet<Individual>(); - String query = String.format("select ?ind WHERE {" + + String query = String.format("SELECT ?ind WHERE {" + "?ind %s ?o." + " FILTER(isLiteral(?o) && DATATYPE(?o) = %s && ?o=%s)}", inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(XSD.BOOLEAN.toStringID()), @@ -311,7 +316,7 @@ @Override public Description getDomain(ObjectProperty objectProperty) { - String query = String.format("select ?domain WHERE {" + + String query = String.format("SELECT ?domain WHERE {" + "%s %s ?domain. FILTER(isIRI(?domain))" + "}", inAngleBrackets(objectProperty.getName()), inAngleBrackets(RDFS.domain.getURI())); @@ -334,7 +339,7 @@ @Override public Description getDomain(DatatypeProperty datatypeProperty) { - String query = String.format("select ?domain WHERE {" + + String query = String.format("SELECT ?domain WHERE {" + "%s %s ?domain. FILTER(isIRI(?domain))" + "}", inAngleBrackets(datatypeProperty.getName()), inAngleBrackets(RDFS.domain.getURI())); @@ -357,7 +362,7 @@ @Override public Description getRange(ObjectProperty objectProperty) { - String query = String.format("select ?range WHERE {" + + String query = String.format("SELECT ?range WHERE {" + "%s %s ?range. FILTER(isIRI(?range))" + "}", inAngleBrackets(objectProperty.getName()), inAngleBrackets(RDFS.range.getURI())); @@ -413,7 +418,7 @@ @Override public Set<Description> getAssertedDefinitions(NamedClass namedClass) { Set<Description> definitions = new HashSet<Description>(); - String query = String.format("SELECT ?class {%s %s ?class. FILTER(isIRI(?class))} UNION {?class. %s %s. FILTER(isIRI(?class))}", + String query = String.format("SELECT ?class { {%s %s ?class. FILTER(isIRI(?class))} UNION {?class. %s %s. FILTER(isIRI(?class))} }", inAngleBrackets(namedClass.getURI().toString()), inAngleBrackets(OWL.equivalentClass.getURI()), inAngleBrackets(OWL.equivalentClass.getURI()), @@ -535,14 +540,35 @@ @Override public SortedSet<DatatypeProperty> getSuperProperties(DatatypeProperty dataProperty) { - // TODO Auto-generated method stub - return null; + SortedSet<DatatypeProperty> superProperties = new TreeSet<DatatypeProperty>(); + String query = String.format("SELECT ?sup {%s %s ?sup. FILTER(isIRI(?sup))}", + inAngleBrackets(dataProperty.getURI().toString()), + inAngleBrackets(RDFS.subPropertyOf.getURI()) + ); + ResultSet rs = executeQuery(query); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + superProperties.add(new DatatypeProperty(qs.getResource("sup").getURI())); + } + return superProperties; } @Override public SortedSet<DatatypeProperty> getSubProperties(DatatypeProperty dataProperty) { - // TODO Auto-generated method stub - return null; + SortedSet<DatatypeProperty> subProperties = new TreeSet<DatatypeProperty>(); + String query = String.format("SELECT ?sub {?sub %s %s. FILTER(isIRI(?sub))}", + inAngleBrackets(RDFS.subPropertyOf.getURI()), + inAngleBrackets(dataProperty.getURI().toString()) + + ); + ResultSet rs = executeQuery(query); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + subProperties.add(new DatatypeProperty(qs.getResource("sub").getURI())); + } + return subProperties; } @Override @@ -556,7 +582,7 @@ } private ResultSet executeQuery(String query){ - System.out.println(query); + logger.info("Sending query \n {}", query); QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query); for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) { queryExecution.addDefaultGraph(dgu); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2011-08-04 08:40:11
|
Revision: 2986 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2986&view=rev Author: jenslehmann Date: 2011-08-04 08:40:05 +0000 (Thu, 04 Aug 2011) Log Message: ----------- removed log folder from SVN (please re-create the components-core/log/ folder locally) Removed Paths: ------------- trunk/components-core/log/ Property Changed: ---------------- trunk/components-core/ Property changes on: trunk/components-core ___________________________________________________________________ Modified: svn:ignore - components-core.iml target .classpath .project .settings + components-core.iml target log .classpath .project .settings This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-08-11 14:20:56
|
Revision: 3032 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3032&view=rev Author: lorenz_b Date: 2011-08-11 14:20:49 +0000 (Thu, 11 Aug 2011) Log Message: ----------- Added preliminary utility class for vocabulary of enrichments. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-08-11 12:56:45 UTC (rev 3031) +++ trunk/components-core/pom.xml 2011-08-11 14:20:49 UTC (rev 3032) @@ -225,6 +225,11 @@ <groupId>com.jamonapi</groupId> <artifactId>jamon</artifactId> </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-digester3</artifactId> + </dependency> <!--JENA ARQ is in central - we use the latest--> <dependency> @@ -276,5 +281,10 @@ <artifactId>slf4j-api</artifactId> <version>1.5.8</version> </dependency> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>20041127.091804</version> + </dependency> </dependencies> </project> Modified: trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-11 12:56:45 UTC (rev 3031) +++ trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-11 14:20:49 UTC (rev 3032) @@ -1,7 +1,15 @@ package org.dllearner.core; +import org.apache.commons.codec.digest.DigestUtils; import org.dllearner.core.owl.Axiom; +import org.dllearner.utilities.EnrichmentVocabulary; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; + public class EvaluatedAxiom { private Axiom axiom; @@ -25,6 +33,18 @@ return axiom + "(" + score.getAccuracy()+ ")"; } + public void toRDF(){ + OWLDataFactory f = new OWLDataFactoryImpl(); + + String id = DigestUtils.md5Hex(axiom.toString()) + score.getAccuracy(); + OWLNamedIndividual ind = f.getOWLNamedIndividual(IRI.create(EnrichmentVocabulary.NS + id)); + + OWLAxiom ax1 = f.getOWLClassAssertionAxiom(EnrichmentVocabulary.Suggestion, ind); + OWLAxiom ax2 = f.getOWLObjectPropertyAssertionAxiom(EnrichmentVocabulary.hasAxiom, ind, null); + OWLAxiom ax3 = f.getOWLDataPropertyAssertionAxiom(EnrichmentVocabulary.confidence, ind, score.getAccuracy()); + + System.out.println(ax1); + } } Added: trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java 2011-08-11 14:20:49 UTC (rev 3032) @@ -0,0 +1,52 @@ +package org.dllearner.utilities; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLObjectProperty; + +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; + +public class EnrichmentVocabulary { + + private static final OWLDataFactory factory = new OWLDataFactoryImpl(); + + public static final String NS = "http://www.dl-learner.org/enrichment.owl#"; + + //the classes + public static final OWLClass ChangeSet = factory.getOWLClass(IRI.create(NS + "ChangeSet")); + + public static final OWLClass Suggestion = factory.getOWLClass(IRI.create(NS + "Suggestion")); + + public static final OWLClass Parameter = factory.getOWLClass(IRI.create(NS + "Parameter")); + + + //the object properties + public static final OWLObjectProperty creation = factory.getOWLObjectProperty(IRI.create(NS + "creation")); + + public static final OWLObjectProperty hasAxiom = factory.getOWLObjectProperty(IRI.create(NS + "hasAxiom")); + + public static final OWLObjectProperty hasChange = factory.getOWLObjectProperty(IRI.create(NS + "hasChange")); + + public static final OWLObjectProperty hasInput = factory.getOWLObjectProperty(IRI.create(NS + "hasInput")); + + public static final OWLObjectProperty hasParameter = factory.getOWLObjectProperty(IRI.create(NS + "hasParameter")); + + public static final OWLObjectProperty usedAlgorithm = factory.getOWLObjectProperty(IRI.create(NS + "usedAlgorithm")); + + + //the data properties + public static final OWLDataProperty confidence = factory.getOWLDataProperty(IRI.create(NS + "confidence")); + + public static final OWLDataProperty explanation = factory.getOWLDataProperty(IRI.create(NS + "explanation")); + + public static final OWLDataProperty parameterName = factory.getOWLDataProperty(IRI.create(NS + "parameterName")); + + public static final OWLDataProperty parameterValue = factory.getOWLDataProperty(IRI.create(NS + "parameterValue")); + + public static final OWLDataProperty timestamp = factory.getOWLDataProperty(IRI.create(NS + "timestamp")); + + public static final OWLDataProperty version = factory.getOWLDataProperty(IRI.create(NS + "version")); + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-08-21 20:31:46
|
Revision: 3078 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3078&view=rev Author: lorenz_b Date: 2011-08-21 20:31:32 +0000 (Sun, 21 Aug 2011) Log Message: ----------- Added maven-license-plugin to automatically create/update license headers (USAGE: mvn license:format -Dyear=${currentYear} ). Added header file. Updated license headers for release. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/Info.java trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/RandomGuesser.java trunk/components-core/src/main/java/org/dllearner/algorithms/SearchTreeNode.java trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/DisjunctiveHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELDescriptionEdge.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELDescriptionEdgeComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELDescriptionNode.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELDescriptionNodeComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELDescriptionTreeComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithmDisjunctive.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/SearchTreeNode.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/Simulation.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/StableHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/TreeAndRoleSet.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/TreeAndRoleSetComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/TreeTuple.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/package.html trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOEHeuristicRuntime.java trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOENode.java trunk/components-core/src/main/java/org/dllearner/algorithms/gp/ADC.java trunk/components-core/src/main/java/org/dllearner/algorithms/gp/GP.java trunk/components-core/src/main/java/org/dllearner/algorithms/gp/GPUtilities.java trunk/components-core/src/main/java/org/dllearner/algorithms/gp/Program.java trunk/components-core/src/main/java/org/dllearner/algorithms/gp/package.html trunk/components-core/src/main/java/org/dllearner/algorithms/hybridgp/GeneticRefinementOperator.java trunk/components-core/src/main/java/org/dllearner/algorithms/hybridgp/Psi.java trunk/components-core/src/main/java/org/dllearner/algorithms/hybridgp/package.html trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityTextRetriever.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/ISLE.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneDocument.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneIndexer.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneSearcher.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/NLPHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/Relevances.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/ExampleBasedHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/ExampleBasedNode.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/FlexibleHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/LexicographicHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/MultiHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/NodeComparatorStable.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/OCEL.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/ROLearner2.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/SubsumptionComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/package.html trunk/components-core/src/main/java/org/dllearner/algorithms/package.html trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyDomainAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DataPropertyRangeAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointDataPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentDataPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/EquivalentObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalDataPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/IrreflexiveObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyRangeAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ReflexiveObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubDataPropertyOfAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SubObjectPropertyOfAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/SymmetricObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/TransitiveObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/Heuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/Node.java trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/NodeComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/NodeComparator2.java trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/NodeComparatorStable.java trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/ROLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/package.html trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java trunk/components-core/src/main/java/org/dllearner/core/AbstractComponent.java trunk/components-core/src/main/java/org/dllearner/core/AbstractKnowledgeSource.java trunk/components-core/src/main/java/org/dllearner/core/AbstractLearningProblem.java trunk/components-core/src/main/java/org/dllearner/core/AbstractReasonerComponent.java trunk/components-core/src/main/java/org/dllearner/core/ActiveLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/AnnComponentManager.java trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/BaseReasoner.java trunk/components-core/src/main/java/org/dllearner/core/ClassExpressionLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/Component.java trunk/components-core/src/main/java/org/dllearner/core/ComponentAnn.java trunk/components-core/src/main/java/org/dllearner/core/ComponentInitException.java trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java trunk/components-core/src/main/java/org/dllearner/core/ComponentPool.java trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java trunk/components-core/src/main/java/org/dllearner/core/EvaluatedDescription.java trunk/components-core/src/main/java/org/dllearner/core/FuzzyClassExpressionLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/IndividualReasoner.java trunk/components-core/src/main/java/org/dllearner/core/KnowledgeSource.java trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/LearningProblem.java trunk/components-core/src/main/java/org/dllearner/core/LearningProblemUnsupportedException.java trunk/components-core/src/main/java/org/dllearner/core/OntologyFormat.java trunk/components-core/src/main/java/org/dllearner/core/OntologyFormatUnsupportedException.java trunk/components-core/src/main/java/org/dllearner/core/Oracle.java trunk/components-core/src/main/java/org/dllearner/core/Reasoner.java trunk/components-core/src/main/java/org/dllearner/core/ReasonerComponent.java trunk/components-core/src/main/java/org/dllearner/core/ReasonerOld.java trunk/components-core/src/main/java/org/dllearner/core/ReasoningMethodUnsupportedException.java trunk/components-core/src/main/java/org/dllearner/core/ResumableLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/SchemaReasoner.java trunk/components-core/src/main/java/org/dllearner/core/Score.java trunk/components-core/src/main/java/org/dllearner/core/SparqlQueryLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/StoppableLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/config/ConfigHelper.java trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/config/DataPropertyEditor.java trunk/components-core/src/main/java/org/dllearner/core/config/IntegerEditor.java trunk/components-core/src/main/java/org/dllearner/core/config/NamedClassEditor.java trunk/components-core/src/main/java/org/dllearner/core/config/ObjectPropertyEditor.java trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java trunk/components-core/src/main/java/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/CELOEConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java trunk/components-core/src/main/java/org/dllearner/core/configurators/Configurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/DIGReasonerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/ELLearningAlgorithmConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/ELLearningAlgorithmDisjunctiveConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyOWLAPIReasonerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyPosNegLPStandardConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/GPConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/ISLEConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/KBFileConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/OCELConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/OWLFileConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/PelletReasonerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/PosOnlyLPConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/ProtegeReasonerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/ROLearnerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/RandomGuesserConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/RefinementOperatorConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/SparqlEndpointKSConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/package.html trunk/components-core/src/main/java/org/dllearner/core/fuzzydll/FuzzyIndividualReasoner.java trunk/components-core/src/main/java/org/dllearner/core/fuzzydll/FuzzyUnsupportedCodeException.java trunk/components-core/src/main/java/org/dllearner/core/options/BooleanConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigMappings.java trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigOptions.java trunk/components-core/src/main/java/org/dllearner/core/options/ConfigEntry.java trunk/components-core/src/main/java/org/dllearner/core/options/ConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/options/DoubleConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/options/IntegerConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/options/InvalidConfigOptionValueException.java trunk/components-core/src/main/java/org/dllearner/core/options/StringConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/options/StringSetConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/options/StringTupleListConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/options/URLConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/options/UnknownConfigOptionException.java trunk/components-core/src/main/java/org/dllearner/core/options/fuzzydll/FuzzyExample.java trunk/components-core/src/main/java/org/dllearner/core/options/fuzzydll/ObjectSetConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/options/package.html trunk/components-core/src/main/java/org/dllearner/core/owl/Annotation.java trunk/components-core/src/main/java/org/dllearner/core/owl/AssertionalAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/AssertionalAxiomVisitor.java trunk/components-core/src/main/java/org/dllearner/core/owl/AsymmetricObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/Axiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/AxiomVisitor.java trunk/components-core/src/main/java/org/dllearner/core/owl/BooleanDataRange.java trunk/components-core/src/main/java/org/dllearner/core/owl/BooleanDatatypePropertyAssertion.java trunk/components-core/src/main/java/org/dllearner/core/owl/BooleanValueRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/CardinalityRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ClassAssertionAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java trunk/components-core/src/main/java/org/dllearner/core/owl/Constant.java trunk/components-core/src/main/java/org/dllearner/core/owl/ConstantAnnotation.java trunk/components-core/src/main/java/org/dllearner/core/owl/ContextDescription.java trunk/components-core/src/main/java/org/dllearner/core/owl/DataRange.java trunk/components-core/src/main/java/org/dllearner/core/owl/Datatype.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeCardinalityRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeProperty.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypePropertyAssertion.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypePropertyDomainAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypePropertyHierarchy.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypePropertyRangeAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeQuantorRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeSomeRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/Description.java trunk/components-core/src/main/java/org/dllearner/core/owl/DescriptionVisitor.java trunk/components-core/src/main/java/org/dllearner/core/owl/DifferentIndividualsAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/DisjointClassesAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/DisjointDatatypePropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/DisjointObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleDataRange.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleDatatypePropertyAssertion.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMaxValue.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinValue.java trunk/components-core/src/main/java/org/dllearner/core/owl/Entity.java trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentClassesAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentDatatypePropertiesAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/EquivalentObjectPropertiesAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/FlatABox.java trunk/components-core/src/main/java/org/dllearner/core/owl/FunctionalDatatypePropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/FunctionalObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/Individual.java trunk/components-core/src/main/java/org/dllearner/core/owl/Intersection.java trunk/components-core/src/main/java/org/dllearner/core/owl/InverseFunctionalObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/InverseObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/IrreflexiveObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/KB.java trunk/components-core/src/main/java/org/dllearner/core/owl/KBElement.java trunk/components-core/src/main/java/org/dllearner/core/owl/KBElementVisitor.java trunk/components-core/src/main/java/org/dllearner/core/owl/LabelAnnotation.java trunk/components-core/src/main/java/org/dllearner/core/owl/NamedClass.java trunk/components-core/src/main/java/org/dllearner/core/owl/NamedKBElement.java trunk/components-core/src/main/java/org/dllearner/core/owl/Negation.java trunk/components-core/src/main/java/org/dllearner/core/owl/Nothing.java trunk/components-core/src/main/java/org/dllearner/core/owl/OWL2Datatype.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectAllRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectCardinalityRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectOneOf.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyAssertion.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyExpression.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyHierarchy.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyInverse.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyRangeAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectQuantorRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectSomeRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectValueRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/Property.java trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAssertion.java trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyAxiomVisitor.java trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyDomainAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyExpression.java trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyExpressionVisitor.java trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyRange.java trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyRangeAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/QuantorRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ReflexiveObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/Restriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/SimpleDoubleDataRange.java trunk/components-core/src/main/java/org/dllearner/core/owl/StringDatatypePropertyAssertion.java trunk/components-core/src/main/java/org/dllearner/core/owl/StringValueRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/SubClassAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/SubDatatypePropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/SubObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/SymmetricObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/TerminologicalAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/TerminologicalAxiomVisitor.java trunk/components-core/src/main/java/org/dllearner/core/owl/Thing.java trunk/components-core/src/main/java/org/dllearner/core/owl/TransitiveObjectPropertyAxiom.java trunk/components-core/src/main/java/org/dllearner/core/owl/TypedConstant.java trunk/components-core/src/main/java/org/dllearner/core/owl/Union.java trunk/components-core/src/main/java/org/dllearner/core/owl/UnsupportedLanguageException.java trunk/components-core/src/main/java/org/dllearner/core/owl/UntypedConstant.java trunk/components-core/src/main/java/org/dllearner/core/owl/ValueRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/fuzzydll/FuzzyIndividual.java trunk/components-core/src/main/java/org/dllearner/core/owl/package.html trunk/components-core/src/main/java/org/dllearner/core/package.html trunk/components-core/src/main/java/org/dllearner/kb/KBFile.java trunk/components-core/src/main/java/org/dllearner/kb/OWLAPIOntology.java trunk/components-core/src/main/java/org/dllearner/kb/OWLFile.java trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java trunk/components-core/src/main/java/org/dllearner/kb/aquisitors/BlankNodeCollector.java trunk/components-core/src/main/java/org/dllearner/kb/aquisitors/LinkedDataTupleAquisitor.java trunk/components-core/src/main/java/org/dllearner/kb/aquisitors/RDFBlankNode.java trunk/components-core/src/main/java/org/dllearner/kb/aquisitors/SparqlTupleAquisitor.java trunk/components-core/src/main/java/org/dllearner/kb/aquisitors/SparqlTupleAquisitorImproved.java trunk/components-core/src/main/java/org/dllearner/kb/aquisitors/TupleAquisitor.java trunk/components-core/src/main/java/org/dllearner/kb/aquisitors/package.html trunk/components-core/src/main/java/org/dllearner/kb/extraction/BlankNode.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/ClassNode.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/Configuration.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/DatatypePropertyNode.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/ExtractionAlgorithm.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/InstanceNode.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/LiteralNode.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/Manager.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/Node.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/OWLAPIOntologyCollector.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/ObjectPropertyNode.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/PropertyNode.java trunk/components-core/src/main/java/org/dllearner/kb/extraction/package.html trunk/components-core/src/main/java/org/dllearner/kb/manipulator/AddAllStringsAsClasses.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/DBPediaNavigatorCityLocatorRule.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/DBpediaNavigatorFilterRule.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/DBpediaNavigatorOtherRule.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/Manipulator.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/ObjectReplacementRule.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/PredicateReplacementRule.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/Rule.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/SimpleObjectFilterRule.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/SimplePredicateFilterRule.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/StringToResource.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/TypeFilterRule.java trunk/components-core/src/main/java/org/dllearner/kb/manipulator/package.html trunk/components-core/src/main/java/org/dllearner/kb/package.html trunk/components-core/src/main/java/org/dllearner/kb/sparql/Cache.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtendedQueryEngineHTTP.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/HttpQuery.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/SPARQLTasks.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlEndpoint.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlQuery.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertRDFS.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlQueryException.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlQueryMaker.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/package.html trunk/components-core/src/main/java/org/dllearner/learningproblems/AxiomScore.java trunk/components-core/src/main/java/org/dllearner/learningproblems/ClassLearningProblem.java trunk/components-core/src/main/java/org/dllearner/learningproblems/ClassScore.java trunk/components-core/src/main/java/org/dllearner/learningproblems/EvaluatedDescriptionClass.java trunk/components-core/src/main/java/org/dllearner/learningproblems/EvaluatedDescriptionPosNeg.java trunk/components-core/src/main/java/org/dllearner/learningproblems/EvaluatedDescriptionPosOnly.java trunk/components-core/src/main/java/org/dllearner/learningproblems/EvaluationCache.java trunk/components-core/src/main/java/org/dllearner/learningproblems/Heuristics.java trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStrict.java trunk/components-core/src/main/java/org/dllearner/learningproblems/PosOnlyLP.java trunk/components-core/src/main/java/org/dllearner/learningproblems/ScorePosNeg.java trunk/components-core/src/main/java/org/dllearner/learningproblems/ScorePosOnly.java trunk/components-core/src/main/java/org/dllearner/learningproblems/ScoreThreeValued.java trunk/components-core/src/main/java/org/dllearner/learningproblems/ScoreTwoValued.java trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLP.java trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java trunk/components-core/src/main/java/org/dllearner/learningproblems/package.html trunk/components-core/src/main/java/org/dllearner/package.html trunk/components-core/src/main/java/org/dllearner/parser/KBParser.java trunk/components-core/src/main/java/org/dllearner/parser/KBParserConstants.java trunk/components-core/src/main/java/org/dllearner/parser/KBParserTokenManager.java trunk/components-core/src/main/java/org/dllearner/parser/ParseException.java trunk/components-core/src/main/java/org/dllearner/parser/PrologParser.java trunk/components-core/src/main/java/org/dllearner/parser/PrologParserConstants.java trunk/components-core/src/main/java/org/dllearner/parser/PrologParserTokenManager.java trunk/components-core/src/main/java/org/dllearner/parser/SimpleCharStream.java trunk/components-core/src/main/java/org/dllearner/parser/Token.java trunk/components-core/src/main/java/org/dllearner/parser/TokenMgrError.java trunk/components-core/src/main/java/org/dllearner/parser/package.html trunk/components-core/src/main/java/org/dllearner/prolog/ArrayListSet.java trunk/components-core/src/main/java/org/dllearner/prolog/Atom.java trunk/components-core/src/main/java/org/dllearner/prolog/Body.java trunk/components-core/src/main/java/org/dllearner/prolog/Clause.java trunk/components-core/src/main/java/org/dllearner/prolog/Constant.java trunk/components-core/src/main/java/org/dllearner/prolog/Function.java trunk/components-core/src/main/java/org/dllearner/prolog/FunctionDefinition.java trunk/components-core/src/main/java/org/dllearner/prolog/List.java trunk/components-core/src/main/java/org/dllearner/prolog/Literal.java trunk/components-core/src/main/java/org/dllearner/prolog/Number.java trunk/components-core/src/main/java/org/dllearner/prolog/PredicateDefinition.java trunk/components-core/src/main/java/org/dllearner/prolog/Program.java trunk/components-core/src/main/java/org/dllearner/prolog/PrologConstant.java trunk/components-core/src/main/java/org/dllearner/prolog/StringConstant.java trunk/components-core/src/main/java/org/dllearner/prolog/Term.java trunk/components-core/src/main/java/org/dllearner/prolog/Variable.java trunk/components-core/src/main/java/org/dllearner/prolog/package.html trunk/components-core/src/main/java/org/dllearner/reasoning/DIGConverter.java trunk/components-core/src/main/java/org/dllearner/reasoning/DIGHTTPConnector.java trunk/components-core/src/main/java/org/dllearner/reasoning/DIGReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java trunk/components-core/src/main/java/org/dllearner/reasoning/FastRetrieval.java trunk/components-core/src/main/java/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIDIGConverter.java trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/PelletReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/ProtegeReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/ReasonerType.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyOWLAPIReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/package.html trunk/components-core/src/main/java/org/dllearner/refinementoperators/ELDown.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/ELDown2.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/MathOperations.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/OperatorInverter.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/PsiDown.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/PsiUp.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/RefinementOperator.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/RefinementOperatorAdapter.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDown.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/Utility.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/fuzzydll/FuzzyRhoDRDown.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/package.html trunk/components-core/src/main/java/org/dllearner/utilities/CSVFileToArray.java trunk/components-core/src/main/java/org/dllearner/utilities/CommonPrefixMap.java trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java trunk/components-core/src/main/java/org/dllearner/utilities/Files.java trunk/components-core/src/main/java/org/dllearner/utilities/Helper.java trunk/components-core/src/main/java/org/dllearner/utilities/JamonMonitorLogger.java trunk/components-core/src/main/java/org/dllearner/utilities/Logging.java trunk/components-core/src/main/java/org/dllearner/utilities/StringFormatter.java trunk/components-core/src/main/java/org/dllearner/utilities/URLencodeUTF8.java trunk/components-core/src/main/java/org/dllearner/utilities/analyse/CountInstances.java trunk/components-core/src/main/java/org/dllearner/utilities/analyse/Hierarchy.java trunk/components-core/src/main/java/org/dllearner/utilities/analyse/ScriptDoAll.java trunk/components-core/src/main/java/org/dllearner/utilities/components/ComponentCombo.java trunk/components-core/src/main/java/org/dllearner/utilities/components/ReasonerComponentFactory.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/Datastructures.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/DescriptionSubsumptionTree.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/Maps.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/RDFNodeTuple.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/ResultConceptSorter.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/SetManipulation.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/SortedSetTuple.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/StringTuple.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/TrainTestList.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/package.html trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderOWL.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL2.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticPositiveExampleFinderOWL.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticPositiveExampleFinderSPARQL.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/ExMakerHelper.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/ExampleContainer.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/ExampleDataCollector.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/package.html trunk/components-core/src/main/java/org/dllearner/utilities/experiments/ExMakerCrossFolds.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/ExMakerFixedSize.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/ExMakerRandomizer.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/Examples.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/ExperimentConfiguration.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/FinalizedMonitor.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/Jamon.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/MyMonKey.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/Table.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/TableRowColumn.java trunk/components-core/src/main/java/org/dllearner/utilities/experiments/Units.java trunk/components-core/src/main/java/org/dllearner/utilities/learn/ConfWriter.java trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnConfiguration.java trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnOWLFileConfiguration.java trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java trunk/components-core/src/main/java/org/dllearner/utilities/learn/UsedEntitiesDetection.java trunk/components-core/src/main/java/org/dllearner/utilities/learn/package.html trunk/components-core/src/main/java/org/dllearner/utilities/owl/ConceptComparator.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/ConceptTransformation.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLLearnerDescriptionConvertVisitor.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionMinimizer.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionSet.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/EvaluatedDescriptionPosNegComparator.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/ManchesterOWLSyntaxParser.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWL2SPARULConverter.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIAxiomConvertVisitor.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIConverter.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIDescriptionConvertVisitor.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIRenderers.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLVocabulary.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OntologyClassRewriter.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OntologyCloser.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OntologyCloserOWLAPI.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/PropertyContext.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/RoleComparator.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/package.html trunk/components-core/src/main/java/org/dllearner/utilities/package-info.java trunk/components-core/src/main/java/org/dllearner/utilities/statistics/FleissKappa.java trunk/components-core/src/main/java/org/dllearner/utilities/statistics/RawAgreement.java trunk/components-core/src/main/java/org/dllearner/utilities/statistics/SimpleClock.java trunk/components-core/src/main/java/org/dllearner/utilities/statistics/Stat.java trunk/components-core/src/main/java/org/dllearner/utilities/statistics/Statistics.java trunk/components-core/src/main/java/org/dllearner/utilities/statistics/Table.java trunk/components-core/src/main/java/org/dllearner/utilities/statistics/TableColumn.java trunk/components-core/src/main/java/org/dllearner/utilities/statistics/package.html trunk/components-core/src/test/java/org/dllearner/examples/AnnotationExample.java trunk/components-core/src/test/java/org/dllearner/examples/ConfigOption.java trunk/components-core/src/test/java/org/dllearner/examples/ConfiguredObject.java trunk/components-core/src/test/java/org/dllearner/examples/ObjectPropertyEditor.java trunk/components-core/src/test/java/org/dllearner/examples/OurStringTrimmerEditor.java trunk/components-core/src/test/java/org/dllearner/test/ClassCastExceptionTest.java trunk/components-core/src/test/java/org/dllearner/test/ComponentTest.java trunk/components-core/src/test/java/org/dllearner/test/FaCTBugDemo.java trunk/components-core/src/test/java/org/dllearner/test/FilterTest.java trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest.java trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains.java trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_Trains_noFuzzyIndividuals.java trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest_noFuzzyTrains.java trunk/components-core/src/test/java/org/dllearner/test/HermitTest.java trunk/components-core/src/test/java/org/dllearner/test/JenaConstruct.java trunk/components-core/src/test/java/org/dllearner/test/JenaHTTPTest.java trunk/components-core/src/test/java/org/dllearner/test/JenaLongQueryTest.java trunk/components-core/src/test/java/org/dllearner/test/JenaQueryToResultSpeedTest.java trunk/components-core/src/test/java/org/dllearner/test/OWLAPIBugDemo.java trunk/components-core/src/test/java/org/dllearner/test/OWLAPIConsistency.java trunk/components-core/src/test/java/org/dllearner/test/OWLLinkReasonerTest.java trunk/components-core/src/test/java/org/dllearner/test/PelletBug.java trunk/components-core/src/test/java/org/dllearner/test/PelletBug2.java trunk/components-core/src/test/java/org/dllearner/test/PelletBug3.java trunk/components-core/src/test/java/org/dllearner/test/PelletPerformanceProblem.java trunk/components-core/src/test/java/org/dllearner/test/SparqlEndpointTest.java trunk/components-core/src/test/java/org/dllearner/test/SparqlExtractionTest.java trunk/components-core/src/test/java/org/dllearner/test/SparqlQueryConverter.java trunk/components-core/src/test/java/org/dllearner/test/SworeTest.java trunk/components-core/src/test/java/org/dllearner/test/TestGetExampleBug.java trunk/components-core/src/test/java/org/dllearner/test/TestOneQueryForMusicRecommender.java trunk/components-core/src/test/java/org/dllearner/test/TripleTypeTest.java trunk/components-core/src/test/java/org/dllearner/test/ValueKBParserTest.java trunk/components-core/src/test/java/org/dllearner/test/junit/AllTestsRunner.java trunk/components-core/src/test/java/org/dllearner/test/junit/ClassExpressionTests.java trunk/components-core/src/test/java/org/dllearner/test/junit/ComponentTests.java trunk/components-core/src/test/java/org/dllearner/test/junit/ELDescriptionTreeTests.java trunk/components-core/src/test/java/org/dllearner/test/junit/ELDownTests.java trunk/components-core/src/test/java/org/dllearner/test/junit/HeuristicTests.java trunk/components-core/src/test/java/org/dllearner/test/junit/OWLAPITests.java trunk/components-core/src/test/java/org/dllearner/test/junit/ParserTests.java trunk/components-core/src/test/java/org/dllearner/test/junit/PropertyLearningTest.java trunk/components-core/src/test/java/org/dllearner/test/junit/RefinementOperatorTests.java trunk/components-core/src/test/java/org/dllearner/test/junit/SimulationTests.java trunk/components-core/src/test/java/org/dllearner/test/junit/TestOntologies.java trunk/components-core/src/test/java/org/dllearner/test/junit/UtilitiesTests.java trunk/components-core/src/test/java/org/dllearner/test/junit/package.html trunk/components-core/src/test/java/org/dllearner/test/package.html Added Paths: ----------- trunk/components-core/src/etc/ trunk/components-core/src/etc/header.txt Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/pom.xml 2011-08-21 20:31:32 UTC (rev 3078) @@ -4,7 +4,6 @@ <groupId>org.dllearner</groupId> <artifactId>components-core</artifactId> - <packaging>jar</packaging> <name>DL Learner Core Components</name> <url>http://aksw.org/Projects/DLLearner</url> @@ -109,6 +108,15 @@ </distroConfigurations> </configuration> </plugin> + <plugin> + <groupId>com.mycila.maven-license-plugin</groupId> + <artifactId>maven-license-plugin</artifactId> + <configuration> + <header>src/etc/header.txt</header> + </configuration> + </plugin> + + </plugins> </build> Added: trunk/components-core/src/etc/header.txt =================================================================== --- trunk/components-core/src/etc/header.txt (rev 0) +++ trunk/components-core/src/etc/header.txt 2011-08-21 20:31:32 UTC (rev 3078) @@ -0,0 +1,16 @@ +Copyright (C) 2007-${year}, 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/>. \ No newline at end of file Property changes on: trunk/components-core/src/etc/header.txt ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/components-core/src/main/java/org/dllearner/Info.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/Info.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/Info.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -1,4 +1,23 @@ +/** + * Copyright (C) 2007-2011, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + // File is updated automatically when a new version is created package org.dllearner; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -1,8 +1,8 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -15,7 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * */ package org.dllearner.algorithms; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * */ + package org.dllearner.algorithms; import java.util.ArrayList; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/RandomGuesser.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/RandomGuesser.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -1,8 +1,8 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * */ + package org.dllearner.algorithms; import java.util.Collection; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/SearchTreeNode.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/SearchTreeNode.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/SearchTreeNode.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -1,8 +1,8 @@ /** - * Copyright (C) 2007-2010, Jens Lehmann + * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * */ + package org.dllearner.algorithms; import java.util.Collection; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * */ + package org.dllearner.algorithms; import java.util.ArrayList; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -1,8 +1,8 @@ /** - * Copyright (C) 2007-2009, Jens Lehmann + * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * */ + package org.dllearner.algorithms.celoe; import java.io.File; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -1,8 +1,8 @@ /** - * Copyright (C) 2007-2009, Jens Lehmann + * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * */ + package org.dllearner.algorithms.celoe; import java.util.Comparator; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -1,8 +1,8 @@ /** - * Copyright (C) 2007-2009, Jens Lehmann + * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * */ + package org.dllearner.algorithms.celoe; import java.text.DecimalFormat; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/el/DisjunctiveHeuristic.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/el/DisjunctiveHeuristic.java 2011-08-20 17:04:42 UTC (rev 3077) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/el/DisjunctiveHeuristic.java 2011-08-21 20:31:32 UTC (rev 3078) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2011, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it... [truncated message content] |
From: <lor...@us...> - 2011-08-22 09:18:04
|
Revision: 3083 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3083&view=rev Author: lorenz_b Date: 2011-08-22 09:17:56 +0000 (Mon, 22 Aug 2011) Log Message: ----------- Cleaned up pom.xml. Removed unused classes. Modified Paths: -------------- trunk/components-core/pom.xml Removed Paths: ------------- trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java trunk/components-core/src/test/java/org/dllearner/examples/ Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-08-22 07:28:14 UTC (rev 3082) +++ trunk/components-core/pom.xml 2011-08-22 09:17:56 UTC (rev 3083) @@ -152,12 +152,6 @@ </dependency> <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - <scope>provided</scope> - </dependency> - - <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </dependency> @@ -177,38 +171,22 @@ </exclusions> </dependency> - <!--SwingX is in central--> - <dependency> - <groupId>org.swinglabs</groupId> - <artifactId>swingx</artifactId> - </dependency> - - <!--JSON is in Central--> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> </dependency> - <dependency> <groupId>net.sf.jopt-simple</groupId> <artifactId>jopt-simple</artifactId> </dependency> - - <!--Lucene is in Central--> <dependency> - <groupId>org.apache.lucene</groupId> - <artifactId>lucene-core</artifactId> - </dependency> - - <dependency> <groupId>org.ini4j</groupId> <artifactId>ini4j</artifactId> </dependency> - <dependency> <groupId>xmlbeans</groupId> <artifactId>xbean</artifactId> @@ -275,12 +253,8 @@ <version>1.0</version> </dependency> + <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-beans</artifactId> - <version>3.0.5.RELEASE</version> - </dependency> - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.8</version> Deleted: trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java 2011-08-22 07:28:14 UTC (rev 3082) +++ trunk/components-core/src/main/java/org/dllearner/core/config/OurStringTrimmerEditor.java 2011-08-22 09:17:56 UTC (rev 3083) @@ -1,41 +0,0 @@ -/** - * Copyright (C) 2007-2011, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package org.dllearner.core.config; - -/** - * Created by IntelliJ IDEA. - * User: Chris - * Date: 7/26/11 - * Time: 10:17 PM - * <p/> - * Making a basic extension so I can get a default constructor so that using reflection is simpler. - * - * I'm extending a Spring provided class for this. - */ -public class OurStringTrimmerEditor extends org.springframework.beans.propertyeditors.StringTrimmerEditor { - - - /** - * Default Constructor - */ - public OurStringTrimmerEditor() { - super(true); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-08-22 11:08:09
|
Revision: 3085 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3085&view=rev Author: lorenz_b Date: 2011-08-22 11:08:02 +0000 (Mon, 22 Aug 2011) Log Message: ----------- Added javadoc-plugin and 2 style files. Modified Paths: -------------- trunk/components-core/pom.xml Added Paths: ----------- trunk/components-core/src/etc/javadoc.css trunk/components-core/src/etc/overview.html Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-08-22 09:19:36 UTC (rev 3084) +++ trunk/components-core/pom.xml 2011-08-22 11:08:02 UTC (rev 3085) @@ -16,31 +16,26 @@ <build> <plugins> - <!--Surefire - for JUnits--> + <!--Surefire - for JUnits --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> - <!-- - Uncomment this when the junits are independent of a runtime - directory - --> - <!--<includes>--> - <!--<include>org/dllearner/test/junit/*</include>--> - <!--</includes>--> + <!-- Uncomment this when the junits are independent of a runtime directory --> + <!--<includes> --> + <!--<include>org/dllearner/test/junit/*</include> --> + <!--</includes> --> <excludes> <exclude>org/dllearner/test/*</exclude> <exclude>org/dllearner/test/junit/TestOntologies.java</exclude> <exclude>org/dllearner/test/junit/PropertyLearningTest.java</exclude> - <!--This line excludes inner classes--> + <!--This line excludes inner classes --> <exclude>**/*$*</exclude> </excludes> </configuration> </plugin> - <!-- - Jar the tests up into a separate jar so other components tests' can - leverage them - --> + <!-- Jar the tests up into a separate jar so other components tests' can + leverage them --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> @@ -108,15 +103,43 @@ </distroConfigurations> </configuration> </plugin> - <plugin> - <groupId>com.mycila.maven-license-plugin</groupId> - <artifactId>maven-license-plugin</artifactId> - <configuration> - <header>src/etc/header.txt</header> - </configuration> - </plugin> - - + <plugin> + <groupId>com.mycila.maven-license-plugin</groupId> + <artifactId>maven-license-plugin</artifactId> + <configuration> + <header>src/etc/header.txt</header> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.8</version> + <configuration> + <show>public</show> + <nohelp>true</nohelp> + <destDir>doc/javadoc</destDir> + <doctitle>DL-Learner Javadoc</doctitle> + <author>true</author> + <nodeprecated>false</nodeprecated> + <nodeprecatedlist>false</nodeprecatedlist> + <noindex>false</noindex> + <nonavbar>false</nonavbar> + <notree>false</notree> + <overview>src/etc/overview.html</overview> + <source>1.6</source> + <sourcepath>src/main/java</sourcepath> + <splitindex>true</splitindex> + <stylesheetfile>src/etc/javadoc.css</stylesheetfile> + <use>true</use> + <version>true</version># + <linksource>true</linksource> + <bottom><img style='float:right' src='http://sflogo.sourceforge.net/sflogo.php?group_id=203619&type=1' width='88' height='31' border='0' alt='SourceForge.net Logo' /> DL-Learner is licenced under the terms of the GNU General Public License.<br />Copyright &#169; 2007-2011 Jens Lehmann</bottom> + <encoding>ISO-8859-1</encoding> + <windowtitle>DL-Learner Javadoc</windowtitle> + </configuration> + </plugin> + + </plugins> </build> @@ -133,13 +156,13 @@ </exclusions> </dependency> - <!-- THIS IS FROM THE UNIBAS REPO--> + <!-- THIS IS FROM THE UNIBAS REPO --> <dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi</artifactId> </dependency> - <!-- THIS IS FROM THE UNIBAS REPO--> + <!-- THIS IS FROM THE UNIBAS REPO --> <dependency> <groupId>com.owldl</groupId> <artifactId>pellet</artifactId> @@ -156,10 +179,8 @@ <artifactId>log4j</artifactId> </dependency> - <!-- - Available via central, we use the latest with minor mods to DL - Learner source (IE Dig related code) - --> + <!-- Available via central, we use the latest with minor mods to DL Learner + source (IE Dig related code) --> <dependency> <groupId>com.hp.hpl.jena</groupId> <artifactId>jena</artifactId> @@ -171,7 +192,7 @@ </exclusions> </dependency> - <!--JSON is in Central--> + <!--JSON is in Central --> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> @@ -211,9 +232,9 @@ <groupId>com.jamonapi</groupId> <artifactId>jamon</artifactId> </dependency> - - <!--JENA ARQ is in central - we use the latest--> + + <!--JENA ARQ is in central - we use the latest --> <dependency> <groupId>com.hp.hpl.jena</groupId> <artifactId>arq</artifactId> @@ -253,16 +274,16 @@ <version>1.0</version> </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>1.5.8</version> - </dependency> - <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - <version>20041127.091804</version> - </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.5.8</version> + </dependency> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>20041127.091804</version> + </dependency> </dependencies> </project> Added: trunk/components-core/src/etc/javadoc.css =================================================================== --- trunk/components-core/src/etc/javadoc.css (rev 0) +++ trunk/components-core/src/etc/javadoc.css 2011-08-22 11:08:02 UTC (rev 3085) @@ -0,0 +1,351 @@ + + + + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<!-- ViewVC :: http://www.viewvc.org/ --> +<head> +<title>SourceForge.net Repository - [dl-learner] Log of /tags/premaven/javadoc.css</title> +<meta name="generator" content="ViewVC 1.1.6" /> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<meta name="description" content="The world's largest development and download repository of Open Source code and applications" /> +<meta name="keywords" content="Open Source, Development, Developers, Projects, Downloads, OSTG, VA Software, SF.net, SourceForge" /> +<title>SourceForge.net Repository - dl-learner Index of /</title> +<link rel="shortcut icon" href="http://a.fsdn.com/con/img/favicon.ico" /> +<link rel="stylesheet" href="http://a.fsdn.com/con/css/sf.min.css?1256826599" type="text/css" /> +<link rel="stylesheet" href="/viewvc-static/styles.css" type="text/css" /> +<style type="text/css"> +#doc3 { max-width: 1000px; margin: 0 auto; } +#hd .logo { +background: url("http://a.fsdn.com/sf/images/phoneix/sf_phoneix.png") no-repeat; +color: transparent; +display: inline-block; +height: 36px; +} +#hd .search { display: none; } +#breadcrumbs { margin-bottom: 1em; } +#fad83 { float: right; } +#yui-main { min-height: 100px; } +#ft .yui-u { display: inline-block; margin-right: 2em; } +</style> + +<!-- BEGIN: AdSolution-Tag 4.2: Global-Code [PLACE IN HTML-HEAD-AREA!] --> +<!-- DoubleClick Random Number --> +<script language="JavaScript" type="text/javascript"> +dfp_ord=Math.random()*10000000000000000; +dfp_tile = 1; +</script> +<!-- End DoubleClick Random Number --> +<script type="text/javascript"> +var google_page_url = 'http://sourceforge.net/projects/dl-learner/'; +var sourceforge_project_name = 'dl-learner'; +var sourceforge_project_description = ''; +</script> +<!-- END: AdSolution-Tag 4.2: Global-Code --> +<!-- after META tags --> +<script type="text/javascript"> +var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); +document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); +</script> +</head> +<body class="short-head"> +<!--[if IE 7]><div id="ie7only"><![endif]--> +<!--[if IE 6]><div id="ie6only"><![endif]--> +<!--[if IE]><div id="ieonly"><![endif]--> +<div id="doc3"> +<div id="hd"> +<div class="yui-b"> +<div class="yui-gc"> +<div class="yui-u first"> +<a href="http://sourceforge.net/" class="logo">Find and develop open source software</a> +</div> +<div class="yui-u"> +<div class="search"> +<form action="http://sourceforge.net/search/" method="get" name="searchform" id="searchform"> +<input type="hidden" name="type_of_search" value="soft" /> +<input type="text" class="text clear hint" name="words" id="words" value="enter keyword" /> +<span class="yui-button yui-push-button default"><span class="first-child"><button type="submit" value="Search">Search</button></span></span> +</form> +</div> +</div> +</div> +</div> +</div> +<div id="bd" class="inner-bd"> +<div id="doc4" class="yui-t6"> +<div id="breadcrumbs"> + +<a href="http://sourceforge.net/">SourceForge.net</a> +> <a href="http://sourceforge.net/softwaremap/">Find Software</a> +> <a href="http://sourceforge.net/projects/dl-learner/">dl-learner</a> +> SCM Repositories + + +<a href="/viewvc/dl-learner/"> + + +> dl-learner + + +</a> + + + +<a href="/viewvc/dl-learner/tags/"> + + +> tags + + +</a> + + + +<a href="/viewvc/dl-learner/tags/premaven/"> + + +> premaven + + +</a> + + + + +> javadoc.css + + + + +</div> + + + + + + + + + + +<div id="project_nav_container"> +<small><div> + +<a href="/viewvc/dl-learner/tags/premaven/"><img src="/viewvc-static/images/back_small.png" width="16" height="16" alt="Parent Directory" /> Parent Directory</a> + +| <a href="/viewvc/dl-learner/tags/premaven/javadoc.css?view=log"><img src="/viewvc-static/images/log.png" width="16" height="16" alt="Revision Log" /> Revision Log</a> + + + + +</div> +</small> +<h1>SCM Repositories - <a href="http://sourceforge.net/projects/dl-learner">dl-learner</a></h1> +</div> +<hr class="clear"> +<div class="yui-b"> +<div id="fad83"> +<!-- DoubleClick Ad Tag --> +<script type="text/javascript"> +//<![CDATA[ +document.write('<script src="http://ad.doubleclick.net/adj/ostg.sourceforge/pg_viewvc_p88_shortrec;pg=viewvc;tile='+dfp_tile+';tpc=dl-learner;ord='+dfp_ord+';sz=1x1?" type="text/javascript"><\/script>'); +dfp_tile++; +//]]> +</script> +<!-- End DoubleClick Ad Tag --> +</div> +</div> +<div id="yui-main"> +<div class="yui-b sfBox"> +<table class="auto"> + + + +<tr> +<td>Links to HEAD:</td> +<td> + +(<a href="/viewvc/dl-learner/tags/premaven/javadoc.css?revision=3084&view=markup">view</a>) +(<a href="/viewvc/dl-learner/tags/premaven/javadoc.css?revision=3084">download</a>) +(<a href="/viewvc/dl-learner/tags/premaven/javadoc.css?revision=3084&content-type=text%2Fplain">as text</a>) +(<a href="/viewvc/dl-learner/tags/premaven/javadoc.css?annotate=3084">annotate</a>) +mime-type: text/css +</td> +</tr> + + + +<tr> +<td>Sticky Revision:</td> +<td><form method="get" action="/viewvc/dl-learner" style="display: inline"> +<div style="display: inline"> +<input type="hidden" name="orig_pathtype" value="FILE"/><input type="hidden" name="orig_view" value="log"/><input type="hidden" name="orig_path" value="tags/premaven/javadoc.css"/><input type="hidden" name="view" value="redirect_pathrev"/> + +<input type="text" name="pathrev" value="" size="6"/> + +<input type="submit" value="Set" /> +</div> +</form> + +</td> +</tr> +</table> + + + +</div> +</div> +<hr class="clear"> +<div> + + + + + + +<div> +<hr /> + +<a name="rev2309"></a> + + +Revision <a href="/viewvc/dl-learner?view=revision&revision=2309"><strong>2309</strong></a> - + + +(<a href="/viewvc/dl-learner/tags/premaven/javadoc.css?revision=2309&view=markup">view</a>) + + +(<a href="/viewvc/dl-learner/tags/premaven/javadoc.css?revision=2309">download</a>) +(<a href="/viewvc/dl-learner/tags/premaven/javadoc.css?revision=2309&content-type=text%2Fplain">as text</a>) +(<a href="/viewvc/dl-learner/tags/premaven/javadoc.css?annotate=2309">annotate</a>) + + + +- <a href="/viewvc/dl-learner/tags/premaven/javadoc.css?r1=2309&view=log">[select for diffs]</a> + + + + +<br /> + +Added + +<em>Fri Sep 17 09:17:53 2010 UTC</em> +(11 months ago) +by <em>kurzum</em> + + + + + + + +<br />File length: 1969 byte(s) + + + + + + + + + + + +<pre class="vc_log">DL-Learner before the transition to maven</pre> +</div> + + + + + + <div class="sfBox"> +<hr class="clear"/> +<a name="diff"></a> +This form allows you to request diffs between any two revisions of this file. +For each of the two "sides" of the diff, + +enter a numeric revision. + +<form method="get" action="/viewvc/dl-learner/tags/premaven/javadoc.css" id="diff_select"> +<table cellpadding="2" cellspacing="0" class="auto"> +<tr> +<td> </td> +<td> + +<input type="hidden" name="view" value="diff"/> + +Diffs between + +<input type="text" size="12" name="r1" +value="2309" /> + +and + +<input type="text" size="12" name="r2" value="2309" /> + +</td> +</tr> +<tr> +<td> </td> +<td> +Type of Diff should be a +<select name="diff_format" onchange="submit()"> +<option value="h" selected="selected">Colored Diff</option> +<option value="l" >Long Colored Diff</option> +<option value="f" >Full Colored Diff</option> +<option value="u" >Unidiff</option> +<option value="c" >Context Diff</option> +<option value="s" >Side by Side</option> +</select> +<input type="submit" value=" Get Diffs " /> +</td> +</tr> +</table> +</form> +</div> + + +<form method="get" action="/viewvc/dl-learner/tags/premaven/javadoc.css"> +<div> +<hr /> +<a name="logsort"></a> +<input type="hidden" name="view" value="log"/> +Sort log by: +<select name="logsort" onchange="submit()"> +<option value="cvs" >Not sorted</option> +<option value="date" >Commit date</option> +<option value="rev" >Revision</option> +</select> +<input type="submit" value=" Sort " /> +</div> +</form> + + +<br /> +</div> +</div> +</div> +<div id="ft"> +<div class="yui-b"> +<div class="yui-gb"> +<div class="yui-u first" style="text-align: center;"> <a href="http://p.sf.net/sourceforge/support">SourceForge Help<a/> </div> +<div class="yui-u" style="text-align: center;"> <strong><a href="/viewvc-static/help_log.html">ViewVC Help</a></strong> </div> +<div class="yui-u" style="text-align: center;"> <a href="http://viewvc.tigris.org/">Powered by ViewVC 1.1.6</a> </div> +</div> +<p class="copyright">Copyright © 2010 <a title="Network which provides and promotes Open Source software downloads, development, discussion and news." href="http://geek.net">Geeknet, Inc.</a> All rights reserved. <a href="http://p.sf.net/sourceforge/terms">Terms of Use</a></p> +</div> +</div> +</div> +<!--[if IE]></div><![endif]--> +<!--[if IE 6]></div><![endif]--> +<!--[if IE 7]></div><![endif]--> +<script type="text/javascript"> +var pageTracker = _gat._getTracker("UA-32013-37"); +pageTracker._setDomainName(".sourceforge.net"); +pageTracker._trackPageview(); +</script> +</body> +</html> + + Added: trunk/components-core/src/etc/overview.html =================================================================== --- trunk/components-core/src/etc/overview.html (rev 0) +++ trunk/components-core/src/etc/overview.html 2011-08-22 11:08:02 UTC (rev 3085) @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head></head> +<body> +<p>DL-Learner is a tool for supervised Machine Learning in OWL and Description Logics.</p> + +<p><img src="http://aksw.org/Projects/DLLearner/files?get=dllearner.gif" alt="DL-Learner logo" /></p> + +<p> +Project Homepage: <a href="http://dl-learner.org">http://dl-learner.org</a> <br /> +Sourceforge.net Website: <a href="http://sourceforge.net/projects/dl-learner">http://sf.net/projects/dl-learner</a> +</p> + +<p><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=203619&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></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. |
From: <lor...@us...> - 2012-03-26 12:10:58
|
Revision: 3618 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3618&view=rev Author: lorenz_b Date: 2012-03-26 12:10:46 +0000 (Mon, 26 Mar 2012) Log Message: ----------- Updated pom. Removed QueryEngineHTTP classes as timeout is now implemented in official JENA jar. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/PCELOE.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/AnnComponentManager.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/refinementoperators/SynchronizedRhoDRDown.java Removed Paths: ------------- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtendedQueryEngineHTTP.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/HttpQuery.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2012-03-23 14:53:07 UTC (rev 3617) +++ trunk/components-core/pom.xml 2012-03-26 12:10:46 UTC (rev 3618) @@ -132,6 +132,7 @@ <artifactId>log4j</artifactId> </dependency> + <!-- Latest JENA ARQ - we have to exclude XercesImpl and use an older version here because use version bei JENA leads to some errors --> <dependency> <groupId>org.apache.jena</groupId> <artifactId>jena-arq</artifactId> @@ -142,6 +143,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + <version>2.6.0</version> + </dependency> <!--JSON is in Central --> <dependency> @@ -185,16 +191,6 @@ </dependency> - <dependency> - <groupId>org.apache.jena</groupId> - <artifactId>jena-core</artifactId> - <exclusions> - <exclusion> - <artifactId>xercesImpl</artifactId> - <groupId>xerces</groupId> - </exclusion> - </exclusions> - </dependency> <dependency> <groupId>junit</groupId> @@ -253,5 +249,7 @@ <groupId>org.apache.lucene</groupId> <artifactId>lucene-core</artifactId> </dependency> + + </dependencies> </project> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/PCELOE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/PCELOE.java 2012-03-23 14:53:07 UTC (rev 3617) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/PCELOE.java 2012-03-26 12:10:46 UTC (rev 3618) @@ -66,6 +66,7 @@ import org.dllearner.refinementoperators.OperatorInverter; import org.dllearner.refinementoperators.RefinementOperator; import org.dllearner.refinementoperators.RhoDRDown; +import org.dllearner.refinementoperators.SynchronizedRhoDRDown; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptComparator; @@ -295,15 +296,15 @@ // variables to it if(operator == null) { // we use a default operator and inject the class hierarchy for now - operator = new RhoDRDown(); - ((RhoDRDown)operator).setStartClass(startClass); - ((RhoDRDown)operator).setReasoner(reasoner); - ((RhoDRDown)operator).init(); + operator = new SynchronizedRhoDRDown(); + ((SynchronizedRhoDRDown)operator).setStartClass(startClass); + ((SynchronizedRhoDRDown)operator).setReasoner(reasoner); + ((SynchronizedRhoDRDown)operator).init(); } // TODO: find a better solution as this is quite difficult to debug - ((RhoDRDown)operator).setSubHierarchy(classHierarchy); - ((RhoDRDown)operator).setObjectPropertyHierarchy(reasoner.getObjectPropertyHierarchy()); - ((RhoDRDown)operator).setDataPropertyHierarchy(reasoner.getDatatypePropertyHierarchy()); + ((SynchronizedRhoDRDown)operator).setSubHierarchy(classHierarchy); + ((SynchronizedRhoDRDown)operator).setObjectPropertyHierarchy(reasoner.getObjectPropertyHierarchy()); + ((SynchronizedRhoDRDown)operator).setDataPropertyHierarchy(reasoner.getDatatypePropertyHierarchy()); // operator = new RhoDRDown(reasoner, classHierarchy, startClass, configurator); @@ -996,6 +997,7 @@ return heuristic; } + @Autowired(required=false) public void setHeuristic(OEHeuristicRuntime heuristic) { this.heuristic = heuristic; } @@ -1052,12 +1054,18 @@ } // chose best node according to heuristics + if(logger.isDebugEnabled()){ + logger.debug("Get next node to expand..."); + } nextNode = getNextNodeToExpand(); if(nextNode != null){ int horizExp = nextNode.getHorizontalExpansion(); // apply operator Monitor mon = MonitorFactory.start("refineNode"); + if(logger.isDebugEnabled()){ + logger.debug("Refining node..."); + } TreeSet<Description> refinements = refineNode(nextNode); mon.stop(); @@ -1081,6 +1089,9 @@ // System.out.println("potentially adding " + refinement + " to search tree as child of " + nextNode + " " + new Date()); Monitor mon2 = MonitorFactory.start("addNode"); + if(logger.isDebugEnabled()){ + logger.debug("Add node..."); + } addNode(refinement, nextNode); mon2.stop(); // adding nodes is potentially computationally expensive, so we have Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2012-03-23 14:53:07 UTC (rev 3617) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2012-03-26 12:10:46 UTC (rev 3618) @@ -215,10 +215,12 @@ public static void main(String[] args) throws Exception{ DisjointObjectPropertyAxiomLearner l = new DisjointObjectPropertyAxiomLearner(new SparqlEndpointKS(new SparqlEndpoint( new URL("http://dbpedia.aksw.org:8902/sparql"), Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList())));//.getEndpointDBpediaLiveAKSW())); - l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/state")); + l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/stateOfOrigin")); l.setMaxExecutionTimeInSeconds(10); l.init(); l.start(); - System.out.println(l.getCurrentlyBestEvaluatedAxioms(Integer.MAX_VALUE)); + for(EvaluatedAxiom ax : l.getCurrentlyBestEvaluatedAxioms(Integer.MAX_VALUE)){ + System.out.println(ax); + } } } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java 2012-03-23 14:53:07 UTC (rev 3617) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/InverseFunctionalObjectPropertyAxiomLearner.java 2012-03-26 12:10:46 UTC (rev 3618) @@ -19,7 +19,9 @@ package org.dllearner.algorithms.properties; +import java.net.URL; import java.util.ArrayList; +import java.util.Collections; import org.dllearner.core.AbstractAxiomLearningAlgorithm; import org.dllearner.core.ComponentAnn; @@ -166,9 +168,10 @@ } public static void main(String[] args) throws Exception{ - SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW()); + SparqlEndpointKS ks = new SparqlEndpointKS(new SparqlEndpoint( + new URL("http://dbpedia.aksw.org:8902/sparql"), Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList())); InverseFunctionalObjectPropertyAxiomLearner l = new InverseFunctionalObjectPropertyAxiomLearner(ks); - l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/starring")); + l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/profession")); l.setMaxExecutionTimeInSeconds(10); l.init(); l.start(); Modified: trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java 2012-03-23 14:53:07 UTC (rev 3617) +++ trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java 2012-03-26 12:10:46 UTC (rev 3618) @@ -38,7 +38,6 @@ import org.dllearner.core.owl.NamedClass; import org.dllearner.kb.LocalModelBasedSparqlEndpointKS; import org.dllearner.kb.SparqlEndpointKS; -import org.dllearner.kb.sparql.ExtendedQueryEngineHTTP; import org.dllearner.kb.sparql.SPARQLTasks; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.learningproblems.AxiomScore; @@ -220,7 +219,7 @@ logger.info("Sending query\n{} ...", query); if(ks.isRemote()){ SparqlEndpoint endpoint = ((SparqlEndpointKS) ks).getEndpoint(); - ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(endpoint.getURL().toString(), + QueryEngineHTTP queryExecution = new QueryEngineHTTP(endpoint.getURL().toString(), query); queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000); queryExecution.setDefaultGraphURIs(endpoint.getDefaultGraphURIs()); @@ -236,7 +235,7 @@ logger.info("Sending query\n{} ...", query); if(ks.isRemote()){ SparqlEndpoint endpoint = ((SparqlEndpointKS) ks).getEndpoint(); - ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(endpoint.getURL().toString(), + QueryEngineHTTP queryExecution = new QueryEngineHTTP(endpoint.getURL().toString(), query); queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000); queryExecution.setDefaultGraphURIs(endpoint.getDefaultGraphURIs()); Modified: trunk/components-core/src/main/java/org/dllearner/core/AnnComponentManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/AnnComponentManager.java 2012-03-23 14:53:07 UTC (rev 3617) +++ trunk/components-core/src/main/java/org/dllearner/core/AnnComponentManager.java 2012-03-26 12:10:46 UTC (rev 3618) @@ -50,7 +50,7 @@ // components must be listed here if they should be supported in interfaces // (CLI, GUI, Web Service) and scripts (HTML documentation generator) private static List<String> componentClassNames = new ArrayList<String> ( Arrays.asList(new String[]{ - "org.dllearner.algorithms.celoe.CELOE", + "org.dllearner.algorithms.celoe.CELOE", "org.dllearner.algorithms.celoe.PCELOE", "org.dllearner.algorithms.el.ELLearningAlgorithm", "org.dllearner.algorithms.el.ELLearningAlgorithmDisjunctive", @@ -91,6 +91,7 @@ "org.dllearner.algorithms.ocel.MultiHeuristic", "org.dllearner.algorithms.celoe.OEHeuristicRuntime", "org.dllearner.refinementoperators.RhoDRDown", + "org.dllearner.refinementoperators.SynchronizedRhoDRDown", } )); private static Collection<Class<? extends Component>> components; private static BidiMap<Class<? extends Component>, String> componentNames; Deleted: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtendedQueryEngineHTTP.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtendedQueryEngineHTTP.java 2012-03-23 14:53:07 UTC (rev 3617) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtendedQueryEngineHTTP.java 2012-03-26 12:10:46 UTC (rev 3618) @@ -1,408 +0,0 @@ -/** - * Copyright (C) 2007-2011, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package org.dllearner.kb.sparql; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.hp.hpl.jena.query.ARQ; -import com.hp.hpl.jena.query.Dataset; -import com.hp.hpl.jena.query.Query; -import com.hp.hpl.jena.query.QueryExecution; -import com.hp.hpl.jena.query.QueryFactory; -import com.hp.hpl.jena.query.QuerySolution; -import com.hp.hpl.jena.query.ResultSet; -import com.hp.hpl.jena.query.ResultSetFactory; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.sparql.engine.http.HttpParams; -import com.hp.hpl.jena.sparql.engine.http.Params; -import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; -import com.hp.hpl.jena.sparql.graph.GraphFactory; -import com.hp.hpl.jena.sparql.resultset.XMLInput; -import com.hp.hpl.jena.sparql.util.Context; -import com.hp.hpl.jena.util.FileManager; - -/** - * Created by Claus Stadler - * Date: Oct 25, 2010 - * Time: 10:15:31 PM - */ -class DisconnectorThread - extends Thread { - private static final Logger logger = LoggerFactory.getLogger(DisconnectorThread.class); - - private HttpQuery connection; - - private long timeOut; - - private boolean canceled = false; - - public DisconnectorThread(HttpQuery connection, long timeOut) { - this.connection = connection; - this.timeOut = timeOut; - } - - public void run() { - synchronized (this) { - - while(!canceled && connection.getConnection() == null) { - //logger.trace("Waiting for connection..."); - - try { - this.wait(500l); - } catch (InterruptedException e) { - } - } - - long startTime = System.currentTimeMillis(); - - long remaining; - while (!canceled && (remaining = (timeOut - (System.currentTimeMillis() - startTime))) > 0) { - logger.trace("Forced disconnect in " + remaining + "ms"); - try { - this.wait(remaining); - } catch (InterruptedException e) { - } - } - - if (!canceled && connection.getConnection() != null) { - logger.warn("Disconnecting Http connection since a sparql query is taking too long"); - connection.getConnection().disconnect(); - canceled = true; - } - } - } - - public void cancel() { - synchronized (this) { - if(!this.canceled) { - logger.trace("Disconnect cancelled"); - } - - this.canceled = true; - this.notify(); - } - } -} - -/** - * A QueryEngineHTTP that is capable of closing connections after a given timeout. - * - * Jena now provides one on its own - */ -public class ExtendedQueryEngineHTTP - implements QueryExecution { - private static Logger log = LoggerFactory.getLogger(QueryEngineHTTP.class); - - public static final String QUERY_MIME_TYPE = "application/sparql-query"; - String queryString; - String service; - Context context = null; - - - long timeOut = 0l; - - public void setTimeOut(long timeOut) { - this.timeOut = timeOut; - } - - public long getTimeOut() { - return timeOut; - } - - - //Params - Params params = null; - - // Protocol - List<String> defaultGraphURIs = new ArrayList<String>(); - List<String> namedGraphURIs = new ArrayList<String>(); - private String user = null; - private char[] password = null; - - // Releasing HTTP input streams is important. We remember this for SELECT, - // and will close when the engine is closed - private InputStream retainedConnection = null; - - public ExtendedQueryEngineHTTP(String serviceURI, Query query) { - this(serviceURI, query.toString()); - } - - public ExtendedQueryEngineHTTP(String serviceURI, String queryString) { - this.queryString = queryString; - service = serviceURI; - // Copy the global context to freeze it. - context = new Context(ARQ.getContext()); - } - -// public void setParams(Params params) -// { this.params = params ; } - - // Meaning-less - - public void setFileManager(FileManager fm) { - throw new UnsupportedOperationException("FileManagers do not apply to remote query execution"); - } - - public void setInitialBinding(QuerySolution binding) { - throw new UnsupportedOperationException("Initial bindings not supported for remote queries"); - } - - public void setInitialBindings(ResultSet table) { - throw new UnsupportedOperationException("Initial bindings not supported for remote queries"); - } - - /** - * @param defaultGraphURIs The defaultGraphURIs to set. - */ - public void setDefaultGraphURIs(List<String> defaultGraphURIs) { - this.defaultGraphURIs = defaultGraphURIs; - } - - /** - * @param namedGraphURIs The namedGraphURIs to set. - */ - public void setNamedGraphURIs(List<String> namedGraphURIs) { - this.namedGraphURIs = namedGraphURIs; - } - - public void addParam(String field, String value) { - if (params == null) - params = new Params(); - params.addParam(field, value); - } - - /** - * @param defaultGraph The defaultGraph to add. - */ - public void addDefaultGraph(String defaultGraph) { - if (defaultGraphURIs == null) - defaultGraphURIs = new ArrayList<String>(); - defaultGraphURIs.add(defaultGraph); - } - - /** - * @param name The URI to add. - */ - public void addNamedGraph(String name) { - if (namedGraphURIs == null) - namedGraphURIs = new ArrayList<String>(); - namedGraphURIs.add(name); - } - - /** - * Set user and password for basic authentication. - * After the request is made (one of the exec calls), the application - * can overwrite the password array to remove details of the secret. - * - * @param user - * @param password - */ - public void setBasicAuthentication(String user, char[] password) { - this.user = user; - this.password = password; - } - - private InputStream doTimedExec(HttpQuery httpQuery) { - DisconnectorThread stopTask = null; - if (timeOut > 0) { - stopTask = new DisconnectorThread(httpQuery, timeOut); -// stopTask.start(); - } - - InputStream in; - try { - in = httpQuery.exec(); - } - finally { - if (stopTask != null) { - stopTask.cancel(); - } - } - - return in; - } - - - public ResultSet execSelect() { - HttpQuery httpQuery = makeHttpQuery(); - // TODO Allow other content types. - httpQuery.setAccept(HttpParams.contentTypeResultsXML); - - InputStream in = httpQuery.exec(); - - - ResultSet rs = ResultSetFactory.fromXML(in); - retainedConnection = in; // This will be closed on close() - return rs; - } - - public Model execConstruct() { - return execConstruct(GraphFactory.makeJenaDefaultModel()); - } - - public Model execConstruct(Model model) { - return execModel(model); - } - - public Model execDescribe() { - return execDescribe(GraphFactory.makeJenaDefaultModel()); - } - - public Model execDescribe(Model model) { - return execModel(model); - } - - private Model execModel(Model model) { - HttpQuery httpQuery = makeHttpQuery(); - httpQuery.setAccept(HttpParams.contentTypeRDFXML); - InputStream in = doTimedExec(httpQuery); - model.read(in, null); - return model; - } - - public boolean execAsk() { - HttpQuery httpQuery = makeHttpQuery(); - httpQuery.setAccept(HttpParams.contentTypeResultsXML); - InputStream in = doTimedExec(httpQuery); - boolean result = XMLInput.booleanFromXML(in); - // Ensure connection is released - try { - in.close(); - } - catch (java.io.IOException e) { - log.warn("Failed to close connection", e); - } - return result; - } - - public Context getContext() { - return context; - } - - private HttpQuery makeHttpQuery() { - HttpQuery httpQuery = new HttpQuery(service); - httpQuery.setTimeOut((int)timeOut); - httpQuery.addParam(HttpParams.pQuery, queryString); - - for (Iterator<String> iter = defaultGraphURIs.iterator(); iter.hasNext();) { - String dft = iter.next(); - httpQuery.addParam(HttpParams.pDefaultGraph, dft); - } - for (Iterator<String> iter = namedGraphURIs.iterator(); iter.hasNext();) { - String name = iter.next(); - httpQuery.addParam(HttpParams.pNamedGraph, name); - } - - if (params != null) - httpQuery.merge(params); - - httpQuery.setBasicAuthentication(user, password); - return httpQuery; - } - - public void abort() { - } - - public void close() { - if (retainedConnection != null) { - try { - retainedConnection.close(); - } - catch (java.io.IOException e) { - log.warn("Failed to close connection", e); - } - finally { - retainedConnection = null; - } - } - } - - @Override - public void setTimeout(long timeout, TimeUnit timeoutUnits) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void setTimeout(long timeout) { - this.timeOut = timeout; - } - - @Override - public void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void setTimeout(long timeout1, long timeout2) { - //To change body of implemented methods use File | Settings | File Templates. - } - -// public boolean isActive() { return false ; } - - @Override - public String toString() { - HttpQuery httpQuery = makeHttpQuery(); - return "GET " + httpQuery.toString(); - } - - public Dataset getDataset() { - return null; - } - - @Override - public Query getQuery() { - return QueryFactory.create(queryString); - } -} - -/* - * (c) Copyright 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2012-03-23 14:53:07 UTC (rev 3617) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2012-03-26 12:10:46 UTC (rev 3618) @@ -19,22 +19,29 @@ package org.dllearner.kb.sparql; +import java.io.ByteArrayOutputStream; +import java.io.StringReader; +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import org.dllearner.utilities.Helper; + import com.hp.hpl.jena.query.ResultSetFactory; import com.hp.hpl.jena.query.ResultSetRewindable; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; -import org.aksw.commons.jena.ExtendedQueryEngineHTTP; -import org.dllearner.utilities.Helper; -import java.io.ByteArrayOutputStream; -import java.io.StringReader; -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.sql.*; - /** * The class is used to cache information about resources to a database. * Provides the connection to an H2 database in a light weight, configuration free @@ -127,8 +134,8 @@ // System.out.println("Posing new query"); // String endpoint = "http://139.18.2.37:8890/sparql"; - ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(endpoint.getURL().toString(), query); - queryExecution.setTimeOut(maxExecutionTimeInSeconds * 1000); + QueryEngineHTTP queryExecution = new QueryEngineHTTP(endpoint.getURL().toString(), query); + queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000); for (String dgu : endpoint.getDefaultGraphURIs()) { queryExecution.addDefaultGraph(dgu); } @@ -187,8 +194,8 @@ } else { mon.start(); // System.out.println("no-cache"); - ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(endpoint.getURL().toString(), query); - queryExecution.setTimeOut(maxExecutionTimeInSeconds * 1000); + QueryEngineHTTP queryExecution = new QueryEngineHTTP(endpoint.getURL().toString(), query); + queryExecution.setTimeout(maxExecutionTimeInSeconds * 1000); for (String dgu : endpoint.getDefaultGraphURIs()) { queryExecution.addDefaultGraph(dgu); } Deleted: trunk/components-core/src/main/java/org/dllearner/kb/sparql/HttpQuery.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/HttpQuery.java 2012-03-23 14:53:07 UTC (rev 3617) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/HttpQuery.java 2012-03-26 12:10:46 UTC (rev 3618) @@ -1,419 +0,0 @@ -/** - * Copyright (C) 2007-2011, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package org.dllearner.kb.sparql; - -/* - * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP - * [See end of file] - */ - - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.commons.codec.binary.Base64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.hp.hpl.jena.query.ARQ; -import com.hp.hpl.jena.shared.JenaException; -import com.hp.hpl.jena.sparql.ARQInternalErrorException; -import com.hp.hpl.jena.sparql.engine.http.HttpParams; -import com.hp.hpl.jena.sparql.engine.http.Params; -import com.hp.hpl.jena.sparql.engine.http.QueryExceptionHTTP; -import com.hp.hpl.jena.sparql.util.Convert; -import com.hp.hpl.jena.util.FileUtils; - -/** Create an execution object for performing a query on a model - * over HTTP. This is the main protocol engine for HTTP query. - * There are higher level classes for doing a query and presenting - * the results in an API fashion. - * - * If the query string is large, then HTTP POST is used. */ -public class HttpQuery extends Params -{ - static final Logger log = LoggerFactory.getLogger(HttpQuery.class.getName()) ; - - /** The definition of "large" queries */ - // Not final so that other code can change it. - static public /*final*/ int urlLimit = 2*1024 ; - - String serviceURL ; - - String contentTypeResult = HttpParams.contentTypeResultsXML ; - HttpURLConnection httpConnection = null ; - - // An object indicate no value associated with parameter name - final static Object noValue = new Object() ; - String user = null ; - char[] password = null ; - - int responseCode = 0; - String responseMessage = null ; - boolean forcePOST = false ; - String queryString = null ; - - private int timeOut = 0; - - public void setTimeOut(int timeOut){ - this.timeOut = timeOut; - } - - //static final String ENC_UTF8 = "UTF-8" ; - - /** Create a execution object for a whole model GET - * @param serviceURL The model - */ - - public HttpQuery(String serviceURL) - { - init(serviceURL) ; - } - - - /** Create a execution object for a whole model GET - * @param url The model - */ - - public HttpQuery(URL url) - { - init(url.toString()) ; - } - - - private void init(String serviceURL) - { - if ( log.isTraceEnabled()) - log.trace("URL: "+serviceURL) ; - - if ( serviceURL.indexOf('?') >= 0 ) - throw new QueryExceptionHTTP(-1, "URL already has a query string ("+serviceURL+")") ; - - this.serviceURL = serviceURL ; - } - - private String getQueryString() - { - if ( queryString == null ) - queryString = super.httpString() ; - return queryString ; - } - - public HttpURLConnection getConnection() { return httpConnection ; } - - /** Set the content type (Accept header) for the results - */ - - public void setAccept(String contentType) - { - contentTypeResult = contentType ; - } - - public void setBasicAuthentication(String user, char[] password) - { - this.user = user ; - this.password = password ; - } - - /** Return whether this request will go by GET or POST - * @return boolean - */ - public boolean usesPOST() - { - if ( forcePOST ) - return true ; - String s = getQueryString() ; - - return serviceURL.length()+s.length() >= urlLimit ; - } - - /** Force the use of HTTP POST for the query operation - */ - - public void setForcePOST() - { - forcePOST = true ; - } - - /** Execute the operation - * @return Model The resulting model - * @throws QueryExceptionHTTP - */ - public InputStream exec() throws QueryExceptionHTTP - { - try { - if (usesPOST()) - return execPost(); - return execGet(); - } catch (QueryExceptionHTTP httpEx) - { - log.trace("Exception in exec", httpEx); - throw httpEx; - } - catch (JenaException jEx) - { - log.trace("JenaException in exec", jEx); - throw jEx ; - } - } - - private InputStream execGet() throws QueryExceptionHTTP - { - URL target = null ; - String qs = getQueryString() ; - - ARQ.getHttpRequestLogger().trace(qs) ; - - try { - if ( count() == 0 ) - target = new URL(serviceURL) ; - else - target = new URL(serviceURL+"?"+qs) ; - } - catch (MalformedURLException malEx) - { throw new QueryExceptionHTTP(0, "Malformed URL: "+malEx) ; } - log.trace("GET "+target.toExternalForm()) ; - - try - { - httpConnection = (HttpURLConnection) target.openConnection(); - httpConnection.setRequestProperty("Accept", contentTypeResult) ; - httpConnection.setReadTimeout(timeOut); - int x = httpConnection.getReadTimeout() ; - - // By default, following 3xx redirects is true - //conn.setFollowRedirects(true) ; - basicAuthentication(httpConnection) ; - - httpConnection.setDoInput(true); - httpConnection.connect(); - try - { - return execCommon(); - } - catch (QueryExceptionHTTP qEx) - { - // Back-off and try POST if something complain about long URIs - // Broken - if (qEx.getResponseCode() == 414 /*HttpServletResponse.SC_REQUEST_URI_TOO_LONG*/ ) - return execPost(); - throw qEx; - } - } - catch (java.net.ConnectException connEx) - { throw new QueryExceptionHTTP(QueryExceptionHTTP.NoServer, "Failed to connect to remote server"); } - catch (IOException ioEx) - { throw new QueryExceptionHTTP(ioEx); } - } - - private InputStream execPost() throws QueryExceptionHTTP - { - URL target = null; - try { target = new URL(serviceURL); } - catch (MalformedURLException malEx) - { throw new QueryExceptionHTTP(0, "Malformed URL: " + malEx); } - log.trace("POST "+target.toExternalForm()) ; - - ARQ.getHttpRequestLogger().trace(target.toExternalForm()) ; - - try - { - httpConnection = (HttpURLConnection) target.openConnection(); - httpConnection.setRequestMethod("POST") ; - httpConnection.setRequestProperty("Accept", contentTypeResult) ; - httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded") ; - basicAuthentication(httpConnection) ; - httpConnection.setDoOutput(true) ; - - boolean first = true ; - OutputStream out = httpConnection.getOutputStream() ; - for ( Iterator<Pair> iter = pairs().listIterator() ; iter.hasNext() ; ) - { - if ( ! first ) - out.write('&') ; - first = false ; - Pair p = iter.next() ; - out.write(p.getName().getBytes()) ; - out.write('=') ; - String x = p.getValue() ; - x = Convert.encWWWForm(x) ; - out.write(x.getBytes()) ; - ARQ.getHttpRequestLogger().trace("Param: "+x) ; - } - out.flush() ; - httpConnection.connect() ; - return execCommon() ; - } - catch (java.net.ConnectException connEx) - { throw new QueryExceptionHTTP(-1, "Failed to connect to remote server"); } - catch (IOException ioEx) - { throw new QueryExceptionHTTP(ioEx); } - } - - private void basicAuthentication(HttpURLConnection httpConnection2) - { - // Do basic authentication : do directly, not via an Authenticator, because it - // avoids an extra round trip (Java normally does the request without authetication, - // then reties with) - - if ( user != null || password != null) - { - try - { - if ( user == null || password == null ) - log.warn("Only one of user/password is set") ; - // We want: "Basic user:password" except user:password is base 64 encoded. - // Build string, get as UTF-8, bytes, translate to base 64. - StringBuffer x = new StringBuffer() ; - byte b[] = x.append(user).append(":").append(password).toString().getBytes("UTF-8") ; - String y = Base64.encodeBase64String(b); - httpConnection.setRequestProperty("Authorization", "Basic "+y) ; - // Overwrite any password details we copied. - // Still leaves the copy in the HTTP connection. But this only basic auth. - for ( int i = 0 ; i < x.length() ; i++ ) x.setCharAt(i, '*') ; - for ( int i = 0 ; i < b.length ; i++ ) b[i] = (byte)0 ; - } catch (UnsupportedEncodingException ex) - { - // Can't happen - UTF-8 is required of all Java platforms. - throw new ARQInternalErrorException("UTF-8 is broken on this platform", ex) ; - } - } - } - - - private InputStream execCommon() throws QueryExceptionHTTP - { - try { - responseCode = httpConnection.getResponseCode() ; - responseMessage = Convert.decWWWForm(httpConnection.getResponseMessage()) ; - - // 1xx: Informational - // 2xx: Success - // 3xx: Redirection - // 4xx: Client Error - // 5xx: Server Error - - if ( 300 <= responseCode && responseCode < 400 ) - throw new QueryExceptionHTTP(responseCode, responseMessage) ; - - // Other 400 and 500 - errors - - if ( responseCode >= 400 ) - throw new QueryExceptionHTTP(responseCode, responseMessage) ; - - // Request suceeded - //httpConnection.setReadTimeout(10) ; - InputStream in = httpConnection.getInputStream() ; - - if ( false ) - { - // Dump the header - Map<String,List<String>> map = httpConnection.getHeaderFields() ; - for ( Iterator<String> iter = map.keySet().iterator() ; iter.hasNext() ; ) - { - String k = iter.next(); - List<String> v = map.get(k) ; - System.out.println(k+" = "+v) ; - } - } - - // Dump response body - if ( false ) - { - StringBuffer b = new StringBuffer(1000) ; - byte[] chars = new byte[1000] ; - while(true) - { - int x = in.read(chars) ; - if ( x < 0 ) break ; - b.append(new String(chars, 0, x, FileUtils.encodingUTF8)) ; - } - System.out.println(b.toString()) ; - System.out.flush() ; - // Reset - in = new ByteArrayInputStream(b.toString().getBytes(FileUtils.encodingUTF8)) ; - } - - - // +++ WORKAROUND for badly behaved apps. - // Apps sometimes call QueryExecution.close straight after .execSelect. - // that results in some resuls being seen, not all of them => XMl parse errors. -// byte[] bytes = IO.readWholeFile(in) ; -// in = new ByteArrayInputStream(bytes) ; - // +++ - - return in ; - } - catch (IOException ioEx) - { - throw new QueryExceptionHTTP(ioEx) ; - } - catch (JenaException rdfEx) - { - throw new QueryExceptionHTTP(rdfEx) ; - } - } - - @Override - public String toString() - { - String s = httpString() ; - if ( s != null && s.length() > 0 ) - return serviceURL+"?"+s ; - return serviceURL ; - } -} - -/* - * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - Added: trunk/components-core/src/main/java/org/dllearner/refinementoperators/SynchronizedRhoDRDown.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/refinementoperators/SynchronizedRhoDRDown.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/refinementoperators/SynchronizedRhoDRDown.java 2012-03-26 12:10:46 UTC (rev 3618) @@ -0,0 +1,1713 @@ +/** + * Copyright (C) 2007-2011, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.dllearner.refinementoperators; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.apache.log4j.Logger; +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.Component; +import org.dllearner.core.ComponentAnn; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.config.BooleanEditor; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.options.CommonConfigOptions; +import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.ClassHierarchy; +import org.dllearner.core.owl.Constant; +import org.dllearner.core.owl.DataRange; +import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypePropertyHierarchy; +import org.dllearner.core.owl.DatatypeSomeRestriction; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.DoubleMaxValue; +import org.dllearner.core.owl.DoubleMinValue; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Negation; +import org.dllearner.core.owl.Nothing; +import org.dllearner.core.owl.ObjectAllRestriction; +import org.dllearner.core.owl.ObjectCardinalityRestriction; +import org.dllearner.core.owl.ObjectMaxCardinalityRestriction; +import org.dllearner.core.owl.ObjectMinCardinalityRestriction; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectPropertyExpression; +import org.dllearner.core.owl.ObjectPropertyHierarchy; +import org.dllearner.core.owl.ObjectQuantorRestriction; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.ObjectValueRestriction; +import org.dllearner.core.owl.StringValueRestriction; +import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.Union; +import org.dllearner.utilities.Helper; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.ConceptTransformation; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * A downward refinement operator, which makes use of domains + * and ranges of properties. The operator is currently under + * development. Its aim is to span a much "cleaner" and smaller search + * tree compared to RhoDown by omitting many class descriptions, + * which are obviously too weak, because they violate + * domain/range restrictions. Furthermore, it makes use of disjoint + * classes in the knowledge base. + * + * TODO Some of the code has moved to {@link Utility} in a modified + * form to make it accessible for implementations of other refinement + * operators. These utility methods may be completed and carefully + * integrated back later. + * + * @author Jens Lehmann + * + */ +@ComponentAnn(name = "synchronized rho refinement operator", shortName = "syncrho", version = 0.8) +public class SynchronizedRhoDRDown extends RefinementOperatorAdapter implements Component { + + private static Logger logger = Logger + .getLogger(SynchronizedRhoDRDown.class); + + private AbstractReasonerComponent reasoner; + + // hierarchies + private ClassHierarchy subHierarchy; + private ObjectPropertyHierarchy objectPropertyHierarchy; + private DatatypePropertyHierarchy dataPropertyHierarchy; + + // domains and ranges + private Map<ObjectProperty,Description> opDomains = new TreeMap<ObjectProperty,Description>(); + private Map<DatatypeProperty,Description> dpDomains = new TreeMap<DatatypeProperty,Description>(); + private Map<ObjectProperty,Description> opRanges = new TreeMap<ObjectProperty,Description>(); + + // maximum number of fillers for eeach role + private Map<ObjectProperty,Integer> maxNrOfFillers = new TreeMap<ObjectProperty,Integer>(); + // limit for cardinality restrictions (this makes sense if we e.g. have compounds with up to + // more than 200 atoms but we are only interested in atoms with certain characteristics and do + // not want something like e.g. >= 204 hasAtom.NOT Carbon-87; which blows up the search space + private int cardinalityLimit = 5; + + // start concept (can be used to start from an arbitrary concept, needs + // to be Thing or NamedClass), note that when you use e.g. Compound as + // start class, then the algorithm should start the search with class + // Compound (and not with Thing), because otherwise concepts like + // NOT Carbon-87 will be returned which itself is not a subclass of Compound + private Description startClass = new Thing(); + + // the length of concepts of top refinements, the first values is + // for refinements of \rho_\top(\top), the second one for \rho_A(\top) + private int topRefinementsLength = 0; + private Map<NamedClass, Integer> topARefinementsLength = new TreeMap<NamedClass, Integer>(); + // M is finite and this value is the maximum length of any value in M + private static int mMaxLength = 4; + + // the sets M_\top and M_A + private Map<Integer,SortedSet<Description>> m = new TreeMap<Integer,SortedSet<Description>>(); + private Map<NamedClass,Map<Integer,SortedSet<Description>>> mA = new TreeMap<NamedClass,Map<Integer,SortedSet<Description>>>(); + + // @see MathOperations.getCombos + private Map<Integer, List<List<Integer>>> combos = new HashMap<Integer, List<List<Integer>>>(); + + // refinements of the top concept ordered by length + private Map<Integer, SortedSet<Description>> topRefinements = Collections.synchronizedSortedMap(new TreeMap<Integer, SortedSet<Description>>()); + private Map<NamedClass,Map<Integer, SortedSet<Description>>> topARefinements = Collections.synchronizedSortedMap(new TreeMap<NamedClass,Map<Integer, SortedSet<Description>>>()); + + // cumulated refinements of top (all from length one to the specified length) + private Map<Integer, TreeSet<Description>> topRefinementsCumulative = Collections.synchronizedMap(new HashMap<Integer, TreeSet<Description>>()); + private Map<NamedClass,Map<Integer, TreeSet<Description>>> topARefinementsCumulative = Collections.synchronizedSortedMap(new TreeMap<NamedClass,Map<Integer, TreeSet<Description>>>()); + + // app_A set of applicable properties for a given class (separate for + // object properties, boolean datatypes, and double datatypes) + private Map<NamedClass, Set<ObjectProperty>> appOP = new TreeMap<NamedClass, Set<ObjectProperty>>(); + private Map<NamedClass, Set<DatatypeProperty>> appBD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); + private Map<NamedClass, Set<DatatypeProperty>> appDD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); + private Map<NamedClass, Set<DatatypeProperty>> appSD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); + + // most general applicable properties + private Map<NamedClass,Set<ObjectProperty>> mgr = new TreeMap<NamedClass,Set<ObjectProperty>>(); + private Map<NamedClass,Set<DatatypeProperty>> mgbd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); + private Map<NamedClass,Set<DatatypeProperty>> mgdd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); + private Map<NamedClass,Set<DatatypeProperty>> mgsd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); + + // concept comparator + private ConceptComparator conceptComparator = new ConceptComparator(); + + // splits for double datatype properties in ascening order + private Map<DatatypeProperty,List<Double>> splits = new TreeMap<DatatypeProperty,List<Double>>(); + private int maxNrOfSplits = 10; + + // data structure for a simple frequent pattern matching preprocessing phase + private int frequencyThreshold = CommonConfigOptions.valueFrequencyThresholdDefault; + private Map<ObjectProperty, Map<Individual, Integer>> valueFrequency = new HashMap<ObjectProperty, Map<Individual, Integer>>(); + // data structure with identified frequent values + private Map<ObjectProperty, Set<Individual>> frequentValues = new HashMap<ObjectProperty, Set<Individual>>(); + // frequent data values + private Map<DatatypeProperty, Set<Constant>> frequentDataValues = new HashMap<DatatypeProperty, Set<Constant>>(); + private Map<DatatypeProperty, Map<Constant, Integer>> dataValueFrequency = new HashMap<DatatypeProperty, Map<Constant, Integer>>(); + private boolean useDataHasValueConstructor = false; + + // statistics + public long mComputationTimeNs = 0; + public long topComputationTimeNs = 0; + + @ConfigOption(name = "applyAllFilter", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean applyAllFilter = true; + + @ConfigOption(name = "applyExistsFilter", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean applyExistsFilter = true; + + @ConfigOption(name = "useAllConstructor", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean useAllConstructor = true; + + @ConfigOption(name = "useExistsConstructor", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean useExistsConstructor = true; + + @ConfigOption(name = "useHasValueConstructor", defaultValue="false", propertyEditorClass = BooleanEditor.class) + private boolean useHasValueConstructor = false; + + @ConfigOption(name = "useCardinalityRestrictions", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean useCardinalityRestrictions = true; + + @ConfigOption(name = "useNegation", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean useNegation = true; + + @ConfigOption(name = "useBooleanDatatypes", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean useBooleanDatatypes = true; + + @ConfigOption(name = "useDoubleDatatypes", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean useDoubleDatatypes = true; + + @ConfigOption(name = "useStringDatatypes", defaultValue="false", propertyEditorClass = BooleanEditor.class) + private boolean useStringDatatypes = false; + + @ConfigOption(name = "disjointChecks", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean disjointChecks = true; + + @ConfigOption(name = "instanceBasedDisjoints", defaultValue="true", propertyEditorClass = BooleanEditor.class) + private boolean instanceBasedDisjoints = true; + + @ConfigOption(name = "dropDisjuncts", defaultValue="false", propertyEditorClass = BooleanEditor.class) + private boolean dropDisjuncts = false; + + // caches for reasoner queries + private Map<Description,Map<Description,Boolean>> cachedDisjoints = new TreeMap<Description,Map<Description,Boolean>>(conceptComparator); + +// private Map<NamedClass,Map<NamedClass,Boolean>> abDisjoint = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); +// private Map<NamedClass,Map<NamedClass,Boolean>> notABDisjoint = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); +// private Map<NamedClass,Map<NamedClass,Boolean>> notABMeaningful = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); + + private boolean isInitialised = false; + + public SynchronizedRhoDRDown() { + + } + +// public RhoDRDown(AbstractReasonerComponent reasoningService) { +//// this(reasoningService, reasoningService.getClassHierarchy(), null, true, true, true, true, true, 3, true, true, true, true, null); +// this.reasoner = reasoningService; +// this.subHierarchy = reasoner.getClassHierarchy(); +// init(); +// } + + // TODO constructor which takes a RhoDRDownConfigurator object; + // this should be an interface implemented e.g. by ExampleBasedROLComponentConfigurator; + // the goal is to use the configurator system while still being flexible enough to + // use one refinement operator in several learning algorithms +// public RhoDRDown(AbstractReasonerComponent reasoningService, ClassHierarchy subHierarchy, boolean applyAllFilter, boolean applyExistsFilter, boolean useAllConstructor, +// boolean useExistsConstructor, boolean useHasValueConstructor, int valueFrequencyThreshold, boolean useCardinalityRestrictions,boolean useNegation, boolean useBooleanDatatypes, boolean useDoubleDatatypes, NamedClass startClass, +// int cardinalityLimit, boolean useStringDatatypes, boolean instanceBasedDisjoints) { +// this.reasoner = reasoningService; +// this.subHierarchy = subHierarchy; +// this.applyAllFilter = applyAllFilter; +// this.applyExistsFilter = applyExistsFilter; +// this.useAllConstructor = useAllConstructor; +// this.useExistsConstructor = useExistsConstructor; +// this.useHasValueConstructor = useHasValueConstructor; +// this.frequencyThreshold = valueFrequencyThreshold; +// this.useCardinalityRestrictions = useCardinalityRestrictions; +// this.cardinalityLimit = cardinalityLimit; +// this.useNegation = useNegation; +// this.useBooleanDatatypes = useBooleanDatatypes; +// this.useDoubleDatatypes = useDoubleDatatypes; +// this.useStringDatatypes = useStringDatatypes; +// this.instanceBasedDisjoints = instanceBasedDisjoints; +// if(startClass != null) { +// this.startClass = startClass; +// } +// init(); +// } + +// subHierarchy = rs.getClassHierarchy(); + public void init() throws ComponentInitException { + if(isInitialised) { + throw new ComponentInitException("Refinement operator cannot be nitialised twice."); + } +// System.out.println("subHierarchy: " + subHierarchy); +// System.out.println("object properties: " + ); + + // query reasoner for domains and ranges + // (because they are used often in the operator) + for(ObjectProperty op : reasoner.getObjectProperties()) { + opDomains.put(op, reasoner.getDomain(op)); + opRanges.put(op, reasoner.getRange(op)); + + if(useHasValueConstructor) { + // init + Map<Individual, Integer> opMap = new TreeMap<Individual, Integer>(); + valueFrequency.put(op, opMap); + + // sets ordered by corresponding individual (which we ignore) + Collection<SortedSet<Individual>> fillerSets = reasoner.getPropertyMembers(op).values(); + for(SortedSet<Individual> fillerSet : fillerSets) { + for(Individual i : fillerSet) { +// System.out.println("op " + op + " i " + i); + Integer value = opMap.get(i); + + if(value != null) { + opMap.put(i, value+1); + } else { + opMap.put(i, 1); + } + } + } + + // keep only frequent patterns + Set<Individual> frequentInds = new TreeSet<Individual>(); + for(Individual i : opMap.keySet()) { + if(opMap.get(i) >= frequencyThreshold) { + frequentInds.add(i); +// break; + } + } + frequentValues.put(op, frequentInds); + + } + + } + + for(DatatypeProperty dp : reasoner.getDatatypeProperties()) { + dpDomains.put(dp, reasoner.getDomain(dp)); + + if(useDataHasValueConstructor) { + Map<Constant, Integer> dpMap = new TreeMap<Constant, Integer>(); + dataValueFrequency.put(dp, dpMap); + + // sets ordered by corresponding individual (which we ignore) + Collection<SortedSet<Constant>> fillerSets = reasoner.getDatatypeMembers(dp).values(); + for(SortedSet<Constant> fillerSet : fillerSets) { + for(Constant i : fillerSet) { +// System.out.println("op " + op + " i " + i); + Integer value = dpMap.get(i); + + if(value != null) { + dpMap.put(i, value+1); + } else { + dpMap.put(i, 1); + } + } + } + + // keep only frequent patterns + Set<Constant> frequentInds = new TreeSet<Constant>(); + for(Constant i : dpMap.keySet()) { + if(dpMap.get(i) >= frequencyThreshold) { + logger.trace("adding value "+i+", because "+dpMap.get(i) +">="+frequencyThreshold); + frequentInds.add(i); + } + } + frequentDataValues.put(dp, frequentInds); + } + } + + // we do not need the temporary set anymore and let the + // garbage collector take c... [truncated message content] |
From: <tc...@us...> - 2012-05-11 05:49:31
|
Revision: 3702 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3702&view=rev Author: tcanvn Date: 2012-05-11 05:49:23 +0000 (Fri, 11 May 2012) Log Message: ----------- Changes: 1. add Apache Common Pool library into the build path (pom) 2. change visibility of some of the properties on OENode from private to protected 3. add RhoDRDown used in Dl-Learner version 2008 back to refinement operators package (for ParCEL) 4. modify KBFile.class to fix the bug that causes file-separate redundancy when loading a KB file by a relative path (in Windows) Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java trunk/components-core/src/main/java/org/dllearner/kb/KBFile.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown2008.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2012-05-10 13:31:25 UTC (rev 3701) +++ trunk/components-core/pom.xml 2012-05-11 05:49:23 UTC (rev 3702) @@ -211,7 +211,6 @@ <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> - <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> @@ -229,7 +228,18 @@ <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> </dependency> - - - </dependencies> + <dependency> + <groupId>commons-pool</groupId> + <artifactId>commons-pool</artifactId> + </dependency> + </dependencies> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>commons-pool</groupId> + <artifactId>commons-pool</artifactId> + <version>1.6</version> + </dependency> + </dependencies> + </dependencyManagement> </project> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java 2012-05-10 13:31:25 UTC (rev 3701) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java 2012-05-11 05:49:23 UTC (rev 3702) @@ -43,14 +43,14 @@ */ public class OENode implements SearchTreeNode { - private Description description; + protected Description description; - private double accuracy; + protected double accuracy; - private int horizontalExpansion; + protected int horizontalExpansion; - private OENode parent; - private List<OENode> children = new LinkedList<OENode>(); + protected OENode parent; + protected List<OENode> children = new LinkedList<OENode>(); // the refinement count corresponds to the number of refinements of the // description in this node - it is a better heuristic indicator than child count Modified: trunk/components-core/src/main/java/org/dllearner/kb/KBFile.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/KBFile.java 2012-05-10 13:31:25 UTC (rev 3701) +++ trunk/components-core/src/main/java/org/dllearner/kb/KBFile.java 2012-05-11 05:49:23 UTC (rev 3702) @@ -37,7 +37,6 @@ import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGConverter; import org.dllearner.utilities.owl.OWLAPIAxiomConvertVisitor; -import org.semanticweb.owlapi.apibinding.OWLManager; import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLOntology; import org.semanticweb.owlapi.model.OWLOntologyCreationException; @@ -106,7 +105,16 @@ /** Leave it as is */ kb = KBParser.parseKBFile(getUrl()); } else { - File f = new File(new URI(baseDir + File.separator + getUrl())); + + //this check is for eliminating the redundancy + //if the baseDir has separator at the end, do not add one more between baseDir and KB filename (or url) + String fullFilepath; + if (baseDir.endsWith("\\") || baseDir.endsWith("/")) + fullFilepath = baseDir + getUrl(); + else + fullFilepath = baseDir + File.separator + getUrl(); + + File f = new File(new URI(fullFilepath)); setUrl(f.toURI().toString()); kb = KBParser.parseKBFile(f); } Added: trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown2008.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown2008.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown2008.java 2012-05-11 05:49:23 UTC (rev 3702) @@ -0,0 +1,1520 @@ +/** + * 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.refinementoperators; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.Map.Entry; + +import org.apache.log4j.Logger; +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.ComponentAnn; +import org.dllearner.core.options.CommonConfigOptions; +import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.ClassHierarchy; +import org.dllearner.core.owl.Constant; +import org.dllearner.core.owl.DataRange; +import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypeSomeRestriction; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.DoubleMaxValue; +import org.dllearner.core.owl.DoubleMinValue; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Negation; +import org.dllearner.core.owl.Nothing; +import org.dllearner.core.owl.ObjectAllRestriction; +import org.dllearner.core.owl.ObjectCardinalityRestriction; +import org.dllearner.core.owl.ObjectMaxCardinalityRestriction; +import org.dllearner.core.owl.ObjectMinCardinalityRestriction; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectPropertyExpression; +import org.dllearner.core.owl.ObjectQuantorRestriction; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.ObjectValueRestriction; +import org.dllearner.core.owl.StringValueRestriction; +import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.Union; +import org.dllearner.utilities.Helper; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.ConceptTransformation; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * A downward refinement operator, which makes use of domains + * and ranges of properties. The operator is currently under + * development. Its aim is to span a much "cleaner" and smaller search + * tree compared to RhoDown by omitting many class descriptions, + * which are obviously too weak, because they violate + * domain/range restrictions. Furthermore, it makes use of disjoint + * classes in the knowledge base. + * + * TODO Some of the code has moved to {@link Utility} in a modified + * form to make it accessible for implementations of other refinement + * operators. These utility methods may be completed and carefully + * integrated back later. + * + * @author Jens Lehmann + * + */ + +@ComponentAnn(name = "rho refinement operator 2008", shortName = "rho2008", version = 0.08) +public class RhoDRDown2008 extends RefinementOperatorAdapter { + + private static Logger logger = Logger.getLogger(RhoDRDown2008.class); + + private AbstractReasonerComponent rs; + + // hierarchies + private ClassHierarchy subHierarchy; + + // domains and ranges + private Map<ObjectProperty,Description> opDomains = new TreeMap<ObjectProperty,Description>(); + private Map<DatatypeProperty,Description> dpDomains = new TreeMap<DatatypeProperty,Description>(); + private Map<ObjectProperty,Description> opRanges = new TreeMap<ObjectProperty,Description>(); + + // maximum number of fillers for eeach role + private Map<ObjectProperty,Integer> maxNrOfFillers = new TreeMap<ObjectProperty,Integer>(); + // limit for cardinality restrictions (this makes sense if we e.g. have compounds with up to + // more than 200 atoms but we are only interested in atoms with certain characteristics and do + // not want something like e.g. >= 204 hasAtom.NOT Carbon-87; which blows up the search space + private int cardinalityLimit = 5; + + // start concept (can be used to start from an arbitrary concept, needs + // to be Thing or NamedClass), note that when you use e.g. Compound as + // start class, then the algorithm should start the search with class + // Compound (and not with Thing), because otherwise concepts like + // NOT Carbon-87 will be returned which itself is not a subclass of Compound + private Description startClass = new Thing(); + + // the length of concepts of top refinements, the first values is + // for refinements of \rho_\top(\top), the second one for \rho_A(\top) + private int topRefinementsLength = 0; + private Map<NamedClass, Integer> topARefinementsLength = new TreeMap<NamedClass, Integer>(); + // M is finite and this value is the maximum length of any value in M + private static int mMaxLength = 4; + + // the sets M_\top and M_A + private Map<Integer,SortedSet<Description>> m = new TreeMap<Integer,SortedSet<Description>>(); + private Map<NamedClass,Map<Integer,SortedSet<Description>>> mA = new TreeMap<NamedClass,Map<Integer,SortedSet<Description>>>(); + + // @see MathOperations.getCombos + private Map<Integer, List<List<Integer>>> combos = new HashMap<Integer, List<List<Integer>>>(); + + // refinements of the top concept ordered by length + private Map<Integer, SortedSet<Description>> topRefinements = new TreeMap<Integer, SortedSet<Description>>(); + private Map<NamedClass,Map<Integer, SortedSet<Description>>> topARefinements = new TreeMap<NamedClass,Map<Integer, SortedSet<Description>>>(); + + // cumulated refinements of top (all from length one to the specified length) + private Map<Integer, TreeSet<Description>> topRefinementsCumulative = new HashMap<Integer, TreeSet<Description>>(); + private Map<NamedClass,Map<Integer, TreeSet<Description>>> topARefinementsCumulative = new TreeMap<NamedClass,Map<Integer, TreeSet<Description>>>(); + + // app_A set of applicable properties for a given class (separate for + // object properties, boolean datatypes, and double datatypes) + private Map<NamedClass, Set<ObjectProperty>> appOP = new TreeMap<NamedClass, Set<ObjectProperty>>(); + private Map<NamedClass, Set<DatatypeProperty>> appBD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); + private Map<NamedClass, Set<DatatypeProperty>> appDD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); + + // most general applicable properties + private Map<NamedClass,Set<ObjectProperty>> mgr = new TreeMap<NamedClass,Set<ObjectProperty>>(); + private Map<NamedClass,Set<DatatypeProperty>> mgbd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); + private Map<NamedClass,Set<DatatypeProperty>> mgdd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); + private Map<NamedClass,Set<DatatypeProperty>> mgsd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); + + // concept comparator + private ConceptComparator conceptComparator = new ConceptComparator(); + + // splits for double datatype properties in ascening order + private Map<DatatypeProperty,List<Double>> splits = null; //new TreeMap<DatatypeProperty,List<Double>>(); + + /** + * how many splits will be made for double data properties + */ + private int maxNrOfSplits = 10; + + // data structure for a simple frequent pattern matching preprocessing phase + private int frequencyThreshold = CommonConfigOptions.valueFrequencyThresholdDefault; + private Map<ObjectProperty, Map<Individual, Integer>> valueFrequency = new HashMap<ObjectProperty, Map<Individual, Integer>>(); + // data structure with identified frequent values + private Map<ObjectProperty, Set<Individual>> frequentValues = new HashMap<ObjectProperty, Set<Individual>>(); + // frequent data values + private Map<DatatypeProperty, Set<Constant>> frequentDataValues = new HashMap<DatatypeProperty, Set<Constant>>(); + private Map<DatatypeProperty, Map<Constant, Integer>> dataValueFrequency = new HashMap<DatatypeProperty, Map<Constant, Integer>>(); + private boolean useDataHasValueConstructor = false; + + // staistics + public long mComputationTimeNs = 0; + public long topComputationTimeNs = 0; + + private boolean applyAllFilter = true; + private boolean applyExistsFilter = true; + private boolean useAllConstructor = true; + private boolean useExistsConstructor = true; + private boolean useHasValueConstructor = false; + private boolean useCardinalityRestrictions = true; + private boolean useNegation = true; + private boolean useBooleanDatatypes = true; + private boolean useDoubleDatatypes = true; + @SuppressWarnings("unused") + private boolean useStringDatatypes = false; + private boolean disjointChecks = true; + private boolean instanceBasedDisjoints = true; + + private boolean dropDisjuncts = false; + + private boolean isDisjunctionAllowed = true; + + // caches for reasoner queries + private Map<Description,Map<Description,Boolean>> cachedDisjoints = new TreeMap<Description,Map<Description,Boolean>>(conceptComparator); + + + public RhoDRDown2008(AbstractReasonerComponent reasoningService) { + this.rs = reasoningService; + this.subHierarchy = rs.getClassHierarchy(); + } + + public RhoDRDown2008(AbstractReasonerComponent reasoner, ClassHierarchy subHierarchy, Description startClass) { + this.rs = reasoner; + this.subHierarchy = subHierarchy; + this.startClass = startClass; + } + + public void init() { + // query reasoner for domains and ranges + // (because they are used often in the operator) + + if (logger.isDebugEnabled()) + logger.debug("[Refinement operator] " + this.getClass().getSimpleName() + " created (splits: " + (splits!=null?"using Splitter":"fix split="+maxNrOfSplits) + ")"); //actran + + + for(ObjectProperty op : rs.getObjectProperties()) { + opDomains.put(op, rs.getDomain(op)); + opRanges.put(op, rs.getRange(op)); + + if(useHasValueConstructor) { + // init + Map<Individual, Integer> opMap = new TreeMap<Individual, Integer>(); + valueFrequency.put(op, opMap); + + // sets ordered by corresponding individual (which we ignore) + Collection<SortedSet<Individual>> fillerSets = rs.getPropertyMembers(op).values(); + for(SortedSet<Individual> fillerSet : fillerSets) { + for(Individual i : fillerSet) { + // System.out.println("op " + op + " i " + i); + Integer value = opMap.get(i); + + if(value != null) { + opMap.put(i, value+1); + } else { + opMap.put(i, 1); + } + } + } + + // keep only frequent patterns + Set<Individual> frequentInds = new TreeSet<Individual>(); + for(Individual i : opMap.keySet()) { + if(opMap.get(i) >= frequencyThreshold) { + frequentInds.add(i); + // break; + } + } + frequentValues.put(op, frequentInds); + + } + + } + + //logger.trace("[rho] Init ObjectProperty: " + opDomains); + //logger.trace("[rho] Init ObjectProperty: " + opRanges); + + for(DatatypeProperty dp : rs.getDatatypeProperties()) { + dpDomains.put(dp, rs.getDomain(dp)); + + if(useDataHasValueConstructor) { + Map<Constant, Integer> dpMap = new TreeMap<Constant, Integer>(); + dataValueFrequency.put(dp, dpMap); + + // sets ordered by corresponding individual (which we ignore) + Collection<SortedSet<Constant>> fillerSets = rs.getDatatypeMembers(dp).values(); + for(SortedSet<Constant> fillerSet : fillerSets) { + for(Constant i : fillerSet) { + // System.out.println("op " + op + " i " + i); + Integer value = dpMap.get(i); + + if(value != null) { + dpMap.put(i, value+1); + } else { + dpMap.put(i, 1); + } + } + } + + // keep only frequent patterns + Set<Constant> frequentInds = new TreeSet<Constant>(); + for(Constant i : dpMap.keySet()) { + if(dpMap.get(i) >= frequencyThreshold) { + logger.trace("adding value "+i+", because "+dpMap.get(i) +">="+frequencyThreshold); + frequentInds.add(i); + } + } + frequentDataValues.put(dp, frequentInds); + } + } + + // we do not need the temporary set anymore and let the + // garbage collector take care of it + valueFrequency = null; + dataValueFrequency = null; + + + // compute splits for double datatype properties + if (this.splits == null) { + splits = new TreeMap<DatatypeProperty,List<Double>>(); + for(DatatypeProperty dp : rs.getDoubleDatatypeProperties()) + computeSplits(dp); + + if (logger.isDebugEnabled()) { + logger.debug("[RhoDRDown2008] Uses original split strategy: " + splits); + } + } + + + + // determine the maximum number of fillers for each role + // (up to a specified cardinality maximum) + if(useCardinalityRestrictions) { + for(ObjectProperty op : rs.getObjectProperties()) { + int maxFillers = 0; + Map<Individual,SortedSet<Individual>> opMembers = rs.getPropertyMembers(op); + for(SortedSet<Individual> inds : opMembers.values()) { + if(inds.size()>maxFillers) + maxFillers = inds.size(); + if(maxFillers >= cardinalityLimit) { + maxFillers = cardinalityLimit; + break; + } + } + maxNrOfFillers.put(op, maxFillers); + } + } + + } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.refinement.RefinementOperator#refine(org.dllearner.core.owl.Description) + */ + @Override + public Set<Description> refine(Description concept) { + throw new RuntimeException(); + } + + @Override + public Set<Description> refine(Description description, int maxLength) { + // check that maxLength is valid + if(maxLength < description.getLength()) { + throw new Error("length has to be at least description length (description: " + description + ", max length: " + maxLength + ")"); + } + return refine(description, maxLength, null, startClass); + } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.refinement.RefinementOperator#refine(org.dllearner.core.owl.Description, int, java.util.List) + */ + @Override + public Set<Description> refine(Description description, int maxLength, + List<Description> knownRefinements) { + return refine(description, maxLength, knownRefinements, startClass); + } + + @SuppressWarnings({"unchecked"}) + public Set<Description> refine(Description description, int maxLength, + List<Description> knownRefinements, Description currDomain) { + + // System.out.println("|- " + description + " " + currDomain + " " + maxLength); + + //logger.trace(" [rho-refine] Refine called for: " + description); + //logger.trace(" \t\tmaxLength: " + maxLength + "; knownRefinrements: " + knownRefinements +"; currDomain: " + currDomain); + + + // actions needing to be performed if this is the first time the + // current domain is used + if(!(currDomain instanceof Thing) && !topARefinementsLength.containsKey(currDomain)) + topARefinementsLength.put((NamedClass)currDomain, 0); + + // check whether using list or set makes more sense + // here; and whether HashSet or TreeSet should be used + // => TreeSet because duplicates are possible + Set<Description> refinements = new TreeSet<Description>(conceptComparator); + + // used as temporary variable + Set<Description> tmp = new HashSet<Description>(); + + if(description instanceof Thing) { + // extends top refinements if necessary + if(currDomain instanceof Thing) { + if(maxLength>topRefinementsLength) + computeTopRefinements(maxLength); + refinements = (TreeSet<Description>) topRefinementsCumulative.get(maxLength).clone(); + } else { + if(maxLength>topARefinementsLength.get(currDomain)) { + computeTopRefinements(maxLength, (NamedClass) currDomain); + } + refinements = (TreeSet<Description>) topARefinementsCumulative.get(currDomain).get(maxLength).clone(); + } + // refinements.addAll(subHierarchy.getMoreSpecialConcepts(description)); + } else if(description instanceof Nothing) { + // cannot be further refined + } else if(description instanceof NamedClass) { + refinements.addAll(subHierarchy.getSubClasses(description)); + refinements.remove(new Nothing()); + } else if (description instanceof Negation && description.getChild(0) instanceof NamedClass) { + + tmp = subHierarchy.getSuperClasses(description.getChild(0)); + + for(Description c : tmp) { + if(!(c instanceof Thing)) + refinements.add(new Negation(c)); + } + } else if (description instanceof Intersection) { + + // refine one of the elements + for(Description child : description.getChildren()) { + + // refine the child; the new max length is the current max length minus + // the currently considered concept plus the length of the child + // TODO: add better explanation + tmp = refine(child, maxLength - description.getLength()+child.getLength(),null,currDomain); + + // create new intersection + for(Description c : tmp) { + List<Description> newChildren = (List<Description>)((LinkedList<Description>)description.getChildren()).clone(); + newChildren.add(c); + newChildren.remove(child); + Intersection mc = new Intersection(newChildren); + + // clean concept and transform it to ordered negation normal form + // (non-recursive variant because only depth 1 was modified) + ConceptTransformation.cleanConceptNonRecursive(mc); + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); + + // check whether the intersection is OK (sanity checks), then add it + if(checkIntersection(mc)) + refinements.add(mc); + } + + } + + } else if (description instanceof Union) { + // refine one of the elements + for(Description child : description.getChildren()) { + + // System.out.println("union child: " + child + " " + maxLength + " " + description.getLength() + " " + child.getLength()); + + // refine child + tmp = refine(child, maxLength - description.getLength()+child.getLength(),null,currDomain); + + // construct intersection (see above) + for(Description c : tmp) { + List<Description> newChildren = new LinkedList<Description>(description.getChildren()); + newChildren.remove(child); + newChildren.add(c); + Union md = new Union(newChildren); + + // transform to ordered negation normal form + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(md, conceptComparator); + // note that we do not have to call clean here because a disjunction will + // never be nested in another disjunction in this operator + + refinements.add(md); + } + + } + + // if enabled, we can remove elements of the disjunction + if(dropDisjuncts) { + // A1 OR A2 => {A1,A2} + if(description.getChildren().size() == 2) { + refinements.add(description.getChild(0)); + refinements.add(description.getChild(1)); + } else { + // copy children list and remove a different element in each turn + for(int i=0; i<description.getChildren().size(); i++) { + List<Description> newChildren = new LinkedList<Description>(description.getChildren()); + newChildren.remove(i); + Union md = new Union(newChildren); + refinements.add(md); + } + } + } + + } else if (description instanceof ObjectSomeRestriction) { + ObjectPropertyExpression role = ((ObjectQuantorRestriction)description).getRole(); + Description range = opRanges.get(role); + + // rule 1: EXISTS r.D => EXISTS r.E + tmp = refine(description.getChild(0), maxLength-2, null, range); + + for(Description c : tmp) + refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)description).getRole(),c)); + + // rule 2: EXISTS r.D => EXISTS s.D or EXISTS r^-1.D => EXISTS s^-1.D + // currently inverse roles are not supported + ObjectProperty ar = (ObjectProperty) role; + Set<ObjectProperty> moreSpecialRoles = rs.getSubProperties(ar); + for(ObjectProperty moreSpecialRole : moreSpecialRoles) + refinements.add(new ObjectSomeRestriction(moreSpecialRole, description.getChild(0))); + + // rule 3: EXISTS r.D => >= 2 r.D + // (length increases by 1 so we have to check whether max length is sufficient) + if(useCardinalityRestrictions) { + if(maxLength > description.getLength() && maxNrOfFillers.get(ar)>1) { + ObjectMinCardinalityRestriction min = new ObjectMinCardinalityRestriction(2,role,description.getChild(0)); + refinements.add(min); + } + } + + // rule 4: EXISTS r.TOP => EXISTS r.{value} + if(useHasValueConstructor && description.getChild(0) instanceof Thing) { + // watch out for frequent patterns + Set<Individual> frequentInds = frequentValues.get(role); + if(frequentInds != null) { + for(Individual ind : frequentInds) { + ObjectValueRestriction ovr = new ObjectValueRestriction((ObjectProperty)role, ind); + refinements.add(ovr); + } + } + } + + } else if (description instanceof ObjectAllRestriction) { + ObjectPropertyExpression role = ((ObjectQuantorRestriction)description).getRole(); + Description range = opRanges.get(role); + + // rule 1: ALL r.D => ALL r.E + tmp = refine(description.getChild(0), maxLength-2, null, range); + + for(Description c : tmp) { + refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)description).getRole(),c)); + } + + // rule 2: ALL r.D => ALL r.BOTTOM if D is a most specific atomic concept + if(description.getChild(0) instanceof NamedClass && tmp.size()==0) { + refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)description).getRole(),new Nothing())); + } + + // rule 3: ALL r.D => ALL s.D or ALL r^-1.D => ALL s^-1.D + // currently inverse roles are not supported + ObjectProperty ar = (ObjectProperty) role; + Set<ObjectProperty> moreSpecialRoles = rs.getSubProperties(ar); + for(ObjectProperty moreSpecialRole : moreSpecialRoles) { + refinements.add(new ObjectAllRestriction(moreSpecialRole, description.getChild(0))); + } + + // rule 4: ALL r.D => <= (maxFillers-1) r.D + // (length increases by 1 so we have to check whether max length is sufficient) + // => commented out because this is acutally not a downward refinement + // if(useCardinalityRestrictions) { + // if(maxLength > description.getLength() && maxNrOfFillers.get(ar)>1) { + // ObjectMaxCardinalityRestriction max = new ObjectMaxCardinalityRestriction(maxNrOfFillers.get(ar)-1,role,description.getChild(0)); + // refinements.add(max); + // } + // } + } else if (description instanceof ObjectCardinalityRestriction) { + ObjectPropertyExpression role = ((ObjectCardinalityRestriction)description).getRole(); + Description range = opRanges.get(role); + int number = ((ObjectCardinalityRestriction)description).getCardinality(); + if(description instanceof ObjectMaxCardinalityRestriction) { + // rule 1: <= x r.C => <= x r.D + tmp = refine(description.getChild(0), maxLength-3, null, range); + + for(Description d : tmp) { + refinements.add(new ObjectMaxCardinalityRestriction(number,role,d)); + } + + // rule 2: <= x r.C => <= (x-1) r.C + ObjectMaxCardinalityRestriction max = (ObjectMaxCardinalityRestriction) description; + // int number = max.getNumber(); + if(number > 1) + refinements.add(new ObjectMaxCardinalityRestriction(number-1,max.getRole(),max.getChild(0))); + + } else if(description instanceof ObjectMinCardinalityRestriction) { + tmp = refine(description.getChild(0), maxLength-3, null, range); + + for(Description d : tmp) { + refinements.add(new ObjectMinCardinalityRestriction(number,role,d)); + } + + // >= x r.C => >= (x+1) r.C + ObjectMinCardinalityRestriction min = (ObjectMinCardinalityRestriction) description; + // int number = min.getNumber(); + if(number < maxNrOfFillers.get(min.getRole())) + refinements.add(new ObjectMinCardinalityRestriction(number+1,min.getRole(),min.getChild(0))); + } + } else if (description instanceof DatatypeSomeRestriction) { + + DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) description; + DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); + DataRange dr = dsr.getDataRange(); + if(dr instanceof DoubleMaxValue) { + double value = ((DoubleMaxValue)dr).getValue(); + // find out which split value was used + int splitIndex = splits.get(dp).lastIndexOf(value); + if(splitIndex == -1) + throw new Error("split error"); + int newSplitIndex = splitIndex - 1; + if(newSplitIndex >= 0) { + DoubleMaxValue max = new DoubleMaxValue(splits.get(dp).get(newSplitIndex)); + DatatypeSomeRestriction newDSR = new DatatypeSomeRestriction(dp,max); + refinements.add(newDSR); + // System.out.println(description + " => " + newDSR); + } + } else if(dr instanceof DoubleMinValue) { + double value = ((DoubleMinValue)dr).getValue(); + // find out which split value was used + int splitIndex = splits.get(dp).lastIndexOf(value); + if(splitIndex == -1) + throw new Error("split error"); + int newSplitIndex = splitIndex + 1; + if(newSplitIndex < splits.get(dp).size()) { + DoubleMinValue min = new DoubleMinValue(splits.get(dp).get(newSplitIndex)); + DatatypeSomeRestriction newDSR = new DatatypeSomeRestriction(dp,min); + refinements.add(newDSR); + } + } + } else if (description instanceof StringValueRestriction) { + StringValueRestriction svr = (StringValueRestriction) description; + DatatypeProperty dp = svr.getRestrictedPropertyExpression(); + Set<DatatypeProperty> subDPs = rs.getSubProperties(dp); + for(DatatypeProperty subDP : subDPs) { + refinements.add(new StringValueRestriction(subDP, svr.getStringValue())); + } + } + + // if a refinement is not Bottom, Top, ALL r.Bottom a refinement of top can be appended + if(!(description instanceof Thing) && !(description instanceof Nothing) + && !(description instanceof ObjectAllRestriction && description.getChild(0) instanceof Nothing)) { + // -1 because of the AND symbol which is appended + int topRefLength = maxLength - description.getLength() - 1; + + // maybe we have to compute new top refinements here + if(currDomain instanceof Thing) { + if(topRefLength > topRefinementsLength) + computeTopRefinements(topRefLength); + } else if(topRefLength > topARefinementsLength.get(currDomain)) + computeTopRefinements(topRefLength,(NamedClass)currDomain); + + if(topRefLength>0) { + Set<Description> topRefs; + if(currDomain instanceof Thing) + topRefs = topRefinementsCumulative.get(topRefLength); + else + topRefs = topARefinementsCumulative.get(currDomain).get(topRefLength); + + for(Description c : topRefs) { + // true if refinement should be skipped due to filters, + // false otherwise + boolean skip = false; + + // if a refinement of of the form ALL r, we check whether ALL r + // does not occur already + if(applyAllFilter) { + if(c instanceof ObjectAllRestriction) { + for(Description child : description.getChildren()) { + if(child instanceof ObjectAllRestriction) { + ObjectPropertyExpression r1 = ((ObjectAllRestriction)c).getRole(); + ObjectPropertyExpression r2 = ((ObjectAllRestriction)child).getRole(); + if(r1.toString().equals(r2.toString())) + skip = true; + } + } + } + } + + // check for double datatype properties + /* + if(c instanceof DatatypeSomeRestriction && + description instanceof DatatypeSomeRestriction) { + DataRange dr = ((DatatypeSomeRestriction)c).getDataRange(); + DataRange dr2 = ((DatatypeSomeRestriction)description).getDataRange(); + // it does not make sense to have statements like height >= 1.8 AND height >= 1.7 + if((dr instanceof DoubleMaxValue && dr2 instanceof DoubleMaxValue) + ||(dr instanceof DoubleMinValue && dr2 instanceof DoubleMinValue)) + skip = true; + }*/ + + // perform a disjointness check when named classes are added; + // this can avoid a lot of superfluous computation in the algorithm e.g. + // when A1 looks good, so many refinements of the form (A1 OR (A2 AND A3)) + // are generated which are all equal to A1 due to disjointness of A2 and A3 + if(disjointChecks && c instanceof NamedClass && description instanceof NamedClass && isDisjoint(description, c)) { + skip = true; + // System.out.println(c + " ignored when refining " + description); + } + + if(!skip) { + Intersection mc = new Intersection(); + mc.addChild(description); + mc.addChild(c); + + // clean and transform to ordered negation normal form + ConceptTransformation.cleanConceptNonRecursive(mc); + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); + + // last check before intersection is added + if(checkIntersection(mc)) + refinements.add(mc); + } + } + } + } + + // for(Description refinement : refinements) { + // if((refinement instanceof Intersection || refinement instanceof Union) && refinement.getChildren().size()<2) { + // System.out.println(description + " " + refinement + " " + currDomain + " " + maxLength); + // System.exit(0); + // } + // } + + + + return refinements; + } + + // when a child of an intersection is refined and reintegrated into the + // intersection, we can perform some sanity checks; + // method returns true if everything is OK and false otherwise + // TODO: can be implemented more efficiently if the newly added child + // is given as parameter + public static boolean checkIntersection(Intersection intersection) { + // rule 1: max. restrictions at most once + boolean maxDoubleOccurence = false; + // rule 2: min restrictions at most once + boolean minDoubleOccurence = false; + // rule 3: no double occurences of boolean datatypes + TreeSet<DatatypeProperty> occuredDP = new TreeSet<DatatypeProperty>(); + // rule 4: no double occurences of hasValue restrictions + TreeSet<ObjectProperty> occuredVR = new TreeSet<ObjectProperty>(); + + for(Description child : intersection.getChildren()) { + if(child instanceof DatatypeSomeRestriction) { + DataRange dr = ((DatatypeSomeRestriction)child).getDataRange(); + if(dr instanceof DoubleMaxValue) { + if(maxDoubleOccurence) + return false; + else + maxDoubleOccurence = true; + } else if(dr instanceof DoubleMinValue) { + if(minDoubleOccurence) + return false; + else + minDoubleOccurence = true; + } + } else if(child instanceof BooleanValueRestriction) { + DatatypeProperty dp = (DatatypeProperty) ((BooleanValueRestriction)child).getRestrictedPropertyExpression(); + // System.out.println("dp: " + dp); + // return false if the boolean property exists already + if(!occuredDP.add(dp)) + return false; + } else if(child instanceof ObjectValueRestriction) { + ObjectProperty op = (ObjectProperty) ((ObjectValueRestriction)child).getRestrictedPropertyExpression(); + if(!occuredVR.add(op)) + return false; + } + // System.out.println(child.getClass()); + } + return true; + } + + /** + * By default, the operator does not specialize e.g. (A or B) to A, because + * it only guarantees weak completeness. Under certain circumstances, e.g. + * refinement of a fixed given concept, it can be useful to allow such + * refinements, which can be done by passing the parameter true to this method. + * @param dropDisjuncts Whether to remove disjuncts in refinement process. + */ + public void setDropDisjuncts(boolean dropDisjuncts) { + this.dropDisjuncts = dropDisjuncts; + } + + private void computeTopRefinements(int maxLength) { + computeTopRefinements(maxLength, null); + } + + private void computeTopRefinements(int maxLength, NamedClass domain) { + long topComputationTimeStartNs = System.nanoTime(); + + if(domain == null && m.size() == 0) + computeM(); + + if(domain != null && !mA.containsKey(domain)) + computeM(domain); + + int refinementsLength; + + if(domain == null) { + refinementsLength = topRefinementsLength; + } else { + if(!topARefinementsLength.containsKey(domain)) + topARefinementsLength.put(domain,0); + + refinementsLength = topARefinementsLength.get(domain); + } + + + // compute all possible combinations of the disjunction + for(int i = refinementsLength+1; i <= maxLength; i++) { + combos.put(i,MathOperations.getCombos(i, mMaxLength)); + + // initialise the refinements with empty sets + if(domain == null) { + topRefinements.put(i, new TreeSet<Description>(conceptComparator)); + } else { + if(!topARefinements.containsKey(domain)) + topARefinements.put(domain, new TreeMap<Integer,SortedSet<Description>>()); + topARefinements.get(domain).put(i, new TreeSet<Description>(conceptComparator)); + } + + for(List<Integer> combo : combos.get(i)) { + + // combination is a single number => try to use M + if(combo.size()==1) { + // note we cannot use "put" instead of "addAll" because there + // can be several combos for one length + if(domain == null) + topRefinements.get(i).addAll(m.get(i)); + else + topARefinements.get(domain).get(i).addAll(mA.get(domain).get(i)); + // combinations has several numbers => generate disjunct + } else if (isDisjunctionAllowed) { + + // check whether the combination makes sense, i.e. whether + // all lengths mentioned in it have corresponding elements + // e.g. when negation is deactivated there won't be elements of + // length 2 in M + boolean validCombo = true; + for(Integer j : combo) { + if((domain == null && m.get(j).size()==0) || + (domain != null && mA.get(domain).get(j).size()==0)) + validCombo = false; + } + + + if(validCombo) { + + SortedSet<Union> baseSet = new TreeSet<Union>(conceptComparator); + for(Integer j : combo) { + if(domain == null) + baseSet = MathOperations.incCrossProduct(baseSet, m.get(j)); + else + baseSet = MathOperations.incCrossProduct(baseSet, mA.get(domain).get(j)); + } + + // convert all concepts in ordered negation normal form + for(Description concept : baseSet) { + ConceptTransformation.transformToOrderedForm(concept, conceptComparator); + } + + // apply the exists filter (throwing out all refinements with + // double \exists r for any r) + // TODO: similar filtering can be done for boolean datatype + // properties + if(applyExistsFilter) { + Iterator<Union> it = baseSet.iterator(); + while(it.hasNext()) { + if(MathOperations.containsDoubleObjectSomeRestriction(it.next())) + it.remove(); + } + } + + // add computed refinements + if(domain == null) + topRefinements.get(i).addAll(baseSet); + else + topARefinements.get(domain).get(i).addAll(baseSet); + + } + } + } //for loop + + // create cumulative versions of refinements such that they can + // be accessed easily + TreeSet<Description> cumulativeRefinements = new TreeSet<Description>(conceptComparator); + for(int j=1; j<=i; j++) { + if(domain == null) { + cumulativeRefinements.addAll(topRefinements.get(j)); + } else { + cumulativeRefinements.addAll(topARefinements.get(domain).get(j)); + } + } + + if(domain == null) { + topRefinementsCumulative.put(i, cumulativeRefinements); + } else { + if(!topARefinementsCumulative.containsKey(domain)) + topARefinementsCumulative.put(domain, new TreeMap<Integer, TreeSet<Description>>()); + topARefinementsCumulative.get(domain).put(i, cumulativeRefinements); + } + } //for loop for disjunction + + + // register new top refinements length + if(domain == null) + topRefinementsLength = maxLength; + else + topARefinementsLength.put(domain,maxLength); + + topComputationTimeNs += System.nanoTime() - topComputationTimeStartNs; + } + + // compute M_\top + private void computeM() { + long mComputationTimeStartNs = System.nanoTime(); + + // initialise all possible lengths (1 to 3) //actran: 3 or 4? + for(int i=1; i<=mMaxLength; i++) { + m.put(i, new TreeSet<Description>(conceptComparator)); + } + + + //actran: computes the most general atomic concepts (subclasses of Thing) + SortedSet<Description> m1 = subHierarchy.getSubClasses(new Thing()); + m.put(1,m1); + + + //actran: computes negated most specific atomic concepts + SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); + if(useNegation) { + Set<Description> m2tmp = subHierarchy.getSuperClasses(new Nothing()); + for(Description c : m2tmp) { + if(!(c instanceof Thing)) { + m2.add(new Negation(c)); + } + } + } + + // boolean datatypes, e.g. testPositive = true + if(useBooleanDatatypes) { + Set<DatatypeProperty> booleanDPs = rs.getBooleanDatatypeProperties(); + for(DatatypeProperty dp : booleanDPs) { + m2.add(new BooleanValueRestriction(dp,true)); + m2.add(new BooleanValueRestriction(dp,false)); + } + } + m.put(2,m2); + + SortedSet<Description> m3 = new TreeSet<Description>(conceptComparator); + if(useExistsConstructor) { + // only uses most general roles + for(ObjectProperty r : rs.getMostGeneralProperties()) { + m3.add(new ObjectSomeRestriction(r, new Thing())); + } + } + + if(useAllConstructor) { + // we allow \forall r.\top here because otherwise the operator + // becomes too difficult to manage due to dependencies between + // M_A and M_A' where A'=ran(r) + for(ObjectProperty r : rs.getMostGeneralProperties()) { + m3.add(new ObjectAllRestriction(r, new Thing())); + } + } + + if(useDoubleDatatypes) { + Set<DatatypeProperty> doubleDPs = rs.getDoubleDatatypeProperties(); + for(DatatypeProperty dp : doubleDPs) { + if ((splits.get(dp) != null) && (splits.get(dp).size() > 0)) { + DoubleMaxValue max = new DoubleMaxValue(splits.get(dp).get(splits.get(dp).size()-1)); + DoubleMinValue min = new DoubleMinValue(splits.get(dp).get(0)); + m3.add(new DatatypeSomeRestriction(dp,max)); + m3.add(new DatatypeSomeRestriction(dp,min)); + } + } + } + + if(useDataHasValueConstructor) { + Set<DatatypeProperty> stringDPs = rs.getStringDatatypeProperties(); + for(DatatypeProperty dp : stringDPs) { + // loop over frequent values + Set<Constant> freqValues = frequentDataValues.get(dp); + for(Constant c : freqValues) { + m3.add(new StringValueRestriction(dp, c.getLiteral())); + } + } + } + + m.put(3,m3); + + SortedSet<Description> m4 = new TreeSet<Description>(conceptComparator); + if(useCardinalityRestrictions) { + for(ObjectProperty r : rs.getMostGeneralProperties()) { + int maxFillers = maxNrOfFillers.get(r); + // zero fillers: <= -1 r.C does not make sense + // one filler: <= 0 r.C is equivalent to NOT EXISTS r.C, + // but we still keep it, because ALL r.NOT C may be difficult to reach + if(maxFillers > 0) + m4.add(new ObjectMaxCardinalityRestriction(maxFillers-1, r, new Thing())); + } + } + m.put(4,m4); + + mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; + } + + // computation of the set M_A + // a major difference compared to the ILP 2007 \rho operator is that + // M is finite and contains elements of length (currently) at most 3 + private void computeM(NamedClass nc) { + long mComputationTimeStartNs = System.nanoTime(); + + // System.out.println(nc); + + mA.put(nc, new TreeMap<Integer,SortedSet<Description>>()); + // initialise all possible lengths (1 to 3) + for(int i=1; i<=mMaxLength; i++) { + mA.get(nc).put(i, new TreeSet<Description>(conceptComparator)); + } + + // incomplete, prior implementation + // SortedSet<Description> m1 = subHierarchy.getSubClasses(nc); + // mA.get(nc).put(1,m1); + + // most general classes, which are not disjoint with nc and provide real refinement + SortedSet<Description> m1 = getClassCandidates(nc); + mA.get(nc).put(1,m1); + + // most specific negated classes, which are not disjoint with nc + SortedSet<Description> m2 = new TreeSet<Description>(); + if(useNegation) { + m2 = getNegClassCandidates(nc); + mA.get(nc).put(2,m2); + } + + // System.out.println("m1 " + "(" + nc + "): " + m1); + // System.out.println("m2 " + "(" + nc + "): " + m2); + + /* + SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); + if(useNegation) { + // the definition in the paper is more complex, but actually + // we only have to insert the most specific concepts satisfying + // the mentioned restrictions; there is no need to implement a + // recursive method because for A subClassOf A' we have not A' + // subClassOf A and thus: if A and B are disjoint then also A' + // and B; if not A AND B = B then also not A' AND B = B + // 2010/03: the latter is not correct => a recursive method is needed + SortedSet<Description> m2tmp = subHierarchy.getSuperClasses(new Nothing()); + + for(Description c : m2tmp) { +// if(c instanceof Thing) +// m2.add(c); +// else { + // we obviously do not add \top (\top refines \top does not make sense) + if(!(c instanceof Thing)) { + NamedClass a = (NamedClass) c; + if(!isNotADisjoint(a, nc) && isNotAMeaningful(a, nc)) + m2.add(new Negation(a)); + } + } + } + */ + + // compute applicable properties + computeMg(nc); + + // boolean datatypes, e.g. testPositive = true + if(useBooleanDatatypes) { + Set<DatatypeProperty> booleanDPs = mgbd.get(nc); + for(DatatypeProperty dp : booleanDPs) { + m2.add(new BooleanValueRestriction(dp,true)); + m2.add(new BooleanValueRestriction(dp,false)); + } + } + + mA.get(nc).put(2,m2); + + SortedSet<Description> m3 = new TreeSet<Description>(conceptComparator); + if(useExistsConstructor) { + for(ObjectProperty r : mgr.get(nc)) { + m3.add(new ObjectSomeRestriction(r, new Thing())); + } + } + + if(useAllConstructor) { + // we allow \forall r.\top here because otherwise the operator + // becomes too difficult to manage due to dependencies between + // M_A and M_A' where A'=ran(r) + for(ObjectProperty r : mgr.get(nc)) { + m3.add(new ObjectAllRestriction(r, new Thing())); + } + } + + if(useDoubleDatatypes) { + Set<DatatypeProperty> doubleDPs = mgdd.get(nc); + // System.out.println("cached disjoints " + cachedDisjoints); + // System.out.println("appOP " + appOP); + // System.out.println("appBD " + appBD); + // System.out.println("appDD " + appDD); + // System.out.println("mgr " + mgr); + // System.out.println("mgbd " + mgbd); + // System.out.println("mgdd " + mgdd); + + for(DatatypeProperty dp : doubleDPs) { + if((splits.get(dp) != null) && (splits.get(dp).size() > 0)) { + DoubleMaxValue max = new DoubleMaxValue(splits.get(dp).get(splits.get(dp).size()-1)); + DoubleMinValue min = new DoubleMinValue(splits.get(dp).get(0)); + m3.add(new DatatypeSomeRestriction(dp,max)); + m3.add(new DatatypeSomeRestriction(dp,min)); + } + } + } + + if(useDataHasValueConstructor) { + Set<DatatypeProperty> stringDPs = mgsd.get(nc); + for(DatatypeProperty dp : stringDPs) { + // loop over frequent values + Set<Constant> freqValues = frequentDataValues.get(dp); + for(Constant c : freqValues) { + m3.add(new StringValueRestriction(dp, c.getLiteral())); + } + } + } + + mA.get(nc).put(3,m3); + + SortedSet<Description> m4 = new TreeSet<Description>(conceptComparator); + if(useCardinalityRestrictions) { + for(ObjectProperty r : mgr.get(nc)) { + int maxFillers = maxNrOfFillers.get(r); + // zero fillers: <= -1 r.C does not make sense + // one filler: <= 0 r.C is equivalent to NOT EXISTS r.C, + // but we still keep it, because ALL r.NOT C may be difficult to reach + if(maxFillers > 0) + m4.add(new ObjectMaxCardinalityRestriction(maxFillers-1, r, new Thing())); + } + } + mA.get(nc).put(4,m4); + + // System.out.println(mA.get(nc)); + + mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; + } + + // get candidates for a refinement of \top restricted to a class B + public SortedSet<Description> getClassCandidates(NamedClass index) { + return getClassCandidatesRecursive(index, Thing.instance); + } + + private SortedSet<Description> getClassCandidatesRecursive(Description index, Description upperClass) { + SortedSet<Description> candidates = new TreeSet<Description>(); + // System.out.println("index " + index + " upper class " + upperClass); + + // we descend the subsumption hierarchy to ensure that we get + // the most general concepts satisfying the criteria + for(Description candidate : subHierarchy.getSubClasses(upperClass)) { + // System.out.println("testing " + candidate + " ... "); + + // NamedClass candidate = (NamedClass) d; + // check disjointness with index (if not no further traversal downwards is necessary) + if(!isDisjoint(candidate,index)) { + // System.out.println( " passed disjointness test ... "); + // check whether the class is meaningful, i.e. adds something to the index + // to do this, we need to make sure that the class is not a superclass of the + // index (otherwise we get nothing new) - for instance based disjoints, we + // make sure that there is at least one individual, which is not already in the + // upper class + boolean meaningful; + if(instanceBasedDisjoints) { + // bug: tests should be performed against the index, not the upper class + // SortedSet<Individual> tmp = rs.getIndividuals(upperClass); + SortedSet<Individual> tmp = rs.getIndividuals(index); + tmp.removeAll(rs.getIndividuals(candidate)); + // System.out.println(" instances of " + index + " and not " + candidate + ": " + tmp.size()); + meaningful = tmp.size() != 0; + } else { + meaningful = !isDisjoint(new Negation(candidate),index); + } + + if(meaningful) { + // candidate went successfully through all checks + candidates.add(candidate); + // System.out.println(" real refinement"); + } else { + // descend subsumption hierarchy to find candidates + // System.out.println(" enter recursion"); + candidates.addAll(getClassCandidatesRecursive(index, candidate)); + } + } + // else { + // System.out.println(" ruled out, because it is disjoint"); + // } + } + // System.out.println("cc method exit"); + return candidates; + } + + // get candidates for a refinement of \top restricted to a class B + public SortedSet<Description> getNegClassCandidates(NamedClass index) { + return getNegClassCandidatesRecursive(index, Nothing.instance); + } + + private SortedSet<Description> getNegClassCandidatesRecursive(Description index, Description lowerClass) { + SortedSet<Description> candidates = new TreeSet<Description>(conceptComparator); + // System.out.println("index " + index + " lower class " + lowerClass); + + for(Description candidate : subHierarchy.getSuperClasses(lowerClass)) { + if(!(candidate instanceof Thing)) { + // System.out.println("candidate: " + candidate); + // check disjointness with index/range (should not be disjoint otherwise not useful) + if(!isDisjoint(new Negation(candidate),index)) { + boolean meaningful; + // System.out.println("not disjoint"); + if(instanceBasedDisjoints) { + SortedSet<Individual> tmp = rs.getIndividuals(index); + tmp.removeAll(rs.getIndividuals(new Negation(candidate))); + meaningful = tmp.size() != 0; + // System.out.println("instances " + tmp.size()); + } else { + meaningful = !isDisjoint(candidate,index); + } + + if(meaningful) { + candidates.add(new Negation(candidate)); + } else { + candidates.addAll(getNegClassCandidatesRecursive(index, candidate)); + } + } + } + } + return candidates; + } + + private void computeMg(NamedClass domain) { + // compute the applicable properties if this has not been done yet + if(appOP.get(domain) == null) + computeApp(domain); + + // initialise mgr, mgbd, mgdd, mgsd + mgr.put(domain, new TreeSet<ObjectProperty>()); + mgbd.put(domain, new TreeSet<DatatypeProperty>()); + mgdd.put(domain, new TreeSet<DatatypeProperty>()); + mgsd.put(domain, new TreeSet<DatatypeProperty>()); + + SortedSet<ObjectProperty> mostGeneral = rs.getMostGeneralProperties(); + computeMgrRecursive(domain, mostGeneral, mgr.get(domain)); + SortedSet<DatatypeProperty> mostGeneralDP = rs.getMostGeneralDatatypeProperties(); + // we make the (reasonable) assumption here that all sub and super + // datatype properties have the same type (e.g. boolean, integer, double) + Set<DatatypeProperty> mostGeneralBDP = Helper.intersection(mostGeneralDP, rs.getBooleanDatatypeProperties()); + Set<DatatypeProperty> mostGeneralDDP = Helper.intersection(mostGeneralDP, rs.getDoubleDatatypeProperties()); + Set<DatatypeProperty> mostGeneralSDP = Helper.intersection(mostGeneralDP, rs.getStringDatatypeProperties()); + computeMgbdRecursive(domain, mostGeneralBDP, mgbd.get(domain)); + computeMgddRecursive(domain, mostGeneralDDP, mgdd.get(domain)); + computeMgsdRecursive(domain, mostGeneralSDP, mgsd.get(domain)); + } + + private void computeMgrRecursive(NamedClass domain, Set<ObjectProperty> currProperties, Set<ObjectProperty> mgrTmp) { + for(ObjectProperty prop : currProperties) { + if(appOP.get(domain).contains(prop)) + mgrTmp.add(prop); + else + computeMgrRecursive(domain, rs.getSubProperties(prop), mgrTmp); + } + } + + private void computeMgbdRecursive(NamedClass domain, Set<DatatypeProperty> currProperties, Set<DatatypeProperty> mgbdTmp) { + for(DatatypeProperty prop : currProperties) { + if(appBD.get(domain).contains(prop)) + mgbdTmp.add(prop); + else + computeMgbdRecursive(domain, rs.getSubProperties(prop), mgbdTmp); + } + } + + private void computeMgddRecursive(NamedClass domain, Set<DatatypeProperty> currProperties, Set<DatatypeProperty> mgddTmp) { + for(DatatypeProperty prop : currProperties) { + if(appDD.get(domain).contains(prop)) + mgddTmp.add(prop); + else + computeMgddRecursive(domain, rs.getSubProperties(prop), mgddTmp); + } + } + + private void computeMgsdRecursive(NamedClass domain, Set<DatatypeProperty> currProperties, Set<DatatypeProperty> mgsdTmp) { + for(DatatypeProperty prop : currProperties) { + if(appDD.get(domain).contains(prop)) + mgsdTmp.add(prop); + else + computeMgsdRecursive(domain, rs.getSubProperties(prop), mgsdTmp); + } + } + + // computes the set of applicable properties for a given class + private void computeApp(NamedClass domain) { + // object properties + Set<ObjectProperty> mostGeneral = rs.getObjectProperties(); + Set<ObjectProperty> applicableRoles = new TreeSet<ObjectProperty>(); + for(ObjectProperty role : mostGeneral) { + // TODO: currently we just rely on named classes as roles, + // instead of computing dom(r) and ran(r) + Description d = rs.getDomain(role); + if(!isDisjoint(domain,d)) + applicableRoles.add(role); + } + appOP.put(domain, applicableRoles); + + // boolean datatype properties + Set<DatatypeProperty> mostGeneralBDPs = rs.getBooleanDatatypeProperties(); + Set<DatatypeProperty> applicableBDPs = new TreeSet<DatatypeProperty>(); + for(DatatypeProperty role : mostGeneralBDPs) { + // Description d = (NamedClass) rs.getDomain(role); + Description d = rs.getDomain(role); + if(!isDisjoint(domain,d)) + applicableBDPs.add(role); + } + appBD.put(domain, applicableBDPs); + + // double datatype properties + Set<DatatypeProperty> mostGeneralDDPs = rs.getDoubleDatatypeProperties(); + Set<DatatypeProperty> applicableDDPs = new TreeSet<DatatypeProperty>(); + for(DatatypeProperty role : mostGeneralDDPs) { + // Description d = (NamedClass) rs.getDomain(role); + Description d = rs.getDomain(role); + // System.out.println("domain: " + d); + if(!isDisjoint(domain,d)) + applicableDDPs.add(role); + } + appDD.put(domain, applicableDDPs); + } + + // returns true of the intersection contains elements disjoint + // to the given description (if true adding the description to + // the intersection results in a description equivalent to bottom) + // e.g. OldPerson AND YoungPerson; Nitrogen-34 AND Tin-113 + // Note: currently we only check named classes in the intersection, + // it would be interesting to see whether it makes sense to extend this + // (advantage: less refinements, drawback: operator will need infinitely many + // reasoner queries in the long run) + @SuppressWarnings({"unused"}) + private boolean containsDisjoints(Intersection intersection, Description d) { + List<Description> children = intersection.getChildren(); + for(Description child : children) { + if(d instanceof Nothing) + return true; + else if(child instanceof NamedClass) { + if(isDisjoint((NamedClass)child, d)) + return true; + } + } + return false; + } + + private boolean isDisjoint(Description d1, Description d2) { + + // System.out.println("| " + d1 + " " + d2); + // System.out.println("| " + cachedDisjoints); + + // check whether we have cached this query + Map<Description,Boolean> tmp = cachedDisjoints.get(d1); + Boolean tmp2 = null; + if(tmp != null) + tmp2 = tmp.get(d2); + + // System.out.println("| " + tmp + " " + tmp2); + + if(tmp2==null) { + Boolean result; + if(instanceBasedDisjoints) { + result = isDisjointInstanceBased(d1,d2); + } else { + Description d = new Intersection(d1, d2); + result = rs.isSuperClassOf(new Nothing(), d); + } + // add the result to the cache (we add it twice such that + // the order of access does not matter) + + // System.out.println("| result: " + result); + + // create new entries if necessary + Map<Description,Boolean> map1 = new TreeMap<Description,Boolean>(conceptComparator); + Map<Description,Boolean> map2 = new TreeMap<Description,Boolean>(conceptComparator); + if(tmp == null) + cachedDisjoints.put(d1, map1); + if(!cachedDisjoints.containsKey(d2)) + cachedDisjoints.put(d2, map2); + + // add result symmetrically in the description matrix + cachedDisjoints.get(d1).put(d2, result); + cachedDisjoints.get(d2).put(d1, result); + // System.out.println("---"); + return result; + } else { + // System.out.println("==="); + return tmp2; + } + } + + private boolean isDisjointInstanceBased(Description d1, Description d2) { + SortedSet<Individual> d1Instances = rs.getIndividuals(d1); + SortedSet<Individual> d2Instances = rs.getIndividuals(d2); + // System.out.println(d1 + " " + d2); + // System.out.println(d1 + " " + d1Instances); + // System.out.println(d2 + " " + d2Instances); + for(Individual d1Instance : d1Instances) { + if(d2Instances.contains(d1Instance)) + return false; + } + return true; + } + + /* + // computes whether two classes are disjoint; this should be computed + // by the reasoner on... [truncated message content] |
From: <lor...@us...> - 2012-07-20 12:43:13
|
Revision: 3800 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3800&view=rev Author: lorenz_b Date: 2012-07-20 12:43:03 +0000 (Fri, 20 Jul 2012) Log Message: ----------- Updated ELK dependency. Fixed problem in SPARQL reasoner. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2012-07-19 08:12:17 UTC (rev 3799) +++ trunk/components-core/pom.xml 2012-07-20 12:43:03 UTC (rev 3800) @@ -230,7 +230,7 @@ <dependency> <groupId>org.semanticweb.elk</groupId> <artifactId>elk-owlapi</artifactId> - <version>0.2.0</version> + <version>0.3.0</version> </dependency> <dependency> <groupId>de.tudresden.inf.lat.cel</groupId> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java 2012-07-19 08:12:17 UTC (rev 3799) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java 2012-07-20 12:43:03 UTC (rev 3800) @@ -190,7 +190,7 @@ ObjectPropertyDomainAxiomLearner l = new ObjectPropertyDomainAxiomLearner(ks); l.setReasoner(reasoner); - l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/creator")); + l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/grammyAward")); l.setMaxExecutionTimeInSeconds(40); l.addFilterNamespace("http://dbpedia.org/ontology/"); // l.setReturnOnlyNewAxioms(true); Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2012-07-19 08:12:17 UTC (rev 3799) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2012-07-20 12:43:03 UTC (rev 3800) @@ -108,15 +108,20 @@ if(useCache){ cache = new ExtractionDBCache("cache"); } + classPopularityMap = new HashMap<NamedClass, Integer>(); } public SPARQLReasoner(SparqlEndpointKS ks, ExtractionDBCache cache) { this.ks = ks; this.cache = cache; + + classPopularityMap = new HashMap<NamedClass, Integer>(); } public SPARQLReasoner(OntModel model) { this.model = model; + + classPopularityMap = new HashMap<NamedClass, Integer>(); } public void precomputePopularity(){ @@ -127,7 +132,6 @@ public void precomputeClassPopularity(){ logger.info("Precomputing class popularity ..."); - classPopularityMap = new HashMap<NamedClass, Integer>(); Set<NamedClass> classes = new SPARQLTasks(ks.getEndpoint()).getAllClasses(); String queryTemplate = "SELECT (COUNT(*) AS ?cnt) WHERE {?s a <%s>}"; @@ -197,7 +201,7 @@ } public int getPopularity(NamedClass nc){ - if(classPopularityMap.containsKey(nc)){ + if(classPopularityMap != null && classPopularityMap.containsKey(nc)){ return classPopularityMap.get(nc); } else { System.out.println("Cache miss: " + nc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2012-08-23 13:19:14
|
Revision: 3834 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3834&view=rev Author: lorenz_b Date: 2012-08-23 13:19:03 +0000 (Thu, 23 Aug 2012) Log Message: ----------- Started feature to explain score in enrichment algorithms and return pos and neg examples. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner2.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2012-08-23 13:13:39 UTC (rev 3833) +++ trunk/components-core/pom.xml 2012-08-23 13:19:03 UTC (rev 3834) @@ -242,7 +242,12 @@ <artifactId>jsexp</artifactId> <version>0.1.0</version> </dependency> - + + <dependency> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + <version>2.8.0</version> + </dependency> </dependencies> <dependencyManagement> <dependencies> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2012-08-23 13:13:39 UTC (rev 3833) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2012-08-23 13:19:03 UTC (rev 3834) @@ -20,6 +20,11 @@ package org.dllearner.algorithms.properties; import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; import org.dllearner.core.AbstractAxiomLearningAlgorithm; import org.dllearner.core.ComponentAnn; @@ -27,12 +32,14 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.ObjectPropertyEditor; import org.dllearner.core.owl.FunctionalObjectPropertyAxiom; +import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.kb.SparqlEndpointKS; import org.dllearner.kb.sparql.SparqlEndpoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.hp.hpl.jena.query.ParameterizedSparqlString; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.Model; @@ -51,6 +58,8 @@ public FunctionalObjectPropertyAxiomLearner(SparqlEndpointKS ks){ this.ks = ks; + posExamplesQueryTemplate = new ParameterizedSparqlString("SELECT ?s WHERE {?s ?p ?o1. FILTER NOT EXISTS {?s ?p ?o2. FILTER(?o1 != ?o2)} }"); + negExamplesQueryTemplate = new ParameterizedSparqlString("SELECT ?s WHERE {?s ?p ?o1. ?s ?p ?o2. FILTER(?o1 != ?o2)}"); } public ObjectProperty getPropertyToDescribe() { @@ -59,6 +68,8 @@ public void setPropertyToDescribe(ObjectProperty propertyToDescribe) { this.propertyToDescribe = propertyToDescribe; + posExamplesQueryTemplate.setIri("p", propertyToDescribe.getURI().toString()); + negExamplesQueryTemplate.setIri("p", propertyToDescribe.getURI().toString()); } @Override @@ -86,36 +97,36 @@ } private void runSPARQL1_0_Mode() { - Model model = ModelFactory.createDefaultModel(); + workingModel = ModelFactory.createDefaultModel(); int limit = 1000; int offset = 0; String baseQuery = "CONSTRUCT {?s <%s> ?o.} WHERE {?s <%s> ?o} LIMIT %d OFFSET %d"; String query = String.format(baseQuery, propertyToDescribe.getName(), propertyToDescribe.getName(), limit, offset); Model newModel = executeConstructQuery(query); while(!terminationCriteriaSatisfied() && newModel.size() != 0){System.out.println(query); - model.add(newModel); + workingModel.add(newModel); // get number of instances of s with <s p o> query = String.format( "SELECT (COUNT(DISTINCT ?s) AS ?all) WHERE {?s <%s> ?o.}", propertyToDescribe.getName()); - ResultSet rs = executeSelectQuery(query, model); + ResultSet rs = executeSelectQuery(query, workingModel); QuerySolution qs; int all = 1; while (rs.hasNext()) { qs = rs.next(); all = qs.getLiteral("all").getInt(); } - System.out.println(all); + // get number of instances of s with <s p o> <s p o1> where o != o1 query = "SELECT (COUNT(DISTINCT ?s) AS ?functional) WHERE {?s <%s> ?o1. FILTER NOT EXISTS {?s <%s> ?o2. FILTER(?o1 != ?o2)} }"; query = query.replace("%s", propertyToDescribe.getURI().toString()); - rs = executeSelectQuery(query, model); + rs = executeSelectQuery(query, workingModel); int functional = 1; while (rs.hasNext()) { qs = rs.next(); functional = qs.getLiteral("functional").getInt(); } - System.out.println(functional); + if (all > 0) { currentlyBestAxioms.clear(); currentlyBestAxioms.add(new EvaluatedAxiom( @@ -155,13 +166,21 @@ } public static void main(String[] args) throws Exception{ - FunctionalObjectPropertyAxiomLearner l = new FunctionalObjectPropertyAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW())); - l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/wikiPageExternalLink")); - l.setMaxExecutionTimeInSeconds(10); -// l.setForceSPARQL_1_0_Mode(true); + FunctionalObjectPropertyAxiomLearner l = new FunctionalObjectPropertyAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia())); + l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/league")); + l.setMaxExecutionTimeInSeconds(20); + l.setForceSPARQL_1_0_Mode(true); l.init(); l.start(); - System.out.println(l.getCurrentlyBestEvaluatedAxioms(5)); + List<EvaluatedAxiom> axioms = l.getCurrentlyBestEvaluatedAxioms(5); + System.out.println(axioms); + + for(EvaluatedAxiom axiom : axioms){ + printSubset(l.getPositiveExamples(axiom), 10); + printSubset(l.getNegativeExamples(axiom), 10); + l.explainScore(axiom); + } + } } Added: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner2.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner2.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner2.java 2012-08-23 13:19:03 UTC (rev 3834) @@ -0,0 +1,221 @@ +/** + * Copyright (C) 2007-2011, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.dllearner.algorithms.properties; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; + +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.Level; +import org.apache.log4j.SimpleLayout; +import org.dllearner.core.AbstractAxiomLearningAlgorithm; +import org.dllearner.core.ComponentAnn; +import org.dllearner.core.EvaluatedAxiom; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.ObjectPropertyEditor; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectPropertyDomainAxiom; +import org.dllearner.kb.SparqlEndpointKS; +import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.reasoning.SPARQLReasoner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.hp.hpl.jena.query.ParameterizedSparqlString; +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.hp.hpl.jena.rdf.model.RDFNode; +import com.hp.hpl.jena.rdf.model.Resource; +import com.hp.hpl.jena.rdf.model.Statement; +import com.hp.hpl.jena.rdf.model.StmtIterator; +import com.hp.hpl.jena.vocabulary.OWL; +import com.hp.hpl.jena.vocabulary.RDF; +import com.hp.hpl.jena.vocabulary.RDFS; + +@ComponentAnn(name="objectproperty domain axiom learner", shortName="opldomain", version=0.1) +public class ObjectPropertyDomainAxiomLearner2 extends AbstractAxiomLearningAlgorithm { + + private static final Logger logger = LoggerFactory.getLogger(ObjectPropertyDomainAxiomLearner2.class); + + private Map<Individual, SortedSet<Description>> individual2Types; + + + @ConfigOption(name="propertyToDescribe", description="", propertyEditorClass=ObjectPropertyEditor.class) + private ObjectProperty propertyToDescribe; + + public ObjectPropertyDomainAxiomLearner2(SparqlEndpointKS ks){ + this.ks = ks; + super.posExamplesQueryTemplate = new ParameterizedSparqlString("SELECT DISTINCT ?s WHERE {?s a ?type}"); + super.negExamplesQueryTemplate = new ParameterizedSparqlString("SELECT DISTINCT ?s WHERE {?s ?p ?o. FILTER NOT EXISTS{?s a ?type}}"); + + } + + public ObjectProperty getPropertyToDescribe() { + return propertyToDescribe; + } + + public void setPropertyToDescribe(ObjectProperty propertyToDescribe) { + this.propertyToDescribe = propertyToDescribe; +// negExamplesQueryTemplate.clearParams(); +// posExamplesQueryTemplate.clearParams(); + } + + @Override + public void start() { + iterativeQueryTemplate.setIri("p", propertyToDescribe.getName()); + logger.info("Start learning..."); + startTime = System.currentTimeMillis(); + fetchedRows = 0; + currentlyBestAxioms = new ArrayList<EvaluatedAxiom>(); + + if(returnOnlyNewAxioms){ + //get existing domains + Description existingDomain = reasoner.getDomain(propertyToDescribe); + if(existingDomain != null){ + existingAxioms.add(new ObjectPropertyDomainAxiom(propertyToDescribe, existingDomain)); + if(reasoner.isPrepared()){ + if(reasoner.getClassHierarchy().contains(existingDomain)){ + for(Description sup : reasoner.getClassHierarchy().getSuperClasses(existingDomain)){ + existingAxioms.add(new ObjectPropertyDomainAxiom(propertyToDescribe, existingDomain)); + logger.info("Existing domain(inferred): " + sup); + } + } + + } + } + } + + runSPARQL1_0_Mode(); + logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime)); + } + + private void runSPARQL1_0_Mode() { + workingModel = ModelFactory.createDefaultModel(); + int limit = 1000; + int offset = 0; + String baseQuery = "CONSTRUCT {?s a ?type.} WHERE {?s <%s> ?o. ?s a ?type.} LIMIT %d OFFSET %d"; + String query = String.format(baseQuery, propertyToDescribe.getName(), limit, offset); + Model newModel = executeConstructQuery(query); + while(!terminationCriteriaSatisfied() && newModel.size() != 0){ + workingModel.add(newModel); + // get number of distinct subjects + query = "SELECT (COUNT(DISTINCT ?s) AS ?all) WHERE {?s a ?type.}"; + ResultSet rs = executeSelectQuery(query, workingModel); + QuerySolution qs; + int all = 1; + while (rs.hasNext()) { + qs = rs.next(); + all = qs.getLiteral("all").getInt(); + } + + // get class and number of instances + query = "SELECT ?type (COUNT(DISTINCT ?s) AS ?cnt) WHERE {?s a ?type.} GROUP BY ?type"; + rs = executeSelectQuery(query, workingModel); + + if (all > 0) { + currentlyBestAxioms.clear(); + while(rs.hasNext()){ + qs = rs.next(); + Resource type = qs.get("type").asResource(); + //omit owl:Thing as trivial domain + if(type.equals(OWL.Thing)){ + continue; + } + currentlyBestAxioms.add(new EvaluatedAxiom( + new ObjectPropertyDomainAxiom(propertyToDescribe, new NamedClass(type.getURI())), + computeScore(all, qs.get("cnt").asLiteral().getInt()))); + } + + } + offset += limit; + query = String.format(baseQuery, propertyToDescribe.getName(), limit, offset); + newModel = executeConstructQuery(query); + fillWithInference(newModel); + } + } + + private void fillWithInference(Model model){ + Model additionalModel = ModelFactory.createDefaultModel(); + if(reasoner.isPrepared()){ + for(StmtIterator iter = model.listStatements(null, RDF.type, (RDFNode)null); iter.hasNext();){ + Statement st = iter.next(); + Description cls = new NamedClass(st.getObject().asResource().getURI()); + if(reasoner.getClassHierarchy().contains(cls)){ + for(Description sup : reasoner.getClassHierarchy().getSuperClasses(cls)){ + additionalModel.add(st.getSubject(), st.getPredicate(), model.createResource(sup.toString())); + } + } + } + } + model.add(additionalModel); + } + + @Override + protected SortedSet<Individual> getPositiveExamples(EvaluatedAxiom evAxiom) { + ObjectPropertyDomainAxiom axiom = (ObjectPropertyDomainAxiom) evAxiom.getAxiom(); + posExamplesQueryTemplate.setIri("type", axiom.getDomain().toString()); + return super.getPositiveExamples(evAxiom); + } + + @Override + protected SortedSet<Individual> getNegativeExamples(EvaluatedAxiom evAxiom) { + ObjectPropertyDomainAxiom axiom = (ObjectPropertyDomainAxiom) evAxiom.getAxiom(); + negExamplesQueryTemplate.setIri("type", axiom.getDomain().toString()); + return super.getNegativeExamples(evAxiom); + } + + public static void main(String[] args) throws Exception{ + org.apache.log4j.Logger.getRootLogger().addAppender(new ConsoleAppender(new SimpleLayout())); + org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO); + org.apache.log4j.Logger.getLogger(DataPropertyDomainAxiomLearner.class).setLevel(Level.INFO); + + SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW()); + + SPARQLReasoner reasoner = new SPARQLReasoner(ks); + reasoner.prepareSubsumptionHierarchy(); + + + ObjectPropertyDomainAxiomLearner2 l = new ObjectPropertyDomainAxiomLearner2(ks); + l.setReasoner(reasoner); + l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/league")); + l.setMaxFetchedRows(20000); + l.setMaxExecutionTimeInSeconds(20); + l.addFilterNamespace("http://dbpedia.org/ontology/"); +// l.setReturnOnlyNewAxioms(true); + l.init(); + l.start(); + + List<EvaluatedAxiom> axioms = l.getCurrentlyBestEvaluatedAxioms(10, 0.3); + System.out.println(axioms); + for(EvaluatedAxiom axiom : axioms){ + printSubset(l.getPositiveExamples(axiom), 10); + printSubset(l.getNegativeExamples(axiom), 10); + l.explainScore(axiom); + } + } + +} Modified: trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java 2012-08-23 13:13:39 UTC (rev 3833) +++ trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java 2012-08-23 13:19:03 UTC (rev 3834) @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -37,6 +38,7 @@ import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; import org.dllearner.kb.LocalModelBasedSparqlEndpointKS; import org.dllearner.kb.SparqlEndpointKS; @@ -116,6 +118,11 @@ protected ParameterizedSparqlString iterativeQueryTemplate; + protected Model workingModel; + protected ParameterizedSparqlString posExamplesQueryTemplate; + protected ParameterizedSparqlString negExamplesQueryTemplate; + + public AbstractAxiomLearningAlgorithm() { existingAxioms = new TreeSet<Axiom>(new AxiomComparator()); } @@ -255,7 +262,7 @@ } - protected Model executeConstructQuery(String query) { + protected Model executeConstructQuery(String query) {System.out.println(query); logger.debug("Sending query\n{} ...", query); if(ks.isRemote()){ SparqlEndpoint endpoint = ((SparqlEndpointKS) ks).getEndpoint(); @@ -266,7 +273,12 @@ queryExecution.setNamedGraphURIs(endpoint.getNamedGraphURIs()); try { Model model = queryExecution.execConstruct(); + fetchedRows += model.size(); timeout = false; + if(model.size() == 0){ + fullDataLoaded = true; + } + return model; } catch (QueryExceptionHTTP e) { if(e.getCause() instanceof SocketTimeoutException){ @@ -277,8 +289,13 @@ return ModelFactory.createDefaultModel(); } } else { - QueryExecution qexec = QueryExecutionFactory.create(query, ((LocalModelBasedSparqlEndpointKS)ks).getModel()); - return qexec.execConstruct(); + QueryExecution queryExecution = QueryExecutionFactory.create(query, ((LocalModelBasedSparqlEndpointKS)ks).getModel()); + Model model = queryExecution.execConstruct(); + fetchedRows += model.size(); + if(model.size() == 0){ + fullDataLoaded = true; + } + return model; } } @@ -456,6 +473,67 @@ filterNamespaces.add(namespace); } + protected SortedSet<Individual> getPositiveExamples(EvaluatedAxiom axiom){ + if(workingModel != null){ + SortedSet<Individual> posExamples = new TreeSet<Individual>(); + + ResultSet rs = executeSelectQuery(posExamplesQueryTemplate.toString(), workingModel); + while(rs.hasNext()){ + posExamples.add(new Individual(rs.next().get("s").asResource().getURI())); + } + + return posExamples; + } else { + throw new UnsupportedOperationException("Getting positive examples is not possible."); + } + } + + protected SortedSet<Individual> getNegativeExamples(EvaluatedAxiom axiom){ + if(workingModel != null){ + SortedSet<Individual> negExamples = new TreeSet<Individual>(); + + ResultSet rs = executeSelectQuery(negExamplesQueryTemplate.toString(), workingModel); + while(rs.hasNext()){ + negExamples.add(new Individual(rs.next().get("s").asResource().getURI())); + } + + return negExamples; + } else { + throw new UnsupportedOperationException("Getting negative examples is not possible."); + } + } + + protected void explainScore(EvaluatedAxiom evAxiom){ + int posExampleCnt = getPositiveExamples(evAxiom).size(); + int negExampleCnt = getNegativeExamples(evAxiom).size(); + int total = posExampleCnt + negExampleCnt; + StringBuilder sb = new StringBuilder(); + String lb = "\n"; + sb.append("######################################").append(lb); + sb.append("Explanation:").append(lb); + sb.append("Score(").append(evAxiom.getAxiom()).append(") = ").append(evAxiom.getScore().getAccuracy()).append(lb); + sb.append("Total number of resources:\t").append(total).append(lb); + sb.append("Number of positive examples:\t").append(posExampleCnt).append(lb); + sb.append("Number of negative examples:\t").append(negExampleCnt).append(lb); + sb.append("Complete data processed:\t").append(fullDataLoaded).append(lb); + sb.append("######################################"); + System.out.println(sb.toString()); + } + + protected static <E> void printSubset(Collection<E> collection, int maxSize){ + StringBuffer sb = new StringBuffer(); + int i = 0; + Iterator<E> iter = collection.iterator(); + while(iter.hasNext() && i < maxSize){ + sb.append(iter.next().toString()).append(", "); + i++; + } + if(iter.hasNext()){ + sb.append("...(").append(collection.size()-i).append(" more)"); + } + System.out.println(sb.toString()); + } + protected <K,T extends Set<V>, V> void addToMap(Map<K, T> map, K key, V value ){ T values = map.get(key); if(values == null){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2012-12-25 13:19:20
|
Revision: 3881 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3881&view=rev Author: lorenz_b Date: 2012-12-25 13:19:09 +0000 (Tue, 25 Dec 2012) Log Message: ----------- Added equals+hashcode for literals. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/core/owl/Datatype.java trunk/components-core/src/main/java/org/dllearner/core/owl/TypedConstant.java trunk/components-core/src/main/java/org/dllearner/core/owl/UntypedConstant.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2012-12-11 19:34:37 UTC (rev 3880) +++ trunk/components-core/pom.xml 2012-12-25 13:19:09 UTC (rev 3881) @@ -169,6 +169,11 @@ <groupId>org.semanticweb.hermit</groupId> <artifactId>hermit</artifactId> </dependency> + + <dependency> + <groupId>eu.trowl</groupId> + <artifactId>trowl-core</artifactId> + </dependency> <dependency> <groupId>com.jamonapi</groupId> Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/Datatype.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/Datatype.java 2012-12-11 19:34:37 UTC (rev 3880) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/Datatype.java 2012-12-25 13:19:09 UTC (rev 3881) @@ -22,6 +22,9 @@ import java.net.URI; import java.util.Map; +import org.semanticweb.owlapi.model.IRI; + + /** * @author Jens Lehmann * Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/TypedConstant.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/TypedConstant.java 2012-12-11 19:34:37 UTC (rev 3880) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/TypedConstant.java 2012-12-25 13:19:09 UTC (rev 3881) @@ -120,6 +120,35 @@ String str = literal + datatype; String str2 = o.literal + ((TypedConstant)o).datatype; return str.compareTo(str2); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((datatype == null) ? 0 : datatype.hashCode()); + result = prime * result + ((getLiteral() == null) ? 0 : getLiteral().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TypedConstant other = (TypedConstant) obj; + if (datatype == null) { + if (other.datatype != null) + return false; + } else if (!datatype.equals(other.datatype)) + return false; + if(!getLiteral().equals(other.getLiteral())){ + return false; + } + return true; } } Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/UntypedConstant.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/UntypedConstant.java 2012-12-11 19:34:37 UTC (rev 3880) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/UntypedConstant.java 2012-12-25 13:19:09 UTC (rev 3881) @@ -124,4 +124,36 @@ return str.compareTo(str2); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (hasLang ? 1231 : 1237); + result = prime * result + ((lang == null) ? 0 : lang.hashCode()); + result = prime * result + ((getLiteral() == null) ? 0 : getLiteral().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UntypedConstant other = (UntypedConstant) obj; + if (hasLang != other.hasLang) + return false; + if (lang == null) { + if (other.lang != null) + return false; + } else if (!lang.equals(other.lang)) + return false; + if(!getLiteral().equals(other.getLiteral())){ + return false; + } + return true; + } + } Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java 2012-12-11 19:34:37 UTC (rev 3880) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java 2012-12-25 13:19:09 UTC (rev 3881) @@ -2,28 +2,22 @@ import java.io.UnsupportedEncodingException; import java.sql.SQLException; -import java.util.Arrays; import java.util.Iterator; import java.util.List; -import java.util.Set; import org.apache.log4j.Level; import org.apache.log4j.Logger; -import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecutionFactory; -import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; -import com.hp.hpl.jena.vocabulary.RDF; -import com.hp.hpl.jena.vocabulary.RDFS; public class ConciseBoundedDescriptionGeneratorImpl implements ConciseBoundedDescriptionGenerator{ private static final Logger logger = Logger.getLogger(ConciseBoundedDescriptionGeneratorImpl.class); - private static final int CHUNK_SIZE = 1000; + private int chunkSize = 0; private ExtractionDBCache cache; private SparqlEndpoint endpoint; @@ -37,6 +31,12 @@ this.cache = cache; } + public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint, ExtractionDBCache cache, int maxRecursionDepth) { + this.endpoint = endpoint; + this.cache = cache; + this.maxRecursionDepth = maxRecursionDepth; + } + public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint) { this(endpoint, null); } @@ -53,8 +53,12 @@ return getModelChunked(resourceURI, depth); } + public void setChunkSize(int chunkSize) { + this.chunkSize = chunkSize; + } + private Model getModelChunked(String resource, int depth){ - String query = makeConstructQueryOptional(resource, CHUNK_SIZE, 0, depth); + String query = makeConstructQueryOptional(resource, chunkSize, 0, depth); Model all = ModelFactory.createDefaultModel(); try { Model model; @@ -65,9 +69,9 @@ } all.add(model); int i = 1; - while(model.size() != 0){ + do{ // while(model.size() == CHUNK_SIZE){ - query = makeConstructQueryOptional(resource, CHUNK_SIZE, i * CHUNK_SIZE, depth); + query = makeConstructQueryOptional(resource, chunkSize, i * chunkSize, depth); if(cache == null){ model = getModel(query); } else { @@ -75,7 +79,7 @@ } all.add(model); i++; - } + } while(chunkSize > 0 && model.size() != 0); } catch (UnsupportedEncodingException e) { logger.error(e); } catch (SQLException e) { @@ -124,8 +128,10 @@ sb.append("}"); } sb.append("}\n"); - sb.append("LIMIT ").append(limit).append("\n"); - sb.append("OFFSET ").append(offset); + if(chunkSize > 0){ + sb.append("LIMIT ").append(limit).append("\n"); + sb.append("OFFSET ").append(offset); + } return sb.toString(); } @@ -179,8 +185,8 @@ Logger.getRootLogger().setLevel(Level.DEBUG); ConciseBoundedDescriptionGenerator cbdGen = new ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint.getEndpointDBpedia()); cbdGen = new CachingConciseBoundedDescriptionGenerator(cbdGen); - cbdGen.setRestrictToNamespaces(Arrays.asList(new String[]{"http://dbpedia.org/ontology/", RDF.getURI(), RDFS.getURI()})); - Model cbd = cbdGen.getConciseBoundedDescription("http://dbpedia.org/resource/Leipzig", 2); +// cbdGen.setRestrictToNamespaces(Arrays.asList(new String[]{"http://dbpedia.org/ontology/", RDF.getURI(), RDFS.getURI()})); + Model cbd = cbdGen.getConciseBoundedDescription("http://dbpedia.org/resource/Leipzig", 3); System.out.println(cbd.size()); } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java 2012-12-11 19:34:37 UTC (rev 3880) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java 2012-12-25 13:19:09 UTC (rev 3881) @@ -23,6 +23,7 @@ import java.net.URI; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -99,7 +100,9 @@ import org.semanticweb.owlapi.model.UnknownOWLOntologyException; import org.semanticweb.owlapi.owllink.OWLlinkHTTPXMLReasonerFactory; import org.semanticweb.owlapi.owllink.OWLlinkReasonerConfiguration; +import org.semanticweb.owlapi.reasoner.FreshEntitiesException; import org.semanticweb.owlapi.reasoner.FreshEntityPolicy; +import org.semanticweb.owlapi.reasoner.InconsistentOntologyException; import org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy; import org.semanticweb.owlapi.reasoner.InferenceType; import org.semanticweb.owlapi.reasoner.Node; @@ -107,8 +110,10 @@ import org.semanticweb.owlapi.reasoner.NullReasonerProgressMonitor; import org.semanticweb.owlapi.reasoner.OWLReasoner; import org.semanticweb.owlapi.reasoner.OWLReasonerConfiguration; +import org.semanticweb.owlapi.reasoner.ReasonerInterruptedException; import org.semanticweb.owlapi.reasoner.ReasonerProgressMonitor; import org.semanticweb.owlapi.reasoner.SimpleConfiguration; +import org.semanticweb.owlapi.reasoner.TimeOutException; import org.semanticweb.owlapi.util.SimpleIRIMapper; import org.semanticweb.owlapi.vocab.PrefixOWLOntologyFormat; import org.springframework.beans.propertyeditors.StringTrimmerEditor; @@ -119,1103 +124,1000 @@ import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; import de.tudresden.inf.lat.cel.owlapi.CelReasoner; +import eu.trowl.owlapi3.rel.reasoner.dl.RELReasonerFactory; /** - * Mapping to OWL API reasoner interface. The OWL API currently supports three - * reasoners: FaCT++, HermiT and Pellet. FaCT++ is connected using JNI and - * native libraries, while HermiT and Pellet are pure Java libraries. - * + * Mapping to OWL API reasoner interface. The OWL API currently + * supports three reasoners: FaCT++, HermiT and Pellet. FaCT++ is connected + * using JNI and native libraries, while HermiT and Pellet are pure Java + * libraries. + * * @author Jens Lehmann */ @ComponentAnn(name = "OWL API Reasoner", shortName = "oar", version = 0.8) public class OWLAPIReasoner extends AbstractReasonerComponent { - // private static Logger logger = Logger - // .getLogger(OWLAPIReasoner.class); +// private static Logger logger = Logger +// .getLogger(OWLAPIReasoner.class); - // private String reasonerType = "pellet"; - private OWLReasoner reasoner; - private OWLOntologyManager manager; + //private String reasonerType = "pellet"; + private OWLReasoner reasoner; + private OWLOntologyManager manager; - private OWLOntology ontology; - // the data factory is used to generate OWL API objects - private OWLDataFactory factory; - // static factory - // private static OWLDataFactory staticFactory = - // OWLManager.createOWLOntologyManager().getOWLDataFactory(); + private OWLOntology ontology; + // the data factory is used to generate OWL API objects + private OWLDataFactory factory; + // static factory +// private static OWLDataFactory staticFactory = OWLManager.createOWLOntologyManager().getOWLDataFactory(); - private ConceptComparator conceptComparator = new ConceptComparator(); - private RoleComparator roleComparator = new RoleComparator(); - // private ClassHierarchy subsumptionHierarchy; - // private ObjectPropertyHierarchy roleHierarchy; - // private DatatypePropertyHierarchy datatypePropertyHierarchy; - // private Set<Description> allowedConceptsInSubsumptionHierarchy; + private ConceptComparator conceptComparator = new ConceptComparator(); + private RoleComparator roleComparator = new RoleComparator(); +// private ClassHierarchy subsumptionHierarchy; +// private ObjectPropertyHierarchy roleHierarchy; +// private DatatypePropertyHierarchy datatypePropertyHierarchy; +// private Set<Description> allowedConceptsInSubsumptionHierarchy; - // primitives - Set<NamedClass> atomicConcepts = new TreeSet<NamedClass>(conceptComparator); - Set<ObjectProperty> atomicRoles = new TreeSet<ObjectProperty>(roleComparator); - SortedSet<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); - SortedSet<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); - SortedSet<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); - SortedSet<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); - SortedSet<DatatypeProperty> stringDatatypeProperties = new TreeSet<DatatypeProperty>(); - SortedSet<Individual> individuals = new TreeSet<Individual>(); + // primitives + Set<NamedClass> atomicConcepts = new TreeSet<NamedClass>(conceptComparator); + Set<ObjectProperty> atomicRoles = new TreeSet<ObjectProperty>(roleComparator); + SortedSet<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); + SortedSet<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); + SortedSet<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); + SortedSet<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); + SortedSet<DatatypeProperty> stringDatatypeProperties = new TreeSet<DatatypeProperty>(); + SortedSet<Individual> individuals = new TreeSet<Individual>(); - // namespaces - private Map<String, String> prefixes = new TreeMap<String, String>(); - private String baseURI; + // namespaces + private Map<String, String> prefixes = new TreeMap<String, String>(); + private String baseURI; - // references to OWL API ontologies - private List<OWLOntology> owlAPIOntologies = new LinkedList<OWLOntology>(); - @ConfigOption(name = "reasonerType", description = "The name of the OWL APIReasoner to use {\"fact\", \"hermit\", \"owllink\", \"pellet\", \"elk\", \"cel\"}", defaultValue = "pellet", required = false, propertyEditorClass = StringTrimmerEditor.class) - private String reasonerTypeString = "pellet"; - @ConfigOption(name = "owlLinkURL", description = "The URL to the owl server", defaultValue = "", required = false, propertyEditorClass = StringTrimmerEditor.class) - private String owlLinkURL; + // references to OWL API ontologies + private List<OWLOntology> owlAPIOntologies = new LinkedList<OWLOntology>(); + @ConfigOption(name = "reasonerType", description = "The name of the OWL APIReasoner to use {\"fact\", \"hermit\", \"owllink\", \"pellet\", \"elk\", \"cel\"}", defaultValue = "pellet", required = false, propertyEditorClass = StringTrimmerEditor.class) + private String reasonerTypeString = "pellet"; + @ConfigOption(name = "owlLinkURL", description = "The URL to the owl server", defaultValue = "", required = false, propertyEditorClass = StringTrimmerEditor.class) + private String owlLinkURL; - public OWLAPIReasoner() { - } + public OWLAPIReasoner() { - public OWLAPIReasoner(Set<KnowledgeSource> sources) { - super(sources); - } + } + + public OWLAPIReasoner(KnowledgeSource... sources) { + super(new HashSet<KnowledgeSource>(Arrays.asList(sources))); + } - public static String getName() { - return "OWL API reasoner"; - } + public OWLAPIReasoner(Set<KnowledgeSource> sources) { + super(sources); + } - @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>(); - stringDatatypeProperties = new TreeSet<DatatypeProperty>(); - individuals = new TreeSet<Individual>(); + public static String getName() { + return "OWL API reasoner"; + } - // create OWL API ontology manager - make sure we use a new data factory - // so that we don't default to the static one which can cause problems - // in a multi threaded environment. - manager = OWLManager.createOWLOntologyManager(new OWLDataFactoryImpl()); + @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>(); + stringDatatypeProperties = new TreeSet<DatatypeProperty>(); + individuals = new TreeSet<Individual>(); - // it is a bit cumbersome to obtain all classes, because there - // are no reasoner queries to obtain them => hence we query them - // for each ontology and add them to a set; a comparator avoids - // duplicates by checking URIs - Comparator<OWLNamedObject> namedObjectComparator = new Comparator<OWLNamedObject>() { - public int compare(OWLNamedObject o1, OWLNamedObject o2) { - return o1.getIRI().compareTo(o2.getIRI()); - } - }; - Set<OWLClass> classes = new TreeSet<OWLClass>(namedObjectComparator); - Set<OWLObjectProperty> owlObjectProperties = new TreeSet<OWLObjectProperty>( - namedObjectComparator); - Set<OWLDataProperty> owlDatatypeProperties = new TreeSet<OWLDataProperty>( - namedObjectComparator); - Set<OWLNamedIndividual> owlIndividuals = new TreeSet<OWLNamedIndividual>( - namedObjectComparator); + // create OWL API ontology manager - make sure we use a new data factory so that we don't default to the static one which can cause problems in a multi threaded environment. + manager = OWLManager.createOWLOntologyManager(new OWLDataFactoryImpl()); - Set<OWLOntology> allImports = new HashSet<OWLOntology>(); - prefixes = new TreeMap<String, String>(); + // it is a bit cumbersome to obtain all classes, because there + // are no reasoner queries to obtain them => hence we query them + // for each ontology and add them to a set; a comparator avoids + // duplicates by checking URIs + Comparator<OWLNamedObject> namedObjectComparator = new Comparator<OWLNamedObject>() { + public int compare(OWLNamedObject o1, OWLNamedObject o2) { + return o1.getIRI().compareTo(o2.getIRI()); + } + }; + Set<OWLClass> classes = new TreeSet<OWLClass>(namedObjectComparator); + Set<OWLObjectProperty> owlObjectProperties = new TreeSet<OWLObjectProperty>(namedObjectComparator); + Set<OWLDataProperty> owlDatatypeProperties = new TreeSet<OWLDataProperty>(namedObjectComparator); + Set<OWLNamedIndividual> owlIndividuals = new TreeSet<OWLNamedIndividual>(namedObjectComparator); - Set<OWLImportsDeclaration> directImports = new HashSet<OWLImportsDeclaration>(); + Set<OWLOntology> allImports = new HashSet<OWLOntology>(); + prefixes = new TreeMap<String, String>(); - for (KnowledgeSource source : sources) { + Set<OWLImportsDeclaration> directImports = new HashSet<OWLImportsDeclaration>(); - if (source instanceof OWLOntologyKnowledgeSource) { - ontology = ((OWLOntologyKnowledgeSource) source).createOWLOntology(manager); - owlAPIOntologies.add(ontology); - } else { - // This reasoner requires an ontology to process - throw new ComponentInitException( - "OWL API Reasoner Requires an OWLKnowledgeSource. Received a KS of type: " - + source.getClass().getName()); - } + for (KnowledgeSource source : sources) { - directImports.addAll(ontology.getImportsDeclarations()); + if (source instanceof OWLOntologyKnowledgeSource) { + ontology = ((OWLOntologyKnowledgeSource) source).createOWLOntology(manager); + owlAPIOntologies.add(ontology); + }else{ + //This reasoner requires an ontology to process + throw new ComponentInitException("OWL API Reasoner Requires an OWLKnowledgeSource. Received a KS of type: " + source.getClass().getName()); + } - try { - // imports includes the ontology itself - // FIXME this line throws the strange error - Set<OWLOntology> imports = manager.getImportsClosure(ontology); - allImports.addAll(imports); + directImports.addAll(ontology.getImportsDeclarations()); - // System.out.println(imports); - for (OWLOntology ont : imports) { - classes.addAll(ont.getClassesInSignature()); - owlObjectProperties.addAll(ont.getObjectPropertiesInSignature()); - owlDatatypeProperties.addAll(ont.getDataPropertiesInSignature()); - owlIndividuals.addAll(ont.getIndividualsInSignature()); - } + try { + // imports includes the ontology itself + //FIXME this line throws the strange error + Set<OWLOntology> imports = manager.getImportsClosure(ontology); + allImports.addAll(imports); - } catch (UnknownOWLOntologyException uooe) { - logger.error("UnknownOWLOntologyException occured, imports were not loaded! This is a bug, which has not been fixed yet."); - } +// System.out.println(imports); + for (OWLOntology ont : imports) { + classes.addAll(ont.getClassesInSignature()); + owlObjectProperties.addAll(ont.getObjectPropertiesInSignature()); + owlDatatypeProperties.addAll(ont.getDataPropertiesInSignature()); + owlIndividuals.addAll(ont.getIndividualsInSignature()); + } - // if several knowledge sources are included, then we can only - // guarantee that the base URI is from one of those sources (there - // can't be more than one); but we will take care that all prefixes - // are - // correctly imported - OWLOntologyFormat format = manager.getOntologyFormat(ontology); - if (format instanceof PrefixOWLOntologyFormat) { - prefixes.putAll(((PrefixOWLOntologyFormat) format).getPrefixName2PrefixMap()); - baseURI = ((PrefixOWLOntologyFormat) format).getDefaultPrefix(); - prefixes.remove(""); - } + } catch (UnknownOWLOntologyException uooe) { + logger.error("UnknownOWLOntologyException occured, imports were not loaded! This is a bug, which has not been fixed yet."); + } - } + // if several knowledge sources are included, then we can only + // guarantee that the base URI is from one of those sources (there + // can't be more than one); but we will take care that all prefixes are + // correctly imported + OWLOntologyFormat format = manager.getOntologyFormat(ontology); + if (format instanceof PrefixOWLOntologyFormat) { + prefixes.putAll(((PrefixOWLOntologyFormat) format).getPrefixName2PrefixMap()); + baseURI = ((PrefixOWLOntologyFormat) format).getDefaultPrefix(); + prefixes.remove(""); + } - // Now merge all of the knowledge sources into one ontology instance. - try { - // The following line illustrates a problem with using different - // OWLOntologyManagers. This can manifest itself if we have multiple - // sources who were created with different manager instances. - // ontology = - // OWLManager.createOWLOntologyManager().createOntology(IRI.create("http://dl-learner/all"), - // new HashSet<OWLOntology>(owlAPIOntologies)); - ontology = manager.createOntology(IRI.create("http://dl-learner/all"), - new HashSet<OWLOntology>(owlAPIOntologies)); - // we have to add all import declarations manually here, because - // this are no axioms - List<OWLOntologyChange> addImports = new ArrayList<OWLOntologyChange>(); - for (OWLImportsDeclaration i : directImports) { - addImports.add(new AddImport(ontology, i)); - } - manager.applyChanges(addImports); - } catch (OWLOntologyCreationException e1) { - e1.printStackTrace(); - } + } - // configure reasoner - ReasonerProgressMonitor progressMonitor = new NullReasonerProgressMonitor(); - FreshEntityPolicy freshEntityPolicy = FreshEntityPolicy.ALLOW; - long timeOut = Integer.MAX_VALUE; - IndividualNodeSetPolicy individualNodeSetPolicy = IndividualNodeSetPolicy.BY_NAME; - OWLReasonerConfiguration conf = new SimpleConfiguration(progressMonitor, freshEntityPolicy, - timeOut, individualNodeSetPolicy); + //Now merge all of the knowledge sources into one ontology instance. + try { + //The following line illustrates a problem with using different OWLOntologyManagers. This can manifest itself if we have multiple sources who were created with different manager instances. + //ontology = OWLManager.createOWLOntologyManager().createOntology(IRI.create("http://dl-learner/all"), new HashSet<OWLOntology>(owlAPIOntologies)); + ontology = manager.createOntology(IRI.create("http://dl-learner/all"), new HashSet<OWLOntology>(owlAPIOntologies)); + //we have to add all import declarations manually here, because this are no axioms + List<OWLOntologyChange> addImports = new ArrayList<OWLOntologyChange>(); + for (OWLImportsDeclaration i : directImports) { + addImports.add(new AddImport(ontology, i)); + } + manager.applyChanges(addImports); + } catch (OWLOntologyCreationException e1) { + e1.printStackTrace(); + } - // create actual reasoner - if (getReasonerTypeString().equals("fact")) { - try { - reasoner = new FaCTPlusPlusReasonerFactory().createNonBufferingReasoner(ontology, - conf); + //configure reasoner + ReasonerProgressMonitor progressMonitor = new NullReasonerProgressMonitor(); + FreshEntityPolicy freshEntityPolicy = FreshEntityPolicy.ALLOW; + long timeOut = Integer.MAX_VALUE; + IndividualNodeSetPolicy individualNodeSetPolicy = IndividualNodeSetPolicy.BY_NAME; + OWLReasonerConfiguration conf = new SimpleConfiguration(progressMonitor, freshEntityPolicy, timeOut, individualNodeSetPolicy); - } catch (Exception e) { - throw new RuntimeException(e); - } - System.out.println("Using FaCT++."); - } else if (getReasonerTypeString().equals("hermit")) { - // instantiate HermiT reasoner - reasoner = new ReasonerFactory().createNonBufferingReasoner(ontology, conf); - } else if (getReasonerTypeString().equals("pellet")) { - // instantiate Pellet reasoner - reasoner = PelletReasonerFactory.getInstance().createNonBufferingReasoner(ontology, - conf); - // change log level to WARN for Pellet, because otherwise log - // output will be very large - Logger pelletLogger = Logger.getLogger("org.mindswap.pellet"); - pelletLogger.setLevel(Level.WARN); - } else if (getReasonerTypeString().equals("elk")) { - // instantiate ELK reasoner - reasoner = new ElkReasonerFactory().createNonBufferingReasoner(ontology, conf); - // reasoner = new - // MyElkReasonerFactory().createNonBufferingReasoner(ontology, - // conf); - } else if (getReasonerTypeString().equals("cel")) { - // instantiate CEL reasoner - reasoner = new CelReasoner(ontology, conf); - } else { - try { - OWLlinkHTTPXMLReasonerFactory factory = new OWLlinkHTTPXMLReasonerFactory(); - URL url = new URL(getOwlLinkURL());// Configure the server - // end-point - OWLlinkReasonerConfiguration config = new OWLlinkReasonerConfiguration(url); - reasoner = factory.createNonBufferingReasoner(ontology, config); - System.out.println(reasoner.getReasonerName()); - } catch (Exception e) { - // e.printStackTrace(); - throw new ComponentInitException(e); - } - } + // create actual reasoner + if (getReasonerTypeString().equals("fact")) { + try { + reasoner = new FaCTPlusPlusReasonerFactory().createNonBufferingReasoner(ontology, conf); + } catch (Exception e) { + throw new RuntimeException(e); + } + System.out.println("Using FaCT++."); + } else if (getReasonerTypeString().equals("hermit")) { + // instantiate HermiT reasoner + reasoner = new ReasonerFactory().createNonBufferingReasoner(ontology, conf); + } else if (getReasonerTypeString().equals("pellet")) { + // instantiate Pellet reasoner + reasoner = PelletReasonerFactory.getInstance().createNonBufferingReasoner(ontology, conf); + // change log level to WARN for Pellet, because otherwise log + // output will be very large + Logger pelletLogger = Logger.getLogger("org.mindswap.pellet"); + pelletLogger.setLevel(Level.WARN); + } else if (getReasonerTypeString().equals("elk")) { + // instantiate ELK reasoner + reasoner = new ElkReasonerFactory().createNonBufferingReasoner(ontology, conf); + } else if (getReasonerTypeString().equals("cel")) { + // instantiate CEL reasoner + reasoner = new CelReasoner(ontology, conf); + } else if (getReasonerTypeString().equals("trowl")) { + // instantiate TrOWL reasoner + reasoner = new RELReasonerFactory().createNonBufferingReasoner(ontology, conf); + } else { + try { + OWLlinkHTTPXMLReasonerFactory factory = new OWLlinkHTTPXMLReasonerFactory(); + URL url = new URL(getOwlLinkURL());//Configure the server end-point + OWLlinkReasonerConfiguration config = new OWLlinkReasonerConfiguration(url); + reasoner = factory.createNonBufferingReasoner(ontology, config); + System.out.println(reasoner.getReasonerName()); + } catch (Exception e) { +// e.printStackTrace(); + throw new ComponentInitException(e); + } + } - /* - * Set<OWLOntology> importsClosure = - * manager.getImportsClosure(ontology); - * System.out.println("imports closure : " + importsClosure); try { - * reasoner.loadOntologies(importsClosure); } catch - * (OWLReasonerException e1) { // TODO Auto-generated catch block - * e1.printStackTrace(); } - */ + /* + Set<OWLOntology> importsClosure = manager.getImportsClosure(ontology); + System.out.println("imports closure : " + importsClosure); + try { + reasoner.loadOntologies(importsClosure); + } catch (OWLReasonerException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }*/ - // System.out.println(classes); - // System.out.println(properties); - // System.out.println(individuals); +// System.out.println(classes); +// System.out.println(properties); +// System.out.println(individuals); - // compute class hierarchy and types of individuals - // (done here to speed up later reasoner calls) - boolean inconsistentOntology = !reasoner.isConsistent(); + // compute class hierarchy and types of individuals + // (done here to speed up later reasoner calls) + boolean inconsistentOntology = !reasoner.isConsistent(); - if (!inconsistentOntology) { - reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY, - InferenceType.CLASS_ASSERTIONS); - } else { - throw new ComponentInitException("Inconsistent ontologies."); - } + if (!inconsistentOntology) { + reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY, InferenceType.CLASS_ASSERTIONS); + } else { + throw new ComponentInitException("Inconsistent ontologies."); + } - factory = manager.getOWLDataFactory(); + factory = manager.getOWLDataFactory(); - // try { - // if(reasoner.isDefined(factory.getOWLIndividual(URI.create("http://example.com/father#female")))) - // System.out.println("DEFINED."); - // else - // System.out.println("NOT DEFINED."); - // } catch (OWLReasonerException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } +// try { +// if(reasoner.isDefined(factory.getOWLIndividual(URI.create("http://example.com/father#female")))) +// System.out.println("DEFINED."); +// else +// System.out.println("NOT DEFINED."); +// } catch (OWLReasonerException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } - // read in primitives - for (OWLClass owlClass : classes) - atomicConcepts.add(new NamedClass(owlClass.toStringID())); - for (OWLObjectProperty owlProperty : owlObjectProperties) - atomicRoles.add(new ObjectProperty(owlProperty.toStringID())); - for (OWLDataProperty owlProperty : owlDatatypeProperties) { - DatatypeProperty dtp = new DatatypeProperty(owlProperty.toStringID()); - Set<OWLDataRange> ranges = owlProperty.getRanges(allImports); - Iterator<OWLDataRange> it = ranges.iterator(); - if (it.hasNext()) { - OWLDataRange range = it.next(); - if (range.isDatatype()) { - URI uri = ((OWLDatatype) range).getIRI().toURI(); - if (uri.equals(OWL2Datatype.BOOLEAN.getURI())) - booleanDatatypeProperties.add(dtp); - else if (uri.equals(OWL2Datatype.DOUBLE.getURI())) - doubleDatatypeProperties.add(dtp); - else if (uri.equals(OWL2Datatype.INT.getURI())) - intDatatypeProperties.add(dtp); - else if (uri.equals(OWL2Datatype.STRING.getURI())) - stringDatatypeProperties.add(dtp); - } - } else { - stringDatatypeProperties.add(dtp); - } - datatypeProperties.add(dtp); - } - for (OWLNamedIndividual owlIndividual : owlIndividuals) { - individuals.add(new Individual(owlIndividual.toStringID())); - } + // read in primitives + for (OWLClass owlClass : classes) + atomicConcepts.add(new NamedClass(owlClass.toStringID())); + for (OWLObjectProperty owlProperty : owlObjectProperties) + atomicRoles.add(new ObjectProperty(owlProperty.toStringID())); + for (OWLDataProperty owlProperty : owlDatatypeProperties) { + DatatypeProperty dtp = new DatatypeProperty(owlProperty.toStringID()); + Set<OWLDataRange> ranges = owlProperty.getRanges(allImports); + Iterator<OWLDataRange> it = ranges.iterator(); + if (it.hasNext()) { + OWLDataRange range = it.next(); + if (range.isDatatype()) { + URI uri = ((OWLDatatype) range).getIRI().toURI(); + if (uri.equals(OWL2Datatype.BOOLEAN.getURI())) booleanDatatypeProperties.add(dtp); + else if (uri.equals(OWL2Datatype.DOUBLE.getURI())) doubleDatatypeProperties.add(dtp); + else if (uri.equals(OWL2Datatype.INT.getURI())) intDatatypeProperties.add(dtp); + else if (uri.equals(OWL2Datatype.STRING.getURI())) stringDatatypeProperties.add(dtp); + } + } else { + stringDatatypeProperties.add(dtp); + } + datatypeProperties.add(dtp); + } + for (OWLNamedIndividual owlIndividual : owlIndividuals) { + individuals.add(new Individual(owlIndividual.toStringID())); + } - // remove top and bottom properties (for backwards compatibility) - // atomicRoles.remove(new - // ObjectProperty("http://www.w3.org/2002/07/owl#bottomObjectProperty")); - // atomicRoles.remove(new - // ObjectProperty("http://www.w3.org/2002/07/owl#topObjectProperty")); - } + // remove top and bottom properties (for backwards compatibility) +// atomicRoles.remove(new ObjectProperty("http://www.w3.org/2002/07/owl#bottomObjectProperty")); +// atomicRoles.remove(new ObjectProperty("http://www.w3.org/2002/07/owl#topObjectProperty")); + } - /* - * (non-Javadoc) - * - * @see org.dllearner.core.Reasoner#getAtomicConcepts() - */ - public Set<NamedClass> getNamedClasses() { - return Collections.unmodifiableSet(atomicConcepts); - } + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getAtomicConcepts() + */ + public Set<NamedClass> getNamedClasses() { + return Collections.unmodifiableSet(atomicConcepts); + } - /* - * (non-Javadoc) - * - * @see org.dllearner.core.Reasoner#getAtomicRoles() - */ - public Set<ObjectProperty> getObjectProperties() { - return Collections.unmodifiableSet(atomicRoles); - } + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getAtomicRoles() + */ + public Set<ObjectProperty> getObjectProperties() { + return Collections.unmodifiableSet(atomicRoles); + } - @Override - public SortedSet<DatatypeProperty> getDatatypePropertiesImpl() { - return datatypeProperties; - } + @Override + public SortedSet<DatatypeProperty> getDatatypePropertiesImpl() { + return datatypeProperties; + } - /* - * (non-Javadoc) - * - * @see org.dllearner.core.Reasoner#getIndividuals() - */ - public SortedSet<Individual> getIndividuals() { - return individuals; - } + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getIndividuals() + */ + public SortedSet<Individual> getIndividuals() { + return individuals; + } - /* - * (non-Javadoc) - * - * @see org.dllearner.core.Reasoner#getReasonerType() - */ - @Override - public ReasonerType getReasonerType() { - if (getReasonerTypeString().equals("fact")) { - return ReasonerType.OWLAPI_FACT; - } else if (getReasonerTypeString().equals("hermit")) { - return ReasonerType.OWLAPI_HERMIT; - } else { - return ReasonerType.OWLAPI_PELLET; - } - } + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getReasonerType() + */ + @Override + public ReasonerType getReasonerType() { + if (getReasonerTypeString().equals("fact")) { + return ReasonerType.OWLAPI_FACT; + } else if (getReasonerTypeString().equals("hermit")) { + return ReasonerType.OWLAPI_HERMIT; + } else { + return ReasonerType.OWLAPI_PELLET; + } + } - // @Override - // public ObjectPropertyHierarchy prepareRoleHierarchy() { - // // code copied from DIG reasoner - // - // TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new - // TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - // roleComparator); - // TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new - // TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - // roleComparator); - // - // // refinement of atomic concepts - // for (ObjectProperty role : atomicRoles) { - // roleHierarchyDown.put(role, getMoreSpecialRolesImpl(role)); - // roleHierarchyUp.put(role, getMoreGeneralRolesImpl(role)); - // } - // - // roleHierarchy = new ObjectPropertyHierarchy(atomicRoles, roleHierarchyUp, - // roleHierarchyDown); - // return roleHierarchy; - // } +// @Override +// public ObjectPropertyHierarchy prepareRoleHierarchy() { +// // code copied from DIG reasoner +// +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// +// // refinement of atomic concepts +// for (ObjectProperty role : atomicRoles) { +// roleHierarchyDown.put(role, getMoreSpecialRolesImpl(role)); +// roleHierarchyUp.put(role, getMoreGeneralRolesImpl(role)); +// } +// +// roleHierarchy = new ObjectPropertyHierarchy(atomicRoles, roleHierarchyUp, +// roleHierarchyDown); +// return roleHierarchy; +// } - /* - * (non-Javadoc) - * - * @see org.dllearner.core.Reasoner#prepareRoleHierarchy(java.util.Set) - */ - // public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { - // // code copied from DIG reasoner - // - // TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new - // TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - // roleComparator); - // TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new - // TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( - // roleComparator); - // - // // refinement of atomic concepts - // for (ObjectProperty role : atomicRoles) { - // roleHierarchyDown.put(role, getMoreSpecialRolesImpl(role)); - // roleHierarchyUp.put(role, getMoreGeneralRolesImpl(role)); - // } - // - // roleHierarchy = new ObjectPropertyHierarchy(allowedRoles, - // roleHierarchyUp, - // roleHierarchyDown); - // } + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#prepareRoleHierarchy(java.util.Set) + */ +// public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { +// // code copied from DIG reasoner +// +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyUp = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// TreeMap<ObjectProperty, TreeSet<ObjectProperty>> roleHierarchyDown = new TreeMap<ObjectProperty, TreeSet<ObjectProperty>>( +// roleComparator); +// +// // refinement of atomic concepts +// for (ObjectProperty role : atomicRoles) { +// roleHierarchyDown.put(role, getMoreSpecialRolesImpl(role)); +// roleHierarchyUp.put(role, getMoreGeneralRolesImpl(role)); +// } +// +// roleHierarchy = new ObjectPropertyHierarchy(allowedRoles, roleHierarchyUp, +// roleHierarchyDown); +// } - // @Override - // public ObjectPropertyHierarchy getRoleHierarchy() { - // return roleHierarchy; - // } +// @Override +// public ObjectPropertyHierarchy getRoleHierarchy() { +// return roleHierarchy; +// } - // public void prepareDatatypePropertyHierarchyImpl(Set<DatatypeProperty> - // allowedRoles) { - // // code copied from DIG reasoner - // - // TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>> - // datatypePropertyHierarchyUp = new TreeMap<DatatypeProperty, - // TreeSet<DatatypeProperty>>( - // roleComparator); - // TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>> - // datatypePropertyHierarchyDown = new TreeMap<DatatypeProperty, - // TreeSet<DatatypeProperty>>( - // roleComparator); - // - // // refinement of atomic concepts - // for (DatatypeProperty role : datatypeProperties) { - // datatypePropertyHierarchyDown.put(role, - // getMoreSpecialDatatypePropertiesImpl(role)); - // datatypePropertyHierarchyUp.put(role, - // getMoreGeneralDatatypePropertiesImpl(role)); - // } - // - // datatypePropertyHierarchy = new DatatypePropertyHierarchy(allowedRoles, - // datatypePropertyHierarchyUp, - // datatypePropertyHierarchyDown); - // } +// public void prepareDatatypePropertyHierarchyImpl(Set<DatatypeProperty> allowedRoles) { +// // code copied from DIG reasoner +// +// TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>> datatypePropertyHierarchyUp = new TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>>( +// roleComparator); +// TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>> datatypePropertyHierarchyDown = new TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>>( +// roleComparator); +// +// // refinement of atomic concepts +// for (DatatypeProperty role : datatypeProperties) { +// datatypePropertyHierarchyDown.put(role, getMoreSpecialDatatypePropertiesImpl(role)); +// datatypePropertyHierarchyUp.put(role, getMoreGeneralDatatypePropertiesImpl(role)); +// } +// +// datatypePropertyHierarchy = new DatatypePropertyHierarchy(allowedRoles, datatypePropertyHierarchyUp, +// datatypePropertyHierarchyDown); +// } - // @Override - // public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { - // return datatypePropertyHierarchy; - // } +// @Override +// public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { +// return datatypePropertyHierarchy; +// } - @Override - public boolean isSuperClassOfImpl(Description superConcept, Description subConcept) { - return reasoner.isEntailed(factory.getOWLSubClassOfAxiom( - OWLAPIDescriptionConvertVisitor.getOWLClassExpression(subConcept), - OWLAPIDescriptionConvertVisitor.getOWLClassExpression(superConcept))); - } + @Override + public boolean isSuperClassOfImpl(Description superConcept, Description subConcept) { + return reasoner.isEntailed(factory.getOWLSubClassOfAxiom(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(subConcept), OWLAPIDescriptionConvertVisitor.getOWLClassExpression(superConcept))); + } - @Override - protected boolean isEquivalentClassImpl(Description class1, Description class2) { - return reasoner.isEntailed(factory.getOWLEquivalentClassesAxiom( - OWLAPIDescriptionConvertVisitor.getOWLClassExpression(class1), - OWLAPIDescriptionConvertVisitor.getOWLClassExpression(class2))); - } + @Override + protected boolean isEquivalentClassImpl(Description class1, Description class2) { + return reasoner.isEntailed(factory.getOWLEquivalentClassesAxiom(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(class1), OWLAPIDescriptionConvertVisitor.getOWLClassExpression(class2))); + } - @Override - protected TreeSet<Description> getSuperClassesImpl(Description concept) { - NodeSet<OWLClass> classes = null; + @Override + protected TreeSet<Description> getSuperClassesImpl(Description concept) { + NodeSet<OWLClass> classes = null; - classes = reasoner.getSuperClasses( - OWLAPIDescriptionConvertVisitor.getOWLClassExpression(concept), true); + classes = reasoner.getSuperClasses(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(concept), true); - return getFirstClasses(classes); - } + return getFirstClasses(classes); + } - @Override - protected TreeSet<Description> getSubClassesImpl(Description concept) { - NodeSet<OWLClass> classes = null; + @Override + protected TreeSet<Description> getSubClassesImpl(Description concept) { + NodeSet<OWLClass> classes = null; - classes = reasoner.getSubClasses( - OWLAPIDescriptionConvertVisitor.getOWLClassExpression(concept), true); + classes = reasoner.getSubClasses(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(concept), true); - return getFirstClasses(classes); - } + return getFirstClasses(classes); + } - @Override - protected TreeSet<ObjectProperty> getSuperPropertiesImpl(ObjectProperty role) { - NodeSet<OWLObjectPropertyExpression> properties = null; + @Override + protected TreeSet<ObjectProperty> getSuperPropertiesImpl(ObjectProperty role) { + NodeSet<OWLObjectPropertyExpression> properties = null; - try { - properties = reasoner.getSuperObjectProperties( - OWLAPIConverter.getOWLAPIObjectProperty(role), true); - return getFirstObjectProperties(properties); - } catch (Exception e) { - TreeSet<ObjectProperty> roles = new TreeSet<ObjectProperty>(roleComparator); - return roles; - } - } + properties = reasoner.getSuperObjectProperties(OWLAPIConverter.getOWLAPIObjectProperty(role), true); - @Override - protected TreeSet<ObjectProperty> getSubPropertiesImpl(ObjectProperty role) { - NodeSet<OWLObjectPropertyExpression> properties = null; + return getFirstObjectProperties(properties); + } - try { - properties = reasoner.getSubObjectProperties( - OWLAPIConverter.getOWLAPIObjectProperty(role), true); - return getFirstObjectProperties(properties); - } catch (Exception e) { - TreeSet<ObjectProperty> roles = new TreeSet<ObjectProperty>(roleComparator); - return roles; - } + @Override + protected TreeSet<ObjectProperty> getSubPropertiesImpl(ObjectProperty role) { + NodeSet<OWLObjectPropertyExpression> properties = null; - } + properties = reasoner.getSubObjectProperties(OWLAPIConverter.getOWLAPIObjectProperty(role), true); - @Override - protected TreeSet<DatatypeProperty> getSuperPropertiesImpl(DatatypeProperty role) { - NodeSet<OWLDataProperty> properties = null; + return getFirstObjectProperties(properties); + } - properties = reasoner.getSuperDataProperties(OWLAPIConverter.getOWLAPIDataProperty(role), - true); + @Override + protected TreeSet<DatatypeProperty> getSuperPropertiesImpl(DatatypeProperty role) { + NodeSet<OWLDataProperty> properties = null; - return getFirstDatatypeProperties(properties); - } + properties = reasoner.getSuperDataProperties(OWLAPIConverter.getOWLAPIDataProperty(role), true); - @Override - protected TreeSet<DatatypeProperty> getSubPropertiesImpl(DatatypeProperty role) { - NodeSet<OWLDataProperty> properties = null; + return getFirstDatatypeProperties(properties); + } - properties = reasoner.getSubDataProperties(OWLAPIConverter.getOWLAPIDataProperty(role), - true); + @Override + protected TreeSet<DatatypeProperty> getSubPropertiesImpl(DatatypeProperty role) { + NodeSet<OWLDataProperty> properties = null; - return getFirstDatatypeProperties(properties); - } + properties = reasoner.getSubDataProperties(OWLAPIConverter.getOWLAPIDataProperty(role), true); - @Override - public boolean hasTypeImpl(Description concept, Individual individual) { - boolean test = false; - OWLClassExpression d = OWLAPIDescriptionConvertVisitor.getOWLClassExpression(concept); - OWLNamedIndividual i = factory.getOWLNamedIndividual(IRI.create(individual.getName())); -// try { -// test = reasoner.isEntailed(factory.getOWLClassAssertionAxiom(d, i)); -// } catch (Exception e) { -// test = true; -// } - if(d.isAnonymous()){ - throw new UnsupportedOperationException("Can not do type checking for complex class expressions."); - } - for(OWLClass type : reasoner.getTypes(i, false).getFlattened()){ - if(type.equals(d.asOWLClass())){ - return true; - } - } - return test; - } + return getFirstDatatypeProperties(properties); + } - @Override - public SortedSet<Individual> getIndividualsImpl(Description concept) { - // OWLDescription d = getOWLAPIDescription(concept); - OWLClassExpression d = OWLAPIDescriptionConvertVisitor.getOWLClassExpression(concept); - Set<OWLNamedIndividual> individuals = reasoner.getInstances(d, false).getFlattened(); - SortedSet<Individual> inds = new TreeSet<Individual>(); - for (OWLNamedIndividual ind : individuals) - // ugly code - if (ind != null) - inds.add(new Individual(ind.toStringID())); - return inds; - } + @Override + public boolean hasTypeImpl(Description concept, Individual individual) { + OWLClassExpression d = OWLAPIDescriptionConvertVisitor.getOWLClassExpression(concept); + OWLIndividual i = factory.getOWLNamedIndividual(IRI.create(individual.getName())); + if(concept instanceof Thing) return true; + if(concept instanceof NamedClass && ((NamedClass)concept).getName().contains("Error"))return false; + return reasoner.isEntailed(factory.getOWLClassAssertionAxiom(d, i)); + } - @Override - public Set<NamedClass> getTypesImpl(Individual individual) { - Set<Node<OWLClass>> result = null; + @Override + public SortedSet<Individual> getIndividualsImpl(Description concept) { +// OWLDescription d = getOWLAPIDescription(concept); + OWLClassExpression d = OWLAPIDescriptionConvertVisitor.getOWLClassExpression(concept); + Set<OWLNamedIndividual> individuals = reasoner.getInstances(d, false).getFlattened(); + SortedSet<Individual> inds = new TreeSet<Individual>(); + for (OWLNamedIndividual ind : individuals) + //ugly code + if (ind != null) inds.add(new Individual(ind.toStringID())); + return inds; + } - result = reasoner.getTypes(factory.getOWLNamedIndividual(IRI.create(individual.getName())), - false).getNodes(); + @Override + public Set<NamedClass> getTypesImpl(Individual individual) { + Set<Node<OWLClass>> result = null; - return getFirstClassesNoTopBottom(result); - } + result = reasoner.getTypes(factory.getOWLNamedIndividual(IRI.create(individual.getName())), false).getNodes(); - @Override - public boolean isSatisfiableImpl() { - return reasoner.isSatisfiable(factory.getOWLThing()); - } + return getFirstClassesNoTopBottom(result); + } - @Override - public Description getDomainImpl(ObjectProperty objectProperty) { - OWLObjectProperty prop = OWLAPIConverter.getOWLAPIObjectProperty(objectProperty); + @Override + public boolean isSatisfiableImpl() { + return reasoner.isSatisfiable(factory.getOWLThing()); + } - // Pellet returns a set of nodes of named classes, which are more - // general than the actual domain/range - NodeSet<OWLClass> set; + @Override + public Description getDomainImpl(ObjectProperty objectProperty) { + OWLObjectProperty prop = OWLAPIConverter.getOWLAPIObjectProperty(objectProperty); + + // Pellet returns a set of nodes of named classes, which are more + // general than the actual domain/range + NodeSet<OWLClass> set; try { set = reasoner.getObjectPropertyDomains(prop, false); return getDescriptionFromReturnedDomain(set); - } catch (Exception e) { - return getDescriptionFromReturnedDomain(null); + } catch (InconsistentOntologyException e) { + e.printStackTrace(); + } catch (FreshEntitiesException e) { + e.printStackTrace(); + } catch (TimeOutException e) { + e.printStackTrace(); + } catch (ReasonerInterruptedException e) { + e.printStackTrace(); + } catch(de.tudresden.inf.lat.cel.owlapi.UnsupportedReasonerOperationInCelException e){ + e.printStackTrace(); } - } + return Thing.instance; - @Override - public Description getDomainImpl(DatatypeProperty datatypeProperty) { - OWLDataProperty prop = OWLAPIConverter.getOWLAPIDataProperty(datatypeProperty); + } - NodeSet<OWLClass> set = reasoner.getDataPropertyDomains(prop, true); - return getDescriptionFromReturnedDomain(set); + @Override + public Description getDomainImpl(DatatypeProperty datatypeProperty) { + OWLDataProperty prop = OWLAPIConverter.getOWLAPIDataProperty(datatypeProperty); - } + NodeSet<OWLClass> set = reasoner.getDataPropertyDomains(prop, true); + return getDescriptionFromReturnedDomain(set); - @Override - public Description getRangeImpl(ObjectProperty objectProperty) { - OWLObjectProperty prop = OWLAPIConverter.getOWLAPIObjectProperty(objectProperty); + } - NodeSet<OWLClass> set; + @Override + public Description getRangeImpl(ObjectProperty objectProperty) { + OWLObjectProperty prop = OWLAPIConverter.getOWLAPIObjectProperty(objectProperty); + + NodeSet<OWLClass> set; try { set = reasoner.getObjectPropertyRanges(prop, true); - if (set.isEmpty()) - return new Thing(); - OWLClass oc = set.iterator().next().getRepresentativeElement(); - if (oc.isOWLThing()) { - return Thing.instance; - } - return new NamedClass(oc.toStringID()); - } catch (Exception e) { - return Thing.instance; + if (set.isEmpty()) return new Thing(); + OWLClass oc = set.iterator().next().getRepresentativeElement(); + if (oc.isOWLThing()) { + return Thing.instance; + } + return new NamedClass(oc.toStringID()); + } catch (InconsistentOntologyException e) { + e.printStackTrace(); + } catch (FreshEntitiesException e) { + e.printStackTrace(); + } catch (TimeOutException e) { + e.printStackTrace(); + } catch (ReasonerInterruptedException e) { + e.printStackTrace(); + } catch(de.tudresden.inf.lat.cel.owlapi.UnsupportedReasonerOperationInCelException e){ + e.printStackTrace(); } - } + return Thing.instance; - private Description getDescriptionFromReturnedDomain(NodeSet<OWLClass> set) { - if (set.isEmpty()) - return new Thing(); + } - Set<OWLClassExpression> union = new HashSet<OWLClassExpression>(); - Set<OWLClassExpression> domains = new HashSet<OWLClassExpression>(); + private Description getDescriptionFromReturnedDomain(NodeSet<OWLClass> set) { + if (set.isEmpty()) return new Thing(); - for (Node<OWLClass> descs : set) { - for (OWLClassExpression desc : descs) { - union.add(desc); - } - } - for (OWLClassExpression desc : union) { - boolean isSuperClass = false; - for (Description d : getClassHierarchy().getSubClasses( - OWLAPIConverter.convertClass(desc.asOWLClass()))) { - if (union.contains(OWLAPIConverter.getOWLAPIDescription(d))) { - isSuperClass = true; - break; - } - } - if (!isSuperClass) { - domains.add(desc); - } - } + Set<OWLClassExpression> union = new HashSet<OWLClassExpression>(); + Set<OWLClassExpression> domains = new HashSet<OWLClassExpression>(); - OWLClass oc = (OWLClass) domains.iterator().next(); - if (oc.isOWLThing()) { - return new Thing(); - } else { - return new NamedClass(oc.toStringID()); - } - } + for (Node<OWLClass> descs : set) { + for (OWLClassExpression desc : descs) { + union.add(desc); + } + } + for (OWLClassExpression desc : union) { + boolean isSuperClass = false; + for (Description d : getClassHierarchy().getSubClasses(OWLAPIConverter.convertClass(desc.asOWLClass()))) { + if (union.contains(OWLAPIConverter.getOWLAPIDescription(d))) { + isSuperClass = true; + break; + } + } + if (!isSuperClass) { + domains.add(desc); + } + } - @Override - public Map<Individual, SortedSet<Individual>> getPropertyMembersImpl(ObjectProperty atomicRole) { - OWLObjectProperty prop = OWLAPIConverter.getOWLAPIObjectProperty(atomicRole); - Map<Individual, SortedSet<Individual>> map = new TreeMap<Individual, SortedSet<Individual>>(); - for (Individual i : individuals) { - OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI.create(i.getName())); + OWLClass oc = (OWLClass) domains.iterator().next(); + if (oc.isOWLThing()) { + return new Thing(); + } else { + return new NamedClass(oc.toStringID()); + } + } - // get all related individuals via OWL API - Set<OWLNamedIndividual> inds; - try { - inds = reasoner.getObjectPropertyValues(ind, prop).getFlattened(); - } catch (Exception e) { - inds = null; - } + @Override + public Map<Individual, SortedSet<Individual>> getPropertyMembersImpl(ObjectProperty atomicRole) { + OWLObjectProperty prop = OWLAPIConverter.getOWLAPIObjectProperty(atomicRole); + Map<Individual, SortedSet<Individual>> map = new TreeMap<Individual, SortedSet<Individual>>(); + for (Individual i : individuals) { + OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI.create(i.getName())); - // convert data back to DL-Learner structures - SortedSet<Individual> is = new TreeSet<Individual>(); - try { - for (OWLNamedIndividual oi : inds) - is.add(new Individual(oi.toStringID())); - map.put(i, is); - } catch (Exception e) { - map = null; - } - } - return map; - } + // get all related individuals via OWL API + Set<OWLNamedIndividual> inds = reasoner.getObjectPropertyValues(ind, prop).getFlattened(); - @Override - protected Map<ObjectProperty, Set<Individual>> getObjectPropertyRelationshipsImpl( - Individual individual) { - OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI.create(individual.getName())); - Map<OWLObjectPropertyExpression, Set<OWLNamedIndividual>> mapAPI = new HashMap<OWLObjectPropertyExpression, Set<OWLNamedIndividual>>(); + // convert data back to DL-Learner structures + SortedSet<Individual> is = new TreeSet<Individual>(); + for (OWLNamedIndividual oi : inds) + ... [truncated message content] |
From: <lor...@us...> - 2013-01-22 09:47:32
|
Revision: 3884 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3884&view=rev Author: lorenz_b Date: 2013-01-22 09:47:20 +0000 (Tue, 22 Jan 2013) Log Message: ----------- Moving QTL algorithm to core module. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeFactory.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/cache/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/cache/QueryTreeCache.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/NodeRenderer.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/GeneralisedQueryTree.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeChange.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/examples/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/examples/DBpediaExample.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/examples/LinkedGeoDataExample.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/exception/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/exception/EmptyLGGException.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/exception/NBRException.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/exception/NegativeTreeCoverageExecption.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/exception/QTLException.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/exception/TimeOutException.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/ExactMatchFilter.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/Filter.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/Filters.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/I_Sub.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/QueryTreeFilter.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/QuestionBasedQueryTreeFilter.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/QuestionBasedQueryTreeFilterAggressive.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/QuestionBasedStatementFilter.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/QuestionBasedStatementFilter2.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/QuestionBasedStatementSelector.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/filters/ZeroFilter.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl2.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/FilterVisitor.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/Generalisation.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/NBR.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/PostLGG.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGenerator.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/nbr/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/nbr/NBRGenerator.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/nbr/NBRGeneratorImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/nbr/strategy/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/nbr/strategy/BruteForceNBRStrategy.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/nbr/strategy/GreedyNBRStrategy.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/nbr/strategy/NBRStrategy.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/nbr/strategy/TagNonSubsumingPartsNBRStrategy.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/Prefixes.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/SPARQLEndpointEx.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/TreeHelper.java trunk/components-core/src/test/java/org/dllearner/algorithms/ trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/ trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/GeneralisationTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/NBRTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/QTLTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/TreeSubsumptionTest.java Property Changed: ---------------- trunk/components-core/ Property changes on: trunk/components-core ___________________________________________________________________ Modified: svn:ignore - components-core.iml target log .classpath .project .settings + components-core.iml target log .classpath .project .settings cache Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-01-22 09:43:25 UTC (rev 3883) +++ trunk/components-core/pom.xml 2013-01-22 09:47:20 UTC (rev 3884) @@ -113,11 +113,18 @@ </exclusions> </dependency> - <!-- THIS IS FROM THE UNIBAS REPO --> <dependency> <groupId>net.sourceforge.owlapi</groupId> - <artifactId>owlapi</artifactId> + <artifactId>owlapi-distribution</artifactId> </dependency> + <dependency> + <groupId>net.sourceforge.owlapi</groupId> + <artifactId>owlapi-reasoner</artifactId> +</dependency> +<dependency> + <groupId>net.sourceforge.owlapi</groupId> + <artifactId>owlapi-util</artifactId> + </dependency> <!-- THIS IS FROM THE UNIBAS REPO --> <dependency> @@ -253,6 +260,12 @@ <artifactId>xercesImpl</artifactId> <version>2.8.0</version> </dependency> + + <dependency> + <groupId>uk.ac.shef.wit</groupId> + <artifactId>simmetrics</artifactId> + <version>1.6.2</version> + </dependency> </dependencies> <dependencyManagement> <dependencies> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java 2013-01-22 09:43:25 UTC (rev 3883) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/DisjointClassesLearner.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -178,12 +178,12 @@ class2Overlap.put(cls, cnt); } //for each property in knowledge base - for(NamedClass cls : allClasses){ + for(NamedClass cls : allClasses){if(!cls.toString().equals("http://dbpedia.org/ontology/MotorcycleRider"))continue; //get the popularity int otherPopularity = reasoner.getPopularity(cls); if(otherPopularity == 0){//skip empty properties continue; - } + }System.out.println(cls); //get the overlap int overlap = class2Overlap.containsKey(cls) ? class2Overlap.get(cls) : 0; //compute the estimated precision @@ -455,7 +455,8 @@ ks = new LocalModelBasedSparqlEndpointKS(new URL("http://dl-learner.svn.sourceforge.net/viewvc/dl-learner/trunk/examples/swore/swore.rdf?revision=2217")); ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW()); DisjointClassesLearner l = new DisjointClassesLearner(ks); - l.setClassToDescribe(new NamedClass("http://dbpedia.org/ontology/Book")); + l.setClassToDescribe(new NamedClass("http://dbpedia.org/ontology/Agent")); + l.setMaxExecutionTimeInSeconds(60); l.init(); l.getReasoner().prepareSubsumptionHierarchy(); l.getReasoner().precomputeClassPopularity(); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2013-01-22 09:43:25 UTC (rev 3883) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -164,7 +164,7 @@ public static void main(String[] args) throws Exception{ FunctionalObjectPropertyAxiomLearner l = new FunctionalObjectPropertyAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia())); - l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/league")); + l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/currency")); l.setMaxExecutionTimeInSeconds(20); l.setForceSPARQL_1_0_Mode(true); l.init(); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java 2013-01-22 09:43:25 UTC (rev 3883) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -206,14 +206,14 @@ ObjectPropertyDomainAxiomLearner l = new ObjectPropertyDomainAxiomLearner(ks); l.setReasoner(reasoner); - l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/grammyAward")); + l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/anthem")); l.setMaxExecutionTimeInSeconds(40); - l.addFilterNamespace("http://dbpedia.org/ontology/"); +// l.addFilterNamespace("http://dbpedia.org/ontology/"); // l.setReturnOnlyNewAxioms(true); l.init(); l.start(); - System.out.println(l.getCurrentlyBestEvaluatedAxioms(10, 0.3)); + System.out.println(l.getCurrentlyBestEvaluatedAxioms()); } } Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -0,0 +1,387 @@ +/** + * Copyright (C) 2007-2011, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.algorithms.qtl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.apache.commons.collections15.ListUtils; +import org.apache.log4j.Logger; +import org.dllearner.algorithms.qtl.cache.QueryTreeCache; +import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; +import org.dllearner.algorithms.qtl.exception.EmptyLGGException; +import org.dllearner.algorithms.qtl.exception.NegativeTreeCoverageExecption; +import org.dllearner.algorithms.qtl.exception.TimeOutException; +import org.dllearner.algorithms.qtl.filters.QueryTreeFilter; +import org.dllearner.algorithms.qtl.operations.NBR; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGenerator; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGeneratorImpl; +import org.dllearner.algorithms.qtl.util.SPARQLEndpointEx; +import org.dllearner.core.AbstractComponent; +import org.dllearner.core.AbstractLearningProblem; +import org.dllearner.core.ComponentAnn; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.SparqlQueryLearningAlgorithm; +import org.dllearner.core.options.CommonConfigOptions; +import org.dllearner.core.options.ConfigOption; +import org.dllearner.core.options.IntegerConfigOption; +import org.dllearner.core.owl.Individual; +import org.dllearner.kb.SparqlEndpointKS; +import org.dllearner.kb.sparql.CachingConciseBoundedDescriptionGenerator; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGeneratorImpl; +import org.dllearner.kb.sparql.ExtractionDBCache; +import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.utilities.Helper; +import org.springframework.beans.factory.annotation.Autowired; + +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSetRewindable; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.Statement; +import com.hp.hpl.jena.util.iterator.Filter; + +/** + * + * Learning algorithm for SPARQL queries based on so called query trees. + * + * @author Lorenz Bühmann + * @author Jens Lehmann + * + * + */ +@ComponentAnn(name="query tree learner", shortName="qtl", version=0.8) +public class QTL extends AbstractComponent implements SparqlQueryLearningAlgorithm { + + private static final Logger logger = Logger.getLogger(QTL.class); + + private LearningProblem learningProblem; + private SparqlEndpointKS endpointKS; +// private QTLConfigurator configurator; + + private SparqlEndpoint endpoint; + private ExtractionDBCache cache; + + private QueryTreeCache treeCache; + + private LGGGenerator<String> lggGenerator; + private NBR<String> nbr; + + private List<String> posExamples; + private List<String> negExamples; + + private List<QueryTree<String>> posExampleTrees; + private List<QueryTree<String>> negExampleTrees; + + private QueryTreeFilter queryTreeFilter; + + private ConciseBoundedDescriptionGenerator cbdGenerator; + + private int maxExecutionTimeInSeconds = 60; + private int maxQueryTreeDepth = 2; + + private QueryTree<String> lgg; + private SortedSet<String> lggInstances; + + public static Collection<ConfigOption<?>> createConfigOptions() { + Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); + options.add(CommonConfigOptions.maxExecutionTimeInSeconds(10)); + options.add(new IntegerConfigOption("maxQueryTreeDepth", "recursion depth of query tree extraction", 2)); + return options; + } + + public QTL() { + + } + + public QTL(AbstractLearningProblem learningProblem, SparqlEndpointKS endpointKS) throws LearningProblemUnsupportedException{ + if(!(learningProblem instanceof PosOnlyLP || learningProblem instanceof PosNegLP)){ + throw new LearningProblemUnsupportedException(learningProblem.getClass(), getClass()); + } + this.learningProblem = learningProblem; + this.endpointKS = endpointKS; + +// this.configurator = new QTLConfigurator(this); + } + + public QTL(SPARQLEndpointEx endpoint, ExtractionDBCache cache) { + this.endpoint = endpoint; + this.cache = cache; + + treeCache = new QueryTreeCache(); + cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(endpoint, cache)); + cbdGenerator.setRecursionDepth(maxQueryTreeDepth); + + lggGenerator = new LGGGeneratorImpl<String>(); + nbr = new NBR<String>(endpoint, cache); + nbr.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); + + posExampleTrees = new ArrayList<QueryTree<String>>(); + negExampleTrees = new ArrayList<QueryTree<String>>(); + } + + public String getQuestion(List<String> posExamples, List<String> negExamples) throws EmptyLGGException, NegativeTreeCoverageExecption, TimeOutException { + this.posExamples = posExamples; + this.negExamples = negExamples; + + generatePositiveExampleTrees(); + generateNegativeExampleTrees(); + + if(negExamples.isEmpty()){ + QueryTree<String> dummyNegTree = new QueryTreeImpl<String>("?"); + dummyNegTree.addChild(new QueryTreeImpl<String>("?"), "dummy"); + negExampleTrees.add(dummyNegTree); + } + + lgg = lggGenerator.getLGG(posExampleTrees); + + if(queryTreeFilter != null){ + lgg = queryTreeFilter.getFilteredQueryTree(lgg); + } + if(logger.isDebugEnabled()){ + logger.debug("LGG: \n" + lgg.getStringRepresentation()); + } + if(lgg.isEmpty()){ + throw new EmptyLGGException(); + } + + int index = coversNegativeQueryTree(lgg); + if(index != -1){ + throw new NegativeTreeCoverageExecption(negExamples.get(index)); + } + + lggInstances = getResources(lgg); + nbr.setLGGInstances(lggInstances); + + String question = nbr.getQuestion(lgg, negExampleTrees, getKnownResources()); + + return question; + } + + public void setExamples(List<String> posExamples, List<String> negExamples){ + this.posExamples = posExamples; + this.negExamples = negExamples; + } + + public void addStatementFilter(Filter<Statement> filter){ + treeCache.setStatementFilter(filter); + } + + public void addQueryTreeFilter(QueryTreeFilter queryTreeFilter){ + this.queryTreeFilter = queryTreeFilter; + } + + public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds){ + this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds; + nbr.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); + } + + public void setMaxQueryTreeDepth(int maxQueryTreeDepth){ + this.maxQueryTreeDepth = maxQueryTreeDepth; + cbdGenerator.setRecursionDepth(maxQueryTreeDepth); + } + + public String getSPARQLQuery(){ + if(lgg == null){ + lgg = lggGenerator.getLGG(getQueryTrees(posExamples)); + } + return lgg.toSPARQLQueryString(); + } + + public void setRestrictToNamespaces(List<String> namespaces){ + cbdGenerator.setRestrictToNamespaces(namespaces); + } + + private void generatePositiveExampleTrees(){ + posExampleTrees.clear(); + posExampleTrees.addAll(getQueryTrees(posExamples)); + } + + private void generateNegativeExampleTrees(){ + negExampleTrees.clear(); + negExampleTrees.addAll(getQueryTrees(negExamples)); + } + + private List<QueryTree<String>> getQueryTrees(List<String> resources){ + List<QueryTree<String>> trees = new ArrayList<QueryTree<String>>(); + Model model; + QueryTree<String> tree; + for(String resource : resources){ + if(logger.isDebugEnabled()){ + logger.debug("Tree for resource " + resource); + } + model = cbdGenerator.getConciseBoundedDescription(resource); + tree = treeCache.getQueryTree(resource, model); + if(logger.isDebugEnabled()){ + logger.debug(tree.getStringRepresentation()); + } + trees.add(tree); + } + return trees; + } + + private List<String> getKnownResources(){ + return ListUtils.union(posExamples, negExamples); + } + +// private boolean coversNegativeQueryTree(QueryTree<String> tree){ +// for(QueryTree<String> negTree : negExampleTrees){ +// if(negTree.isSubsumedBy(tree)){ +// return true; +// } +// } +// return false; +// } + + private int coversNegativeQueryTree(QueryTree<String> tree){ + for(int i = 0; i < negExampleTrees.size(); i++){ + if(negExampleTrees.get(i).isSubsumedBy(tree)){ + return i; + } + } + return -1; + } + + private SortedSet<String> getResources(QueryTree<String> tree){ + SortedSet<String> resources = new TreeSet<String>(); + String query = getDistinctSPARQLQuery(tree); + String result = cache.executeSelectQuery(endpoint, query); + ResultSetRewindable rs = SparqlQuery.convertJSONtoResultSet(result); + String uri; + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + uri = qs.getResource("x0").getURI(); + resources.add(uri); + } + return resources; + } + + private String getDistinctSPARQLQuery(QueryTree<String> tree){ + String query = tree.toSPARQLQueryString(); +// query = "SELECT DISTINCT " + query.substring(7); + return query; + } + + @Override + public void start(){ + generatePositiveExampleTrees(); + + lgg = lggGenerator.getLGG(posExampleTrees); + + if(queryTreeFilter != null){ + lgg = queryTreeFilter.getFilteredQueryTree(lgg); + } + if(logger.isDebugEnabled()){ + logger.debug("LGG: \n" + lgg.getStringRepresentation()); + } + + } + + @Override + public List<String> getCurrentlyBestSPARQLQueries(int nrOfSPARQLQueries) { + return Collections.singletonList(getBestSPARQLQuery()); + } + + @Override + public String getBestSPARQLQuery() { + return lgg.toSPARQLQueryString(); + } + + public void init() { + if(learningProblem instanceof PosOnlyLP){ + this.posExamples = convert(((PosOnlyLP)learningProblem).getPositiveExamples()); + } else if(learningProblem instanceof PosNegLP){ + this.posExamples = convert(((PosNegLP)learningProblem).getPositiveExamples()); + this.negExamples = convert(((PosNegLP)learningProblem).getNegativeExamples()); + } + endpoint = endpointKS.getEndpoint(); + + treeCache = new QueryTreeCache(); + cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(endpoint, cache)); + cbdGenerator.setRecursionDepth(maxQueryTreeDepth); + + lggGenerator = new LGGGeneratorImpl<String>(); + nbr = new NBR<String>(endpoint); + nbr.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); + + posExampleTrees = new ArrayList<QueryTree<String>>(); + negExampleTrees = new ArrayList<QueryTree<String>>(); + } + + private List<String> convert(Set<Individual> individuals){ + List<String> list = new ArrayList<String>(); + for(Individual ind : individuals){ + list.add(ind.toString()); + } + return list; + } + + public static void main(String[] args) throws Exception { + Set<String> positiveExamples = new HashSet<String>(); + positiveExamples.add("http://dbpedia.org/resource/Liverpool_F.C."); + positiveExamples.add("http://dbpedia.org/resource/Chelsea_F.C."); + + ComponentManager cm = ComponentManager.getInstance(); + SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW()); + ks.init(); + PosOnlyLP lp = new PosOnlyLP(); + cm.getPool().registerComponent(lp); + lp.setPositiveExamples(Helper.getIndividualSet(positiveExamples)); + QTL qtl = new QTL(lp, ks); + qtl.init(); + qtl.start(); + String query = qtl.getBestSPARQLQuery(); + System.out.println(query); + } + + public LearningProblem getLearningProblem() { + return learningProblem; + } + + @Autowired + public void setLearningProblem(LearningProblem learningProblem) { + this.learningProblem = learningProblem; + } + + public SparqlEndpointKS getEndpointKS() { + return endpointKS; + } + + @Autowired + public void setEndpointKS(SparqlEndpointKS endpointKS) { + this.endpointKS = endpointKS; + } + + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeFactory.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeFactory.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeFactory.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2007-2010, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.algorithms.qtl; + +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; +import org.dllearner.algorithms.qtl.filters.Filter; + +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.Resource; +import com.hp.hpl.jena.rdf.model.Selector; +import com.hp.hpl.jena.rdf.model.Statement; + +/** + * + * @author Lorenz Bühmann + * + */ +public interface QueryTreeFactory<N> { + + QueryTreeImpl<N> getQueryTree(String example, Model model); + + QueryTreeImpl<N> getQueryTree(String example, Model model, int maxEdges); + + QueryTreeImpl<N> getQueryTree(Resource example, Model model); + + QueryTreeImpl<N> getQueryTree(String example); + + void setPredicateFilter(Filter filter); + + void setObjectFilter(Filter filter); + + void setStatementSelector(Selector selector); + + void setStatementFilter(com.hp.hpl.jena.util.iterator.Filter<Statement> filter); + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/cache/QueryTreeCache.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/cache/QueryTreeCache.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/cache/QueryTreeCache.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -0,0 +1,65 @@ +package org.dllearner.algorithms.qtl.cache; + +import java.util.HashMap; +import java.util.Map; + +import org.dllearner.algorithms.qtl.QueryTreeFactory; +import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.filters.Filter; +import org.dllearner.algorithms.qtl.impl.QueryTreeFactoryImpl; + +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.Resource; +import com.hp.hpl.jena.rdf.model.Selector; +import com.hp.hpl.jena.rdf.model.Statement; + +public class QueryTreeCache { + + private Map<Model, QueryTree<String>> cache; + private QueryTreeFactory<String> factory; + + public QueryTreeCache(){ + cache = new HashMap<Model, QueryTree<String>>(); + factory = new QueryTreeFactoryImpl(); + } + + public QueryTree<String> getQueryTree(String root, Model model){ + QueryTree<String> tree = cache.get(model); + if(tree == null){ + tree = factory.getQueryTree(root, model); + } + return tree; + } + + public QueryTree<String> getQueryTree(Resource root, Model model){ + QueryTree<String> tree = cache.get(model); + if(tree == null){ + tree = factory.getQueryTree(root, model); + } + return tree; + } + + public void setPredicateFilter(Filter filter){ + factory.setPredicateFilter(filter); + } + + public void setObjectFilter(Filter filter){ + factory.setObjectFilter(filter); + } + + public void setStatementFilter(com.hp.hpl.jena.util.iterator.Filter<Statement> filter){ + factory.setStatementFilter(filter); + } + + public void setStatementSelector(Selector selector){ + factory.setStatementSelector(selector); + } + + public void clear(){ + cache.clear(); + } + + public void dispose(){ + cache = null; + } +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/NodeRenderer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/NodeRenderer.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/NodeRenderer.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2007-2010, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.algorithms.qtl.datastructures; + + +/** + * + * @author Lorenz Bühmann + * + */ +public interface NodeRenderer<N> { + + String render(QueryTree<N> node); + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -0,0 +1,144 @@ +/** + * Copyright (C) 2007-2010, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.algorithms.qtl.datastructures; + +import java.io.PrintWriter; +import java.util.Comparator; +import java.util.List; +import java.util.Set; + +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; + +import com.hp.hpl.jena.datatypes.RDFDatatype; +import com.hp.hpl.jena.query.Query; +import com.hp.hpl.jena.rdf.model.Literal; + +/** + * + * @author Lorenz Bühmann + * + */ +public interface QueryTree<N> { + + /** + * Gets the "content" of this tree node. + * @return The user content of this node. + */ + N getUserObject(); + + void setUserObject(N userObject); + + void setId(int id); + + int getId(); + + boolean isEmpty(); + + QueryTree<N> getNodeById(int nodeId); + + boolean isLiteralNode(); + + void setLiteralNode(boolean isLiteralNode); + + boolean isResourceNode(); + + void setResourceNode(boolean isResourceNode); + + boolean isVarNode(); + + void setVarNode(boolean isVarNode); + + QueryTree<N> getParent(); + + List<QueryTree<N>> getChildren(); + + List<QueryTree<N>> getChildren(Object edge); + + List<QueryTree<N>> getChildrenClosure(); + + Object getEdge(QueryTree<N> child); + + void addChild(QueryTreeImpl<N> child); + + void addChild(QueryTreeImpl<N> child, int position); + + void addChild(QueryTreeImpl<N> child, Object edge); + + void addChild(QueryTreeImpl<N> child, Object edge, int position); + + int removeChild(QueryTreeImpl<N> child); + + Set<Object> getEdges(); + + void sortChildren(Comparator<QueryTree<N>> comparator); + + int getChildCount(); + + int getMaxDepth(); + + boolean isRoot(); + + boolean isLeaf(); + + boolean isSubsumedBy(QueryTree<N> tree); + + boolean isSubsumedBy(QueryTree<N> tree, boolean stopAfterError); + + boolean isSameTreeAs(QueryTree<N> tree); + + void tag(); + + boolean isTagged(); + + QueryTree<N> getRoot(); + + List<QueryTree<N>> getLeafs(); + + List<QueryTree<N>> getPathToRoot(); + + List<N> getUserObjectPathToRoot(); + + void dump(); + + public String getStringRepresentation(); + + void dump(PrintWriter writer); + + void dump(PrintWriter writer, int indent); + + Set<N> getUserObjectClosure(); + + List<N> fillDepthFirst(); + + String toSPARQLQueryString(); + + String toSPARQLQueryString(boolean filtered); + + Query toSPARQLQuery(); + + int getTriplePatternCount(); + + Query toQuery(); + + RDFDatatype getDatatype(); + + List<Literal> getLiterals(); + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/GeneralisedQueryTree.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/GeneralisedQueryTree.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/GeneralisedQueryTree.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -0,0 +1,51 @@ +package org.dllearner.algorithms.qtl.datastructures.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeChange.ChangeType; + +public class GeneralisedQueryTree<N> { + + private QueryTree<N> tree; + private List<QueryTreeChange> changes; + + public GeneralisedQueryTree(QueryTree<N> tree){ + this.tree = tree; + changes = new ArrayList<QueryTreeChange>(); + } + + public GeneralisedQueryTree(QueryTree<N> tree, List<QueryTreeChange> changes){ + this.tree = tree; + this.changes = changes; + } + + public void setQueryTree(QueryTree<N> tree){ + this.tree = tree; + } + + public QueryTree<N> getQueryTree(){ + return tree; + } + + public void addChange(QueryTreeChange change){ + changes.add(change); + } + + public void addChanges(List<QueryTreeChange> changes){ + this.changes.addAll(changes); + } + + public List<QueryTreeChange> getChanges(){ + return changes; + } + + public QueryTreeChange getLastChange(){ + if(changes.isEmpty()){ + return new QueryTreeChange(0, ChangeType.REPLACE_LABEL); + } + return changes.get(changes.size()-1); + } + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeChange.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeChange.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeChange.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -0,0 +1,72 @@ +package org.dllearner.algorithms.qtl.datastructures.impl; + + + +public class QueryTreeChange { + + public enum ChangeType{ + REPLACE_LABEL, + REMOVE_NODE; + } + + private int nodeId; + + private ChangeType type; + + private String object; + private String edge; + + public QueryTreeChange(int nodeId, ChangeType type){ + this.nodeId = nodeId; + this.type = type; + } + + public int getNodeId() { + return nodeId; + } + + public ChangeType getType() { + return type; + } + + public String getObject() { + return object; + } + + public void setObject(String object) { + this.object = object; + } + + public String getEdge() { + return edge; + } + + public void setEdge(String edge) { + this.edge = edge; + } + + @Override + public String toString() { +// return "nodeId" + (type==ChangeType.REPLACE_LABEL ? "Replace" : "Remove"); + return nodeId + (type==ChangeType.REPLACE_LABEL ? "a" : "b"); + } + + @Override + public boolean equals(Object obj) { + if(obj == this){ + return true; + } + if(obj == null || !(obj instanceof QueryTreeChange)){ + return false; + } + QueryTreeChange other = (QueryTreeChange)obj; + return nodeId == other.getNodeId() && type == other.getType(); + } + + @Override + public int hashCode() { + return nodeId + type.hashCode() + 37; + } + + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2013-01-22 09:47:20 UTC (rev 3884) @@ -0,0 +1,905 @@ +/** + * Copyright (C) 2007-2010, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.algorithms.qtl.datastructures.impl; + +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.regex.Pattern; + +import javax.xml.bind.DatatypeConverter; + +import org.dllearner.algorithms.qtl.datastructures.NodeRenderer; +import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.filters.Filters; + +import com.hp.hpl.jena.datatypes.BaseDatatype; +import com.hp.hpl.jena.datatypes.RDFDatatype; +import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; +import com.hp.hpl.jena.graph.Node; +import com.hp.hpl.jena.graph.Triple; +import com.hp.hpl.jena.query.Query; +import com.hp.hpl.jena.query.QueryFactory; +import com.hp.hpl.jena.query.Syntax; +import com.hp.hpl.jena.rdf.model.Literal; +import com.hp.hpl.jena.sparql.syntax.ElementGroup; +import com.hp.hpl.jena.sparql.syntax.ElementTriplesBlock; + +/** + * + * @author Lorenz Bühmann + * + */ +public class QueryTreeImpl<N> implements QueryTree<N>{ + + private N userObject; + + private QueryTreeImpl<N> parent; + + private List<QueryTreeImpl<N>> children; + + private Map<QueryTree<N>, Object> child2EdgeMap; + private Map<String, List<QueryTree<N>>> edge2ChildrenMap; + + private NodeRenderer<N> toStringRenderer; + + private boolean tagged = false; + + private int cnt; + + private int id; + + private boolean isLiteralNode = false; + private boolean isResourceNode = false; + + private List<Literal> literals = new ArrayList<Literal>(); + + + public QueryTreeImpl(N userObject) { + this.userObject = userObject; + children = new ArrayList<QueryTreeImpl<N>>(); + child2EdgeMap = new HashMap<QueryTree<N>, Object>(); + edge2ChildrenMap = new HashMap<String, List<QueryTree<N>>>(); + toStringRenderer = new NodeRenderer<N>() { + public String render(QueryTree<N> object) { + String label = object.toString() + "(" + object.getId() + ")"; + if(object.isLiteralNode()){ + if(!object.getLiterals().isEmpty()){ + label += "Values: " + object.getLiterals(); + } + } + return label; + } + }; + } + + public QueryTreeImpl(QueryTree<N> tree){ + this(tree.getUserObject()); + setId(tree.getId()); + QueryTreeImpl<N> subTree; + for(QueryTree<N> child : tree.getChildren()){ + subTree = new QueryTreeImpl<N>(child); + subTree.setId(child.getId()); + subTree.setLiteralNode(child.isLiteralNode()); + subTree.setResourceNode(child.isResourceNode()); + addChild(subTree, tree.getEdge(child)); + } + } + + public N getUserObject() { + return userObject; + } + + public void setUserObject(N userObject) { + this.userObject = userObject; + } + + @Override + public void setId(int id) { + this.id = id; + } + + @Override + public int getId() { + return id; + } + + @Override + public boolean isEmpty(){ + return this.children.isEmpty(); + } + + public QueryTree<N> getNodeById(int nodeId){ + QueryTree<N> node = null; + if(this.id == nodeId){ + node = this; + } else { + for(QueryTree<N> child : children){ + node = child.getNodeById(nodeId); + if(node != null){ + return node; + } + } + } + return node; + } + + @Override + public boolean isLiteralNode() { + return isLiteralNode; + } + + @Override + public void setLiteralNode(boolean isLiteralNode) { + this.isLiteralNode = isLiteralNode; + } + + @Override + public boolean isResourceNode() { + return isResourceNode; + } + + @Override + public void setResourceNode(boolean isResourceNode) { + this.isResourceNode = isResourceNode; + } + + @Override + public boolean isVarNode() { + return !isLiteralNode && !isResourceNode; + } + + @Override + public void setVarNode(boolean isVarNode) { + isLiteralNode = false; + isResourceNode = false; + } + + + public void setParent(QueryTreeImpl<N> parent) { + if (this.parent != null) { + this.parent.children.remove(this); + } + this.parent = parent; + this.parent.children.add(this); + } + + + public void addChild(QueryTreeImpl<N> child) { + children.add(child); + child.parent = this; + } + + @Override + public void addChild(QueryTreeImpl<N> child, int position) { + children.add(position, child); + child.parent = this; + } + + public void addChild(QueryTreeImpl<N> child, Object edge) { + addChild(child); + child2EdgeMap.put(child, edge); + + List<QueryTree<N>> children = edge2ChildrenMap.get(edge); + if(children == null){ + children = new ArrayList<QueryTree<N>>(); + edge2ChildrenMap.put((String)edge, children); + } + children.add(child); + } + + @Override + public void addChild(QueryTreeImpl<N> child, Object edge, int position) { + addChild(child, position); + child2EdgeMap.put(child, edge); + + List<QueryTree<N>> children = edge2ChildrenMap.get(edge); + if(children == null){ + children = new ArrayList<QueryTree<N>>(); + edge2ChildrenMap.put((String)edge, children); + } + children.add(child); + + } + + + public int removeChild(QueryTreeImpl<N> child) { + int pos = children.indexOf(child); + children.remove(child); + edge2ChildrenMap.get(child2EdgeMap.get(child)).remove(child); + child.parent = null; + return pos; + } + + public void removeChildren(Set<QueryTreeImpl<N>> children) { + for(QueryTreeImpl<N> child : children){ + this.children.remove(child); + child.parent = null; + } + } + + + public Object getEdge(QueryTree<N> child) { + return child2EdgeMap.get(child); + } + + public Set<Object> getEdges(){ + return new TreeSet<Object>(child2EdgeMap.values()); + } + + + public void sortChildren(Comparator<QueryTree<N>> comparator) { + Collections.sort(children, comparator); + } + + + public void clearChildren() { + for (QueryTreeImpl<N> child : new ArrayList<QueryTreeImpl<N>>(children)) { + removeChild(child); + } + } + + + public QueryTree<N> getParent() { + return parent; + } + + + public List<QueryTree<N>> getChildren() { + return new ArrayList<QueryTree<N>>(children); + } + + public List<QueryTree<N>> getChildren(Object edge) { +// List<QueryTree<N>> children = new ArrayList<QueryTree<N>>(); +// for(Entry<QueryTree<N>, Object> entry : child2EdgeMap.entrySet()){ +// if(entry.getValue().equals(edge)){ +// children.add(entry.getKey()); +// } +// } +// return children; + List<QueryTree<N>> children = edge2ChildrenMap.get(edge); + if(children == null){ + children = new ArrayList<QueryTree<N>>(); + } + return new ArrayList<QueryTree<N>>(children); + } + + public int getChildCount() { + return children.size(); + } + + + public boolean isRoot() { + return parent == null; + } + + + public boolean isLeaf() { + return children.isEmpty(); + } + + @Override + public boolean isSubsumedBy(QueryTree<N> tree) { + if(!(tree.getUserObject().equals("?") || tree.getUserObject().equals(this.userObject))){ + return false; + } + + Object edge; + for(QueryTree<N> child : tree.getChildren()){ + boolean isSubsumed = false; + edge = tree.getEdge(child); + for(QueryTree<N> child2 : this.getChildren(edge)){ + if(child2.isSubsumedBy(child)){ + isSubsumed = true; + break; + } + } + if(!isSubsumed){ + return false; + } + } + return true; + } + + @Override + public boolean isSubsumedBy(QueryTree<N> tree, boolean stopAfterError) { + if(!(tree.getUserObject().equals("?") || tree.getUserObject().equals(this.userObject))){ + return false; + } + + Object edge; + for(QueryTree<N> child : tree.getChildren()){ + boolean isSubsumed = false; + edge = tree.getEdge(child); + for(QueryTree<N> child2 : this.getChildren(edge)){ + if(child2.isSubsumedBy(child, true)){ + isSubsumed = true; + break; + } + } + if(!isSubsumed){ + child.tag(); + return false; + } + } + return true; + } + + public void tag(){ + tagged = true; + } + + public boolean isTagged(){ + return tagged; + } + + + public QueryTree<N> getRoot() { + if (parent == null) { + return this; + } + return parent.getRoot(); + } + + public List<QueryTree<N>> getLeafs(){ + List<QueryTree<N>> leafs = new LinkedList<QueryTree<N>>(); + if(isLeaf()){ + leafs.add(this); + } else { + for(QueryTree<N> child : children){ + leafs.addAll(child.getLeafs()); + } + } + return leafs; + } + + + public List<QueryTree<N>> getPathToRoot() { + List<QueryTree<N>> path = new ArrayList<QueryTree<N>>(); + path.add(0, this); + QueryTree<N> par = parent; + while (par != null) { + path.add(0, par); + par = par.getParent(); + } + return path; + } + + + + + public List<N> getUserObjectPathToRoot() { + List<N> path = new ArrayList<N>(); + path.add(0, this.getUserObject()); + QueryTree<N> par = parent; + while (par != null) { + path.add(0, par.getUserObject()); + par = par.getParent(); + } + return path; + } + + public List<QueryTree<N>> getChildrenClosure() { + List<QueryTree<N>> children = new ArrayList<QueryTree<N>>(); + getChildrenClosure(this, children); + return children; + } + + private void getChildrenClosure(QueryTree<N> tree, List<QueryTree<N>> bin) { + bin.add(tree); + for (QueryTree<N> child : tree.getChildren()) { + getChildrenClosure(child, bin); + } + } + + + public Set<N> getUserObjectClosure() { + Set<N> objects = new HashSet<N>(); + getUserObjectClosure(this, objects); + return objects; + } + + public int getTriplePatternCount(){ + return countTriplePattern(this); + } + + private int countTriplePattern(QueryTree<N> tree){ + int cnt = 0; + Object object; + if(!tree.isLeaf()){ + for(QueryTree<N> child : tree.getChildren()){ + object = child.getUserObject(); + boolean objectIsResource = !object.equals("?"); + cnt++; + if(!objectIsResource){ + cnt+=countTriplePattern(child); + } + } + } + return cnt; + } + + public QueryTree<N> getSPARQLQueryTree(){ + return createSPARQLQueryTree(this); + } + + private QueryTree<N> createSPARQLQueryTree(QueryTree<N> tree){ + QueryTree<N> copy = new QueryTreeImpl<N>(tree.getUserObject()); + if(tree.getUserObject().equals("?")){ + for(QueryTree<N> child : tree.getChildren()){ + copy.addChild((QueryTreeImpl<N>) createSPARQLQueryTree(child), tree.getEdge(child)); + } + } +// for(QueryTree<N> child : tree.getChildren()){ +// if(child.getUserObject().equals("?")){ +// copy.addChild((QueryTreeImpl<N>) createSPARQLQueryTree(child), tree.getEdge(child)); +// } else { +// copy.addChild((QueryTreeImpl<N>) child, tree.getEdge(child)); +// } +// +// } + + return copy; + } + + private void getUserObjectClosure(QueryTree<N> tree, Set<N> bin) { + bin.add(tree.getUserObject()); + for (QueryTree<N> child : tree.getChildren()) { + getUserObjectClosure(child, bin); + } + } + + public String getStringRepresentation(){ + int depth = getPathToRoot().size(); + StringBuilder sb = new StringBuilder(); + if(isRoot()){ + sb.append("TREE\n\n"); + } + String ren = toStringRenderer.render(this); + ren = ren.replace("\n", "\n" + sb); + sb.append(ren); + sb.append("\n"); + for (QueryTree<N> child : getChildren()) { + for (int i = 0; i < depth; i++) { + sb.append("\t"); + } + Object edge = getEdge(child); + if (edge != null) { + sb.append(" "); + sb.append(edge); + sb.append(" ---> "); + } + sb.append(((QueryTreeImpl<N>)child).getStringRepresentation()); + } + return sb.toString(); + } + + public String getStringRepresentation(int indent){ + int depth = getPathToRoot().size(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < depth + indent; i++) { + sb.append("\t"); + } + String ren = toStringRenderer.render(this); + ren = ren.replace("\n", "\n" + sb); + sb.append(ren); + sb.append("\n"); + for (QueryTree<N> child : getChildren()) { + Object edge = getEdge(child); + if (edge != null) { + sb.append("--- "); + sb.append(edge); + sb.append(" ---\n"); + } + sb.append(((QueryTreeImpl<N>)child).getStringRepresentation(indent)); + } + return sb.toString(); + } + + public void dump() { + dump(new PrintWriter(System.out), 0); + } + + public void dump(PrintWriter writer) { + dump(writer, 0); + } + + public void dump(PrintWriter writer, int indent) { + int depth = getPathToRoot().size(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < depth + indent; i++) { + sb.append("\t"); + } + writer.print(sb.toString()); + String ren = toStringRenderer.render(this); + ren = ren.replace("\n", "\n" + sb); + writer.println(ren); + for (QueryTree<N> child : getChildren()) { + Object edge = getEdge(child); + if (edge != null) { + writer.print(sb.toString()); + writer.print("--- "); + writer.print(edge); + writer.print(" ---\n"); + } + child.dump(writer, indent); + } + writer.flush(); +// int depth = getPathToRoot().size(); +// StringBuilder sb = new StringBuilder(); +// for (int i = 0; i < depth + indent; i++) { +// sb.append("\t"); +// } +// writer.print(sb.toString()); +// String ren = toStringRenderer.render(this); +// ren = ren.replace("\n", "\n" + sb); +// writer.println(ren); +// for (QueryTree<N> child : getChildren()) { +// Object edge = getEdge(child); +// if (edge != null) { +// writer.print(sb.toString()); +// writer.print("--- "); +// writer.print(edge); +// writer.print(" ---\n"); +// } +// child.dump(writer, indent); +// } +// writer.flush(); + } + + + public List<N> fillDepthFirst() { + List<N> results = new ArrayList<N>(); + fillDepthFirst(this, results); + return results; + } + + private void fillDepthFirst(QueryTree<N> tree, List<N> bin) { + bin.add(tree.getUserObject()); + for (QueryTree<N> child : tree.getChildren()) { + fillDepthFirst(child, bin); + } + } + + public void replace(QueryTreeImpl<N> tree) { + parent.children.remove(this); + parent.children.add(tree); + parent = null; + tree.children.clear(); + tree.children.addAll(children); + children.clear(); + } + + public String toString() { + if (userObject != null) { + return userObject.toString(); + } else { + return ""; + } + } + + + public int getSize() { + return getUserObjectClosure().size(); + } + + + + public int getMaxDepth() { + return getMaxDepth(this); + } + + private int getMaxDepth(QueryTree<N> tree) { + int maxChildDepth = tree.getPathToRoot().size(); + for (QueryTree<N> child : tree.getChildren()) { + int childDepth = getMaxDepth(child); + if(childDepth > maxChildDepth) { + maxChildDepth = childDepth; + } + } + return maxChildDepth; + } + + @Override + public Object clone() throws CloneNotSupportedException { + QueryTreeImpl<N> copy = new QueryTreeImpl<N>(this.userObject); + for(QueryTreeImpl<N> child : children){ + copy.addChild((QueryTreeImpl<N>)child.clone(), getEdge(child)); + } + + return copy; + } + +// @Override +// public boolean equals(Object obj) { +// if(obj == this){ +// return true; +// } +// if(!(obj instanceof QueryTreeImpl<?>)){ +// return false; +// } +// QueryTreeImpl<N> other = (QueryTreeImpl<N>)obj; +// if(!this.userObject.equals(other.getUserObject())){ +// return false; +// } +// Object edge; +// for(QueryTreeImpl<N> child : this.children){ +// boolean existsEqualChild = false; +// edge = child2EdgeMap.get(child); +// for(QueryTree<N> child2 : other.getChildren(edge)){ +// if(child.equals(child2)){ +// existsEqualChild = true; +// break; +// } +// } +// if(!existsEqualChild){ +// return false; +// } +// } +// return true; +// } + + public boolean isSameTreeAs(QueryTree<N> tree){ + if(!this.userObject.equals(tree.getUserObject())){ + return false; + } + Object edge; + for(QueryTreeImpl<N> child : this.children){ + boolean existsEqualChild = false; + edge = child2EdgeMap.get(child); + for(QueryTree<N> child2 : tree.getChildren(edge)){ + if(child.isSameTreeAs(child2)){ + existsEqualChild = true; + break; + } + } + if(!existsEqualChild){ + return false; + } + } + return true; + } + + @Override + public Query toSPARQLQuery() { + return QueryFactory.create(toSPARQLQueryString(), Syntax.syntaxARQ); + } + + @Override + public String toSPARQLQueryString() { + if(children.isEmpty()){ + return "SELECT ?x0 WHERE {?x0 ?y ?z.}"; + } + cnt = 0; + StringBuilder sb = new StringBuilder(); + sb.append("SELECT DISTINCT ?x0 WHERE {\n"); + List<String> filters = new ArrayList<String>(); + buildSPARQLQueryString(this, sb, false, filters); + for(String filter : filters){ + sb.append(filter).append("\n"); + } + sb.append("}"); + return sb.toString(); + } + + @Override + public String toSPARQLQueryString(boolean filtered) { + if(children.isEmpty()){ + return "SELECT ?x0 WHERE {?x0 ?y ?z.}"; + } + cnt = 0; + StringBuilder sb = new StringBuilder(); + List<String> filters = new ArrayList<String>(); + sb.append("SELECT DISTINCT ?x0 WHERE {\n"); + buildSPARQLQueryString(this, sb, filtered, filters); + for(String filter : filters){ + sb.append(filter).append("\n"); + } + sb.append("}"); + return sb.toString(); + } + + private void buildSPARQLQueryString(QueryTree<N> tree, StringBuilder sb, boolean filtered, List<String> filters){ + Object subject = null; + if(tree.getUserObject().equals("?")){ + subject = "?x" + cnt++; + if(tree.isLiteralNode() && !tree.getLiterals().isEmpty()){ + filters.add(getFilter(subject.toString(), tree.getLiterals())); + } + } else { + subject = "<" + tree.getUserObject() + ">"; + } + Object predicate; + Object object; + if(!tree.isLeaf()){ + for(QueryTree<N> child : tree.getChildren()){ + predicate = tree.getEdge(child); + if(filtered){ + if(Filters.getAllFilterProperties().contains(predicate.toString())){ + continue; + } + } + object = child.getUserObject(); + boolean objectIsResource = !object.equals("?"); + if(!objectIsResource){ + object = "?x" + cnt; + } else if(((String)object).startsWith("http://")){ + object = "<" + object + ">"; + ... [truncated message content] |
From: <lor...@us...> - 2013-03-18 12:24:48
|
Revision: 3912 http://sourceforge.net/p/dl-learner/code/3912 Author: lorenz_b Date: 2013-03-18 12:24:44 +0000 (Mon, 18 Mar 2013) Log Message: ----------- Some updates. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGenerator.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlEndpoint.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-03-12 09:29:04 UTC (rev 3911) +++ trunk/components-core/pom.xml 2013-03-18 12:24:44 UTC (rev 3912) @@ -116,12 +116,23 @@ <dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-distribution</artifactId> + <version>3.4.4</version> </dependency> <dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-reasoner</artifactId> </dependency> <dependency> + <groupId>net.sourceforge.owlapi</groupId> + <artifactId>owlapi-debugging</artifactId> + <version>3.3</version> +</dependency> +<dependency> + <groupId>net.sourceforge.owlapi</groupId> + <artifactId>owlapi-modularity</artifactId> + <version>3.3</version> +</dependency> +<dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-util</artifactId> </dependency> @@ -135,6 +146,10 @@ <groupId>org.mortbay.jetty</groupId> <artifactId>org.mortbay.jetty</artifactId> </exclusion> + <exclusion> + <artifactId>owlapi</artifactId> + <groupId>net.sourceforge.owlapi</groupId> + </exclusion> </exclusions> </dependency> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2013-03-12 09:29:04 UTC (rev 3911) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2013-03-18 12:24:44 UTC (rev 3912) @@ -116,7 +116,7 @@ //compute the overlap if exist Map<ObjectProperty, Integer> property2Overlap = new HashMap<ObjectProperty, Integer>(); String query = String.format("SELECT ?p (COUNT(*) AS ?cnt) WHERE {?s <%s> ?o. ?s ?p ?o.} GROUP BY ?p", propertyToDescribe.getName()); - ResultSet rs = executeSelectQuery(query); + System.out.println(query);ResultSet rs = executeSelectQuery(query); QuerySolution qs; while(rs.hasNext()){ qs = rs.next(); @@ -336,13 +336,13 @@ } public static void main(String[] args) throws Exception{ - SparqlEndpoint endpoint = SparqlEndpoint.getEndpointDBpedia(); + SparqlEndpoint endpoint = SparqlEndpoint.getEndpointDBpediaLiveAKSW(); // endpoint = new SparqlEndpoint(new URL("http://dbpedia.aksw.org:8902/sparql"), Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList())); DisjointObjectPropertyAxiomLearner l = new DisjointObjectPropertyAxiomLearner(new SparqlEndpointKS(endpoint));//.getEndpointDBpediaLiveAKSW())); l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/league")); l.setMaxExecutionTimeInSeconds(10); l.init(); - l.getReasoner().precomputeObjectPropertyPopularity(); +// l.getReasoner().precomputeObjectPropertyPopularity(); l.start(); for(EvaluatedAxiom ax : l.getCurrentlyBestEvaluatedAxioms(Integer.MAX_VALUE)){ System.out.println(ax); Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGenerator.java 2013-03-12 09:29:04 UTC (rev 3911) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGenerator.java 2013-03-18 12:24:44 UTC (rev 3912) @@ -13,4 +13,5 @@ public void setRestrictToNamespaces(List<String> namespaces); public void setRecursionDepth(int maxRecursionDepth); + } Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2013-03-12 09:29:04 UTC (rev 3911) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2013-03-18 12:24:44 UTC (rev 3912) @@ -38,9 +38,9 @@ import com.hp.hpl.jena.query.ResultSetRewindable; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; -import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; +//import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; /** * The class is used to cache information about resources to a database. Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlEndpoint.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlEndpoint.java 2013-03-12 09:29:04 UTC (rev 3911) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/SparqlEndpoint.java 2013-03-18 12:24:44 UTC (rev 3912) @@ -20,6 +20,7 @@ package org.dllearner.kb.sparql; import java.net.URL; +import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -49,6 +50,10 @@ this.namedGraphURIs=namedGraphURIs; } + public SparqlEndpoint(URL url, String defaultGraphURI) { + this(url, Collections.singletonList(defaultGraphURI), Collections.<String>emptyList()); + } + public URL getURL() { return this.url; } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-03-12 09:29:04 UTC (rev 3911) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-03-18 12:24:44 UTC (rev 3912) @@ -783,12 +783,34 @@ return isObjectProperty; } - public boolean isDataProperty(String propertyURI){ - String query = String.format("ASK {<%s> a <%s>}", propertyURI, OWL.DatatypeProperty.getURI()); + public boolean isObjectProperty(String propertyURI, boolean analyzeData){ + String query = String.format("ASK {<%s> a <%s>}", propertyURI, OWL.ObjectProperty.getURI()); boolean isObjectProperty = executeAskQuery(query); + if(!isObjectProperty && analyzeData){ + query = String.format("ASK {?s <%s> ?o.FILTER(isURI(?o))}", propertyURI); + isObjectProperty = executeAskQuery(query); + } return isObjectProperty; } + public boolean isDataProperty(String propertyURI){ + if(propertyURI.equals("http://www.w3.org/2000/01/rdf-schema#label")) return true; + String query = String.format("ASK {<%s> a <%s>}", propertyURI, OWL.DatatypeProperty.getURI()); + boolean isDataProperty = executeAskQuery(query); + return isDataProperty; + } + + public boolean isDataProperty(String propertyURI, boolean analyzeData){ + if(propertyURI.equals("http://www.w3.org/2000/01/rdf-schema#label")) return true; + String query = String.format("ASK {<%s> a <%s>}", propertyURI, OWL.DatatypeProperty.getURI()); + boolean isDataProperty = executeAskQuery(query); + if(!isDataProperty && analyzeData){ + query = String.format("ASK {?s <%s> ?o.FILTER(isLITERAL(?o))}", propertyURI); + isDataProperty = executeAskQuery(query); + } + return isDataProperty; + } + public int getIndividualsCount(NamedClass nc){ String query = String.format("SELECT (COUNT(?s) AS ?cnt) WHERE {" + "?s a <%s>." + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-04-15 20:52:45
|
Revision: 3922 http://sourceforge.net/p/dl-learner/code/3922 Author: lorenz_b Date: 2013-04-15 20:52:41 +0000 (Mon, 15 Apr 2013) Log Message: ----------- Continued pattern learning algorithm. Added classes for remote ontology repositories and local datasets. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java trunk/components-core/src/test/java/org/dllearner/algorithms/pattern/OWLAxiomRenamerTest.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/kb/dataset/ trunk/components-core/src/main/java/org/dllearner/kb/dataset/AbstractOWLOntologyDataset.java trunk/components-core/src/main/java/org/dllearner/kb/dataset/BioPortalDataset.java trunk/components-core/src/main/java/org/dllearner/kb/dataset/OWLOntologyDataset.java trunk/components-core/src/main/java/org/dllearner/kb/dataset/TONESDataset.java trunk/components-core/src/main/java/org/dllearner/kb/repository/ trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepository.java trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryEntry.java trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryManager.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/BioPortalRepository.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Data.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyAclEntry.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyBean.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Success.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/UserAcl.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/UserEntry.java trunk/components-core/src/main/java/org/dllearner/kb/repository/tones/ trunk/components-core/src/main/java/org/dllearner/kb/repository/tones/TONESRepository.java trunk/components-core/src/test/java/org/dllearner/algorithms/pattern/OWLPatternDetectionTest.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/pom.xml 2013-04-15 20:52:41 UTC (rev 3922) @@ -281,6 +281,26 @@ <artifactId>simmetrics</artifactId> <version>1.6.2</version> </dependency> + <dependency> + <groupId>com.thoughtworks.xstream</groupId> + <artifactId>xstream</artifactId> + <version>1.4.3</version> + </dependency> + <dependency> + <groupId>xpp3</groupId> + <artifactId>xpp3_min</artifactId> + <version>1.1.4c</version> + </dependency> + <dependency> + <groupId>net.sf.kxml</groupId> + <artifactId>kxml2-min</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> </dependencies> <dependencyManagement> <dependencies> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -1,55 +1,27 @@ package org.dllearner.algorithms.pattern; -import java.util.ArrayList; -import java.util.Arrays; +import java.net.URI; import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import java.util.Queue; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; +import org.dllearner.kb.dataset.OWLOntologyDataset; +import org.dllearner.kb.repository.OntologyRepository; +import org.dllearner.kb.repository.OntologyRepositoryEntry; import org.semanticweb.owlapi.apibinding.OWLManager; -import org.semanticweb.owlapi.expression.OWLEntityChecker; -import org.semanticweb.owlapi.expression.ParserException; -import org.semanticweb.owlapi.io.ToStringRenderer; -import org.semanticweb.owlapi.model.EntityType; import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLAnnotationProperty; import org.semanticweb.owlapi.model.OWLAxiom; -import org.semanticweb.owlapi.model.OWLClass; -import org.semanticweb.owlapi.model.OWLClassExpression; import org.semanticweb.owlapi.model.OWLDataFactory; -import org.semanticweb.owlapi.model.OWLDataProperty; -import org.semanticweb.owlapi.model.OWLDatatype; -import org.semanticweb.owlapi.model.OWLEntity; -import org.semanticweb.owlapi.model.OWLNamedIndividual; -import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; -import org.semanticweb.owlapi.model.OWLObjectProperty; -import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLLogicalAxiom; import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; import org.semanticweb.owlapi.model.OWLOntologyManager; -import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; -import org.semanticweb.owlapi.reasoner.OWLReasoner; -import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; -import org.semanticweb.owlapi.util.IRIShortFormProvider; -import org.semanticweb.owlapi.util.OWLAxiomVisitorAdapter; -import org.semanticweb.owlapi.util.OWLClassExpressionVisitorAdapter; -import org.semanticweb.owlapi.util.SimpleIRIShortFormProvider; -import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; -import uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntaxObjectRenderer; - -import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; +import com.google.common.collect.Multisets; + public class OWLAxiomPatternFinder { private static Queue<String> classVarQueue = new LinkedList<String>(); @@ -69,133 +41,46 @@ } }; + + private OntologyRepository repository; + private OWLOntologyManager manager; + private OWLDataFactory dataFactory; - public OWLAxiomPatternFinder(OWLOntology ontology) { - generalizeAxioms(ontology.getLogicalAxioms()); + public OWLAxiomPatternFinder(OWLOntologyDataset dataset) { + } - private void generalizeAxioms(Collection<? extends OWLAxiom> axioms){ - ManchesterOWLSyntaxOWLObjectRendererImpl renderer = new ManchesterOWLSyntaxOWLObjectRendererImpl(); - String NS = "http://dl-learner.org/pattern/"; - IRIShortFormProvider sfp = new SimpleIRIShortFormProvider(); -// renderer.setShortFormProvider(new FullIRIEntityShortFromProvider()); - for(OWLAxiom axiom : axioms){ - OWLAxiom nnfAxiom = axiom.getNNF(); - String renderedAxiom = renderer.render(nnfAxiom); - final OWLDataFactory dataFactory = new OWLDataFactoryImpl(); - Map<OWLEntity, OWLEntity> map = new HashMap<OWLEntity, OWLEntity>(); - Queue<String> classVarQueue = new LinkedList<String>(this.classVarQueue); - Queue<String> propertyVarQueue = new LinkedList<String>(this.propertyVarQueue); - Queue<String> individualVarQueue = new LinkedList<String>(this.individualVarQueue); - Queue<String> datatypeVarQueue = new LinkedList<String>(this.datatypeVarQueue); - final Set<String> classNames = new HashSet<String>(); - final Set<String> objectPropertyNames = new HashSet<String>(); - final Set<String> dataPropertyNames = new HashSet<String>(); - final Set<String> individualNames = new HashSet<String>(); - final Set<String> datatypeNames = new HashSet<String>(); - for(OWLEntity entity : axiom.getSignature()){ - if(entity.isOWLClass()){ - if(entity.asOWLClass().isBuiltIn()){ - - } else { - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.CLASS, IRI.create(NS + classVarQueue.poll())); - map.put(entity, newEntity); - classNames.add(newEntity.toStringID()); - } - } else if(entity.isOWLObjectProperty()){ - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.OBJECT_PROPERTY, IRI.create(NS + propertyVarQueue.poll())); - map.put(entity, newEntity); - objectPropertyNames.add(newEntity.toStringID()); - } else if(entity.isOWLDataProperty()){ - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.DATA_PROPERTY, IRI.create(NS + propertyVarQueue.poll())); - map.put(entity, newEntity); - dataPropertyNames.add(newEntity.toStringID()); - } else if(entity.isOWLNamedIndividual()){ - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.NAMED_INDIVIDUAL, IRI.create(NS + individualVarQueue.poll())); - map.put(entity, newEntity); - individualNames.add(newEntity.toStringID()); - } else if(entity.isOWLDatatype()){ -// OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.DATATYPE, IRI.create(datatypeVarQueue.poll())); - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.DATATYPE, IRI.create(sfp.getShortForm(entity.getIRI()))); -// OWLEntity newEntity = entity; - map.put(entity, newEntity); - datatypeNames.add(newEntity.toStringID()); + public OWLAxiomPatternFinder(OntologyRepository repository) { + this.repository = repository; + manager = OWLManager.createOWLOntologyManager(); + dataFactory = manager.getOWLDataFactory(); + } + + public void start(){ + OWLAxiomRenamer renamer = new OWLAxiomRenamer(dataFactory); + Collection<OntologyRepositoryEntry> entries = repository.getEntries(); + Multiset<OWLAxiom> multiset = HashMultiset.create(); + for (OntologyRepositoryEntry entry : entries) { + try { + URI uri = entry.getPhysicalURI(); + OWLOntology ontology = manager.loadOntology(IRI.create(uri)); + for(OWLLogicalAxiom axiom : ontology.getLogicalAxioms()){ + OWLAxiom renamedAxiom = renamer.rename(axiom); + multiset.add(renamedAxiom); } + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); } -// System.out.println(renderedAxiom); - for (Entry<OWLEntity, OWLEntity> entry : map.entrySet()) { - OWLEntity key = entry.getKey(); - OWLEntity value = entry.getValue(); - renderedAxiom = renderedAxiom.replaceAll("\\b" + sfp.getShortForm(key.getIRI()) + "\\b", value.toStringID()); + for (OWLAxiom owlAxiom : Multisets.copyHighestCountFirst(multiset).elementSet()) { + System.out.println(owlAxiom + ": " + multiset.count(owlAxiom)); } - ManchesterOWLSyntaxEditorParser parser = new ManchesterOWLSyntaxEditorParser(dataFactory, renderedAxiom); - parser.setOWLEntityChecker(new OWLEntityChecker() { - - @Override - public OWLObjectProperty getOWLObjectProperty(String iri) { - return objectPropertyNames.contains(iri) ? dataFactory.getOWLObjectProperty(IRI.create(iri)) : null; - } - - @Override - public OWLNamedIndividual getOWLIndividual(String iri) { - return individualNames.contains(iri) ? dataFactory.getOWLNamedIndividual(IRI.create(iri)) : null; - } - - @Override - public OWLDatatype getOWLDatatype(String iri) { - return datatypeNames.contains(iri) ? dataFactory.getOWLDatatype(IRI.create(iri)) : null; - } - - @Override - public OWLDataProperty getOWLDataProperty(String iri) { - return dataPropertyNames.contains(iri) ? dataFactory.getOWLDataProperty(IRI.create(iri)) : null; - } - - @Override - public OWLClass getOWLClass(String iri) { - if(iri.equals("Thing")){ - return dataFactory.getOWLThing(); - } else if(iri.equals("Nothing")){ - return dataFactory.getOWLNothing(); - } else { - return classNames.contains(iri) ? dataFactory.getOWLClass(IRI.create(iri)) : null; - } - } - - @Override - public OWLAnnotationProperty getOWLAnnotationProperty(String iri) { - return null; - } - }); - try { - OWLAxiom parsedAxiom = parser.parseAxiom(); - System.out.println(parsedAxiom); - } catch (ParserException e) { - e.printStackTrace(); - } } + for (OWLAxiom owlAxiom : Multisets.copyHighestCountFirst(multiset).elementSet()) { + System.out.println(owlAxiom + ": " + multiset.count(owlAxiom)); + } } public static void main(String[] args) throws Exception { - ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); - String ontologyURL = "http://protege.stanford.edu/plugins/owl/owl-library/koala.owl"; - OWLOntologyManager man = OWLManager.createOWLOntologyManager(); - OWLDataFactory dataFactory = man.getOWLDataFactory(); - OWLOntology ontology = man.loadOntology(IRI.create(ontologyURL)); - OWLAxiomRenamer renamer = new OWLAxiomRenamer(dataFactory); - Multiset<OWLAxiom> multiset = HashMultiset.create(); - for (OWLAxiom axiom : ontology.getLogicalAxioms()) { - OWLAxiom renamedAxiom = renamer.rename(axiom); - multiset.add(renamedAxiom); -// System.out.println(axiom + "-->" + renamedAxiom); - } - for (OWLAxiom owlAxiom : multiset.elementSet()) { - System.out.println(owlAxiom + ": " + multiset.count(owlAxiom)); - } - - -// OWLAxiomPatternFinder pf = new OWLAxiomPatternFinder(ontology); } - } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -38,6 +38,7 @@ import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; @@ -166,6 +167,13 @@ @Override public void visit(OWLObjectPropertyAssertionAxiom axiom) { + OWLObjectPropertyExpression property = axiom.getProperty(); + property = expressionRenamer.rename(property); + OWLIndividual subject = axiom.getSubject(); + subject = expressionRenamer.rename(subject); + OWLIndividual object = axiom.getObject(); + object = expressionRenamer.rename(object); + renamedAxiom = df.getOWLObjectPropertyAssertionAxiom(property, subject, object); } @Override @@ -177,6 +185,11 @@ @Override public void visit(OWLSubObjectPropertyOfAxiom axiom) { + OWLObjectPropertyExpression subProperty = axiom.getSubProperty(); + subProperty = expressionRenamer.rename(subProperty); + OWLObjectPropertyExpression superProperty = axiom.getSuperProperty(); + superProperty = expressionRenamer.rename(superProperty); + renamedAxiom = df.getOWLSubObjectPropertyOfAxiom(subProperty, superProperty); } @Override @@ -231,6 +244,13 @@ @Override public void visit(OWLDataPropertyAssertionAxiom axiom) { + OWLDataPropertyExpression property = axiom.getProperty(); + property = expressionRenamer.rename(property); + OWLIndividual subject = axiom.getSubject(); + subject = expressionRenamer.rename(subject); + OWLLiteral object = axiom.getObject(); + object = expressionRenamer.rename(object); + renamedAxiom = df.getOWLDataPropertyAssertionAxiom(property, subject, object); } @Override @@ -249,6 +269,11 @@ @Override public void visit(OWLSubDataPropertyOfAxiom axiom) { + OWLDataPropertyExpression subProperty = axiom.getSubProperty(); + subProperty = expressionRenamer.rename(subProperty); + OWLDataPropertyExpression superProperty = axiom.getSuperProperty(); + superProperty = expressionRenamer.rename(superProperty); + renamedAxiom = df.getOWLSubDataPropertyOfAxiom(subProperty, superProperty); } @Override Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -64,9 +64,9 @@ private static final String NS = "http://dl-learner.org/pattern/"; - private Queue<String> classVarQueue = new LinkedList<String>(Arrays.asList("A", "B", "C" , "D")); - private Queue<String> propertyVarQueue = new LinkedList<String>(Arrays.asList("p", "q", "r" , "s")); - private Queue<String> individualVarQueue = new LinkedList<String>(Arrays.asList("a", "b", "c" , "d")); + private Queue<String> classVarQueue = new LinkedList<String>(Arrays.asList("A", "B", "C" , "D", "E", "F", "G")); + private Queue<String> propertyVarQueue = new LinkedList<String>(Arrays.asList("p", "q", "r" , "s", "t")); + private Queue<String> individualVarQueue = new LinkedList<String>(Arrays.asList("a", "b", "c" , "d", "e", "f", "g")); private OWLDataFactory df; private Map<OWLEntity, OWLEntity> renaming; private OWLObject renamedOWLObject; @@ -101,6 +101,12 @@ return (OWLDataRange) renamedOWLObject; } + public OWLLiteral rename(OWLLiteral lit){ + renamedOWLObject = null; + renamedOWLObject = lit; + return (OWLLiteral) renamedOWLObject; + } + @Override public void visit(OWLObjectIntersectionOf desc) { List<OWLClassExpression> operands = desc.getOperandsAsList(); @@ -325,6 +331,12 @@ @Override public void visit(OWLAnonymousIndividual ind) { + OWLEntity newEntity = renaming.get(ind); + if(newEntity == null){ + newEntity = df.getOWLNamedIndividual(getIRI(individualVarQueue.poll())); +// renaming.put(ind, newEntity); + } + renamedOWLObject = (OWLNamedIndividual)newEntity; } @Override @@ -333,7 +345,13 @@ } @Override - public void visit(OWLDataOneOf arg0) { + public void visit(OWLDataOneOf desc) { + Set<OWLLiteral> literals = desc.getValues(); + Set<OWLLiteral> renamedLiterals = new TreeSet<OWLLiteral>(); + for (OWLLiteral lit : literals) { + renamedLiterals.add(rename(lit)); + } + renamedOWLObject = df.getOWLDataOneOf(renamedLiterals); } @Override Modified: trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -28,6 +28,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.ListStringEditor; +import org.dllearner.kb.sparql.ExtractionDBCache; import org.dllearner.kb.sparql.SPARQLTasks; import org.dllearner.kb.sparql.SparqlEndpoint; import org.springframework.beans.propertyeditors.URLEditor; @@ -44,6 +45,7 @@ public class SparqlEndpointKS implements KnowledgeSource { private SparqlEndpoint endpoint; + private ExtractionDBCache cache; private boolean supportsSPARQL_1_1 = false; private boolean isRemote = true; private boolean initialized = false; @@ -64,9 +66,18 @@ } public SparqlEndpointKS(SparqlEndpoint endpoint) { + this(endpoint, null); + } + + public SparqlEndpointKS(SparqlEndpoint endpoint, ExtractionDBCache cache) { this.endpoint = endpoint; + this.cache = cache; } + public ExtractionDBCache getCache() { + return cache; + } + @Override public void init() throws ComponentInitException { if(!initialized){ Added: trunk/components-core/src/main/java/org/dllearner/kb/dataset/AbstractOWLOntologyDataset.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/dataset/AbstractOWLOntologyDataset.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/dataset/AbstractOWLOntologyDataset.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,342 @@ +package org.dllearner.kb.dataset; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeSet; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.semanticweb.HermiT.Configuration; +import org.semanticweb.HermiT.Reasoner; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.ConsoleProgressMonitor; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.reasoner.SimpleConfiguration; + +import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; +import com.google.common.io.Files; + +public abstract class AbstractOWLOntologyDataset implements OWLOntologyDataset{ + + protected Collection<OWLOntology> ontologies = new TreeSet<OWLOntology>(); + protected Collection<OWLOntology> correctOntologies = new TreeSet<OWLOntology>(); + protected Collection<OWLOntology> incoherentOntologies = new TreeSet<OWLOntology>(); + protected Collection<OWLOntology> inconsistentOntologies = new TreeSet<OWLOntology>(); + + protected String name; + + protected File directory; + protected File correctSubdirectory; + protected File inconsistentSubdirectory; + protected File incoherentSubdirectory; + protected File errorSubdirectory; + protected File tooLargeSubdirectory; + + protected OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance(); + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + + protected Map<URL, String> ontologyURLs = new HashMap<URL, String>(); + + private final int nrOfThreads = 1; + private boolean analyze = false; + + public AbstractOWLOntologyDataset(String name, boolean analyze) { + this.name = name; + this.analyze = analyze; + //create file structure + directory = new File(datasetDirectory, name); + directory.mkdirs(); + correctSubdirectory = new File(directory, "correct"); + correctSubdirectory.mkdirs(); + incoherentSubdirectory = new File(directory, "incoherent"); + incoherentSubdirectory.mkdirs(); + inconsistentSubdirectory = new File(directory, "inconsistent"); + inconsistentSubdirectory.mkdirs(); + tooLargeSubdirectory = new File(directory, "too_large"); + tooLargeSubdirectory.mkdirs(); + errorSubdirectory = new File(directory, "error"); + errorSubdirectory.mkdirs(); + addOntologyURLs(); + initialize(); + } + + public AbstractOWLOntologyDataset(String name) { + this(name, false); + } + + private boolean analyzed(URL url){ + String filename = getFilename(url); + for(File parent : Arrays.asList(tooLargeSubdirectory, correctSubdirectory, incoherentSubdirectory, inconsistentSubdirectory, errorSubdirectory)){ + File file = new File(parent, filename); + if(file.exists()){ + return true; + } + } + return false; + } + + private Set<String> load403Errors(){ + Set<String> errors = new HashSet<String>(); + try { + if(new File(directory, "403.txt").exists()){ + errors = new HashSet<String>(Files.readLines(new File(directory, "403.txt"), Charset.defaultCharset())); + } + } catch (IOException e) { + e.printStackTrace(); + } + return errors; + } + + private boolean analyzedDataset(){ + return new File(directory + "/" + "analyzed").exists(); + } + + public void initialize(){ + //check if dataset was already analyzed + boolean analyzed = analyzedDataset(); + if(!analyzed){ + Set<String> errors = load403Errors(); + ExecutorService threadPool = Executors.newFixedThreadPool(nrOfThreads); + List<Entry<URL, String>> urlList = new ArrayList<java.util.Map.Entry<URL, String>>(ontologyURLs.entrySet()); + Collections.shuffle(urlList); + for (java.util.Map.Entry<URL, String> entry : urlList) { + URL url = entry.getKey(); + if(!errors.contains(url.toString()) && !analyzed(url)){ + threadPool.submit(new OntologyLoadingTask(url)); + } + } + threadPool.shutdown(); + try { + threadPool.awaitTermination(100, TimeUnit.MINUTES); + } catch (InterruptedException e) { + e.printStackTrace(); + } + try { + new File(directory + "/" + "analyzed").createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + + } + } + + protected abstract void addOntologyURLs(); + + private void analyzeAndCategorizeOntology(OWLOntology ontology, String filename){ + System.out.println("Analyzing ontology " + filename + "..."); + OWLReasoner reasoner; + File from = new File(man.getOntologyDocumentIRI(ontology).toURI()); + try { + Configuration conf = new Configuration(); + conf.reasonerProgressMonitor = new ConsoleProgressMonitor(); + conf.ignoreUnsupportedDatatypes = true; + reasoner = new Reasoner(conf, ontology); + int logicalAxiomCount = ontology.getLogicalAxiomCount(); + boolean consistent = reasoner.isConsistent(); + Set<OWLClass> unsatisfiableClasses = null; + + if(consistent){ + unsatisfiableClasses = reasoner.getUnsatisfiableClasses().getEntitiesMinusBottom(); + if(!unsatisfiableClasses.isEmpty()){ + File to = new File(incoherentSubdirectory, filename); + Files.move(from, to); + } else { + File to = new File(correctSubdirectory, filename); + Files.move(from, to); + } + } else { + File to = new File(inconsistentSubdirectory, filename); + Files.move(from, to); + } + System.out.println(consistent + "\t" + logicalAxiomCount + "\t" + ((unsatisfiableClasses != null) ? unsatisfiableClasses.size() : "n/a")); + reasoner.dispose(); + } catch (Exception e){ + e.printStackTrace(); + try { + reasoner = reasonerFactory.createNonBufferingReasoner(ontology, new SimpleConfiguration(new ConsoleProgressMonitor())); + int logicalAxiomCount = ontology.getLogicalAxiomCount(); + boolean consistent = reasoner.isConsistent(); + Set<OWLClass> unsatisfiableClasses = null; + if(consistent){ + unsatisfiableClasses = reasoner.getUnsatisfiableClasses().getEntitiesMinusBottom(); + if(!unsatisfiableClasses.isEmpty()){ + File to = new File(incoherentSubdirectory, filename); + Files.move(from, to); + } else { + File to = new File(correctSubdirectory, filename); + Files.move(from, to); + } + } else { + File to = new File(inconsistentSubdirectory, filename); + Files.move(from, to); + } + System.out.println(consistent + "\t" + logicalAxiomCount + "\t" + ((unsatisfiableClasses != null) ? unsatisfiableClasses.size() : "n/a")); + reasoner.dispose(); + } catch (Exception e1){ + File to = new File(errorSubdirectory, filename); + try { + Files.move(from, to); + } catch (IOException e2) { + e2.printStackTrace(); + } + } + } + } + + protected OWLOntology loadOWLOntology(URL url) { + OWLOntology ontology = loadFromLocal(url); + if(ontology == null){ + File file = null; + try { + file = downloadFile(url); + if(file != null){ + ontology = man.loadOntologyFromOntologyDocument(file); + } + } catch (Exception e) { + e.printStackTrace(); + String filename = getFilename(url); + File to = new File(errorSubdirectory, filename); + try { + Files.move(file, to); + } catch (IOException e2) { + e2.printStackTrace(); + } + } + } + return ontology; + } + + private OWLOntology loadFromLocal(URL url){ + String filename = getFilename(url); + for(File parent : Arrays.asList(directory)){ + File file = new File(parent, filename); + if(file.exists()){ + try { + OWLOntology ontology = man.loadOntologyFromOntologyDocument(file); + return ontology; + } catch(Exception e){ + e.printStackTrace(); + File to = new File(errorSubdirectory, filename); + try { + Files.move(file, to); + } catch (IOException e2) { + e2.printStackTrace(); + } + } + } + } + return null; + } + + private String getFilename(URL url){ + return ontologyURLs.get(url); +// String filename = url.toString().substring(url.toString().lastIndexOf("/")); +// return filename; + } + + /** + * Download the file such that later on we can load it from the local file system. + */ + protected File downloadFile(URL url){ + + String filename = getFilename(url); + File file = new File(directory + "/" + filename); + if(!file.exists()){ + System.out.print("Downloading file..."); + try { + InputStream is = url.openConnection().getInputStream(); + OutputStream out = new FileOutputStream(file); + int read = 0; + byte[] bytes = new byte[1024]; + + while ((read = is.read(bytes)) != -1) { + out.write(bytes, 0, read); + } + + is.close(); + out.flush(); + out.close(); + System.out.println("done."); + return file; + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + add403Error(url); + } + } + return null; + } + + private void add403Error(URL url){ + try { + Files.append(url.toString() + "\n", new File(directory, "403.txt"), Charset.defaultCharset()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public Collection<OWLOntology> loadOntologies() { + return ontologies; + } + + @Override + public Collection<OWLOntology> loadIncoherentOntologies() { + return incoherentOntologies; + } + + @Override + public Collection<OWLOntology> loadInconsistentOntologies() { + return inconsistentOntologies; + } + + class OntologyLoadingTask implements Runnable{ + + private URL url; + + public OntologyLoadingTask(URL url) { + this.url = url; + } + + @Override + public void run() { + System.out.println("Processing " + ontologyURLs.get(url)); + OWLOntology ontology = loadOWLOntology(url); + if(ontology != null){ + if(analyze){ + analyzeAndCategorizeOntology(ontology, getFilename(url)); + } else { + ontologies.add(ontology); + } + } + } + + } + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/dataset/BioPortalDataset.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/dataset/BioPortalDataset.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/dataset/BioPortalDataset.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,34 @@ +package org.dllearner.kb.dataset; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URLEncoder; + +import org.dllearner.kb.repository.OntologyRepositoryEntry; +import org.dllearner.kb.repository.bioportal.BioPortalRepository; + +public class BioPortalDataset extends AbstractOWLOntologyDataset{ + + private static final String name = "BioPortal"; + + public BioPortalDataset() { + super(name); + } + + @Override + protected void addOntologyURLs() { + BioPortalRepository bioportal = new BioPortalRepository(); + bioportal.initialize(); + for (OntologyRepositoryEntry entry : bioportal.getEntries()) { + try { + String name = URLEncoder.encode(entry.getOntologyShortName(), "UTF-8"); + super.ontologyURLs.put(entry.getPhysicalURI().toURL(), name); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + } + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/dataset/OWLOntologyDataset.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/dataset/OWLOntologyDataset.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/dataset/OWLOntologyDataset.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,16 @@ +package org.dllearner.kb.dataset; + +import java.io.File; +import java.util.Collection; + +import org.semanticweb.owlapi.model.OWLOntology; + +public interface OWLOntologyDataset { + + static File datasetDirectory = new File("dataset"); + + Collection<OWLOntology> loadOntologies(); + Collection<OWLOntology> loadIncoherentOntologies(); + Collection<OWLOntology> loadInconsistentOntologies(); + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/dataset/TONESDataset.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/dataset/TONESDataset.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/dataset/TONESDataset.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,36 @@ +package org.dllearner.kb.dataset; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URLEncoder; + +import org.dllearner.kb.repository.OntologyRepositoryEntry; +import org.dllearner.kb.repository.tones.TONESRepository; + +public class TONESDataset extends AbstractOWLOntologyDataset{ + + private static final String name = "TONES"; + + public TONESDataset() { + super(name); + } + + @Override + protected void addOntologyURLs() { + TONESRepository tones = new TONESRepository(); + tones.initialize(); + for (OntologyRepositoryEntry entry : tones.getEntries()) { + try { + String name = URLEncoder.encode(entry.getOntologyShortName(), "UTF-8"); + ontologyURLs.put(entry.getPhysicalURI().toURL(), name); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + } + + + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepository.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepository.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepository.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,32 @@ +package org.dllearner.kb.repository; + +import java.util.Collection; +import java.util.List; + +public interface OntologyRepository { + + /** + * Gets the name of the repository + * @return A short name for the repository + */ + String getName(); + + /** + * Gets a description of the location of the repository + * @return A human readable description of the repository location + */ + String getLocation(); + + + /** + * Ensures the repository is up to date + */ + void refresh(); + + void initialize(); + + Collection<OntologyRepositoryEntry> getEntries(); + + List<Object> getMetaDataKeys(); + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryEntry.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryEntry.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryEntry.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,33 @@ +package org.dllearner.kb.repository; + +import java.net.URI; + +public interface OntologyRepositoryEntry { + /** + * Gets a short human readable name for this entry + * @return A short human readable name + */ + String getOntologyShortName(); + + + /** + * Gets the URI of the ontology that is described by this entry. + * @return The ontology URI. + */ + URI getOntologyURI(); + + + /** + * Gets the physical URI of the ontology that is described by this entry. + * @return The physical URI. + */ + URI getPhysicalURI(); + + + /** + * Gets associated metadata. + * @param key The key that describes the metadata + * @return The metadata or <code>null</code> if there is no metadata associated with this key. + */ + String getMetaData(Object key); +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryManager.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryManager.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,32 @@ +package org.dllearner.kb.repository; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +public class OntologyRepositoryManager { + private static OntologyRepositoryManager instance; + + private List<OntologyRepository> repositories; + + private OntologyRepositoryManager() { + repositories = new ArrayList<OntologyRepository>(); + } + + public static synchronized OntologyRepositoryManager getManager() { + if(instance == null) { + instance = new OntologyRepositoryManager(); + } + return instance; + } + + + public void addRepository(OntologyRepository repository) { + repositories.add(repository); + } + + public Collection<OntologyRepository> getOntologyRepositories() { + return Collections.unmodifiableList(repositories); + } +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/BioPortalRepository.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/BioPortalRepository.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/BioPortalRepository.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,166 @@ +package org.dllearner.kb.repository.bioportal; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.log4j.Logger; +import org.dllearner.kb.repository.OntologyRepository; +import org.dllearner.kb.repository.OntologyRepositoryEntry; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.xml.KXml2Driver; + +public class BioPortalRepository implements OntologyRepository { + + private static final Logger log = Logger.getLogger(BioPortalRepository.class); + + private String apiKey = "8fadfa2c-47de-4487-a1f5-b7af7378d693"; + private String serviceURL = "http://rest.bioontology.org/bioportal/ontologies"; + + private List<OntologyRepositoryEntry> entries = new ArrayList<OntologyRepositoryEntry>(); + + @Override + public String getName() { + return "BioPortal"; + } + + @Override + public String getLocation() { + return "http://www.bioontology.org/"; + } + + @Override + public void initialize() { + refresh(); + } + + @Override + public void refresh() { + fillRepository(); + } + + private void fillRepository(){ + XStream xstream = new XStream(new KXml2Driver()); + xstream.alias("success", Success.class); + xstream.alias("data", Data.class); + xstream.alias("ontologyBean", OntologyBean.class); +// xstream.alias("userAcl", UserAcl.class); + xstream.alias("userEntry", UserEntry.class); + + InputStream is = null; + try { + is = getInputStream(new URL(withAPIKey(serviceURL))); + } catch (IOException e) { + e.printStackTrace(); + } + if (is == null) { + return; + } + Success success = (Success) xstream.fromXML(is); + if (success == null) { + return; + } + List<OntologyBean> beans = success.getData().getOntologyBeans(); + entries = new ArrayList<OntologyRepositoryEntry>(); + for(OntologyBean bean : beans){ + URI physicalURI = URI.create(withAPIKey(serviceURL + "/download/" + bean.getId())); + String shortName = bean.getDisplayLabel(); + boolean add = false; + for(String filename : bean.getFilenames()){ + if(filename.endsWith(".owl") || filename.endsWith("rdf") || filename.endsWith(".obo") || filename.endsWith(".nt") || filename.endsWith("*.ttl")){ + add = true; + break; + } + } + if(add){ + entries.add(new RepositoryEntry(physicalURI, physicalURI, shortName)); + } + } + log.info("Loaded " + entries.size() + " ontology entries from BioPortal."); + } + + @Override + public Collection<OntologyRepositoryEntry> getEntries() { + return entries; + } + + @Override + public List<Object> getMetaDataKeys() { + // TODO Auto-generated method stub + return null; + } + + private InputStream getInputStream(URL url) throws IOException { + if (url.getProtocol().equals("http")) { + URLConnection conn; + conn = url.openConnection(); + conn.setRequestProperty("Accept", "application/rdf+xml"); + conn.addRequestProperty("Accept", "text/xml"); + conn.addRequestProperty("Accept", "*/*"); + return conn.getInputStream(); + } else { + return url.openStream(); + } + } + + private String withAPIKey(String url){ + return url + "?apikey=" + apiKey; + } + + public static void main(String[] args) throws Exception{ + Collection<OntologyRepositoryEntry> entries = new BioPortalRepository().getEntries(); + for(OntologyRepositoryEntry entry : entries){ + System.out.println("Loading " + entry.getOntologyShortName()); + System.out.println("From " + entry.getPhysicalURI()); + OWLOntology ont = OWLManager.createOWLOntologyManager().loadOntology(IRI.create(entry.getPhysicalURI())); + System.out.println(ont.getAxiomCount()); + } + + } + + private class RepositoryEntry implements OntologyRepositoryEntry { + + private String shortName; + + private URI ontologyURI; + + private URI physicalURI; + + public RepositoryEntry(URI ontologyURI, URI physicalURI, String shortName) { + this.ontologyURI = ontologyURI; + this.physicalURI = physicalURI; + this.shortName = shortName; + } + + + public String getOntologyShortName() { + return shortName; + } + + + public URI getOntologyURI() { + return ontologyURI; + } + + + public URI getPhysicalURI() { + return physicalURI; + } + + + public String getMetaData(Object key) { + return null; + } + + } + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Data.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Data.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Data.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,16 @@ +package org.dllearner.kb.repository.bioportal; + +import java.util.ArrayList; +import java.util.List; + +public class Data { + List<OntologyBean> list = new ArrayList<OntologyBean>(); + + public void setOntologyBeans(List<OntologyBean> list) { + this.list = list; + } + + public List<OntologyBean> getOntologyBeans() { + return list; + } +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyAclEntry.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyAclEntry.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyAclEntry.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,45 @@ +package org.dllearner.kb.repository.bioportal; + +public class OntologyAclEntry { + private String ontologyId; + private String isOwner; + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "OntologyAclEntry [isOwner=" + isOwner + ", ontologyId=" + + ontologyId + "]"; + } + + /** + * @return the ontologyId + */ + public String getOntologyId() { + return ontologyId; + } + + /** + * @param ontologyId + * the ontologyId to set + */ + public void setOntologyId(String ontologyId) { + this.ontologyId = ontologyId; + } + + /** + * @return the isOwner + */ + public String getIsOwner() { + return isOwner; + } + + /** + * @param isOwner + * the isOwner to set + */ + public void setIsOwner(String isOwner) { + this.isOwner = isOwner; + } +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyBean.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyBean.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyBean.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,564 @@ +package org.dllearner.kb.repository.bioportal; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * Simplified version of the + * <code>org.ncbo.stanford.bean.concept.OntologyBean</code> class used to decode + * the "ontologyBean" element from a successful REST call to a BioPortal + * ontology service + * + * @author csnyulas + * + */ +public class OntologyBean implements Comparable<OntologyBean> { + + public static final String DEFAULT_SYNONYM_SLOT = "http://www.w3.org/2004/02/skos/core#altLabel"; + public static final String DEFAULT_PREFERRED_NAME_SLOT = "http://www.w3.org/2004/02/skos/core#prefLabel"; + public static final String DEFAULT_DEFINITION_SLOT = "http://www.w3.org/2004/02/skos/core#definition"; + public static final String DEFAULT_AUTHOR_SLOT = "http://purl.org/dc/elements/1.1/creator"; + + private Integer id; + private Integer ontologyId; + // virtual view id(s) on the virtual ontology + private List<Integer> virtualViewIds = new ArrayList<Integer>(0); + private Integer internalVersionNumber; + private List<Integer> userIds; + private String versionNumber; + private String versionStatus; + private Byte isRemote; + private Byte isReviewed; + private Integer statusId; + private Date dateCreated; + private Date dateReleased; + private String oboFoundryId; + private Byte isManual; + private String displayLabel; + private String description; + private String abbreviation; + private String format; + private String contactName; + private String contactEmail; + private String homepage; + private String documentation; + private String publication; + private String urn; + private String codingScheme; + private String targetTerminologies; + private Byte isFlat; + private Byte isFoundry; + private Byte isMetadataOnly; + private String synonymSlot; + private String preferredNameSlot; + private String documentationSlot; + private String authorSlot; + private String slotWithUniqueValue; + private Integer preferredMaximumSubclassLimit; + private String obsoleteParent; + private String naturalLanguage; + private String obsoleteProperty; + private String licenseInformation; + + private String viewingRestriction; + + private List<UserEntry> userAcl = new ArrayList<UserEntry>(0); + + private boolean isView = false; + + // category id(s) + private List<Integer> categoryIds = new ArrayList<Integer>(0); + + // group id(s) + private List<Integer> groupIds = new ArrayList<Integer>(0); + + // file name(s) + private List<String> filenames = new ArrayList<String>(0); + + // source fileItem + // private FileItem fileItem; + + // destination directory + private String filePath; + + // Download location of ontology + private String downloadLocation; + + // views on this ontology version + private List<Integer> hasViews = new ArrayList<Integer>(0); + + // view specific properties + private List<Integer> viewOnOntologyVersionId = new ArrayList<Integer>(0); + private String viewDefinition; + private String viewDefinitionLanguage; + private String viewGenerationEngine; + + @Override + public String toString() { + final int max = 80; + String viewDef = this.getViewDefinition(); + + if (viewDef != null && viewDef.length() > max) { + viewDef = viewDef.substring(0, max) + "..."; + } + + String name = isView ? "OntologyView " : "Ontology "; + + return name + "{Id: " + this.getId() + ", Ontology Id: " + this.getOntologyId() + ", Virtual View Ids: " + + this.getVirtualViewIds() + ", Remote: " + this.getIsRemote() + ", Obo Foundry Id: " + + this.getOboFoundryId() + ", Internal Version Number: " + this.getInternalVersionNumber() + + ", Date Created: " + this.getDateCreated() + ", User Ids: " + this.getUserIds() + + ", Version Number: " + this.getVersionNumber() + ", Version Status: " + this.getVersionStatus() + + ", Display Label: " + this.getDisplayLabel() + ", Description: " + this.getDescription() + + ", Abbreviation: " + this.getAbbreviation() + ", Format: " + this.getFormat() + ", Contact Name: " + + this.getContactName() + ", Contact Email: " + this.getContactEmail() + ", Foundry: " + + this.getIsFoundry() + " Coding Scheme: " + this.getCodingScheme() + ", Target Terminologies: " + + this.getTargetTerminologies() + ", Synonym Slot: " + this.getSynonymSlot() + + ", Preferred Name Slot: " + this.getPreferredNameSlot() + ", View Definition: " + viewDef + + ", View Definition Language: " + this.getViewDefinitionLanguage() + ", View Generation Engine: " + + this.getViewGenerationEngine() + ", View on Ontology Versions: " + this.getViewOnOntologyVersionId() + + "}"; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getOntologyId() { + return ontologyId; + } + + public void setOntologyId(Integer ontologyId) { + this.ontologyId = ontologyId; + } + + public List<Integer> getVirtualViewIds() { + return virtualViewIds; + } + + public void setVirtualViewIds(List<Integer> virtualViewIds) { + this.virtualViewIds = virtualViewIds; + } + + public Integer getInternalVersionNumber() { + return internalVersionNumber; + } + + public void setInternalVersionNumber(Integer internalVersionNumber) { + this.internalVersionNumber = internalVersionNumber; + } + + public List<Integer> getUserIds() { + return userIds; + } + + public void setUserIds(List<Integer> userIds) { + this.userIds = userIds; + } + + public String getVersionNumber() { + return versionNumber; + } + + public void setVersionNumber(String versionNumber) { + this.versionNumber = versionNumber; + } + + public String getVersionStatus() { + return versionStatus; + } + + public void setVersionStatus(String versionStatus) { + this.versionStatus = versionStatus; + } + + public Byte getIsRemote() { + return isRemote; + } + + public void setIsRemote(Byte isRemote) { + this.isRemote = isRemote; + } + + public Byte getIsReviewed() { + return isReviewed; + } + + public void setIsReviewed(Byte isReviewed) { + this.isReviewed = isReviewed; + } + + public Integer getStatusId() { + return statusId; + } + + public void setStatusId(Integer statusId) { + this.statusId = statusId; + } + + public Date getDateCreated() { + return dateCreated; + } + + public void setDateCreated(Date dateCreated) { + this.dateCreated = dateCreated; + } + + public Date getDateReleased() { + return dateReleased; + } + + public void setDateReleased(Date dateReleased) { + this.dateReleased = dateReleased; + } + + public String getOboFoundryId() { + return oboFoundryId; + } + + public void setOboFoundryId(String oboFoundryId) { + this.oboFoundryId = oboFoundryId; + } + + public Byte getIsManual() { + return isManual; + } + + public void setIsManual(Byte isManual) { + this.isManual = isManual; + } + + public String getDisplayLabel() { + return displayLabel; + } + + public void setDisplayLabel(String displayLabel) { + this.displayLabel = displayLabel; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getAbbreviation() { + return abbreviation; + } + + public void setAbbreviation(String abbreviation) { + this.abbreviation = abbreviation; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getContactName() { + return contactName; + } + + public void setContactName(String contactName) { + this.contactName = contactName; + } + + public String getContactEmail() { + return contactEmail; + } + + public void setContactEmail(String contactEmail) { + this.contactEmail = contactEmail; + } + + public String getHomepage() { + return homepage; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public String getDocumentation() { + return documentation; + } + + public void setDocumentation(String documentation) { + this.documentation = documentation; + } + + public String getPublication() { + return publication; + } + + public void setPublication(String publication) { + this.publication = publication; + } + + public String getUrn() { + return urn; + } + + public void setUrn(String urn) { + this.urn = urn; + } + + public String getCodingScheme() { + return codingScheme; + } + + public void setCodingScheme(String codingScheme) { + this.codingScheme = codingScheme; + } + + public String getTargetTerminologies() { + return targetTerminologies; + } + + public void setTargetTerminologies(String targetTerminologies) { + this.targetTerminologies = targetTerminologies; + } + + public Byte getIsFlat() { + return isFlat; + } + + public void setIsFlat(Byte isFlat) { + this.isFlat = isFlat; + } + + public Byte getIsFoundry() { + return isFoundry; + } + + public void setIsFoundry(Byte isFoundry) { + this.isFoundry = isFoundry; + } + + public Byte getIsMetadataOnly() { + return isMetadataOnly; + } + + public void setIsMetadataOnly(Byte isMetadataOnly) { + this.isMetadataOnly = isMetadataOnly; + } + + public String getSynonymSlot() { + return synonymSlot; + } + + public void setSynonymSlot(String synonymSlot) { + this.synonymSlot = synonymSlot; + } + + public String getPreferredNameSlot() { + return preferredNameSlot; + } + + public void setPreferredNameSlot(String preferredNameSlot) { + this.preferredNameSlot = preferredNameSlot; + } + + public String getDocumentationSlot() { + return documentationSlot; + } + + public void setDocumentationSlot(String documentationSlot) { + this.documentationSlot = documentationSlot; + } + + public String getAuthorSlot() { + return authorSlot; + } + + public void setAuthorSlot(String authorSlot) { + this.authorSlot = authorSlot; + } + + public String getSlotWithUniqueValue() { + return slotWithUniqueValue; + } + + public void setSlotWithUniqueValue(String slotWithUniqueValue) { + this.slotWithUniqueValue = slotWithUniqueValue; + } + + public Integer getPreferredMaximumSubclassLimit() { + return preferredMaximumSubclassLimit; + } + + public void setPreferredMaximumSubclassLimit(Integer preferredMaximumSubclassLimit) { + this.preferredMaximumSubclassLimit = preferredMaximumSubclassLimit; + } + + public boolean isView() { + return isView; + } + + public void setView(boolean isView) { + this.isView = isView; + } + + public List<Integer> getCategoryIds() { + return categoryIds; + } + + public void setCategoryIds(List<Integer> categoryIds) { + this.categoryIds = categoryIds; + } + + public List<Integer> getGroupIds() { + return groupIds; + } + + public void setGroupIds(List<Integer> groupIds) { + this.groupIds = groupIds; + } + + public List<String> getFilenames() { + return filenames; + } + + public void setFilenames(List<String> filenames) { + this.filenames = filenames; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public List<Integer> getHasViews() { + return hasViews; + } + + public void setHasViews(List<Integer> hasViews) { + this.hasViews = hasViews; + } + + public List<Integer> getViewOnOntologyVersionId() { + return viewOnOntologyVersionId; + } + + public void setViewOnOntologyVersionId(List<Integer> viewOnOntologyVersionId) { + this.viewOnOntologyVersionId = viewOnOntologyVersionId; + } + + public String getViewDefinition() { + return viewDefinition; + } + + public void setViewDefinition(String viewDefinition) { + this.viewDefinition = viewDefinition; + } + + public String getViewDefinitionLanguage() { + return viewDefinitionLanguage; + } + + public void setViewDefinitionLanguage(String viewDefinitionLanguage) { + this.viewDefinitionLanguage = viewDefinitionLanguage; + } + + public String getViewGenerationEngine() { + return viewGenerationEngine; + } + + public void setViewGenerationEngine(String viewGenerationEngine) { + this.viewGenerationEngine = viewGenerationEngine; + } + + public static String getDefaultPreferredNameSlot() { + return DEFAULT_PREFERRED_NAME_SLOT; + } + + public static String getDefaultDefinitionSlot() { + return DEFAULT_DEFINITION_SLOT; + } + + public static String getDefaultAuthorSlot() { + return DEFAULT_AUTHOR_SLOT; + } + + public String getDownloadLocation() { + return downloadLocation; + } + + public void setDownloadLocation(String downloadLocation) { + this.downloadLocation = downloadLocation; + } + + /** + * @return the userAcl + */ + public List<UserEntry> getUserAcl() { + return userAcl; + } + + /** + * @param userAcl + * the userAcl to set + */ + public void setUserAcl(List<UserEntry> userAcl) { + this.userAcl = userAcl; + } + + public String getViewingRestriction() { + return viewingRestriction; + } + + public void setViewingRestriction(String viewingRestriction) { + this.viewingRestriction = viewingRestriction; + } + + public String getObsoleteParent() { + return obsoleteParent; + } + + public void setObsoleteParent(String obsoleteParent) { + this.obsoleteParent = obsoleteParent; + } + + public String getNaturalLanguage() { + return naturalLanguage; + } + + public void setNaturalLanguage(String naturalLanguage) { + this.naturalLanguage = naturalLanguage; + } + + public String getObsoleteProperty() { + return obsoleteProperty; + } + + public void setObsoleteProperty(String obsoleteProperty) { + this.obsoleteProperty = obsoleteProperty; + } + + public String getLicenseInformation() { + return licenseInformation; + } + + public void setLicenseInformation(String licenseInformation) { + this.licenseInformation = licenseInformation; + } + + @Override + public int compareTo(OntologyBean o) { + return this.displayLabel.compareTo(o.getDisplayLabel()); + } + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Success.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Success.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/biopo... [truncated message content] |
From: <lor...@us...> - 2013-04-19 14:04:25
|
Revision: 3924 http://sourceforge.net/p/dl-learner/code/3924 Author: lorenz_b Date: 2013-04-19 14:04:20 +0000 (Fri, 19 Apr 2013) Log Message: ----------- Added class expression to SPARQL rewriter. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionOrderingComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLLiteralRenamer.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLObjectComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternAxiomToSPARQLConverter.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternExpressionToSPARQLConverter.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java trunk/components-core/src/main/resources/db_settings.ini.dist Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-04-15 20:53:29 UTC (rev 3923) +++ trunk/components-core/pom.xml 2013-04-19 14:04:20 UTC (rev 3924) @@ -112,13 +112,32 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.ini4j</groupId> + <artifactId>ini4j</artifactId> + </dependency> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + </dependency> <dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-distribution</artifactId> - <version>3.4.4</version> + <version>3.4</version> </dependency> <dependency> + <groupId>net.sourceforge.owlapi</groupId> + <artifactId>owlapi-dlsyntax</artifactId> + <version>3.3</version> + </dependency> + <dependency> + <groupId>net.sourceforge.owlapi</groupId> + <artifactId>owlapi-functional</artifactId> + <version>3.3</version> + </dependency> + + <dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-reasoner</artifactId> </dependency> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java 2013-04-15 20:53:29 UTC (rev 3923) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java 2013-04-19 14:04:20 UTC (rev 3924) @@ -1,22 +1,46 @@ package org.dllearner.algorithms.pattern; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; import java.net.URI; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; import java.util.Collection; import java.util.LinkedList; import java.util.Queue; +import java.util.prefs.Preferences; +import org.coode.owlapi.functionalrenderer.OWLFunctionalSyntaxRenderer; import org.dllearner.kb.dataset.OWLOntologyDataset; import org.dllearner.kb.repository.OntologyRepository; import org.dllearner.kb.repository.OntologyRepositoryEntry; +import org.ini4j.IniPreferences; +import org.ini4j.InvalidFileFormatException; import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.AbstractOWLRenderer; +import org.semanticweb.owlapi.io.OWLObjectRenderer; import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLAxiom; import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; import org.semanticweb.owlapi.model.OWLLogicalAxiom; import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl; + +import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; import com.google.common.collect.Multisets; @@ -45,6 +69,15 @@ private OntologyRepository repository; private OWLOntologyManager manager; private OWLDataFactory dataFactory; + + private Connection conn; + private PreparedStatement selectOntologyIdPs; + private PreparedStatement insertOntologyPs; + private PreparedStatement selectPatternIdPs; + private PreparedStatement insertPatternIdPs; + private PreparedStatement insertOntologyPatternPs; + + private OWLObjectRenderer axiomRenderer = new ManchesterOWLSyntaxOWLObjectRendererImpl(); public OWLAxiomPatternFinder(OWLOntologyDataset dataset) { @@ -54,33 +87,228 @@ this.repository = repository; manager = OWLManager.createOWLOntologyManager(); dataFactory = manager.getOWLDataFactory(); + + initDBConnection(); + createTables(); + try { + selectOntologyIdPs = conn.prepareStatement("SELECT id FROM Ontology WHERE url=?"); + insertOntologyPs = conn.prepareStatement("INSERT INTO Ontology (url, iri, repository) VALUES(?,?,?)"); + selectPatternIdPs = conn.prepareStatement("SELECT id FROM Pattern WHERE pattern=?"); + insertPatternIdPs = conn.prepareStatement("INSERT INTO Pattern (pattern,pattern_pretty) VALUES(?,?)"); + insertOntologyPatternPs = conn.prepareStatement("INSERT INTO Ontology_Pattern (ontology_id, pattern_id, occurrences) VALUES(?,?,?)"); + } catch (SQLException e) { + e.printStackTrace(); + } } - public void start(){ + private String render(OWLAxiom axiom){ + try { + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLOntology ontology = man.createOntology(); + man.addAxiom(ontology, axiom); + StringWriter sw = new StringWriter(); + org.coode.owlapi.functionalrenderer.OWLObjectRenderer r = new org.coode.owlapi.functionalrenderer.OWLObjectRenderer(man, ontology, sw); + axiom.accept(r); + return sw.toString(); + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); + } + return null; + } + + private void initDBConnection() { + try { + InputStream is = this.getClass().getClassLoader().getResourceAsStream("db_settings.ini"); + Preferences prefs = new IniPreferences(is); + String dbServer = prefs.node("database").get("server", null); + String dbName = prefs.node("database").get("name", null); + String dbUser = prefs.node("database").get("user", null); + String dbPass = prefs.node("database").get("pass", null); + + Class.forName("com.mysql.jdbc.Driver"); + String url = "jdbc:mysql://" + dbServer + "/" + dbName; + conn = DriverManager.getConnection(url, dbUser, dbPass); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (InvalidFileFormatException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void createTables(){ + try { + Statement statement = conn.createStatement(); + + statement.execute("CREATE TABLE IF NOT EXISTS Pattern (" + + "id MEDIUMINT NOT NULL AUTO_INCREMENT," + + "pattern VARCHAR(2000) NOT NULL," + + "pattern_pretty VARCHAR(2000) NOT NULL," + + "PRIMARY KEY(id)," + + "INDEX(pattern)) DEFAULT CHARSET=utf8"); + + statement.execute("CREATE TABLE IF NOT EXISTS Ontology (" + + "id MEDIUMINT NOT NULL AUTO_INCREMENT," + + "url VARCHAR(2000) NOT NULL," + + "iri VARCHAR(2000) NOT NULL," + + "repository VARCHAR(200) NOT NULL," + + "PRIMARY KEY(id)," + + "INDEX(url)) DEFAULT CHARSET=utf8"); + + statement.execute("CREATE TABLE IF NOT EXISTS Ontology_Pattern (" + + "ontology_id MEDIUMINT NOT NULL," + + "pattern_id MEDIUMINT NOT NULL," + + "occurrences INTEGER(8) NOT NULL," + + "FOREIGN KEY (ontology_id) REFERENCES Ontology(id)," + + "FOREIGN KEY (pattern_id) REFERENCES Pattern(id)," + + "PRIMARY KEY(ontology_id, pattern_id)) DEFAULT CHARSET=utf8"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + + private int addPattern(OWLAxiom axiom){ + String axiomString = render(axiom); + //check for existing entry + try { + selectPatternIdPs.setString(1, axiomString); + ResultSet rs = selectPatternIdPs.executeQuery(); + if(rs.next()){ + return rs.getInt(1); + } + } catch (SQLException e) { + e.printStackTrace(); + } + //add pattern entry + try { + insertPatternIdPs.setString(1, axiomString); + insertPatternIdPs.setString(2, axiomRenderer.render(axiom)); + insertPatternIdPs.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } + //get the auto generated ID + try { + selectPatternIdPs.setString(1, axiomString); + ResultSet rs = selectPatternIdPs.executeQuery(); + if(rs.next()){ + return rs.getInt(1); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return -1; + } + + private boolean ontologyProcessed(URI uri){ + //check if ontology was already processed + try { + selectOntologyIdPs.setString(1, uri.toString()); + ResultSet rs = selectOntologyIdPs.executeQuery(); + return rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + } + return false; + } + + private int addOntology(URI physicalURI, OWLOntology ontology){ + String url = physicalURI.toString(); + String ontologyIRI = ontology.getOntologyID().getOntologyIRI().toString(); + //check for existing entry + try { + selectOntologyIdPs.setString(1, url); + ResultSet rs = selectOntologyIdPs.executeQuery(); + if(rs.next()){ + return rs.getInt(1); + } + } catch (SQLException e) { + e.printStackTrace(); + } + //add ontology entry + try { + insertOntologyPs.setString(1, url); + insertOntologyPs.setString(2, ontologyIRI); + insertOntologyPs.setString(3, repository.getName()); + insertOntologyPs.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } + //get the auto generated ID + try { + selectOntologyIdPs.setString(1, url); + ResultSet rs = selectOntologyIdPs.executeQuery(); + if(rs.next()){ + return rs.getInt(1); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return -1; + } + + private void addOntologyPatterns(URI physicalURI, OWLOntology ontology, Multiset<OWLAxiom> patterns){ + int ontologyId = addOntology(physicalURI, ontology); + for (OWLAxiom pattern : patterns.elementSet()) { + try { + int patternId = addPattern(pattern); + int occurrences = patterns.count(pattern); + insertOntologyPatternPs.setInt(1, ontologyId); + insertOntologyPatternPs.setInt(2, patternId); + insertOntologyPatternPs.setInt(3, occurrences); + insertOntologyPatternPs.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + public void start() { OWLAxiomRenamer renamer = new OWLAxiomRenamer(dataFactory); Collection<OntologyRepositoryEntry> entries = repository.getEntries(); - Multiset<OWLAxiom> multiset = HashMultiset.create(); + Multiset<OWLAxiom> allAxiomPatterns = HashMultiset.create(); for (OntologyRepositoryEntry entry : entries) { - try { - URI uri = entry.getPhysicalURI(); - OWLOntology ontology = manager.loadOntology(IRI.create(uri)); - for(OWLLogicalAxiom axiom : ontology.getLogicalAxioms()){ - OWLAxiom renamedAxiom = renamer.rename(axiom); - multiset.add(renamedAxiom); + URI uri = entry.getPhysicalURI(); + if (!ontologyProcessed(uri)) { + System.out.println("Loading " + uri); + try { + OWLOntology ontology = manager.loadOntology(IRI.create(uri)); + Multiset<OWLAxiom> axiomPatterns = HashMultiset.create(); + for (OWLLogicalAxiom axiom : ontology.getLogicalAxioms()) { + OWLAxiom renamedAxiom = renamer.rename(axiom); + axiomPatterns.add(renamedAxiom); + } + allAxiomPatterns.addAll(axiomPatterns); + addOntologyPatterns(uri, ontology, axiomPatterns); + for (OWLAxiom owlAxiom : Multisets.copyHighestCountFirst(allAxiomPatterns).elementSet()) { +// System.out.println(owlAxiom + ": " + allAxiomPatterns.count(owlAxiom)); + } + manager.removeOntology(ontology); + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); } - } catch (OWLOntologyCreationException e) { - e.printStackTrace(); } - for (OWLAxiom owlAxiom : Multisets.copyHighestCountFirst(multiset).elementSet()) { - System.out.println(owlAxiom + ": " + multiset.count(owlAxiom)); - } + } - for (OWLAxiom owlAxiom : Multisets.copyHighestCountFirst(multiset).elementSet()) { - System.out.println(owlAxiom + ": " + multiset.count(owlAxiom)); - } } public static void main(String[] args) throws Exception { + String ontologyURL = "ontologyURL"; + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLDataFactory dataFactory = man.getOWLDataFactory(); + OWLFunctionalDataPropertyAxiom axiom = dataFactory.getOWLFunctionalDataPropertyAxiom(dataFactory.getOWLDataProperty(IRI.create("http://ex.org/p"))); + OWLOntology ontology = man.createOntology(); + man.addAxiom(ontology, axiom); + StringWriter sw = new StringWriter(); + org.coode.owlapi.functionalrenderer.OWLObjectRenderer r = new org.coode.owlapi.functionalrenderer.OWLObjectRenderer(man, ontology, sw); + axiom.accept(r); + System.out.println(sw.toString()); } } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java 2013-04-15 20:53:29 UTC (rev 3923) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java 2013-04-19 14:04:20 UTC (rev 3924) @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeSet; import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; @@ -12,6 +14,7 @@ import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; import org.semanticweb.owlapi.model.OWLAxiom; import org.semanticweb.owlapi.model.OWLAxiomVisitor; +import org.semanticweb.owlapi.model.OWLClass; import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; import org.semanticweb.owlapi.model.OWLClassExpression; import org.semanticweb.owlapi.model.OWLDataFactory; @@ -108,14 +111,26 @@ @Override public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + OWLObjectPropertyExpression property = axiom.getProperty(); + property = expressionRenamer.rename(property); + renamedAxiom = df.getOWLAsymmetricObjectPropertyAxiom(property); } @Override public void visit(OWLReflexiveObjectPropertyAxiom axiom) { + OWLObjectPropertyExpression property = axiom.getProperty(); + property = expressionRenamer.rename(property); + renamedAxiom = df.getOWLReflexiveObjectPropertyAxiom(property); } @Override public void visit(OWLDisjointClassesAxiom axiom) { + Set<OWLClassExpression> classExpressions = axiom.getClassExpressions(); + Set<OWLClassExpression> renamedClassExpressions = new HashSet<OWLClassExpression>(); + for (OWLClassExpression classExpression : classExpressions) { + renamedClassExpressions.add(expressionRenamer.rename(classExpression)); + } + renamedAxiom = df.getOWLDisjointClassesAxiom(renamedClassExpressions); } @Override @@ -138,22 +153,46 @@ @Override public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + Set<OWLObjectPropertyExpression> properties = axiom.getProperties(); + Set<OWLObjectPropertyExpression> renamedProperties = new HashSet<OWLObjectPropertyExpression>(); + for (OWLObjectPropertyExpression property : properties) { + renamedProperties.add(expressionRenamer.rename(property)); + } + renamedAxiom = df.getOWLEquivalentObjectPropertiesAxiom(renamedProperties); } @Override public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { +// axiom. } @Override public void visit(OWLDifferentIndividualsAxiom axiom) { + Set<OWLIndividual> renamedIndividuals = new HashSet<OWLIndividual>(); + for(OWLIndividual ind : axiom.getIndividuals()){ + renamedIndividuals.add(expressionRenamer.rename(ind)); + } + renamedAxiom = df.getOWLDifferentIndividualsAxiom(renamedIndividuals); } @Override public void visit(OWLDisjointDataPropertiesAxiom axiom) { + Set<OWLDataPropertyExpression> properties = axiom.getProperties(); + Set<OWLDataPropertyExpression> renamedProperties = new HashSet<OWLDataPropertyExpression>(); + for (OWLDataPropertyExpression property : properties) { + renamedProperties.add(expressionRenamer.rename(property)); + } + renamedAxiom = df.getOWLDisjointDataPropertiesAxiom(renamedProperties); } @Override public void visit(OWLDisjointObjectPropertiesAxiom axiom) { + Set<OWLObjectPropertyExpression> properties = axiom.getProperties(); + Set<OWLObjectPropertyExpression> renamedProperties = new HashSet<OWLObjectPropertyExpression>(); + for (OWLObjectPropertyExpression property : properties) { + renamedProperties.add(expressionRenamer.rename(property)); + } + renamedAxiom = df.getOWLDisjointObjectPropertiesAxiom(renamedProperties); } @Override @@ -194,6 +233,14 @@ @Override public void visit(OWLDisjointUnionAxiom axiom) { + OWLClass cls = axiom.getOWLClass(); + cls = expressionRenamer.rename(cls).asOWLClass(); + Set<OWLClassExpression> classExpressions = axiom.getClassExpressions(); + Set<OWLClassExpression> renamedClassExpressions = new HashSet<OWLClassExpression>(); + for (OWLClassExpression classExpression : classExpressions) { + renamedClassExpressions.add(expressionRenamer.rename(classExpression)); + } + renamedAxiom = df.getOWLDisjointUnionAxiom(cls, renamedClassExpressions); } @Override @@ -221,6 +268,12 @@ @Override public void visit(OWLEquivalentDataPropertiesAxiom axiom) { + Set<OWLDataPropertyExpression> properties = axiom.getProperties(); + Set<OWLDataPropertyExpression> renamedProperties = new HashSet<OWLDataPropertyExpression>(); + for (OWLDataPropertyExpression property : properties) { + renamedProperties.add(expressionRenamer.rename(property)); + } + renamedAxiom = df.getOWLEquivalentDataPropertiesAxiom(renamedProperties); } @Override @@ -278,10 +331,18 @@ @Override public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + OWLObjectPropertyExpression property = axiom.getProperty(); + property = expressionRenamer.rename(property); + renamedAxiom = df.getOWLInverseFunctionalObjectPropertyAxiom(property); } @Override public void visit(OWLSameIndividualAxiom axiom) { + Set<OWLIndividual> renamedIndividuals = new HashSet<OWLIndividual>(); + for(OWLIndividual ind : axiom.getIndividuals()){ + renamedIndividuals.add(expressionRenamer.rename(ind)); + } + renamedAxiom = df.getOWLSameIndividualAxiom(renamedIndividuals); } @Override @@ -290,6 +351,11 @@ @Override public void visit(OWLInverseObjectPropertiesAxiom axiom) { + OWLObjectPropertyExpression firstProperty = axiom.getFirstProperty(); + firstProperty = expressionRenamer.rename(firstProperty); + OWLObjectPropertyExpression secondProperty = axiom.getSecondProperty(); + secondProperty = expressionRenamer.rename(secondProperty); + renamedAxiom = df.getOWLInverseObjectPropertiesAxiom(firstProperty, secondProperty); } @Override Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionOrderingComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionOrderingComparator.java 2013-04-15 20:53:29 UTC (rev 3923) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionOrderingComparator.java 2013-04-19 14:04:20 UTC (rev 3924) @@ -5,6 +5,7 @@ import java.util.List; import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.util.OWLObjectTypeIndexProvider; import uk.ac.manchester.cs.owl.owlapi.OWLClassExpressionImpl; import uk.ac.manchester.cs.owl.owlapi.OWLClassImpl; @@ -32,6 +33,8 @@ OWLObjectMaxCardinalityImpl.class, OWLObjectExactCardinalityImpl.class ); + + private final OWLObjectTypeIndexProvider indexProvider = new OWLObjectTypeIndexProvider(); @Override public int compare(OWLClassExpression o1, OWLClassExpression o2) { Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java 2013-04-15 20:53:29 UTC (rev 3923) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java 2013-04-19 14:04:20 UTC (rev 3924) @@ -1,10 +1,6 @@ package org.dllearner.algorithms.pattern; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Arrays; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -58,23 +54,46 @@ import org.semanticweb.owlapi.model.OWLObjectUnionOf; import org.semanticweb.owlapi.model.OWLPropertyExpression; import org.semanticweb.owlapi.model.OWLPropertyExpressionVisitor; -import org.semanticweb.owlapi.util.OWLClassExpressionVisitorAdapter; public class OWLClassExpressionRenamer implements OWLClassExpressionVisitor, OWLPropertyExpressionVisitor, OWLIndividualVisitor, OWLDataRangeVisitor { private static final String NS = "http://dl-learner.org/pattern/"; - private Queue<String> classVarQueue = new LinkedList<String>(Arrays.asList("A", "B", "C" , "D", "E", "F", "G")); - private Queue<String> propertyVarQueue = new LinkedList<String>(Arrays.asList("p", "q", "r" , "s", "t")); - private Queue<String> individualVarQueue = new LinkedList<String>(Arrays.asList("a", "b", "c" , "d", "e", "f", "g")); private OWLDataFactory df; private Map<OWLEntity, OWLEntity> renaming; private OWLObject renamedOWLObject; - private OWLClassExpressionOrderingComparator comparator = new OWLClassExpressionOrderingComparator(); +// private OWLClassExpressionOrderingComparator comparator = new OWLClassExpressionOrderingComparator(); + private OWLObjectComparator comparator = new OWLObjectComparator(); + private Queue<String> classVarQueue = new LinkedList<String>(); + private Queue<String> propertyVarQueue = new LinkedList<String>(); + private Queue<String> individualVarQueue = new LinkedList<String>(); + private OWLLiteralRenamer literalRenamer; + + private boolean normalizeCardinalities = true; + private boolean normalizeHasValue = true; + private boolean normalizeOneOf = true; + public OWLClassExpressionRenamer(OWLDataFactory df, Map<OWLEntity, OWLEntity> renaming) { this.df = df; this.renaming = renaming; + + literalRenamer = new OWLLiteralRenamer(df); + + for(int i = 65; i <= 90; i++){ + classVarQueue.add(String.valueOf((char)i)); + } + for(int j = 2; j <=5; j++){ + for(int i = 65; i <= 90; i++){ + classVarQueue.add(String.valueOf((char)i) + "_" + j); + } + } + for(int i = 97; i <= 111; i++){ + individualVarQueue.add(String.valueOf((char)i)); + } + for(int i = 112; i <= 122; i++){ + propertyVarQueue.add(String.valueOf((char)i)); + } } public OWLClassExpression rename(OWLClassExpression expr){ @@ -103,7 +122,7 @@ public OWLLiteral rename(OWLLiteral lit){ renamedOWLObject = null; - renamedOWLObject = lit; + renamedOWLObject = literalRenamer.rename(lit); return (OWLLiteral) renamedOWLObject; } @@ -134,6 +153,7 @@ OWLDataPropertyExpression property = desc.getProperty(); property = rename(property); OWLLiteral value = desc.getValue(); + value = rename(value); renamedOWLObject = df.getOWLDataHasValue(property, value); } @@ -178,6 +198,9 @@ OWLClassExpression filler = desc.getFiller(); filler = rename(filler); int cardinality = desc.getCardinality(); + if(normalizeCardinalities){ + cardinality = 1; + } renamedOWLObject = df.getOWLObjectMinCardinality(cardinality, property, filler); } @@ -188,6 +211,9 @@ OWLClassExpression filler = desc.getFiller(); filler = rename(filler); int cardinality = desc.getCardinality(); + if(normalizeCardinalities){ + cardinality = 1; + } renamedOWLObject = df.getOWLObjectExactCardinality(cardinality, property, filler); } @@ -198,6 +224,9 @@ OWLClassExpression filler = desc.getFiller(); filler = rename(filler); int cardinality = desc.getCardinality(); + if(normalizeCardinalities){ + cardinality = 1; + } renamedOWLObject = df.getOWLObjectMaxCardinality(cardinality, property, filler); } @@ -243,6 +272,9 @@ OWLDataRange filler = desc.getFiller(); filler = rename(filler); int cardinality = desc.getCardinality(); + if(normalizeCardinalities){ + cardinality = 1; + } renamedOWLObject = df.getOWLDataMinCardinality(cardinality, property, filler); } @@ -253,6 +285,9 @@ OWLDataRange filler = desc.getFiller(); filler = rename(filler); int cardinality = desc.getCardinality(); + if(normalizeCardinalities){ + cardinality = 1; + } renamedOWLObject = df.getOWLDataExactCardinality(cardinality, property, filler); } @@ -263,6 +298,9 @@ OWLDataRange filler = desc.getFiller(); filler = rename(filler); int cardinality = desc.getCardinality(); + if(normalizeCardinalities){ + cardinality = 1; + } renamedOWLObject = df.getOWLDataMaxCardinality(cardinality, property, filler); } @@ -355,19 +393,37 @@ } @Override - public void visit(OWLDataComplementOf arg0) { + public void visit(OWLDataComplementOf desc) { + OWLDataRange dataRange = desc.getDataRange(); + dataRange = rename(dataRange); + renamedOWLObject = df.getOWLDataComplementOf(dataRange); } @Override - public void visit(OWLDataIntersectionOf arg0) { + public void visit(OWLDataIntersectionOf desc) { + List<OWLDataRange> operands = new ArrayList<OWLDataRange>(desc.getOperands()); + Collections.sort(operands, comparator); + SortedSet<OWLDataRange> renamedOperands = new TreeSet<OWLDataRange>(comparator); + for(OWLDataRange expr : operands){ + renamedOperands.add(rename(expr)); + } + renamedOWLObject = df.getOWLDataIntersectionOf(renamedOperands); } @Override - public void visit(OWLDataUnionOf arg0) { + public void visit(OWLDataUnionOf desc) { + List<OWLDataRange> operands = new ArrayList<OWLDataRange>(desc.getOperands()); + Collections.sort(operands, comparator); + SortedSet<OWLDataRange> renamedOperands = new TreeSet<OWLDataRange>(comparator); + for(OWLDataRange expr : operands){ + renamedOperands.add(rename(expr)); + } + renamedOWLObject = df.getOWLDataUnionOf(renamedOperands); } @Override - public void visit(OWLDatatypeRestriction arg0) { + public void visit(OWLDatatypeRestriction desc) { + renamedOWLObject = desc; } } Added: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLLiteralRenamer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLLiteralRenamer.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLLiteralRenamer.java 2013-04-19 14:04:20 UTC (rev 3924) @@ -0,0 +1,44 @@ +package org.dllearner.algorithms.pattern; + +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +public class OWLLiteralRenamer { + + private OWLDataFactory dataFactory; + + public OWLLiteralRenamer(OWLDataFactory dataFactory) { + this.dataFactory = dataFactory; + } + + public OWLLiteral rename(OWLLiteral literal){ + OWLLiteral renamedLiteral = literal; + OWLDatatype datatype = literal.getDatatype(); + if(datatype.isRDFPlainLiteral()){ + if(literal.hasLang()){ + renamedLiteral = dataFactory.getOWLLiteral("plain", literal.getLang()); + } else { + renamedLiteral = dataFactory.getOWLLiteral("plain"); + } + } else { + if(datatype.getIRI().equals(OWL2Datatype.XSD_STRING.getIRI())){ + renamedLiteral = dataFactory.getOWLLiteral("string", datatype); + } else if(datatype.getIRI().equals(OWL2Datatype.XSD_DOUBLE.getIRI()) || + datatype.getIRI().equals(OWL2Datatype.XSD_DECIMAL.getIRI()) || + datatype.getIRI().equals(OWL2Datatype.XSD_FLOAT.getIRI())){ + renamedLiteral = dataFactory.getOWLLiteral("1.0", datatype); + } else if(datatype.getIRI().equals(OWL2Datatype.XSD_INT.getIRI()) || + datatype.getIRI().equals(OWL2Datatype.XSD_INTEGER.getIRI()) || + datatype.getIRI().equals(OWL2Datatype.XSD_LONG.getIRI()) || + datatype.getIRI().equals(OWL2Datatype.XSD_BYTE.getIRI()) || + datatype.getIRI().equals(OWL2Datatype.XSD_SHORT.getIRI())){ + renamedLiteral = dataFactory.getOWLLiteral("1", datatype); + } + } + renamedLiteral = dataFactory.getOWLLiteral("", OWL2Datatype.RDF_PLAIN_LITERAL); + return renamedLiteral; + } + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLObjectComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLObjectComparator.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLObjectComparator.java 2013-04-19 14:04:20 UTC (rev 3924) @@ -0,0 +1,21 @@ +package org.dllearner.algorithms.pattern; + +import java.util.Comparator; + +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.util.OWLObjectTypeIndexProvider; + +public class OWLObjectComparator implements Comparator<OWLObject> { + + private final OWLObjectTypeIndexProvider indexProvider = new OWLObjectTypeIndexProvider(); + + @Override + public int compare(OWLObject o1, OWLObject o2) { + int diff = indexProvider.getTypeIndex(o1) - indexProvider.getTypeIndex(o2); + if(diff == 0){ + return o1.compareTo(o2); + } else { + return diff; + } + } +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternAxiomToSPARQLConverter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternAxiomToSPARQLConverter.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternAxiomToSPARQLConverter.java 2013-04-19 14:04:20 UTC (rev 3924) @@ -0,0 +1,286 @@ +package org.dllearner.algorithms.pattern; + +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.ToStringRenderer; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLAxiomVisitor; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.util.DefaultPrefixManager; + +import uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntaxObjectRenderer; + +import com.hp.hpl.jena.query.Query; +import com.hp.hpl.jena.query.QueryFactory; +import com.hp.hpl.jena.query.Syntax; + +public class PatternAxiomToSPARQLConverter implements OWLAxiomVisitor { + + private String root = "?x"; + private PatternExpressionToSPARQLConverter expressionConverter; + private String sparql; + + public PatternAxiomToSPARQLConverter() { + } + + public Query convert(OWLAxiom axiom) { + expressionConverter = new PatternExpressionToSPARQLConverter(); + + sparql = "SELECT " + root + " WHERE {\n"; + axiom.accept(this); + sparql += "}"; + + return QueryFactory.create(sparql, Syntax.syntaxARQ); + } + + @Override + public void visit(OWLAnnotationAssertionAxiom axiom) { + } + + @Override + public void visit(OWLSubAnnotationPropertyOfAxiom axiom) { + } + + @Override + public void visit(OWLAnnotationPropertyDomainAxiom axiom) { + } + + @Override + public void visit(OWLAnnotationPropertyRangeAxiom axiom) { + } + + @Override + public void visit(OWLDeclarationAxiom axiom) { + } + + @Override + public void visit(OWLSubClassOfAxiom axiom) { + OWLClassExpression subClass = axiom.getSubClass(); + sparql += expressionConverter.convert(root, subClass); + OWLClassExpression superClass = axiom.getSuperClass(); + sparql += expressionConverter.convert(root, superClass); + } + + @Override + public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + } + + @Override + public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + } + + @Override + public void visit(OWLReflexiveObjectPropertyAxiom axiom) { + } + + @Override + public void visit(OWLDisjointClassesAxiom axiom) { + } + + @Override + public void visit(OWLDataPropertyDomainAxiom axiom) { + } + + @Override + public void visit(OWLObjectPropertyDomainAxiom axiom) { + } + + @Override + public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + } + + @Override + public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + } + + @Override + public void visit(OWLDifferentIndividualsAxiom axiom) { + } + + @Override + public void visit(OWLDisjointDataPropertiesAxiom axiom) { + } + + @Override + public void visit(OWLDisjointObjectPropertiesAxiom axiom) { + } + + @Override + public void visit(OWLObjectPropertyRangeAxiom axiom) { + } + + @Override + public void visit(OWLObjectPropertyAssertionAxiom axiom) { + } + + @Override + public void visit(OWLFunctionalObjectPropertyAxiom axiom) { + } + + @Override + public void visit(OWLSubObjectPropertyOfAxiom axiom) { + } + + @Override + public void visit(OWLDisjointUnionAxiom axiom) { + } + + @Override + public void visit(OWLSymmetricObjectPropertyAxiom axiom) { + } + + @Override + public void visit(OWLDataPropertyRangeAxiom axiom) { + } + + @Override + public void visit(OWLFunctionalDataPropertyAxiom axiom) { + } + + @Override + public void visit(OWLEquivalentDataPropertiesAxiom axiom) { + } + + @Override + public void visit(OWLClassAssertionAxiom axiom) { + } + + @Override + public void visit(OWLEquivalentClassesAxiom axiom) { + } + + @Override + public void visit(OWLDataPropertyAssertionAxiom axiom) { + } + + @Override + public void visit(OWLTransitiveObjectPropertyAxiom axiom) { + } + + @Override + public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + } + + @Override + public void visit(OWLSubDataPropertyOfAxiom axiom) { + } + + @Override + public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + } + + @Override + public void visit(OWLSameIndividualAxiom axiom) { + } + + @Override + public void visit(OWLSubPropertyChainOfAxiom axiom) { + } + + @Override + public void visit(OWLInverseObjectPropertiesAxiom axiom) { + } + + @Override + public void visit(OWLHasKeyAxiom axiom) { + } + + @Override + public void visit(OWLDatatypeDefinitionAxiom axiom) { + } + + @Override + public void visit(SWRLRule axiom) { + } + + public static void main(String[] args) throws Exception { + ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); + PatternAxiomToSPARQLConverter converter = new PatternAxiomToSPARQLConverter(); + + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLDataFactory df = man.getOWLDataFactory(); + PrefixManager pm = new DefaultPrefixManager("http://examples.org/ontology#"); + + OWLClass clsA = df.getOWLClass("A", pm); + OWLClass clsB = df.getOWLClass("B", pm); + OWLClass clsC = df.getOWLClass("C", pm); + + OWLObjectProperty propR = df.getOWLObjectProperty("r", pm); + OWLObjectProperty propS = df.getOWLObjectProperty("s", pm); + + OWLIndividual indA = df.getOWLNamedIndividual("a", pm); + OWLIndividual indB = df.getOWLNamedIndividual("b", pm); + + OWLAxiom axiom = df.getOWLSubClassOfAxiom( + clsA, + clsB); + Query query = converter.convert(axiom); + System.out.println(axiom + "\n" + query); + + axiom = df.getOWLSubClassOfAxiom( + clsA, + df.getOWLObjectSomeValuesFrom(propR, clsB)); + query = converter.convert(axiom); + System.out.println(axiom + "\n" + query); + + axiom = df.getOWLSubClassOfAxiom( + clsA, + df.getOWLObjectIntersectionOf( + df.getOWLObjectSomeValuesFrom(propR, clsB), + clsB)); + query = converter.convert(axiom); + System.out.println(axiom + "\n" + query); + + axiom = df.getOWLSubClassOfAxiom( + clsA, + df.getOWLObjectAllValuesFrom(propR, clsB)); + query = converter.convert(axiom); + System.out.println(axiom + "\n" + query); + + } + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternExpressionToSPARQLConverter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternExpressionToSPARQLConverter.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternExpressionToSPARQLConverter.java 2013-04-19 14:04:20 UTC (rev 3924) @@ -0,0 +1,207 @@ +package org.dllearner.algorithms.pattern; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.Stack; + +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLPropertyExpressionVisitor; + +public class PatternExpressionToSPARQLConverter implements OWLClassExpressionVisitor, OWLPropertyExpressionVisitor{ + + private String sparql = ""; + private Stack<String> variables = new Stack<String>(); + private Map<OWLEntity, String> variablesMapping; + + private int classCnt = 0; + private int propCnt = 0; + private int indCnt = 0; + + public PatternExpressionToSPARQLConverter() { + variablesMapping = new HashMap<OWLEntity, String>(); + } + + public String convert(String root, OWLClassExpression expr){ + sparql = ""; + variables.push(root); + expr.accept(this); + return sparql; + } + + private String getVariable(OWLEntity entity){ + String var = variablesMapping.get(entity); + if(var == null){ + if(entity.isOWLClass()){ + var = "?cls" + classCnt++; + } else if(entity.isOWLObjectProperty() || entity.isOWLDataProperty()){ + var = "?p" + propCnt++; + } else if(entity.isOWLNamedIndividual()){ + var = buildIndividualVariable(); + } + variablesMapping.put(entity, var); + } + return var; + } + + private String buildIndividualVariable(){ + return "?s" + indCnt++; + } + + private String triple(String subject, String predicate, String object){ + return subject + " " + predicate + " " + object + ".\n"; + } + + @Override + public void visit(OWLClass expr) { + sparql += variables.peek() + " a " + getVariable(expr) +".\n"; + } + + @Override + public void visit(OWLObjectProperty property) { + + } + + @Override + public void visit(OWLDataProperty property) { + } + + @Override + public void visit(OWLObjectIntersectionOf expr) { + Set<OWLClassExpression> operands = expr.getOperands(); + String variable = variables.peek(); + for (OWLClassExpression operand : operands) { + sparql += convert(variable, operand); + } + } + + @Override + public void visit(OWLObjectUnionOf expr) { + } + + @Override + public void visit(OWLObjectComplementOf expr) { + } + + @Override + public void visit(OWLObjectSomeValuesFrom expr) { + String variable = variables.peek(); + OWLObjectPropertyExpression property = expr.getProperty(); + if(!property.isAnonymous()){ + String objectVariable = buildIndividualVariable(); + variables.push(objectVariable); + //build the triple for the property + sparql += triple(variable, getVariable(property.asOWLObjectProperty()), objectVariable); + //build the rest according to the role filler + OWLClassExpression filler = expr.getFiller(); + filler.accept(this); + variables.pop(); + + } else { + System.err.println("TODO: complex property expressions"); + } + + } + + @Override + public void visit(OWLObjectAllValuesFrom expr) { + String variable = variables.peek(); + OWLObjectPropertyExpression property = expr.getProperty(); + if(!property.isAnonymous()){ + String objectVariable = buildIndividualVariable(); + variables.push(objectVariable); + //build the triple for the property + sparql += triple(variable, getVariable(property.asOWLObjectProperty()), objectVariable); + OWLClassExpression filler = expr.getFiller(); + filler.accept(this); + //build the rest according to the role filler + sparql += "FILTER NOT EXISTS{"; + objectVariable = buildIndividualVariable(); + variables.push(objectVariable); + sparql += triple(variable, getVariable(property.asOWLObjectProperty()), objectVariable); + variables.pop(); + sparql += "}"; + + + } else { + System.err.println("TODO: complex property expressions"); + } + } + + @Override + public void visit(OWLObjectHasValue expr) { + } + + @Override + public void visit(OWLObjectMinCardinality expr) { + } + + @Override + public void visit(OWLObjectExactCardinality expr) { + } + + @Override + public void visit(OWLObjectMaxCardinality expr) { + } + + @Override + public void visit(OWLObjectHasSelf expr) { + } + + @Override + public void visit(OWLObjectOneOf expr) { + } + + @Override + public void visit(OWLDataSomeValuesFrom expr) { + } + + @Override + public void visit(OWLDataAllValuesFrom expr) { + } + + @Override + public void visit(OWLDataHasValue expr) { + } + + @Override + public void visit(OWLDataMinCardinality expr) { + } + + @Override + public void visit(OWLDataExactCardinality expr) { + } + + @Override + public void visit(OWLDataMaxCardinality expr) { + } + + @Override + public void visit(OWLObjectInverseOf property) { + } + +} Added: trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java 2013-04-19 14:04:20 UTC (rev 3924) @@ -0,0 +1,568 @@ +package org.dllearner.utilities.owl; + +import java.util.List; +import java.util.Map; +import java.util.Stack; + +import org.aksw.commons.collections.diff.ModelDiff; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.ToStringRenderer; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataRangeVisitor; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLPropertyExpression; +import org.semanticweb.owlapi.model.OWLPropertyExpressionVisitor; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.util.DefaultPrefixManager; + +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; +import uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntaxObjectRenderer; + +import com.hp.hpl.jena.query.Query; +import com.hp.hpl.jena.query.QueryFactory; +import com.hp.hpl.jena.query.Syntax; + +public class OWLClassExpressionToSPARQLConverter implements OWLClassExpressionVisitor, OWLPropertyExpressionVisitor, OWLDataRangeVisitor{ + + private String sparql = ""; + private Stack<String> variables = new Stack<String>(); + private Map<OWLEntity, String> variablesMapping; + + private int classCnt = 0; + private int propCnt = 0; + private int indCnt = 0; + + private OWLDataFactory df = new OWLDataFactoryImpl(); + + public OWLClassExpressionToSPARQLConverter() { + } + + public String convert(String rootVariable, OWLClassExpression expr){ + reset(); + variables.push(rootVariable); + expr.accept(this); + return sparql; + } + + public String convert(String rootVariable, OWLPropertyExpression expr){ + variables.push(rootVariable); + sparql = ""; + expr.accept(this); + return sparql; + } + + public Query asQuery(String rootVariable, OWLClassExpression expr){ + String queryString = "SELECT " + rootVariable + " WHERE {"; + queryString += convert(rootVariable, expr); + queryString += "}";System.out.println(queryString); + return QueryFactory.create(queryString, Syntax.syntaxARQ); + } + + private void reset(){ + variables.clear(); + classCnt = 0; + propCnt = 0; + indCnt = 0; + sparql = ""; + } + + private String getVariable(OWLEntity entity){ + String var = variablesMapping.get(entity); + if(var == null){ + if(entity.isOWLClass()){ + var = "?cls" + classCnt++; + } else if(entity.isOWLObjectProperty() || entity.isOWLDataProperty()){ + var = "?p" + propCnt++; + } else if(entity.isOWLNamedIndividual()){ + var = buildIndividualVariable(); + } + variablesMapping.put(entity, var); + } + return var; + } + + private String buildIndividualVariable(){ + return "?s" + indCnt++; + } + + private int modalDepth(){ + return variables.size(); + } + + private String triple(String subject, String predicate, String object){ + return (subject.startsWith("?") ? subject : "<" + subject + ">") + " " + + (predicate.startsWith("?") || predicate.equals("a") ? predicate : "<" + predicate + ">") + " " + + (object.startsWith("?") ? object : "<" + object + ">") + ".\n"; + } + + private String triple(String subject, String predicate, OWLLiteral object){ + return (subject.startsWith("?") ? subject : "<" + subject + ">") + " " + + (predicate.startsWith("?") || predicate.equals("a") ? predicate : "<" + predicate + ">") + " " + + "\"" + object + "\"^^<" + object.getDatatype().toStringID() + ">.\n"; + } + + private String triple(String subject, String predicate, OWLIndividual object){ + return (subject.startsWith("?") ? subject : "<" + subject + ">") + " " + + (predicate.startsWith("?") || predicate.equals("a") ? predicate : "<" + predicate + ">") + " " + + "<" + object.toStringID() + ">.\n"; + } + + @Override + public void visit(OWLObjectProperty property) { + } + + @Override + public void visit(OWLObjectInverseOf property) { + } + + @Override + public void visit(OWLDataProperty property) { + } + + @Override + public void visit(OWLClass ce) { + sparql += triple(variables.peek(), "a", ce.toStringID()); + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + List<OWLClassExpression> operands = ce.getOperandsAsList(); + for (OWLClassExpression operand : operands) { + operand.accept(this); + } + } + + @Override + public void visit(OWLObjectUnionOf ce) { + List<OWLClassExpression> operands = ce.getOperandsAsList(); + for (int i = 0; i < operands.size()-1; i++) { + sparql += "{"; + operands.get(i).accept(this); + sparql += "}"; + sparql += " UNION "; + } + sparql += "{"; + operands.get(operands.size()-1).accept(this); + sparql += "}"; + } + + @Override + public void visit(OWLObjectComplementOf ce) { + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + String objectVariable = buildIndividualVariable(); + OWLObjectPropertyExpression propertyExpression = ce.getProperty(); + if(propertyExpression.isAnonymous()){ + //property expression is inverse of a property + sparql += triple(objectVariable, propertyExpression.getNamedProperty().toStringID(), variables.peek()); + } else { + sparql += triple(variables.peek(), propertyExpression.getNamedProperty().toStringID(), objectVariable); + } + OWLClassExpression filler = ce.getFiller(); + if(filler.isAnonymous()){ + if(filler instanceof OWLObjectOneOf){ + variables.push(objectVariable); + filler.accept(this); + variables.pop(); + } else { + String var = buildIndividualVariable(); + variables.push(var); + sparql += triple(objectVariable, "a", var); + filler.accept(this); + variables.pop(); + } + } else { + sparql += triple(objectVariable, "a", filler.asOWLClass().toStringID()); + } + + } + + @Override + public void visit(OWLObjectAllValuesFrom ce) { + String subject = variables.peek(); + String objectVariable = buildIndividualVariable(); + OWLObjectPropertyExpression propertyExpression = ce.getProperty(); + String predicate = propertyExpression.getNamedProperty().toStringID(); + OWLClassExpression filler = ce.getFiller(); + if(propertyExpression.isAnonymous()){ + //property expression is inverse of a property + sparql += triple(objectVariable, predicate, variables.peek()); + } else { + sparql += triple(variables.peek(), predicate, objectVariable); + } + + String var = buildIndividualVariable(); + sparql += "{SELECT " + subject + " (COUNT(" + var + ") AS ?cnt1) WHERE {"; + sparql += triple(subject, predicate, var); + variables.push(var); + filler.accept(this); + variables.pop(); + sparql += "} GROUP BY " + subject + "}"; + + var = buildIndividualVariable(); + sparql += "{SELECT " + subject + " (COUNT(" + var + ") AS ?cnt2) WHERE {"; + sparql += triple(subject, predicate, var); + sparql += "} GROUP BY " + subject + "}"; + + sparql += "FILTER(?cnt1=?cnt2)"; + + } + + @Override + public void visit(OWLObjectHasValue ce) { + OWLObjectPropertyExpression propertyExpression = ce.getProperty(); + OWLIndividual value = ce.getValue(); + if(propertyExpression.isAnonymous()){ + //property expression is inverse of a property + sparql += triple(value.toStringID(), propertyExpression.getNamedProperty().toStringID(), variables.peek()); + } else { + sparql += triple(variables.peek(), propertyExpression.getNamedProperty().toStringID(), value.toStringID()); + } + } + + @Override + public void visit(OWLObjectMinCardinality ce) { + String subjectVariable = variables.peek(); + String objectVariable = buildIndividualVariable(); + OWLObjectPropertyExpression propertyExpression = ce.getProperty(); + int cardinality = ce.getCardinality(); + sparql += "{SELECT " + subjectVariable + " WHERE {"; + if(propertyExpression.isAnonymous()){ + //property expression is inverse of a property + sparql += triple(objectVariable, propertyExpression.getNamedProperty().toStringID(), subjectVariable); + } else { + sparql += triple(subjectVariable, propertyExpression.getNamedProperty().toStringID(), objectVariable); + } + OWLClassExpression filler = ce.getFiller(); + if(filler.isAnonymous()){ + String var = buildIndividualVariable(); + variables.push(var); + sparql += triple(objectVariable, "a", var); + filler.accept(this); + variables.pop(); + } else { + sparql += triple(objectVariable, "a", filler.asOWLClass().toStringID()); + } + + sparql += "} GROUP BY " + subjectVariable + " HAVING(COUNT(" + objectVariable + ")>=" + cardinality + ")}"; + + } + + @Override + public void visit(OWLObjectExactCardinality ce) { + String subjectVariable = variables.peek(); + String objectVariable = buildIndividualVariable(); + OWLObjectPropertyExpression propertyExpression = ce.getProperty(); + int cardinality = ce.getCardinality(); + sparql += "{SELECT " + subjectVariable + " WHERE {"; + if(propertyExpression.isAnonymous()){ + //property expression is inverse of a property + sparql += triple(objectVariable, propertyExpression.getNamedProperty().toStringID(), subjectVariable); + } else { + sparql += triple(subjectVariable, propertyExpression.getNamedProperty().toStringID(), objectVariable); + } + OWLClassExpression filler = ce.getFiller(); + if(filler.isAnonymous()){ + String var = buildIndividualVariable(); + variables.push(var); + sparql += triple(objectVariable, "a", var); + filler.accept(this); + variables.pop(); + } else { + sparql += triple(objectVariable, "a", filler.asOWLClass().toStringID()); + } + + sparql += "} GROUP BY " + subjectVariable + " HAVING(COUNT(" + objectVariable + ")=" + cardinality + ")}"; + } + + @Override + public void visit(OWLObjectMaxCardinality ce) { + String subjectVariable = variables.peek(); + String objectVariable = buildIndividualVariable(); + OWLObjectPropertyExpression propertyExpression = ce.getProperty(); + int cardinality = ce.getCardinality(); + sparql += "{SELECT " + subjectVariable + " WHERE {"; + if(propertyExpression.isAnonymous()){ + //property expression is inverse of a property + sparql += triple(objectVariable, propertyExpression.getNamedProperty().toStringID(), subjectVariable); + } else { + sparql += triple(subjectVariable, propertyExpression.getNamedProperty().toStringID(), objectVariable); + } + OWLClassExpression filler = ce.getFiller(); + if(filler.isAnonymous()){ + String var = buildIndividualVariable(); + variables.push(var); + sparql += triple(objectVariable, "a", var); + filler.accept(this); + variables.pop(); + } else { + sparql += triple(objectVariable, "a", filler.asOWLClass().toStringID()); + } + + sparql += "} GROUP BY " + subjectVariable + " HAVING(COUNT(" + objectVariable + ")<=" + cardinality + ")}"; + } + + @Override + public void visit(OWLObjectHasSelf ce) { + String subject = variables.peek(); + OWLObjectPropertyExpression property = ce.getProperty(); + sparql += triple(subject, property.getNamedProperty().toStringID(), subject); + } + + @Override + public void visit(OWLObjectOneOf ce) { + String subject = variables.peek(); + if(modalDepth() == 1){ + sparql += triple(subject, "?p", "?o"); + } + sparql += "FILTER(" + subject + " IN ("; + String values = ""; + for (OWLIndividual ind : ce.getIndividuals()) { + if(!values.isEmpty()){ + values += ","; + } + values += "<" + ind.toStringID() + ">"; + } + sparql += values; + sparql += ... [truncated message content] |
From: <lor...@us...> - 2013-06-06 13:32:33
|
Revision: 3985 http://sourceforge.net/p/dl-learner/code/3985 Author: lorenz_b Date: 2013-06-06 13:32:30 +0000 (Thu, 06 Jun 2013) Log Message: ----------- Updated LGG. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/NoiseSensitiveLGG.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL2.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java trunk/components-core/src/main/resources/prefixes.csv Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/pom.xml 2013-06-06 13:32:30 UTC (rev 3985) @@ -320,6 +320,11 @@ <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> + <dependency> + <groupId>org.aksw.jena-sparql-api</groupId> + <artifactId>jena-sparql-api-core</artifactId> + <version>2.10.0-3</version> + </dependency> </dependencies> <dependencyManagement> <dependencies> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java 2013-06-06 13:32:30 UTC (rev 3985) @@ -55,6 +55,8 @@ QueryTree<N> getNodeById(int nodeId); + boolean sameType(QueryTree<N> tree); + boolean isLiteralNode(); void setLiteralNode(boolean isLiteralNode); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2013-06-06 13:32:30 UTC (rev 3985) @@ -124,6 +124,12 @@ addChild(subTree, tree.getEdge(child)); } } + + public boolean sameType(QueryTree<N> tree){ + return (isResourceNode && tree.isResourceNode()) || + (isVarNode() && tree.isVarNode()) || + (isLiteralNode && tree.isLiteralNode()); + } public N getUserObject() { return userObject; @@ -327,6 +333,9 @@ @Override public boolean isSubsumedBy(QueryTree<N> tree) { +// if(!sameType(tree)){ +// return false; +// } if(!(tree.getUserObject().equals("?") || tree.getUserObject().equals(this.userObject))){ return false; } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java 2013-06-06 13:32:30 UTC (rev 3985) @@ -145,7 +145,7 @@ // } // } // } - if(!lgg.getUserObject().equals(tree2.getUserObject())){ + if(!lgg.sameType(tree2) || !lgg.getUserObject().equals(tree2.getUserObject())){ lgg.setUserObject((N)"?"); lgg.setLiteralNode(false); lgg.setResourceNode(false); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/NoiseSensitiveLGG.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/NoiseSensitiveLGG.java 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/NoiseSensitiveLGG.java 2013-06-06 13:32:30 UTC (rev 3985) @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; @@ -11,6 +10,9 @@ import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; + public class NoiseSensitiveLGG<N> { private LGGGenerator<N> lggGenerator = new LGGGeneratorImpl<N>(); @@ -22,19 +24,25 @@ } public List<EvaluatedQueryTree<N>> computeLGG(List<QueryTree<N>> trees){ + Monitor subMon = MonitorFactory.getTimeMonitor("subsumption-mon"); + Monitor lggMon = MonitorFactory.getTimeMonitor("lgg-mon"); init(trees); EvaluatedQueryTree<N> currentElement; - do{ + do{System.out.println("TODO list size: " + todoList.size()); //pick best element from todo list currentElement = todoList.poll(); for (QueryTree<N> example : currentElement.getUncoveredExamples()) { QueryTree<N> tree = currentElement.getTree(); //compute the LGG + lggMon.start(); QueryTree<N> lgg = lggGenerator.getLGG(tree, example); + lggMon.stop(); //compute examples which are not covered by LGG - Collection<QueryTree<N>> uncoveredExamples = new HashSet<QueryTree<N>>(); + Collection<QueryTree<N>> uncoveredExamples = new ArrayList<QueryTree<N>>(); for (QueryTree<N> queryTree : trees) { + subMon.start(); boolean subsumed = queryTree.isSubsumedBy(lgg); + subMon.stop(); if(!subsumed){ uncoveredExamples.add(queryTree); } @@ -45,6 +53,12 @@ EvaluatedQueryTree<N> solution = new EvaluatedQueryTree<N>(lgg, uncoveredExamples, score); todo(solution); } + System.out.println("LGG time: " + lggMon.getTotal() + "ms"); + System.out.println("Avg. LGG time: " + lggMon.getAvg() + "ms"); + System.out.println("#LGG computations: " + lggMon.getHits()); + System.out.println("Subsumption test time: " + subMon.getTotal() + "ms"); + System.out.println("Avg. subsumption test time: " + subMon.getAvg() + "ms"); + System.out.println("#Subsumption tests: " + subMon.getHits()); solutions.add(currentElement); // todoList.remove(currentElement); } while(!terminationCriteriaSatisfied()); @@ -57,8 +71,8 @@ // EvaluatedQueryTree<N> dummy = new EvaluatedQueryTree<N>(new QueryTreeImpl<N>((N)"TOP"), trees, 0d); // todoList.add(dummy); //compute distinct trees - Collection<QueryTree<N>> distinctTrees = new HashSet<QueryTree<N>>(); - for (QueryTree<N> queryTree : trees) { + Collection<QueryTree<N>> distinctTrees = new ArrayList<QueryTree<N>>(); + for (QueryTree<N> queryTree : trees) {//System.out.println(queryTree.getStringRepresentation()); boolean distinct = true; for (QueryTree<N> otherTree : distinctTrees) { if(queryTree.isSubsumedBy(otherTree)){ @@ -71,7 +85,7 @@ } } for (QueryTree<N> queryTree : distinctTrees) { - Collection<QueryTree<N>> uncoveredExamples = new HashSet<QueryTree<N>>(distinctTrees); + Collection<QueryTree<N>> uncoveredExamples = new ArrayList<QueryTree<N>>(distinctTrees); uncoveredExamples.remove(queryTree); double score = (trees.size() - uncoveredExamples.size()) / (double)trees.size(); todoList.add(new EvaluatedQueryTree<N>(queryTree, uncoveredExamples, score)); Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java 2013-06-06 13:32:30 UTC (rev 3985) @@ -1,16 +1,24 @@ package org.dllearner.kb.sparql; -import java.io.UnsupportedEncodingException; import java.sql.SQLException; import java.util.Iterator; import java.util.List; +import java.util.concurrent.TimeUnit; +import org.aksw.jena_sparql_api.cache.core.QueryExecutionFactoryCacheEx; +import org.aksw.jena_sparql_api.cache.extra.CacheCoreEx; +import org.aksw.jena_sparql_api.cache.extra.CacheCoreH2; +import org.aksw.jena_sparql_api.cache.extra.CacheEx; +import org.aksw.jena_sparql_api.cache.extra.CacheExImpl; +import org.aksw.jena_sparql_api.core.QueryExecutionFactory; +import org.aksw.jena_sparql_api.http.QueryExecutionFactoryHttp; +import org.aksw.jena_sparql_api.model.QueryExecutionFactoryModel; +import org.aksw.jena_sparql_api.pagination.core.QueryExecutionFactoryPaginated; import org.apache.log4j.Level; import org.apache.log4j.Logger; -import com.hp.hpl.jena.query.QueryExecutionFactory; +import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelFactory; //import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; public class ConciseBoundedDescriptionGeneratorImpl implements ConciseBoundedDescriptionGenerator{ @@ -25,6 +33,7 @@ private List<String> namespaces; private int maxRecursionDepth = 1; + private String cacheDir; public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint, ExtractionDBCache cache) { this.endpoint = endpoint; @@ -37,8 +46,19 @@ this.maxRecursionDepth = maxRecursionDepth; } + public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint, String cacheDir, int maxRecursionDepth) { + this.endpoint = endpoint; + this.cacheDir = cacheDir; + this.maxRecursionDepth = maxRecursionDepth; + } + + public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint, String cacheDir) { + this.endpoint = endpoint; + this.cacheDir = cacheDir; + } + public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint) { - this(endpoint, null); + this(endpoint, (String)null); } public ConciseBoundedDescriptionGeneratorImpl(Model model) { @@ -59,34 +79,28 @@ private Model getModelChunked(String resource, int depth){ String query = makeConstructQueryOptional(resource, chunkSize, 0, depth); - Model all = ModelFactory.createDefaultModel(); - try { - Model model; - if(cache == null){ - model = getModel(query); - } else { - model = cache.executeConstructQuery(endpoint, query); + QueryExecutionFactory qef; + if(endpoint != null){ + qef = new QueryExecutionFactoryHttp(endpoint.getURL().toString(), endpoint.getDefaultGraphURIs()); + if(cacheDir != null){ + try { + long timeToLive = TimeUnit.DAYS.toMillis(30); + CacheCoreEx cacheBackend = CacheCoreH2.create(cacheDir, timeToLive, true); + CacheEx cacheFrontend = new CacheExImpl(cacheBackend); + qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } } - all.add(model); - int i = 1; - do{ -// while(model.size() == CHUNK_SIZE){ - query = makeConstructQueryOptional(resource, chunkSize, i * chunkSize, depth); - if(cache == null){ - model = getModel(query); - } else { - model = cache.executeConstructQuery(endpoint, query); - } - all.add(model); - i++; - } while(chunkSize > 0 && model.size() != 0); - } catch (UnsupportedEncodingException e) { - logger.error(e); - } catch (SQLException e) { - logger.error(e); + qef = new QueryExecutionFactoryPaginated(qef, 10000); + } else { + qef = new QueryExecutionFactoryModel(baseModel); } - - return all; + QueryExecution qe = qef.createQueryExecution(query); + Model model = qe.execConstruct(); + return model; } @Override @@ -151,36 +165,6 @@ return filter; } - private Model getModel(String query) throws UnsupportedEncodingException, SQLException{ - if(logger.isDebugEnabled()){ - logger.debug("Sending SPARQL query ..."); - logger.debug("Query:\n" + query.toString()); - } - - Model model; - if(baseModel == null){ - if(cache == null){ - QueryEngineHTTP queryExecution = new QueryEngineHTTP(endpoint.getURL().toString(), query); - for (String dgu : endpoint.getDefaultGraphURIs()) { - queryExecution.addDefaultGraph(dgu); - } - for (String ngu : endpoint.getNamedGraphURIs()) { - queryExecution.addNamedGraph(ngu); - } - model = queryExecution.execConstruct(); - } else { - model = cache.executeConstructQuery(endpoint, query); - } - } else { - model = QueryExecutionFactory.create(query, baseModel).execConstruct(); - } - - if(logger.isDebugEnabled()){ - logger.debug("Got " + model.size() + " new triples in."); - } - return model; - } - public static void main(String[] args) { Logger.getRootLogger().setLevel(Level.DEBUG); ConciseBoundedDescriptionGenerator cbdGen = new ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint.getEndpointDBpedia()); Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2013-06-06 13:32:30 UTC (rev 3985) @@ -78,6 +78,10 @@ Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE IF NOT EXISTS QUERY_CACHE(QUERYHASH BINARY PRIMARY KEY,QUERY VARCHAR(20000), TRIPLES CLOB, STORE_TIME TIMESTAMP)"); } + + public String getCacheDirectory() { + return databaseDirectory; + } public ExtractionDBCache(String cacheDir) { databaseDirectory = cacheDir; Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-06-06 13:32:30 UTC (rev 3985) @@ -73,6 +73,7 @@ import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; @@ -494,7 +495,7 @@ Set<NamedClass> siblings = new HashSet<NamedClass>(); String query = "SELECT ?sub WHERE { <" + cls.getName() + "> <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?super ."; query += "?sub <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?super ."; - query += "FILTER( !SAMETERM(?sub, <" + cls.getName() + ">)) . }"; + query += "FILTER( !SAMETERM(?sub, <" + cls.getName() + ">)) . }";System.out.println(query); ResultSet rs = executeSelectQuery(query); QuerySolution qs; while(rs.hasNext()){ @@ -590,7 +591,6 @@ * @author sherif */ public SortedSet<Individual> getIndividualsExcluding(Description wantedClass, Description excludeClass, int limit) { - if(!(wantedClass instanceof NamedClass)){ throw new UnsupportedOperationException("Only named classes are supported."); } @@ -598,7 +598,7 @@ String query = "SELECT DISTINCT ?ind WHERE {" + "?ind a <"+((NamedClass)wantedClass).getName() + "> . " + - "FILTER(NOT EXISTS { ?ind a <" + ((NamedClass)excludeClass).getName() + "> } )}"; + "FILTER NOT EXISTS { ?ind a <" + ((NamedClass)excludeClass).getName() + "> } }"; if(limit != 0) { query += " LIMIT " + limit; } Modified: trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL2.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL2.java 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL2.java 2013-06-06 13:32:30 UTC (rev 3985) @@ -19,10 +19,22 @@ package org.dllearner.utilities.examples; +import static org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL2.Strategy.RANDOM; +import static org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL2.Strategy.SIBLING; +import static org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL2.Strategy.SUPERCLASS; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.owl.ClassHierarchy; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; import org.dllearner.kb.SparqlEndpointKS; import org.dllearner.kb.sparql.SPARQLTasks; @@ -30,6 +42,10 @@ import org.dllearner.reasoning.SPARQLReasoner; import org.dllearner.utilities.datastructures.Datastructures; +import com.google.common.base.Predicate; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multiset; +import com.google.common.collect.Multisets; /** * * Utility class for automatically retrieving negative examples from a @@ -40,12 +56,18 @@ * */ public class AutomaticNegativeExampleFinderSPARQL2 { + + public enum Strategy{ + SUPERCLASS, SIBLING, RANDOM; + } private SparqlEndpoint se; // for re-using existing queries private SPARQLReasoner sr; private SPARQLTasks st; + + private String namespace; public AutomaticNegativeExampleFinderSPARQL2(SparqlEndpoint se) { this.se = se; @@ -54,6 +76,15 @@ st = new SPARQLTasks(se); } + public AutomaticNegativeExampleFinderSPARQL2(SPARQLReasoner reasoner, String namespace) { + this.sr = reasoner; + this.namespace = namespace; + } + + public AutomaticNegativeExampleFinderSPARQL2(SPARQLReasoner reasoner) { + this.sr = reasoner; + } + /** * Get negative examples when learning the description of a class, i.e. * all positives are from some known class. @@ -82,4 +113,92 @@ return negEx; } + public SortedSet<Individual> getNegativeExamples(Set<Individual> positiveExamples, int limit) { + return getNegativeExamples(positiveExamples, Arrays.asList(SUPERCLASS, SIBLING, RANDOM), limit); + } + + public SortedSet<Individual> getNegativeExamples(Set<Individual> positiveExamples, Collection<Strategy> strategies, int limit) { + Map<Strategy, Double> strategiesWithWeight = new HashMap<Strategy, Double>(); + double weight = 1d/strategies.size(); + for (Strategy strategy : strategies) { + strategiesWithWeight.put(strategy, weight); + } + return getNegativeExamples(positiveExamples, strategiesWithWeight, limit); + } + + public SortedSet<Individual> getNegativeExamples(Set<Individual> positiveExamples, Map<Strategy, Double> strategiesWithWeight, int maxNrOfReturnedInstances) { + SortedSet<Individual> negEx = new TreeSet<Individual>(); + + //get the types for each instance + Multiset<NamedClass> types = HashMultiset.create(); + for (Individual ex : positiveExamples) { + types.addAll(sr.getTypes(ex)); + } + + //remove types that do not have the given namespace + if(namespace != null){ + types = Multisets.filter(types, new Predicate<NamedClass>() { + public boolean apply(NamedClass input){ + return input.getName().startsWith(namespace); + } + }); + } + + //keep the most specific types + keepMostSpecificClasses(types); + + for (Entry<Strategy, Double> entry : strategiesWithWeight.entrySet()) { + Strategy strategy = entry.getKey(); + Double weight = entry.getValue(); + //the max number of instances returned by the current strategy + int limit = (int)(weight * maxNrOfReturnedInstances); + //the highest frequency value + int maxFrequency = types.entrySet().iterator().next().getCount(); + if(strategy == SIBLING){ + System.out.println("Sibling Classes Strategy"); + for (NamedClass nc : types.elementSet()) { + int frequency = types.count(nc); + //get sibling classes + Set<NamedClass> siblingClasses = sr.getSiblingClasses(nc); + int nrOfSiblings = siblingClasses.size(); + int v = (int)Math.ceil(((double)frequency / types.size()) / nrOfSiblings * limit); System.out.println(nc + ": " + v); + for (NamedClass siblingClass : siblingClasses) { + negEx.addAll(sr.getIndividualsExcluding(siblingClass, nc, v)); + } + + } + } else if(strategy == SUPERCLASS){ + System.out.println("Super Classes Strategy"); + for (NamedClass nc : types.elementSet()) { + int frequency = types.count(nc); + //get sibling classes + Set<Description> superClasses = sr.getSuperClasses(nc);System.out.println(superClasses); + int nrOfSuperClasses = superClasses.size(); + int v = (int)Math.ceil(((double)frequency / types.size()) / nrOfSuperClasses * limit); System.out.println(nc + ": " + v); + for (Description superClass : superClasses) { + negEx.addAll(sr.getIndividualsExcluding(superClass, nc, v)); + } + } + } else if(strategy == RANDOM){ + + } + } + return negEx; + } + + private void keepMostSpecificClasses(Multiset<NamedClass> classes){ + HashMultiset<NamedClass> copy = HashMultiset.create(classes); + final ClassHierarchy hierarchy = sr.getClassHierarchy(); + for (NamedClass nc1 : copy.elementSet()) { + for (NamedClass nc2 : copy.elementSet()) { + if(!nc1.equals(nc2)){ + //remove class nc1 if it is superclass of another class nc2 + if(hierarchy.isSubclassOf(nc2, nc1)){ + classes.remove(nc1, classes.count(nc1)); + break; + } + } + } + } + } } Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java 2013-06-06 13:32:30 UTC (rev 3985) @@ -73,12 +73,7 @@ private String sparql = ""; private Stack<String> variables = new Stack<String>(); - private Map<OWLEntity, String> variablesMapping = new HashMap<OWLEntity, String>(); - private int classCnt = 0; - private int propCnt = 0; - private int indCnt = 0; - private OWLDataFactory df = new OWLDataFactoryImpl(); private Multimap<Integer, OWLEntity> properties = HashMultimap.create(); @@ -86,8 +81,19 @@ private Map<Integer, Boolean> intersection; private Set<? extends OWLEntity> variableEntities = new HashSet<OWLEntity>(); + private VariablesMapping mapping; + + public OWLClassExpressionToSPARQLConverter(VariablesMapping mapping) { + this.mapping = mapping; + } + public OWLClassExpressionToSPARQLConverter() { + mapping = new VariablesMapping(); } + + public VariablesMapping getVariablesMapping() { + return mapping; + } public String convert(String rootVariable, OWLClassExpression expr){ reset(); @@ -132,7 +138,7 @@ queryString += rootVariable + " WHERE {"; } else { for (OWLEntity owlEntity : variableEntities) { - String var = variablesMapping.get(owlEntity); + String var = mapping.get(owlEntity); queryString += var + " "; } if(count){ @@ -149,7 +155,7 @@ if(count){ queryString += "GROUP BY "; for (OWLEntity owlEntity : variableEntities) { - String var = variablesMapping.get(owlEntity); + String var = mapping.get(owlEntity); queryString += var; } queryString += " ORDER BY DESC(?cnt)"; @@ -158,40 +164,14 @@ return QueryFactory.create(queryString, Syntax.syntaxARQ); } - public Map<OWLEntity, String> getVariablesMapping() { - return variablesMapping; - } - private void reset(){ - variablesMapping.clear(); variables.clear(); properties.clear(); - classCnt = 0; - propCnt = 0; - indCnt = 0; sparql = ""; intersection = new HashMap<Integer, Boolean>(); + mapping.reset(); } - private String getVariable(OWLEntity entity){ - String var = variablesMapping.get(entity); - if(var == null){ - if(entity.isOWLClass()){ - var = "?cls" + classCnt++; - } else if(entity.isOWLObjectProperty() || entity.isOWLDataProperty()){ - var = "?p" + propCnt++; - } else if(entity.isOWLNamedIndividual()){ - var = buildIndividualVariable(); - } - variablesMapping.put(entity, var); - } - return var; - } - - private String buildIndividualVariable(){ - return "?s" + indCnt++; - } - private int modalDepth(){ return variables.size(); } @@ -253,7 +233,7 @@ private String render(OWLEntity entity){ String s; if(variableEntities.contains(entity)){ - s = getVariable(entity); + s = mapping.getVariable(entity); } else { s = "<" + entity.toStringID() + ">"; } @@ -295,8 +275,8 @@ if(props.size() > 1){ Collection<String> vars = new TreeSet<String>(); for (OWLEntity p : props) { - if(variablesMapping.containsKey(p)){ - vars.add(variablesMapping.get(p)); + if(mapping.containsKey(p)){ + vars.add(mapping.get(p)); } } if(vars.size() == 2){ @@ -334,7 +314,7 @@ @Override public void visit(OWLObjectSomeValuesFrom ce) { - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLObjectPropertyExpression propertyExpression = ce.getProperty(); if(propertyExpression.isAnonymous()){ //property expression is inverse of a property @@ -356,7 +336,7 @@ @Override public void visit(OWLObjectAllValuesFrom ce) { String subject = variables.peek(); - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLObjectPropertyExpression propertyExpression = ce.getProperty(); OWLObjectProperty predicate = propertyExpression.getNamedProperty(); OWLClassExpression filler = ce.getFiller(); @@ -367,7 +347,7 @@ sparql += triple(variables.peek(), predicate, objectVariable); } - String var = buildIndividualVariable(); + String var = mapping.newIndividualVariable(); sparql += "{SELECT " + subject + " (COUNT(" + var + ") AS ?cnt1) WHERE {"; sparql += triple(subject, predicate, var); variables.push(var); @@ -375,7 +355,7 @@ variables.pop(); sparql += "} GROUP BY " + subject + "}"; - var = buildIndividualVariable(); + var = mapping.newIndividualVariable(); sparql += "{SELECT " + subject + " (COUNT(" + var + ") AS ?cnt2) WHERE {"; sparql += triple(subject, predicate, var); sparql += "} GROUP BY " + subject + "}"; @@ -399,7 +379,7 @@ @Override public void visit(OWLObjectMinCardinality ce) { String subjectVariable = variables.peek(); - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLObjectPropertyExpression propertyExpression = ce.getProperty(); int cardinality = ce.getCardinality(); sparql += "{SELECT " + subjectVariable + " WHERE {"; @@ -411,7 +391,7 @@ } OWLClassExpression filler = ce.getFiller(); if(filler.isAnonymous()){ - String var = buildIndividualVariable(); + String var = mapping.newIndividualVariable(); variables.push(var); sparql += triple(objectVariable, "a", var); filler.accept(this); @@ -427,7 +407,7 @@ @Override public void visit(OWLObjectExactCardinality ce) { String subjectVariable = variables.peek(); - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLObjectPropertyExpression propertyExpression = ce.getProperty(); int cardinality = ce.getCardinality(); sparql += "{SELECT " + subjectVariable + " WHERE {"; @@ -439,7 +419,7 @@ } OWLClassExpression filler = ce.getFiller(); if(filler.isAnonymous()){ - String var = buildIndividualVariable(); + String var = mapping.newIndividualVariable(); variables.push(var); sparql += triple(objectVariable, "a", var); filler.accept(this); @@ -454,7 +434,7 @@ @Override public void visit(OWLObjectMaxCardinality ce) { String subjectVariable = variables.peek(); - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLObjectPropertyExpression propertyExpression = ce.getProperty(); int cardinality = ce.getCardinality(); sparql += "{SELECT " + subjectVariable + " WHERE {"; @@ -466,7 +446,7 @@ } OWLClassExpression filler = ce.getFiller(); if(filler.isAnonymous()){ - String var = buildIndividualVariable(); + String var = mapping.newIndividualVariable(); variables.push(var); sparql += triple(objectVariable, "a", var); filler.accept(this); @@ -506,7 +486,7 @@ @Override public void visit(OWLDataSomeValuesFrom ce) { - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLDataPropertyExpression propertyExpression = ce.getProperty(); sparql += triple(variables.peek(), propertyExpression.asOWLDataProperty(), objectVariable); OWLDataRange filler = ce.getFiller(); @@ -518,13 +498,13 @@ @Override public void visit(OWLDataAllValuesFrom ce) { String subject = variables.peek(); - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLDataPropertyExpression propertyExpression = ce.getProperty(); String predicate = propertyExpression.asOWLDataProperty().toStringID(); OWLDataRange filler = ce.getFiller(); sparql += triple(variables.peek(), predicate, objectVariable); - String var = buildIndividualVariable(); + String var = mapping.newIndividualVariable(); sparql += "{SELECT " + subject + " (COUNT(" + var + ") AS ?cnt1) WHERE {"; sparql += triple(subject, predicate, var); variables.push(var); @@ -532,7 +512,7 @@ variables.pop(); sparql += "} GROUP BY " + subject + "}"; - var = buildIndividualVariable(); + var = mapping.newIndividualVariable(); sparql += "{SELECT " + subject + " (COUNT(" + var + ") AS ?cnt2) WHERE {"; sparql += triple(subject, predicate, var); sparql += "} GROUP BY " + subject + "}"; @@ -550,7 +530,7 @@ @Override public void visit(OWLDataMinCardinality ce) { String subjectVariable = variables.peek(); - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLDataPropertyExpression propertyExpression = ce.getProperty(); int cardinality = ce.getCardinality(); sparql += "{SELECT " + subjectVariable + " WHERE {"; @@ -566,7 +546,7 @@ @Override public void visit(OWLDataExactCardinality ce) { String subjectVariable = variables.peek(); - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLDataPropertyExpression propertyExpression = ce.getProperty(); int cardinality = ce.getCardinality(); sparql += "{SELECT " + subjectVariable + " WHERE {"; @@ -582,7 +562,7 @@ @Override public void visit(OWLDataMaxCardinality ce) { String subjectVariable = variables.peek(); - String objectVariable = buildIndividualVariable(); + String objectVariable = mapping.newIndividualVariable(); OWLDataPropertyExpression propertyExpression = ce.getProperty(); int cardinality = ce.getCardinality(); sparql += "{SELECT " + subjectVariable + " WHERE {"; @@ -774,7 +754,4 @@ System.out.println(expr + "\n" + query); } - - - } \ No newline at end of file Modified: trunk/components-core/src/main/resources/prefixes.csv =================================================================== --- trunk/components-core/src/main/resources/prefixes.csv 2013-05-24 09:16:41 UTC (rev 3984) +++ trunk/components-core/src/main/resources/prefixes.csv 2013-06-06 13:32:30 UTC (rev 3985) @@ -4,609 +4,963 @@ dbp,http://dbpedia.org/property/ owl,http://www.w3.org/2002/07/owl# dc,http://purl.org/dc/elements/1.1/ +rdfs,http://www.w3.org/2000/01/rdf-schema# dbo,http://dbpedia.org/ontology/ -rdfs,http://www.w3.org/2000/01/rdf-schema# -sc,http://umbel.org/umbel/sc/ rss,http://purl.org/rss/1.0/ +sc,http://purl.org/science/owl/sciencecommons/ +skos,http://www.w3.org/2004/02/skos/core# fb,http://rdf.freebase.com/ns/ geonames,http://www.geonames.org/ontology# -skos,http://www.w3.org/2004/02/skos/core# -cyc,http://sw.opencyc.org/concept/ geo,http://www.w3.org/2003/01/geo/wgs84_pos# sioc,http://rdfs.org/sioc/ns# +gr,http://purl.org/goodrelations/v1# +gldp,http://www.w3.org/ns/people# +cyc,http://sw.opencyc.org/concept/ akt,http://www.aktors.org/ontology/portal# +xsd,http://www.w3.org/2001/XMLSchema# dbpedia,http://dbpedia.org/resource/ +dcterms,http://purl.org/dc/terms/ +swrc,http://swrc.ontoware.org/ontology# +commerce,http://search.yahoo.com/searchmonkey/commerce/ admin,http://webns.net/mvcb/ -gr,http://purl.org/goodrelations/v1# -swrc,http://swrc.ontoware.org/ontology# -xsd,http://www.w3.org/2001/XMLSchema# -xhtml,http://www.w3.org/1999/xhtml/vocab# +content,http://purl.org/rss/1.0/modules/content/ doap,http://usefulinc.com/ns/doap# +void,http://rdfs.org/ns/void# +xhtml,http://www.w3.org/1999/xhtml# +bibo,http://purl.org/ontology/bibo/ +org,http://www.w3.org/ns/org# vcard,http://www.w3.org/2006/vcard/ns# -content,http://purl.org/rss/1.0/modules/content/ +gen,http://www.w3.org/2006/gen/ont# bill,http://www.rdfabout.com/rdf/schema/usbill/ -dcterms,http://purl.org/dc/terms/ -mo,http://purl.org/ontology/mo/ +aiiso,http://purl.org/vocab/aiiso/schema# wot,http://xmlns.com/wot/0.1/ -wn20schema,http://www.w3.org/2006/03/wn/wn20/schema/ -d2rq,http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1# -gen,http://www.w3.org/2006/gen/ont# +qb,http://purl.org/linked-data/cube# nie,http://www.semanticdesktop.org/ontologies/2007/01/19/nie# -void,http://rdfs.org/ns/void# test2,http://this.invalid/test2# -org,http://www.w3.org/ns/org# -movie,http://data.linkedmdb.org/resource/movie/ -ex,http://example.com/ +d2rq,http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1# rel,http://purl.org/vocab/relationship/ -bio,http://purl.org/vocab/bio/0.1/ +dcmit,http://purl.org/dc/dcmitype/ http,http://www.w3.org/2006/http# -dcmit,http://purl.org/dc/dcmitype/ -reco,http://purl.org/reco# cc,http://creativecommons.org/ns# -nfo,http://www.semanticdesktop.org/ontologies/2007/03/22/nfo# -ac,http://umbel.org/umbel/ac/ -xfn,http://vocab.sindice.com/xfn# +og,http://opengraphprotocol.org/schema/ +factbook,http://www4.wiwiss.fu-berlin.de/factbook/ns# +vann,http://purl.org/vocab/vann/ +ex,http://example.com/ +bio,http://purl.org/vocab/bio/0.1/ +mo,http://purl.org/ontology/mo/ +ad,http://schemas.talis.com/2005/address/schema# +media,http://purl.org/microformat/hmedia/ +event,http://purl.org/NET/c4dm/event.owl# earl,http://www.w3.org/ns/earl# -og,http://opengraphprotocol.org/schema/ +book,http://purl.org/NET/book/vocab# +cv,http://purl.org/captsolo/resume-rdf/0.2/cv# +ical,http://www.w3.org/2002/12/cal/ical# +botany,http://purl.org/NET/biol/botany# air,http://dig.csail.mit.edu/TAMI/2007/amord/air# -ical,http://www.w3.org/2002/12/cal/ical# -media,http://purl.org/media# -rev,http://purl.org/stuff/rev# -cv,http://rdfs.org/resume-rdf/ tag,http://www.holygoat.co.uk/owl/redwood/0.1/tags/ +dv,http://rdf.data-vocabulary.org/# +cld,http://purl.org/cld/terms/ swc,http://data.semanticweb.org/ns/swc/ontology# -botany,http://purl.org/NET/biol/botany# -bibo,http://purl.org/ontology/bibo/ -xf,http://www.w3.org/2002/xforms/ -factbook,http://www4.wiwiss.fu-berlin.de/factbook/ns# +drugbank,http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/ +musim,http://purl.org/ontology/similarity/ +dir,http://schemas.talis.com/2005/dir/schema# +reco,http://purl.org/reco# +rev,http://purl.org/stuff/rev# +biblio,http://purl.org/net/biblio# +ctag,http://commontag.org/ns# +af,http://purl.org/ontology/af/ days,http://ontologi.es/days# -cfp,http://sw.deri.org/2005/08/conf/cfp.owl# -sism,http://purl.oclc.org/NET/sism/0.1/ -vann,http://purl.org/vocab/vann/ +log,http://www.w3.org/2000/10/swap/log# +cs,http://purl.org/vocab/changeset/schema# +sd,http://www.w3.org/ns/sparql-service-description# osag,http://www.ordnancesurvey.co.uk/ontology/AdministrativeGeography/v2.0/AdministrativeGeography.rdf# -owlim,http://www.ontotext.com/trree/owlim# -dir,http://schemas.talis.com/2005/dir/schema# -cld,http://purl.org/cld/terms/ -afn,http://jena.hpl.hp.com/ARQ/function# -book,http://purl.org/NET/book/vocab# +xhv,http://www.w3.org/1999/xhtml/vocab# +rdfg,http://www.w3.org/2004/03/trix/rdfg-1/ +co,http://purl.org/ontology/co/core# fn,http://www.w3.org/2005/xpath-functions# -musim,http://purl.org/ontology/similarity/ -akts,http://www.aktors.org/ontology/support# -cs,http://purl.org/vocab/changeset/schema# -aiiso,http://purl.org/vocab/aiiso/schema# -ad,http://schemas.talis.com/2005/address/schema# +sism,http://purl.oclc.org/NET/sism/0.1/ mu,http://www.kanzaki.com/ns/music# -sd,http://www.w3.org/ns/sparql-service-description# -po,http://purl.org/ontology/po/ -biblio,http://purl.org/net/biblio# -event,http://purl.org/NET/c4dm/event.owl# -dv,http://rdf.data-vocabulary.org/# -drugbank,http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/ -uniprot,http://purl.uniprot.org/core/ memo,http://ontologies.smile.deri.ie/2009/02/27/memo# -dcn,http://www.w3.org/2007/uwa/context/deliverycontext.owl# -rdfg,http://www.w3.org/2004/03/trix/rdfg-1/ -log,http://www.w3.org/2000/10/swap/log# -co,http://purl.org/ontology/co/core# -qb,http://purl.org/linked-data/cube# ome,http://purl.org/ontomedia/core/expression# -af,http://purl.org/ontology/af/ +daia,http://purl.org/ontology/daia/ +cmp,http://www.ontologydesignpatterns.org/cp/owl/componency.owl# +owlim,http://www.ontotext.com/trree/owlim# +cfp,http://sw.deri.org/2005/08/conf/cfp.owl# +xfn,http://vocab.sindice.com/xfn# +afn,http://jena.hpl.hp.com/ARQ/function# +ok,http://okkam.org/terms# giving,http://ontologi.es/giving# +ir,http://www.ontologydesignpatterns.org/cp/owl/informationrealization.owl# +xf,http://www.w3.org/2002/xforms/ +dcn,http://www.w3.org/2007/uwa/context/deliverycontext.owl# swanq,http://purl.org/swan/1.2/qualifiers/ -cmp,http://www.ontologydesignpatterns.org/cp/owl/componency.owl# lomvoc,http://ltsc.ieee.org/rdf/lomv1p0/vocabulary# +math,http://www.w3.org/2000/10/swap/math# +swande,http://purl.org/swan/1.2/discourse-elements/ rif,http://www.w3.org/2007/rif# -ir,http://www.ontologydesignpatterns.org/cp/owl/informationrealization.owl# -ctag,http://commontag.org/ns# -ok,http://okkam.org/terms# -swande,http://purl.org/swan/1.2/discourse-elements/ -math,http://www.w3.org/2000/10/swap/math# -daia,http://purl.org/ontology/daia/ -sioct,http://rdfs.org/sioc/types# +sr,http://www.openrdf.org/config/repository/sail# jdbc,http://d2rq.org/terms/jdbc/ +tzont,http://www.w3.org/2006/timezone# myspace,http://purl.org/ontology/myspace# -sr,http://www.openrdf.org/config/repository/sail# -tzont,http://www.w3.org/2006/timezone# +con,http://www.w3.org/2000/10/swap/pim/contact# +sider,http://www4.wiwiss.fu-berlin.de/sider/resource/sider/ +wn20schema,http://www.w3.org/2006/03/wn/wn20/schema/ +cert,http://www.w3.org/ns/auth/cert# +pto,http://www.productontology.org/id/ +movie,http://data.linkedmdb.org/resource/movie/ +oo,http://purl.org/openorg/ +nfo,http://www.semanticdesktop.org/ontologies/nfo/# +ac,http://umbel.org/umbel/ac/ +po,http://purl.org/ontology/po/ +akts,http://www.aktors.org/ontology/support# +frbr,http://purl.org/vocab/frbr/core# +uniprot,http://purl.uniprot.org/core/ +dcat,http://www.w3.org/ns/dcat# +rsa,http://www.w3.org/ns/auth/rsa# +ov,http://open.vocab.org/terms/ +sioct,http://rdfs.org/sioc/types# +prv,http://purl.org/net/provenance/ns# +prov,http://www.w3.org/ns/prov# +granatum,http://chem.deri.ie/granatum/ +wo,http://purl.org/ontology/wo/ daml,http://www.daml.org/2001/03/daml+oil# -wo,http://purl.org/ontology/wo/ -politico,http://www.rdfabout.com/rdf/schema/politico/ +spacerel,http://data.ordnancesurvey.co.uk/ontology/spatialrelations/ +pc,http://purl.org/procurement/public-contracts# pmlj,http://inference-web.org/2.0/pml-justification.owl# +vs,http://www.w3.org/2003/06/sw-vocab-status/ns# usgov,http://www.rdfabout.com/rdf/schema/usgovt/ +acm,http://www.rkbexplorer.com/ontologies/acm# taxo,http://purl.org/rss/1.0/modules/taxonomy/ -lfm,http://purl.org/ontology/last-fm/ -vote,http://www.rdfabout.com/rdf/schema/vote/ -frbr,http://purl.org/vocab/frbr/core# -doac,http://ramonantonio.net/doac/0.1/# wn,http://xmlns.com/wordnet/1.6/ -affy,http://www.affymetrix.com/community/publications/affymetrix/tmsplice# -con,http://www.w3.org/2000/10/swap/pim/contact# -prv,http://purl.org/net/provenance/ns# -scot,http://scot-project.org/scot/ns# -irrl,http://www.ontologydesignpatterns.org/cp/owl/informationobjectsandrepresentationlanguages.owl# +wdrs,http://www.w3.org/2007/05/powder-s# scovo,http://purl.org/NET/scovo# -nco,http://www.semanticdesktop.org/ontologies/2007/03/22/nco# +oauth,http://demiblog.org/vocab/oauth# +politico,http://www.rdfabout.com/rdf/schema/politico/ lgd,http://linkedgeodata.org/ontology/ -wordmap,http://purl.org/net/ns/wordmap# +lode,http://linkedevents.org/ontology/ +acl,http://www.w3.org/ns/auth/acl# +ore,http://www.openarchives.org/ore/terms/ +abc,http://www.metadata.net/harmony/ABCSchemaV5Commented.rdf# omt,http://purl.org/ontomedia/ext/common/trait# -sider,http://www4.wiwiss.fu-berlin.de/sider/resource/sider/ +nao,http://www.semanticdesktop.org/ontologies/2007/08/15/nao# +omb,http://purl.org/ontomedia/ext/common/being# +loc,http://www.w3.org/2007/uwa/context/location.owl# +mit,http://purl.org/ontology/mo/mit# +skosxl,http://www.w3.org/2008/05/skos-xl# +spc,http://purl.org/ontomedia/core/space# +vote,http://www.rdfabout.com/rdf/schema/vote/ +lfm,http://purl.org/ontology/last-fm/ +irrl,http://www.ontologydesignpatterns.org/cp/owl/informationobjectsandrepresentationlanguages.owl# +rep,http://www.openrdf.org/config/repository# +chord,http://purl.org/ontology/chord/ +dcam,http://purl.org/dc/dcam/ user,http://schemas.talis.com/2005/user/schema# -ore,http://www.openarchives.org/ore/terms/ -lode,http://linkedevents.org/ontology/ -ecs,http://rdf.ecs.soton.ac.uk/ontology/ecs# -rep,http://www.openrdf.org/config/repository# -nao,http://www.semanticdesktop.org/ontologies/2007/08/15/nao# -spin,http://spinrdf.org/spin# +resex,http://resex.rkbexplorer.com/ontologies/resex# swrl,http://www.w3.org/2003/11/swrl# -lx,http://purl.org/NET/lx# +music,http://musicontology.com/ +doac,http://ramonantonio.net/doac/0.1/# +scot,http://scot-project.org/scot/ns# +irw,http://www.ontologydesignpatterns.org/ont/web/irw.owl# ti,http://www.ontologydesignpatterns.org/cp/owl/timeinterval.owl# -unit,http://qudt.org/vocab/unit# -spc,http://purl.org/ontomedia/core/space# -es,http://eulersharp.sourceforge.net/2003/03swap/log-rules# -zoology,http://purl.org/NET/biol/zoology# -swrlb,http://www.w3.org/2003/11/swrlb# +affy,http://www.affymetrix.com/community/publications/affymetrix/tmsplice# +lingvoj,http://www.lingvoj.org/ontology# +courseware,http://courseware.rkbexplorer.com/ontologies/courseware# +link,http://www.w3.org/2006/link# +video,http://purl.org/media/video# +tl,http://purl.org/NET/c4dm/timeline.owl# +nco,http://www.semanticdesktop.org/ontologies/2007/03/22/nco# fec,http://www.rdfabout.com/rdf/schema/usfec/ -lang,http://ontologi.es/lang/core# -coref,http://www.rkbexplorer.com/ontologies/coref# -doc,http://www.w3.org/2000/10/swap/pim/doc# -os,http://www.w3.org/2000/10/swap/os# -atomix,http://buzzword.org.uk/rdf/atomix# -ne,http://umbel.org/umbel/ne/ -omb,http://purl.org/ontomedia/ext/common/being# money,http://purl.org/net/rdf-money/ -hard,http://www.w3.org/2007/uwa/context/hardware.owl# -ov,http://open.vocab.org/terms/ -java,http://www.w3.org/2007/uwa/context/java.owl# -eztag,http://ontologies.ezweb.morfeo-project.org/eztag/ns# -abc,http://www.metadata.net/harmony/ABCSchemaV5Commented.rdf# -tmo,http://www.semanticdesktop.org/ontologies/2008/05/20/tmo# -vs,http://www.w3.org/2003/06/sw-vocab-status/ns# sede,http://eventography.org/sede/0.1/ +rec,http://purl.org/ontology/rec/core# +atom,http://www.w3.org/2005/Atom/ +atomix,http://buzzword.org.uk/rdf/atomix# +sit,http://www.ontologydesignpatterns.org/cp/owl/situation.owl# +powder,http://www.w3.org/2007/05/powder# +fresnel,http://www.w3.org/2004/09/fresnel# +rei,http://www.w3.org/2004/06/rei# +doc,http://www.w3.org/2000/10/swap/pim/doc# +coref,http://www.rkbexplorer.com/ontologies/coref# nrl,http://www.semanticdesktop.org/ontologies/2007/08/15/nrl# -ibis,http://purl.org/ibis# +spin,http://spinrdf.org/spin# +umbel,http://umbel.org/umbel# code,http://telegraphis.net/ontology/measurement/code# -omp,http://purl.org/ontomedia/ext/common/profession# -dcam,http://purl.org/dc/dcam/ +zoology,http://purl.org/NET/biol/zoology# +wordmap,http://purl.org/net/ns/wordmap# +lotico,http://www.lotico.com/resource/ +audio,http://purl.org/media/audio# +meta,http://www.openrdf.org/rdf/2009/metadata# +protege,http://protege.stanford.edu/system# +time,http://www.w3.org/2006/time# +sv,http://schemas.talis.com/2005/service/schema# +ya,http://blogs.yandex.ru/schema/foaf/ +bio2rdf,http://bio2rdf.org/ +biol,http://purl.org/NET/biol/ns# imm,http://schemas.microsoft.com/imm/ -xhe,http://buzzword.org.uk/rdf/xhtml-elements# +sp,http://spinrdf.org/sp# +exif,http://www.w3.org/2003/12/exif/ns# +swrlb,http://www.w3.org/2003/11/swrlb# +iswc,http://annotation.semanticweb.org/2004/iswc# +ecs,http://rdf.ecs.soton.ac.uk/ontology/ecs# +p3p,http://www.w3.org/2002/01/p3prdfv1# kwijibo,http://kwijibo.talis.com/ -sv,http://schemas.talis.com/2005/service/schema# -h5,http://buzzword.org.uk/rdf/h5# -space,http://purl.org/net/schemas/space/ -wdrs,http://www.w3.org/2007/05/powder-s# -video,http://purl.org/media/video# -wnschema,http://www.cogsci.princeton.edu/~wn/schema/ +eztag,http://ontologies.ezweb.morfeo-project.org/eztag/ns# +so,http://purl.org/ontology/symbolic-music/ +lang,http://ontologi.es/lang/core# +tmo,http://www.semanticdesktop.org/ontologies/2008/05/20/tmo# +airport,http://www.daml.org/2001/10/html/airport-ont# +java,http://www.w3.org/2007/uwa/context/java.owl# +acc,http://purl.org/NET/acc# +os,http://www.w3.org/2000/10/swap/os# +ne,http://umbel.org/umbel/ne/ +omp,http://purl.org/ontomedia/ext/common/profession# +lx,http://purl.org/NET/lx# +doclist,http://www.junkwork.net/xml/DocumentList# +lifecycle,http://purl.org/vocab/lifecycle/schema# +omc,http://purl.org/ontomedia/ext/common/bestiary# +dailymed,http://www4.wiwiss.fu-berlin.de/dailymed/resource/dailymed/ +ibis,http://purl.org/ibis# sail,http://www.openrdf.org/config/sail# -custom,http://www.openrdf.org/config/sail/custom# -acc,http://purl.org/NET/acc# -rsa,http://www.w3.org/ns/auth/rsa# -sit,http://www.ontologydesignpatterns.org/cp/owl/situation.owl# -wdr,http://www.w3.org/2007/05/powder# -airport,http://www.daml.org/2001/10/html/airport-ont# -rei,http://www.w3.org/2004/06/rei# -mit,http://purl.org/ontology/mo/mit# -phss,http://ns.poundhill.com/phss/1.0/ -ncal,http://www.semanticdesktop.org/ontologies/2007/04/02/ncal# osoc,http://web-semantics.org/ns/opensocial# +hard,http://www.w3.org/2007/uwa/context/hardware.owl# +grddl,http://www.w3.org/2003/g/data-view# ptr,http://www.w3.org/2009/pointers# -protege,http://protege.stanford.edu/system# -irw,http://www.ontologydesignpatterns.org/ont/web/irw.owl# -omc,http://purl.org/ontomedia/ext/common/bestiary# -tdb,http://jena.hpl.hp.com/2008/tdb# -meta,http://www.openrdf.org/rdf/2009/metadata# -iswc,http://annotation.semanticweb.org/2004/iswc# -lingvoj,http://www.lingvoj.org/ontology# -resex,http://resex.rkbexplorer.com/ontologies/resex# -chord,http://purl.org/ontology/chord/ -p3p,http://www.w3.org/2002/01/p3prdfv1# -oauth,http://demiblog.org/vocab/oauth# -acl,http://www.w3.org/ns/auth/acl# -tl,http://purl.org/NET/c4dm/timeline.owl# -xen,http://buzzword.org.uk/rdf/xen# -acm,http://www.rkbexplorer.com/ontologies/acm# -link,http://www.w3.org/2006/link# -umbel,http://umbel.org/umbel# -swh,http://plugin.org.uk/swh-plugins/ +spl,http://spinrdf.org/spl# +wnschema,http://www.cogsci.princeton.edu/~wn/schema/ +es,http://eulersharp.sourceforge.net/2003/03swap/log-rules# +unit,http://qudt.org/vocab/unit# +label,http://purl.org/net/vocab/2004/03/label# +moat,http://moat-project.org/ns# +hlisting,http://sindice.com/hlisting/0.1/ +test,http://test2.example.com/ lom,http://ltsc.ieee.org/rdf/lomv1p0/lom# -common,http://www.w3.org/2007/uwa/context/common.owl# -ya,http://blogs.yandex.ru/schema/foaf/ -frbre,http://purl.org/vocab/frbr/extended# +osgb,http://data.ordnancesurvey.co.uk/id/ +custom,http://www.openrdf.org/config/sail/custom# prj,http://purl.org/stuff/project/ +resist,http://www.rkbexplorer.com/ontologies/resist# +pmlp,http://inference-web.org/2.0/pml-provenance.owl# +smiley,http://www.smileyontology.com/ns# +formats,http://www.w3.org/ns/formats/ +h5,http://buzzword.org.uk/rdf/h5# +sdl,http://purl.org/vocab/riro/sdl# +space,http://purl.org/net/schemas/space/ +wv,http://vocab.org/waiver/terms/ +ncal,http://www.semanticdesktop.org/ontologies/2007/04/02/ncal# +ping,http://purl.org/net/pingback/ +list,http://www.w3.org/2000/10/swap/list# +sml,http://topbraid.org/sparqlmotionlib# +phss,http://ns.poundhill.com/phss/1.0/ +omm,http://purl.org/ontomedia/core/media# +meetup,http://www.lotico.com/meetup/ net,http://www.w3.org/2007/uwa/context/network.owl# -hlisting,http://sindice.com/hlisting/0.1/ -sdl,http://purl.org/vocab/riro/sdl# -trackback,http://madskills.com/public/xml/rss/module/trackback/ +qdoslf,http://foaf.qdos.com/lastfm/schema/ +xen,http://buzzword.org.uk/rdf/xen# +tdb,http://jena.hpl.hp.com/2008/tdb# +gold,http://purl.org/linguistics/gold/ nmo,http://www.semanticdesktop.org/ontologies/2007/03/22/nmo# -cert,http://www.w3.org/ns/auth/cert# -spl,http://spinrdf.org/spl# -sp,http://spinrdf.org/sp# -dailymed,http://www4.wiwiss.fu-berlin.de/dailymed/resource/dailymed/ -resist,http://www.rkbexplorer.com/ontologies/resist# +xhe,http://buzzword.org.uk/rdf/xhtml-elements# swp,http://www.w3.org/2004/03/trix/swp-2/ -fresnel,http://www.w3.org/2004/09/fresnel# -lt,http://diplomski.nelakolundzija.org/LTontology.rdf# -wv,http://vocab.org/waiver/terms/ product,http://purl.org/commerce/product# -test,http://test2.example.com/ -gold,http://purl.org/linguistics/gold/ -smiley,http://www.smileyontology.com/ns# +lfn,http://www.dotnetrdf.org/leviathan# +whois,http://www.kanzaki.com/ns/whois# +pr,http://ontologi.es/profiling# +biocore,http://bio2rdf.org/core# +cnt,http://www.w3.org/2008/content# swandr,http://purl.org/swan/1.2/discourse-relationships/ -ddc,http://purl.org/NET/decimalised# -soft,http://www.w3.org/2007/uwa/context/software.owl# +frbre,http://purl.org/vocab/frbr/extended# nexif,http://www.semanticdesktop.org/ontologies/2007/05/10/nexif# -skosxl,http://www.w3.org/2008/05/skos-xl# +sm,http://topbraid.org/sparqlmotion# +fed,http://www.openrdf.org/config/sail/federation# +oat,http://openlinksw.com/schemas/oat/ +c4n,http://vocab.deri.ie/c4n# +smf,http://topbraid.org/sparqlmotionfunctions# +trackback,http://madskills.com/public/xml/rss/module/trackback/ ire,http://www.ontologydesignpatterns.org/cpont/ire.owl# -fed,http://www.openrdf.org/config/sail/federation# -courseware,http://courseware.rkbexplorer.com/ontologies/courseware# -biol,http://purl.org/NET/biol/ns# +opm,http://openprovenance.org/ontology# +common,http://www.w3.org/2007/uwa/context/common.owl# gpt,http://purl.org/vocab/riro/gpt# +soft,http://www.w3.org/2007/uwa/context/software.owl# +bibtex,http://purl.oclc.org/NET/nknouf/ns/bibtex# +climb,http://climb.dataincubator.org/vocabs/climb/ +wisski,http://wiss-ki.eu/ +pmt,http://tipsy.googlecode.com/svn/trunk/vocab/pmt# +opensearch,http://a9.com/-/spec/opensearch/1.1/ +bsbm,http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/ sesame,http://www.openrdf.org/schema/sesame# -time,http://www.w3.org/2006/time# -atom,http://www.w3.org/2005/Atom/ -omm,http://purl.org/ontomedia/core/media# -lotico,http://www.lotico.com/resource/ +swh,http://plugin.org.uk/swh-plugins/ +mysql,http://web-semantics.org/ns/mysql/ +nid3,http://www.semanticdesktop.org/ontologies/2007/05/10/nid3# +lt,http://diplomski.nelakolundzija.org/LTontology.rdf# web,http://www.w3.org/2007/uwa/context/web.owl# -sm,http://topbraid.org/sparqlmotion# +like,http://ontologi.es/like# states,http://www.w3.org/2005/07/aaa# -moat,http://moat-project.org/ns# -pimo,http://www.semanticdesktop.org/ontologies/2007/11/01/pimo# -push,http://www.w3.org/2007/uwa/context/push.owl# -bio2rdf,http://bio2rdf.org/ -bsbm,http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/ -bibtex,http://purl.oclc.org/NET/nknouf/ns/bibtex# -music,http://musicontology.com/ +ddc,http://purl.org/NET/decimalised# +imreg,http://www.w3.org/2004/02/image-regions# +ddl,http://purl.org/vocab/riro/ddl# +cycann,http://sw.cyc.com/CycAnnotations_v1# dummy,http://hello.com/ -am,http://vocab.deri.ie/am# -wairole,http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy# -pmt,http://tipsy.googlecode.com/svn/trunk/vocab/pmt# -loc,http://www.w3.org/2007/uwa/context/location.owl# -doclist,http://www.junkwork.net/xml/DocumentList# -pmlr,http://inference-web.org/2.0/pml-relation.owl# -ddl,http://purl.org/vocab/riro/ddl# -audio,http://purl.org/media/audio# -qdoslf,http://foaf.qdos.com/lastfm/schema/ -uri,http://purl.org/NET/uri# +obj,http://www.openrdf.org/rdf/2009/object# +resource,http://purl.org/vocab/resourcelist/schema# +compass,http://purl.org/net/compass# +swanag,http://purl.org/swan/1.2/agents/ crypto,http://www.w3.org/2000/10/swap/crypto# -like,http://ontologi.es/like# -lfn,http://www.dotnetrdf.org/leviathan# +push,http://www.w3.org/2007/uwa/context/push.owl# +puc,http://purl.org/NET/puc# +rdfa,http://www.w3.org/ns/rdfa# xl,http://langegger.at/xlwrap/vocab# +xhtmlvocab,http://www.w3.org/1999/xhtml/vocab/ dady,http://purl.org/NET/dady# -sl,http://www.semanlink.net/2001/00/semanlink-schema# -wisski,http://wiss-ki.eu/ -pr,http://ontologi.es/profiling# -climb,http://climb.dataincubator.org/vocabs/climb/ +pmlr,http://inference-web.org/2.0/pml-relation.owl# +psych,http://purl.org/vocab/psychometric-profile/ +pimo,http://www.semanticdesktop.org/ontologies/2007/11/01/pimo# +string,http://www.w3.org/2000/10/swap/string# +urn,http://fliqz.com/ +coin,http://purl.org/court/def/2009/coin# +plink,http://buzzword.org.uk/rdf/personal-link-types# conserv,http://conserv.deri.ie/ontology# -sml,http://topbraid.org/sparqlmotionlib# -dcat,http://www.w3.org/ns/dcat# -formats,http://www.w3.org/ns/formats/ -label,http://purl.org/net/vocab/2004/03/label# -puc,http://purl.org/NET/puc# -list,http://www.w3.org/2000/10/swap/list# -lifecycle,http://purl.org/vocab/lifecycle/schema# -swanpav,http://purl.org/swan/1.2/pav/ -smf,http://topbraid.org/sparqlmotionfunctions# -grddl,http://www.w3.org/2003/g/data-view# -pmlp,http://inference-web.org/2.0/pml-provenance.owl# -opm,http://openprovenance.org/ontology# -cycann,http://sw.cyc.com/CycAnnotations_v1# -obj,http://www.openrdf.org/rdf/2009/object# -urn,http://fliqz.com/ +rooms,http://vocab.deri.ie/rooms# +cco,http://purl.org/ontology/cco/core# +xesam,http://freedesktop.org/standards/xesam/1.0/core# +am,http://vocab.deri.ie/am# play,http://uriplay.org/spec/ontology/# -ping,http://purl.org/net/pingback/ -c4n,http://vocab.deri.ie/c4n# -mysql,http://web-semantics.org/ns/mysql/ -rdfa,http://www.w3.org/ns/rdfa# -osgb,http://data.ordnancesurvey.co.uk/id/ -resource,http://purl.org/vocab/resourcelist/schema# -xesam,http://freedesktop.org/standards/xesam/1.0/core# -plink,http://buzzword.org.uk/rdf/personal-link-types# -so,http://purl.org/ontology/symbolic-music/ -commerce,http://purl.org/commerce# -opensearch,http://a9.com/-/spec/opensearch/1.1/ -exif,http://www.w3.org/2003/12/exif/ns# -psych,http://purl.org/vocab/psychometric-profile/ evset,http://dsnotify.org/vocab/eventset/0.1/ +mf,http://poshrdf.org/ns/mf# +geographis,http://telegraphis.net/ontology/geography/geography# sysont,http://ns.ontowiki.net/SysOnt/ -ldap,http://purl.org/net/ldap/ -string,http://www.w3.org/2000/10/swap/string# -swanag,http://purl.org/swan/1.2/agents/ -nid3,http://www.semanticdesktop.org/ontologies/2007/05/10/nid3# +sl,http://www.semanlink.net/2001/00/semanlink-schema# +uri,http://purl.org/NET/uri# +wairole,http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy# ttl,http://www.w3.org/2008/turtle# +swanpav,http://purl.org/swan/1.2/pav/ +bib,http://zeitkunst.org/bibtex/0.1/bibtex.owl# +tripfs,http://purl.org/tripfs/2010/02# swanco,http://purl.org/swan/1.2/swan-commons/ -tripfs,http://purl.org/tripfs/2010/02# -imreg,http://www.w3.org/2004/02/image-regions# -swanci,http://purl.org/swan/1.2/citations/ -meetup,http://www.lotico.com/meetup/ -cnt,http://www.w3.org/2008/content# +opo,http://online-presence.net/opo/ns# okkam,http://models.okkam.org/ENS-core-vocabulary# -mf,http://poshrdf.org/ns/mf# -rec,http://purl.org/ontology/rec/core# -xhtmlvocab,http://www.w3.org/1999/xhtml/vocab/ -coin,http://purl.org/court/def/2009/coin# -geographis,http://telegraphis.net/ontology/geography/geography# -opo,http://online-presence.net/opo/ns# +game,http://data.totl.net/game/ swivt,http://semantic-mediawiki.org/swivt/1.0# -rooms,http://vocab.deri.ie/rooms# -oat,http://openlinksw.com/schemas/oat/ -bib,http://zeitkunst.org/bibtex/0.1/bibtex.owl# +status,http://ontologi.es/status# +swanci,http://purl.org/swan/1.2/citations/ +olo,http://purl.org/ontology/olo/core# +txn,http://lod.taxonconcept.org/ontology/txn.owl# oc,http://opencoinage.org/rdf/ -status,http://ontologi.es/status# ezcontext,http://ontologies.ezweb.morfeo-project.org/ezcontext/ns# -swid,http://semanticweb.org/id/ -pmlt,http://inference-web.org/2.0/pml-trust.owl# +geoes,http://geo.linkeddata.es/ontology/ +xtypes,http://purl.org/xtypes/ +meteo,http://purl.org/ns/meteo# sparql,http://www.openrdf.org/config/repository/sparql# -txn,http://lod.taxonconcept.org/ontology/txn.owl# -oo,http://purl.org/openorg/ -ct,http://data.linkedct.org/resource/linkedct/ -wlp,http://weblab-project.org/core/model/property/processing/ -ufmedia,http://purl.org/microformat/hmedia/ -sioca,http://rdfs.org/sioc/actions# awol,http://bblfish.net/work/atom-owl/2006-06-06/# -pdo,http://ontologies.smile.deri.ie/pdo# -pto,http://www.productontology.org/id/ +evopat,http://ns.aksw.org/Evolution/ +sdmx,http://purl.org/linked-data/sdmx# +ldap,http://purl.org/net/ldap/ +isq,http://purl.org/ontology/is/quality/ +lark1,http://users.utcluj.ro/~raluca/ontology/Ontology1279614123500.owl# aifb,http://www.aifb.kit.edu/id/ -prot,http://www.proteinontology.info/po.owl# -evopat,http://ns.aksw.org/Evolution/ -meteo,http://purl.org/ns/meteo# +isi,http://purl.org/ontology/is/inst/ +ao,http://purl.org/ontology/ao/core# +wlp,http://weblab-project.org/core/model/property/processing/ +ct,http://data.linkedct.org/resource/linkedct/ tarot,http://data.totl.net/tarot/card/ +anca,http://users.utcluj.ro/~raluca/rdf_ontologies_ralu/ralu_modified_ontology_pizzas2_0# +kb,http://deductions.sf.net/ontology/knowledge_base.owl# +opmv,http://purl.org/net/opmv/ns# +pmlt,http://inference-web.org/2.0/pml-trust.owl# +xbrli,http://www.xbrl.org/2003/instance# ist,http://purl.org/ontology/is/types/ -anca,http://users.utcluj.ro/~raluca/rdf_ontologies_ralu/ralu_modified_ontology_pizzas2_0# -whois,http://www.kanzaki.com/ns/whois# +xro,http://purl.org/xro/ns# +postcode,http://data.ordnancesurvey.co.uk/id/postcodeunit/ +dayta,http://dayta.me/resource# +swid,http://semanticweb.org/id/ +prot,http://www.proteinontology.info/po.owl# +opus,http://lsdis.cs.uga.edu/projects/semdis/opus# +core,http://vivoweb.org/ontology/core# +geospecies,http://rdf.geospecies.org/ont/geospecies# +go,http://www.geneontology.org/go# sawsdl,http://www.w3.org/ns/sawsdl# +pdo,http://ontologies.smil... [truncated message content] |
From: <lor...@us...> - 2013-06-13 13:34:03
|
Revision: 3995 http://sourceforge.net/p/dl-learner/code/3995 Author: lorenz_b Date: 2013-06-13 13:34:00 +0000 (Thu, 13 Jun 2013) Log Message: ----------- Cleaned up pom. Optimzed cache usage. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/kb/OWLAPIOntology.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/SimpleOntologyToByteConverter.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-06-13 10:28:10 UTC (rev 3994) +++ trunk/components-core/pom.xml 2013-06-13 13:34:00 UTC (rev 3995) @@ -102,37 +102,8 @@ <dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-distribution</artifactId> - <type>pom</type> + <version>3.4.4</version> </dependency> - <dependency> - <groupId>net.sourceforge.owlapi</groupId> - <artifactId>owlapi-dlsyntax</artifactId> - <version>3.3</version> - </dependency> - <dependency> - <groupId>net.sourceforge.owlapi</groupId> - <artifactId>owlapi-functional</artifactId> - <version>3.3</version> - </dependency> - - <dependency> - <groupId>net.sourceforge.owlapi</groupId> - <artifactId>owlapi-reasoner</artifactId> -</dependency> -<dependency> - <groupId>net.sourceforge.owlapi</groupId> - <artifactId>owlapi-debugging</artifactId> - <version>3.3</version> -</dependency> -<dependency> - <groupId>net.sourceforge.owlapi</groupId> - <artifactId>owlapi-modularity</artifactId> - <version>3.3</version> -</dependency> -<dependency> - <groupId>net.sourceforge.owlapi</groupId> - <artifactId>owlapi-util</artifactId> - </dependency> <!-- THIS IS FROM THE UNIBAS REPO --> <dependency> Modified: trunk/components-core/src/main/java/org/dllearner/kb/OWLAPIOntology.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/OWLAPIOntology.java 2013-06-13 10:28:10 UTC (rev 3994) +++ trunk/components-core/src/main/java/org/dllearner/kb/OWLAPIOntology.java 2013-06-13 13:34:00 UTC (rev 3995) @@ -21,6 +21,7 @@ import java.io.File; import java.net.URI; +import java.util.Collections; import org.dllearner.core.AbstractKnowledgeSource; import org.dllearner.core.OntologyFormat; @@ -39,10 +40,12 @@ private byte[] ontologyBytes; private OntologyToByteConverter converter = new SimpleOntologyToByteConverter(); + private OWLOntology ontology; - public OWLAPIOntology(OWLOntology onto) { - ontologyBytes = converter.convert(onto); + public OWLAPIOntology(OWLOntology ontology) { + this.ontology = ontology; +// ontologyBytes = converter.convert(ontology); } public static String getName() { @@ -51,7 +54,20 @@ @Override public OWLOntology createOWLOntology(OWLOntologyManager manager) { - return converter.convert(ontologyBytes, manager); + OWLOntology copy = null; + try { + IRI iri; + if(ontology.getOntologyID().isAnonymous()){ + iri = IRI.generateDocumentIRI(); + } else { + iri = ontology.getOntologyID().getOntologyIRI(); + } + copy = manager.createOntology(iri, Collections.singleton(ontology)); + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); + } +// return converter.convert(ontologyBytes, manager); + return copy; } @Override Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java 2013-06-13 10:28:10 UTC (rev 3994) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ConciseBoundedDescriptionGeneratorImpl.java 2013-06-13 13:34:00 UTC (rev 3995) @@ -11,7 +11,6 @@ import org.aksw.jena_sparql_api.cache.extra.CacheEx; import org.aksw.jena_sparql_api.cache.extra.CacheExImpl; import org.aksw.jena_sparql_api.core.QueryExecutionFactory; -//import org.aksw.jena_sparql_api.http.QueryExecutionFactoryHttp; import org.aksw.jena_sparql_api.model.QueryExecutionFactoryModel; import org.aksw.jena_sparql_api.pagination.core.QueryExecutionFactoryPaginated; import org.apache.log4j.Level; @@ -19,6 +18,7 @@ import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.rdf.model.Model; +//import org.aksw.jena_sparql_api.http.QueryExecutionFactoryHttp; //import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; public class ConciseBoundedDescriptionGeneratorImpl implements ConciseBoundedDescriptionGenerator{ @@ -27,34 +27,42 @@ private int chunkSize = 0; - private ExtractionDBCache cache; - private SparqlEndpoint endpoint; private Model baseModel; private List<String> namespaces; + private static final int MAX_RECURSION_DEPTH_DEFAULT = 1; private int maxRecursionDepth = 1; - private String cacheDir; + private QueryExecutionFactory qef; public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint, ExtractionDBCache cache) { - this.endpoint = endpoint; - this.cache = cache; + this(endpoint, cache, MAX_RECURSION_DEPTH_DEFAULT); } public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint, ExtractionDBCache cache, int maxRecursionDepth) { - this.endpoint = endpoint; - this.cache = cache; - this.maxRecursionDepth = maxRecursionDepth; + this(endpoint, cache.getCacheDirectory(), maxRecursionDepth); } public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint, String cacheDir, int maxRecursionDepth) { - this.endpoint = endpoint; - this.cacheDir = cacheDir; this.maxRecursionDepth = maxRecursionDepth; + + qef = new QueryExecutionFactoryHttp(endpoint.getURL().toString(), endpoint.getDefaultGraphURIs()); + if(cacheDir != null){ + try { + long timeToLive = TimeUnit.DAYS.toMillis(30); + CacheCoreEx cacheBackend = CacheCoreH2.create(cacheDir, timeToLive, true); + CacheEx cacheFrontend = new CacheExImpl(cacheBackend); + qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + qef = new QueryExecutionFactoryPaginated(qef, 10000); } public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint, String cacheDir) { - this.endpoint = endpoint; - this.cacheDir = cacheDir; + this(endpoint, cacheDir, MAX_RECURSION_DEPTH_DEFAULT); } public ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint endpoint) { @@ -63,6 +71,8 @@ public ConciseBoundedDescriptionGeneratorImpl(Model model) { this.baseModel = model; + + qef = new QueryExecutionFactoryModel(baseModel); } public Model getConciseBoundedDescription(String resourceURI){ @@ -79,25 +89,6 @@ private Model getModelChunked(String resource, int depth){ String query = makeConstructQueryOptional(resource, chunkSize, 0, depth); - QueryExecutionFactory qef; - if(endpoint != null){ - qef = new QueryExecutionFactoryHttp(endpoint.getURL().toString(), endpoint.getDefaultGraphURIs()); - if(cacheDir != null){ - try { - long timeToLive = TimeUnit.DAYS.toMillis(30); - CacheCoreEx cacheBackend = CacheCoreH2.create(cacheDir, timeToLive, true); - CacheEx cacheFrontend = new CacheExImpl(cacheBackend); - qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - qef = new QueryExecutionFactoryPaginated(qef, 10000); - } else { - qef = new QueryExecutionFactoryModel(baseModel); - } QueryExecution qe = qef.createQueryExecution(query); Model model = qe.execConstruct(); return model; Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-06-13 10:28:10 UTC (rev 3994) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-06-13 13:34:00 UTC (rev 3995) @@ -19,7 +19,6 @@ package org.dllearner.reasoning; -import java.net.SocketTimeoutException; import java.net.URL; import java.sql.SQLException; import java.util.ArrayList; @@ -41,6 +40,7 @@ import org.aksw.jena_sparql_api.cache.extra.CacheExImpl; import org.aksw.jena_sparql_api.core.QueryExecutionFactory; import org.aksw.jena_sparql_api.http.QueryExecutionFactoryHttp; +import org.aksw.jena_sparql_api.model.QueryExecutionFactoryModel; import org.aksw.jena_sparql_api.pagination.core.QueryExecutionFactoryPaginated; import org.dllearner.core.ComponentAnn; import org.dllearner.core.IndividualReasoner; @@ -81,9 +81,6 @@ import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; -import com.hp.hpl.jena.sparql.engine.http.QueryExceptionHTTP; -import com.hp.hpl.jena.sparql.resultset.ResultSetMem; import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL2; import com.hp.hpl.jena.vocabulary.RDF; @@ -98,6 +95,7 @@ private boolean useCache = true; private ExtractionDBCache cache; + private QueryExecutionFactory qef; private SparqlEndpointKS ks; private ClassHierarchy hierarchy; @@ -128,6 +126,27 @@ classPopularityMap = new HashMap<NamedClass, Integer>(); objectPropertyPopularityMap = new HashMap<ObjectProperty, Integer>(); + + if(ks.isRemote()){ + SparqlEndpoint endpoint = ks.getEndpoint(); + qef = new QueryExecutionFactoryHttp(endpoint.getURL().toString(), endpoint.getDefaultGraphURIs()); + if(cache != null){ + try { + long timeToLive = TimeUnit.DAYS.toMillis(30); + CacheCoreEx cacheBackend = CacheCoreH2.create(cache.getCacheDirectory(), timeToLive, true); + CacheEx cacheFrontend = new CacheExImpl(cacheBackend); + qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + qef = new QueryExecutionFactoryPaginated(qef, 10000); + + } else { + qef = new QueryExecutionFactoryModel(((LocalModelBasedSparqlEndpointKS)ks).getModel()); + } } public SPARQLReasoner(OntModel model) { @@ -1362,58 +1381,25 @@ private ResultSet executeSelectQuery(String query){ logger.debug("Sending query \n {}", query); - ResultSet rs = null; - if(ks.isRemote()){ - SparqlEndpoint endpoint = ks.getEndpoint(); - QueryExecutionFactory qef = new QueryExecutionFactoryHttp(endpoint.getURL().toString(), endpoint.getDefaultGraphURIs()); - if(cache != null){ - try { - long timeToLive = TimeUnit.DAYS.toMillis(30); - CacheCoreEx cacheBackend = CacheCoreH2.create(cache.getCacheDirectory(), timeToLive, true); - CacheEx cacheFrontend = new CacheExImpl(cacheBackend); - qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - qef = new QueryExecutionFactoryPaginated(qef, 10000); - QueryExecution qe = qef.createQueryExecution(query); - rs = qe.execSelect(); - } else { - QueryExecution qExec = com.hp.hpl.jena.query.QueryExecutionFactory.create(query, ((LocalModelBasedSparqlEndpointKS)ks).getModel()); - rs = qExec.execSelect(); - } + QueryExecution qe = qef.createQueryExecution(query); + ResultSet rs = qe.execSelect(); return rs; } private ResultSet executeSelectQuery(String query, long timeout){ logger.debug("Sending query \n {}", query); - ResultSet rs = null; - if(ks.isRemote()){ - SparqlEndpoint endpoint = ((SparqlEndpointKS) ks).getEndpoint(); - QueryEngineHTTP queryExecution = new QueryEngineHTTP(endpoint.getURL().toString(), - query); - queryExecution.setTimeout(timeout); - queryExecution.setDefaultGraphURIs(endpoint.getDefaultGraphURIs()); - queryExecution.setNamedGraphURIs(endpoint.getNamedGraphURIs()); - try { - rs = queryExecution.execSelect(); - } catch (QueryExceptionHTTP e) { - if(e.getCause() instanceof SocketTimeoutException){ - logger.warn("Got timeout"); - } else { - logger.error("Exception executing query", e); - } - rs = new ResultSetMem(); - } - } else { - QueryExecution qExec = com.hp.hpl.jena.query.QueryExecutionFactory.create(query, ((LocalModelBasedSparqlEndpointKS)ks).getModel()); - rs = qExec.execSelect(); - } + QueryExecution qe = qef.createQueryExecution(query); + qe.setTimeout(timeout); + ResultSet rs = qe.execSelect(); return rs; } + + private boolean executeAskQuery(String query){ + logger.debug("Sending query \n {}", query); + QueryExecution qe = qef.createQueryExecution(query); + boolean ret = qe.execAsk(); + return ret; + } /** * Returns TRUE if the class hierarchy was computed before. @@ -1431,27 +1417,6 @@ this.useCache = useCache; } - private boolean executeAskQuery(String query){ - boolean ret; - if(ks.isRemote()){ - QueryEngineHTTP queryExecution = new QueryEngineHTTP(ks.getEndpoint().getURL().toString(), query); - for (String dgu : ks.getEndpoint().getDefaultGraphURIs()) { - queryExecution.addDefaultGraph(dgu); - } - for (String ngu : ks.getEndpoint().getNamedGraphURIs()) { - queryExecution.addNamedGraph(ngu); - } - ret = queryExecution.execAsk(); - - } else { - QueryExecution qExec = com.hp.hpl.jena.query.QueryExecutionFactory.create(query, ((LocalModelBasedSparqlEndpointKS)ks).getModel()); - ret = qExec.execAsk(); - } - - return ret; - } - - public static void main(String[] args) throws Exception{ // QueryEngineHTTP e = new QueryEngineHTTP("http://bibleontology.com/sparql/index.jsp", // "SELECT DISTINCT ?type WHERE {?s a ?type) LIMIT 10"); Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/SimpleOntologyToByteConverter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/SimpleOntologyToByteConverter.java 2013-06-13 10:28:10 UTC (rev 3994) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/SimpleOntologyToByteConverter.java 2013-06-13 13:34:00 UTC (rev 3995) @@ -1,5 +1,8 @@ package org.dllearner.utilities.owl; +import org.coode.owlapi.turtle.TurtleOntologyFormat; +import org.semanticweb.owlapi.io.RDFXMLOntologyFormat; +import org.semanticweb.owlapi.model.OWLNamedIndividual; import org.semanticweb.owlapi.model.OWLOntology; import org.semanticweb.owlapi.model.OWLOntologyCreationException; import org.semanticweb.owlapi.model.OWLOntologyManager; @@ -7,7 +10,9 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.util.Set; /** * Created by IntelliJ IDEA. @@ -26,7 +31,7 @@ OWLOntologyManager manager = ontology.getOWLOntologyManager(); try { - manager.saveOntology(ontology,baos); + manager.saveOntology(ontology, baos); baos.close(); } catch (OWLOntologyStorageException e) { throw new RuntimeException(e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-07-01 19:05:53
|
Revision: 4013 http://sourceforge.net/p/dl-learner/code/4013 Author: lorenz_b Date: 2013-07-01 19:05:50 +0000 (Mon, 01 Jul 2013) Log Message: ----------- Minor changes in SPARQL reasonr. Updated LUCENE libs for ISLE: Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityTextRetriever.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneIndexer.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneSearcher.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/kb/repository/oxford/OxfordRepository.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/QueryEngineHTTP.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/pom.xml 2013-07-01 19:05:50 UTC (rev 4013) @@ -215,6 +215,14 @@ <artifactId>lucene-core</artifactId> </dependency> <dependency> + <groupId>org.apache.lucene</groupId> + <artifactId>lucene-analyzers-common</artifactId> + </dependency> + <dependency> + <groupId>org.apache.lucene</groupId> + <artifactId>lucene-queryparser</artifactId> + </dependency> + <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> </dependency> @@ -272,7 +280,7 @@ <dependency> <groupId>org.aksw.jena-sparql-api</groupId> <artifactId>jena-sparql-api-core</artifactId> - <version>2.10.0-4-SNAPSHOT</version> + <version>2.10.0-5-SNAPSHOT</version> </dependency> </dependencies> <dependencyManagement> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityTextRetriever.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityTextRetriever.java 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityTextRetriever.java 2013-07-01 19:05:50 UTC (rev 4013) @@ -43,6 +43,6 @@ * @param entity The entity to handle. * @return A weighted set of strings. For a value x, we need to have 0 <= x <= 1. */ - public Map<String, Integer> getRelevantText(Entity entity); + public Map<String, Double> getRelevantText(Entity entity); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneIndexer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneIndexer.java 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneIndexer.java 2013-07-01 19:05:50 UTC (rev 4013) @@ -25,8 +25,10 @@ import java.io.IOException; import java.util.Date; +import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.FSDirectory; import org.apache.lucene.util.Version; @@ -51,12 +53,12 @@ Date start = new Date(); try { - IndexWriter writer = new IndexWriter( FSDirectory.open( INDEX ), - new StandardAnalyzer( Version.LUCENE_CURRENT ), true, IndexWriter.MaxFieldLength.LIMITED ); + Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_43); + IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_43, analyzer); + IndexWriter writer = new IndexWriter( FSDirectory.open( INDEX ), indexWriterConfig); System.out.println( "Creating index ..." ); index( writer, docDir ); System.out.println( "Optimizing index ..." ); - writer.optimize(); writer.close(); Date end = new Date(); System.out.println( end.getTime() - start.getTime() + " total milliseconds" ); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneSearcher.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneSearcher.java 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LuceneSearcher.java 2013-07-01 19:05:50 UTC (rev 4013) @@ -32,13 +32,14 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; +import org.apache.lucene.index.AtomicReaderContext; +import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.queryParser.QueryParser; +import org.apache.lucene.queryparser.classic.QueryParser; import org.apache.lucene.search.Collector; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.Scorer; -import org.apache.lucene.search.Searcher; import org.apache.lucene.store.FSDirectory; import org.apache.lucene.util.Version; @@ -48,7 +49,7 @@ private String FIELD = "contents"; private IndexReader m_reader = null; - private Searcher m_searcher = null; + private IndexSearcher m_searcher = null; private Analyzer m_analyzer = null; private QueryParser m_parser = null; @@ -70,10 +71,10 @@ @SuppressWarnings("deprecation") public LuceneSearcher() throws Exception { - m_reader = IndexReader.open( FSDirectory.open( new File( INDEX ) ), true ); + m_reader = DirectoryReader.open( FSDirectory.open( new File( INDEX ) )); m_searcher = new IndexSearcher( m_reader ); - m_analyzer = new StandardAnalyzer( Version.LUCENE_CURRENT ); - m_parser = new QueryParser( Version.LUCENE_CURRENT, FIELD, m_analyzer ); + m_analyzer = new StandardAnalyzer( Version.LUCENE_43); + m_parser = new QueryParser( Version.LUCENE_43, FIELD, m_analyzer ); } public void close() throws Exception { @@ -139,13 +140,13 @@ return true; } @Override - public void setNextReader( IndexReader reader, int docBase ) throws IOException { - this.docBase = docBase; - } - @Override public void setScorer(Scorer scorer) throws IOException { this.scorer = scorer; } + @Override + public void setNextReader(AtomicReaderContext context) throws IOException { + this.docBase = context.docBase; + } }; m_searcher.search( query, collector ); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java 2013-07-01 19:05:50 UTC (rev 4013) @@ -364,7 +364,7 @@ System.out.print(i++ + ": "); URI uri = entry.getPhysicalURI(); // if(uri.toString().startsWith("http://rest.bioontology.org/bioportal/ontologies/download/42764")){ - if (!ontologyProcessed(uri)) { + if (!ontologyProcessed(uri)) {//if(entry.getOntologyShortName().equals("00698"))continue; System.out.print("Loading \"" + entry.getOntologyShortName() + "\" from "+ uri); try { manager = OWLManager.createOWLOntologyManager(); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/DisjointObjectPropertyAxiomLearner.java 2013-07-01 19:05:50 UTC (rev 4013) @@ -116,7 +116,7 @@ //compute the overlap if exist Map<ObjectProperty, Integer> property2Overlap = new HashMap<ObjectProperty, Integer>(); String query = String.format("SELECT ?p (COUNT(*) AS ?cnt) WHERE {?s <%s> ?o. ?s ?p ?o.} GROUP BY ?p", propertyToDescribe.getName()); - System.out.println(query);ResultSet rs = executeSelectQuery(query); + ResultSet rs = executeSelectQuery(query); QuerySolution qs; while(rs.hasNext()){ qs = rs.next(); Modified: trunk/components-core/src/main/java/org/dllearner/kb/repository/oxford/OxfordRepository.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/oxford/OxfordRepository.java 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/oxford/OxfordRepository.java 2013-07-01 19:05:50 UTC (rev 4013) @@ -90,7 +90,7 @@ private URI physicalURI; public RepositoryEntry(URI ontologyIRI) { - this.ontologyURI = ontologyIRI;System.out.println(ontologyIRI); + this.ontologyURI = ontologyIRI; OntologyIRIShortFormProvider sfp = new OntologyIRIShortFormProvider(); shortName = sfp.getShortForm(IRI.create(ontologyIRI)); physicalURI = ontologyIRI; Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/QueryEngineHTTP.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/QueryEngineHTTP.java 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/QueryEngineHTTP.java 2013-07-01 19:05:50 UTC (rev 4013) @@ -268,7 +268,7 @@ private Model execModel(Model model) { HttpQuery httpQuery = makeHttpQuery() ; - httpQuery.setAccept(WebContent.contentTypeNTriplesAlt) ; + httpQuery.setAccept(WebContent.contentTypeTurtleAlt1) ; InputStream in = httpQuery.exec() ; //Don't assume the endpoint actually gives back the content type we asked for @@ -284,7 +284,7 @@ //Try to select language appropriately here based on the model content type Lang lang = WebContent.contentTypeToLang(actualContentType); if (! RDFLanguages.isTriples(lang)) throw new QueryException("Endpoint returned Content Type: " + actualContentType + " which is not a valid RDF Graph syntax"); - model.read(in, null, "N-TRIPLES") ; + model.read(in, null, "TURTLE") ; return model ; } Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2013-07-01 19:05:50 UTC (rev 4013) @@ -11,7 +11,6 @@ import org.dllearner.core.AbstractKnowledgeSource; import org.dllearner.core.ComponentAnn; import org.dllearner.core.ComponentInitException; -import org.dllearner.core.KnowledgeSource; import org.dllearner.core.OntologyFormat; import org.dllearner.core.OntologyFormatUnsupportedException; import org.dllearner.core.config.ConfigOption; @@ -36,7 +35,6 @@ import com.jamonapi.MonitorFactory; @ComponentAnn(name = "efficient SPARQL fragment extractor", shortName = "sparqls", version = 0.1) - public class SparqlSimpleExtractor extends AbstractKnowledgeSource implements OWLOntologyKnowledgeSource{ @@ -334,5 +332,10 @@ JenaToOwlapiConverter converter = new JenaToOwlapiConverter(); return converter.convert(this.model,manager); } + + public static String getName(){ + return "efficient SPARQL fragment extractor"; + } + } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-07-01 18:51:19 UTC (rev 4012) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-07-01 19:05:50 UTC (rev 4013) @@ -22,10 +22,12 @@ import java.net.URL; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.SortedSet; import java.util.TreeMap; @@ -73,6 +75,8 @@ import org.slf4j.LoggerFactory; import com.clarkparsia.owlapiv3.XSD; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.query.QueryExecution; @@ -80,6 +84,7 @@ import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL2; @@ -134,7 +139,7 @@ e.printStackTrace(); } } - qef = new QueryExecutionFactoryPaginated(qef, 10000); +// qef = new QueryExecutionFactoryPaginated(qef, 10000); } else { qef = new QueryExecutionFactoryModel(((LocalModelBasedSparqlEndpointKS)ks).getModel()); @@ -518,6 +523,100 @@ } return types; } + + public Set<Property> getProperties(boolean inferType, String namespace) { + Set<Property> properties = new HashSet<Property>(); + String query = "SELECT DISTINCT ?p ?type WHERE {?s ?p ?o." + + (namespace != null ? ("FILTER(REGEX(?p,'^" + namespace + "'))") : "") + + "OPTIONAL{?p a ?type.}}"; + ResultSet rs = executeSelectQuery(query); + Multimap<String, String> uri2Types = HashMultimap.create(); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + String uri = qs.getResource("p").getURI(); + String type = ""; + if(qs.getResource("type") != null){ + type = qs.getResource("type").getURI(); + } + uri2Types.put(uri, type); + } + for (Entry<String, Collection<String>> entry : uri2Types.asMap().entrySet()) { + String uri = entry.getKey(); + Collection<String> types = entry.getValue(); + if(types.contains(OWL.ObjectProperty.getURI()) && !types.contains(OWL.DatatypeProperty.getURI())){ + properties.add(new ObjectProperty(uri)); + } else if(!types.contains(OWL.ObjectProperty.getURI()) && types.contains(OWL.DatatypeProperty.getURI())){ + properties.add(new DatatypeProperty(uri)); + } else { + //infer the type by values + query = "SELECT ?o WHERE {?s <" + uri + "> ?o. } LIMIT 100"; + rs = executeSelectQuery(query); + boolean op = true; + boolean dp = true; + RDFNode node; + while(rs.hasNext()){ + node = rs.next().get("o"); + op = node.isResource(); + dp = node.isLiteral(); + } + if(op && !dp){ + properties.add(new ObjectProperty(uri)); + } else if(!op && dp){ + properties.add(new DatatypeProperty(uri)); + } else { + //not possible to decide + } + } + } + return properties; + } + + public Set<Property> getProperties(boolean inferType) { + Set<Property> properties = new TreeSet<Property>(); + String query = "SELECT DISTINCT ?p ?type WHERE {?s ?p ?o. OPTIONAL{?p a ?type.}}"; + ResultSet rs = executeSelectQuery(query); + Multimap<String, String> uri2Types = HashMultimap.create(); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + String uri = qs.getResource("p").getURI(); + String type = ""; + if(qs.getResource("type") != null){ + type = qs.getResource("type").getURI(); + } + uri2Types.put(uri, type); + } + for (Entry<String, Collection<String>> entry : uri2Types.asMap().entrySet()) { + String uri = entry.getKey(); + Collection<String> types = entry.getValue(); + if(types.contains(OWL.ObjectProperty.getURI()) && !types.contains(OWL.DatatypeProperty.getURI())){ + properties.add(new ObjectProperty(uri)); + } else if(!types.contains(OWL.ObjectProperty.getURI()) && types.contains(OWL.DatatypeProperty.getURI())){ + properties.add(new DatatypeProperty(uri)); + } else { + //infer the type by values + query = "SELECT ?o WHERE {?s <" + uri + "> ?o. } LIMIT 100"; + rs = executeSelectQuery(query); + boolean op = true; + boolean dp = true; + RDFNode node; + while(rs.hasNext()){ + node = rs.next().get("o"); + op = node.isResource(); + dp = node.isLiteral(); + } + if(op && !dp){ + properties.add(new ObjectProperty(uri)); + } else if(!op && dp){ + properties.add(new DatatypeProperty(uri)); + } else { + //not possible to decide + } + } + } + return properties; + } public Set<NamedClass> getOWLClasses() { Set<NamedClass> types = new HashSet<NamedClass>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-09-04 13:18:24
|
Revision: 4056 http://sourceforge.net/p/dl-learner/code/4056 Author: lorenz_b Date: 2013-09-04 13:18:17 +0000 (Wed, 04 Sep 2013) Log Message: ----------- Added wordnet+stanford. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StopWordFilter.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Annotation.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotation.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotator.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/semantic/simple/SimpleSemanticIndex.java trunk/components-core/src/main/resources/wordnet_properties.xml trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/SimpleWordSenseDisambiguation.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-09-04 10:04:14 UTC (rev 4055) +++ trunk/components-core/pom.xml 2013-09-04 13:18:17 UTC (rev 4056) @@ -282,6 +282,32 @@ <artifactId>jena-sparql-api-core</artifactId> <version>2.10.0-5-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.1</version> + </dependency> + <dependency> + <groupId>edu.stanford.nlp</groupId> + <artifactId>stanford-corenlp</artifactId> + <version>1.3.4</version> + </dependency> + <dependency> + <groupId>edu.stanford.nlp</groupId> + <artifactId>stanford-corenlp</artifactId> + <version>1.3.4</version> + </dependency> + <dependency> + <groupId>edu.stanford.nlp</groupId> + <artifactId>stanford-corenlp</artifactId> + <version>1.3.4</version> + <classifier>models</classifier> + </dependency> + <dependency> + <groupId>net.didion.jwnl</groupId> + <artifactId>jwnl</artifactId> + <version>1.4.1.RC2</version> + </dependency> </dependencies> <dependencyManagement> <dependencies> Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/SimpleWordSenseDisambiguation.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/SimpleWordSenseDisambiguation.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/SimpleWordSenseDisambiguation.java 2013-09-04 13:18:17 UTC (rev 4056) @@ -0,0 +1,79 @@ +/** + * + */ +package org.dllearner.algorithms.isle; + +import java.util.HashSet; +import java.util.Set; + +import org.dllearner.algorithms.isle.index.Annotation; +import org.dllearner.algorithms.isle.index.SemanticAnnotation; +import org.dllearner.core.owl.Entity; +import org.dllearner.utilities.owl.OWLAPIConverter; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.util.IRIShortFormProvider; +import org.semanticweb.owlapi.util.SimpleIRIShortFormProvider; + +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; + +/** + * @author Lorenz Buehmann + * + */ +public class SimpleWordSenseDisambiguation extends WordSenseDisambiguation{ + + private IRIShortFormProvider sfp = new SimpleIRIShortFormProvider(); + private OWLDataFactory df = new OWLDataFactoryImpl(); + private OWLAnnotationProperty annotationProperty = df.getRDFSLabel(); + + /** + * @param ontology + */ + public SimpleWordSenseDisambiguation(OWLOntology ontology) { + super(ontology); + } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.isle.WordSenseDisambiguation#disambiguate(org.dllearner.algorithms.isle.index.Annotation, java.util.Set) + */ + @Override + public SemanticAnnotation disambiguate(Annotation annotation, Set<Entity> candidateEntities) { + String token = annotation.getToken(); + //check if annotation token matches label of entity or the part behind #(resp. /) + for (Entity entity : candidateEntities) { + Set<String> labels = getLabels(entity); + for (String label : labels) { + if(label.equals(token)){ + return new SemanticAnnotation(annotation, entity); + } + } + String shortForm = sfp.getShortForm(IRI.create(entity.getURI())); + if(annotation.equals(shortForm)){ + return new SemanticAnnotation(annotation, entity); + } + } + return null; + } + + private Set<String> getLabels(Entity entity){ + Set<String> labels = new HashSet<String>(); + OWLEntity owlEntity = OWLAPIConverter.getOWLAPIEntity(entity); + Set<OWLAnnotationAssertionAxiom> axioms = ontology.getAnnotationAssertionAxioms(owlEntity.getIRI()); + for (OWLAnnotationAssertionAxiom annotation : axioms) { + if(annotation.getProperty().equals(annotationProperty)){ + if (annotation.getValue() instanceof OWLLiteral) { + OWLLiteral val = (OWLLiteral) annotation.getValue(); + labels.add(val.getLiteral()); + } + } + } + return labels; + } + +} Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StopWordFilter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StopWordFilter.java 2013-09-04 10:04:14 UTC (rev 4055) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StopWordFilter.java 2013-09-04 13:18:17 UTC (rev 4056) @@ -45,7 +45,7 @@ public void removeStopWordAnnotations(Set<Annotation> annotations) { for (Iterator<Annotation> iter = annotations.iterator(); iter.hasNext();) { Annotation annotation = iter.next(); - String content = annotation.getGetReferencedDocument().getContent(); + String content = annotation.getReferencedDocument().getContent(); String token = content.substring(annotation.getOffset(), annotation.getOffset()+annotation.getLength()); if(stopWords.contains(token)){ iter.remove(); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Annotation.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Annotation.java 2013-09-04 10:04:14 UTC (rev 4055) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Annotation.java 2013-09-04 13:18:17 UTC (rev 4056) @@ -10,18 +10,18 @@ */ public class Annotation { - private Document getReferencedDocument; + private Document referencedDocument; private int offset; private int length; - public Annotation(Document getReferencedDocument, int offset, int length) { - this.getReferencedDocument = getReferencedDocument; + public Annotation(Document referencedDocument, int offset, int length) { + this.referencedDocument = referencedDocument; this.offset = offset; this.length = length; } - public Document getGetReferencedDocument() { - return getReferencedDocument; + public Document getReferencedDocument() { + return referencedDocument; } public int getOffset() { @@ -31,12 +31,16 @@ public int getLength() { return length; } + + public String getToken(){ + return referencedDocument.getContent().substring(offset, offset + length); + } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((getReferencedDocument == null) ? 0 : getReferencedDocument.hashCode()); + result = prime * result + ((referencedDocument == null) ? 0 : referencedDocument.hashCode()); result = prime * result + length; result = prime * result + offset; return result; @@ -51,10 +55,10 @@ if (getClass() != obj.getClass()) return false; Annotation other = (Annotation) obj; - if (getReferencedDocument == null) { - if (other.getReferencedDocument != null) + if (referencedDocument == null) { + if (other.referencedDocument != null) return false; - } else if (!getReferencedDocument.equals(other.getReferencedDocument)) + } else if (!referencedDocument.equals(other.referencedDocument)) return false; if (length != other.length) return false; @@ -68,6 +72,6 @@ */ @Override public String toString() { - return "\"" + getReferencedDocument.getContent().substring(offset, offset+length) + "\" at position " + offset; + return "\"" + referencedDocument.getContent().substring(offset, offset+length) + "\" at position " + offset; } } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotation.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotation.java 2013-09-04 10:04:14 UTC (rev 4055) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotation.java 2013-09-04 13:18:17 UTC (rev 4056) @@ -14,7 +14,7 @@ private Entity entity; public SemanticAnnotation(Annotation annotation, Entity entity) { - super(annotation.getGetReferencedDocument(), annotation.getOffset(), annotation.getLength()); + super(annotation.getReferencedDocument(), annotation.getOffset(), annotation.getLength()); this.entity = entity; } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotator.java 2013-09-04 10:04:14 UTC (rev 4055) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotator.java 2013-09-04 13:18:17 UTC (rev 4056) @@ -43,8 +43,9 @@ for (Annotation annotation : annotations) { Set<Entity> candidateEntities = entityCandidateGenerator.getCandidates(annotation); SemanticAnnotation semanticAnnotation = wordSenseDisambiguation.disambiguate(annotation, candidateEntities); - semanticAnnotations.add(semanticAnnotation); - + if(semanticAnnotation != null){ + semanticAnnotations.add(semanticAnnotation); + } } AnnotatedDocument annotatedDocument = new AnnotatedTextDocument(document, semanticAnnotations); return annotatedDocument; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/semantic/simple/SimpleSemanticIndex.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/semantic/simple/SimpleSemanticIndex.java 2013-09-04 10:04:14 UTC (rev 4055) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/semantic/simple/SimpleSemanticIndex.java 2013-09-04 13:18:17 UTC (rev 4056) @@ -4,6 +4,7 @@ package org.dllearner.algorithms.isle.index.semantic.simple; import org.dllearner.algorithms.isle.RandomWordSenseDisambiguation; +import org.dllearner.algorithms.isle.SimpleWordSenseDisambiguation; import org.dllearner.algorithms.isle.index.SimpleEntityCandidateGenerator; import org.dllearner.algorithms.isle.index.SimpleLinguisticAnnotator; import org.dllearner.algorithms.isle.index.semantic.SemanticIndex; @@ -28,7 +29,7 @@ public SimpleSemanticIndex(OWLOntology ontology, SyntacticIndex syntacticIndex) { super(ontology, syntacticIndex, - new RandomWordSenseDisambiguation(ontology), + new SimpleWordSenseDisambiguation(ontology), new SimpleEntityCandidateGenerator(ontology), new SimpleLinguisticAnnotator()); } Modified: trunk/components-core/src/main/resources/wordnet_properties.xml =================================================================== --- trunk/components-core/src/main/resources/wordnet_properties.xml 2013-09-04 10:04:14 UTC (rev 4055) +++ trunk/components-core/src/main/resources/wordnet_properties.xml 2013-09-04 13:18:17 UTC (rev 4056) @@ -38,7 +38,7 @@ <param name="dictionary_element_factory" value="net.didion.jwnl.princeton.data.PrincetonWN17FileDictionaryElementFactory"/> <param name="file_manager" value="net.didion.jwnl.dictionary.file_manager.FileManagerImpl"> <param name="file_type" value="net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile"/> - <param name="dictionary_path" value="/opt/wordnet/dict"/> + <param name="dictionary_path" value="/opt/wordnet"/> </param> </dictionary> <resource class="PrincetonResource"/> Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java 2013-09-04 10:04:14 UTC (rev 4055) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java 2013-09-04 13:18:17 UTC (rev 4056) @@ -118,8 +118,14 @@ public void testSemanticIndexAnnotationProperty(){ semanticIndex = new SimpleSemanticIndex(ontology, syntacticIndex); semanticIndex.buildIndex(df.getRDFSLabel(), null); - Set<AnnotatedDocument> documents = semanticIndex.getDocuments(new NamedClass("http://example.com/father#father")); - System.out.println(documents); + + NamedClass nc = new NamedClass("http://example.com/father#father"); + Set<AnnotatedDocument> documents = semanticIndex.getDocuments(nc); + System.out.println("Documents for " + nc + ":\n" + documents); + + nc = new NamedClass("http://example.com/father#person"); + documents = semanticIndex.getDocuments(nc); + System.out.println("Documents for " + nc + ":\n" + documents); } @Test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |