You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(120) |
Sep
(36) |
Oct
(116) |
Nov
(17) |
Dec
(44) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(143) |
Feb
(192) |
Mar
(74) |
Apr
(84) |
May
(105) |
Jun
(64) |
Jul
(49) |
Aug
(120) |
Sep
(159) |
Oct
(156) |
Nov
(51) |
Dec
(28) |
2009 |
Jan
(17) |
Feb
(55) |
Mar
(33) |
Apr
(57) |
May
(54) |
Jun
(28) |
Jul
(6) |
Aug
(16) |
Sep
(38) |
Oct
(30) |
Nov
(26) |
Dec
(52) |
2010 |
Jan
(7) |
Feb
(91) |
Mar
(65) |
Apr
(2) |
May
(14) |
Jun
(25) |
Jul
(38) |
Aug
(48) |
Sep
(80) |
Oct
(70) |
Nov
(75) |
Dec
(77) |
2011 |
Jan
(68) |
Feb
(53) |
Mar
(51) |
Apr
(35) |
May
(65) |
Jun
(101) |
Jul
(29) |
Aug
(230) |
Sep
(95) |
Oct
(49) |
Nov
(110) |
Dec
(63) |
2012 |
Jan
(41) |
Feb
(42) |
Mar
(25) |
Apr
(46) |
May
(51) |
Jun
(44) |
Jul
(45) |
Aug
(29) |
Sep
(12) |
Oct
(9) |
Nov
(17) |
Dec
(2) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(7) |
Apr
(16) |
May
(54) |
Jun
(27) |
Jul
(11) |
Aug
(5) |
Sep
(85) |
Oct
(27) |
Nov
(37) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(29) |
Mar
(5) |
Apr
(3) |
May
(22) |
Jun
(3) |
Jul
(4) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ku...@us...> - 2008-05-19 14:03:16
|
Revision: 902 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=902&view=rev Author: kurzum Date: 2008-05-19 07:03:09 -0700 (Mon, 19 May 2008) Log Message: ----------- started cleanup Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-19 13:11:24 UTC (rev 901) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-19 14:03:09 UTC (rev 902) @@ -384,11 +384,12 @@ return algorithm.getBestSolutions(nrOfSolutions); } - //HACK @Override - public List<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ - return this.algorithm.getBestSolutionsAsKBSyntax(nrOfSolutions); + public synchronized List<Description> getGoodSolutions() { + return algorithm.getGoodSolutions(); } + + @Override public void stop() { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-19 13:11:24 UTC (rev 901) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-19 14:03:09 UTC (rev 902) @@ -472,6 +472,7 @@ logger.debug("size of candidate set: " + candidates.size()); boolean showOrderedSolutions = false; printBestSolutions(20,showOrderedSolutions); + printStatistics(true); if(stop) @@ -1057,6 +1058,7 @@ return candidatesStable.last().getConcept(); } + public synchronized List<Description> getBestSolutions(int nrOfSolutions) { List<Description> best = new LinkedList<Description>(); int i=0; @@ -1070,7 +1072,28 @@ return best; } - //HACK + + /** + * returns the solutions, that have at least a certain quality + * either accuracy = 100% full solutions + * or accuracy > 100% - noise; + * @return + */ + public synchronized List<Description> getGoodSolutions() { + List<Description> best = new LinkedList<Description>(); + + for(ExampleBasedNode n : candidatesStable.descendingSet()) { + if(n.getAccuracy(nrOfPositiveExamples, nrOfNegativeExamples)<(1-noise)) + return best; + best.add(n.getConcept()); + + } + return best; + } + + + + /*//HACK public List<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ if(nrOfSolutions==0)nrOfSolutions=99999; List<String> result = new LinkedList<String>(); @@ -1091,7 +1114,7 @@ } } return result; - } + }*/ public void printBestSolutions(int nrOfSolutions, boolean showOrderedSolutions){ @@ -1109,8 +1132,19 @@ i++; } + if(nrOfSolutions==0) + nrOfSolutions=solutions.size(); + int a=0; + for(;a<nrOfSolutions && a < solutions.size();a++) { + + logger.trace("nnn: "+solutions.get(a)); + if(a==nrOfSolutions) + break ; + + } + if(showOrderedSolutions) { logger.trace("ordered by generality (most special solutions first):"); SubsumptionComparator sc = new SubsumptionComparator(rs); Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-05-19 13:11:24 UTC (rev 901) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-05-19 14:03:09 UTC (rev 902) @@ -57,17 +57,33 @@ */ public abstract Description getBestSolution(); + + + /** + * returns the best nrOfSolutions solutions + * regardless of quality, just depends on input int + * @param nrOfSolutions + * @return List<Description> + */ public synchronized List<Description> getBestSolutions(int nrOfSolutions) { List<Description> single = new LinkedList<Description>(); single.add(getBestSolution()); return single; } - //HACK - public List<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ - return null; + /** + * returns the solutions, that have at least a certain quality + * either accuracy = 100%, i.e. full solutions + * or accuracy > 100% - noise; + * @return + */ + public synchronized List<Description> getGoodSolutions() { + List<Description> single = new LinkedList<Description>(); + single.add(getBestSolution()); + return single; } + /** * Returns all learning problems supported by this component. */ Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-19 13:11:24 UTC (rev 901) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-19 14:03:09 UTC (rev 902) @@ -191,16 +191,16 @@ //igno.add(oneConcept.replaceAll("\"", "")); - List<String> conceptresults= ls.learnDBpediaSKOS(posExamples, negExamples, url,new TreeSet<String>(),recursiondepth, closeAfterRecursion,randomizeCache,resultsize,noise); + List<Description> conceptresults= ls.learnDBpediaSKOS(posExamples, negExamples, url,new TreeSet<String>(),recursiondepth, closeAfterRecursion,randomizeCache,resultsize,noise); System.out.println("concepts"+conceptresults); //System.exit(0); logger.debug("found nr of concepts:"+conceptresults.size()); SortedSet<ResultCompare> res=new TreeSet<ResultCompare>(); - for (String oneConcept : conceptresults) { + for (Description oneConcept : conceptresults) { try{ System.out.println("oneconcept: "+oneConcept); - SortedSet<String> instances = ae.queryConceptAsStringSet(conceptRewrite(oneConcept), 200); + SortedSet<String> instances = ae.queryConceptAsStringSet(conceptRewrite(oneConcept.toKBSyntaxString()), 200); SortedSet<String> coveredInRest = new TreeSet<String>(); SortedSet<String> possibleNewCandidates = new TreeSet<String>(); SortedSet<String> notCoveredInTotal = new TreeSet<String>(); @@ -243,7 +243,7 @@ double accuracy= (double)i/rest.size(); double accuracy2= (double)a/totalSKOSset.size(); - logger.debug((new ResultCompare(oneConcept,instances,accuracy,accuracy2,instances.size(), + logger.debug((new ResultCompare(oneConcept.toKBSyntaxString(),instances,accuracy,accuracy2,instances.size(), coveredInRest,possibleNewCandidates,notCoveredInTotal)).toStringFull()); //if(instances.size()>=0)System.out.println("size of instances "+instances.size()); Modified: trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java 2008-05-19 13:11:24 UTC (rev 901) +++ trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java 2008-05-19 14:03:09 UTC (rev 902) @@ -1,6 +1,7 @@ package org.dllearner.utilities.learn; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.SortedSet; @@ -13,6 +14,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.Description; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegLP; @@ -114,7 +116,7 @@ //System.out.println( la.getBestSolution());; } - public List<String> learnDBpediaSKOS(SortedSet<String> posExamples,SortedSet<String> negExamples, + public List<Description> learnDBpediaSKOS(SortedSet<String> posExamples,SortedSet<String> negExamples, String uri, SortedSet<String> ignoredConcepts, int recursiondepth, boolean closeAfterRecursion, boolean randomizeCache, int resultsize, double noise){ @@ -193,7 +195,9 @@ sc.setTime(); la.start(); Statistics.addTimeLearning(sc.getTime()); - return la.getBestSolutionsAsKBSyntax(resultsize); + return la.getBestSolutions(resultsize); + + //if(sc.getTime()/1000 >= 20)System.out.println("XXXMAX time reached"); //System.out.println("best"+la(20)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-05-19 13:11:36
|
Revision: 901 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=901&view=rev Author: jenslehmann Date: 2008-05-19 06:11:24 -0700 (Mon, 19 May 2008) Log Message: ----------- small fixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/package.html Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/utilities/statistics/PaperStatistics.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/package.html 2008-05-19 12:57:31 UTC (rev 900) +++ trunk/src/dl-learner/org/dllearner/core/owl/package.html 2008-05-19 13:11:24 UTC (rev 901) @@ -3,7 +3,7 @@ <head></head> <body bgcolor="white"> <p>Classes/Interfaces for representing OWL constructs - see -the <a href="http://www.w3.org/TR/owl11-syntax">OWL 1.1 Structural +the <a href="http://www.w3.org/TR/owl2-syntax/">OWL 2 Structural Specification</a> for details.</p> </body> </html> \ No newline at end of file Copied: trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java (from rev 899, trunk/src/dl-learner/org/dllearner/utilities/statistics/PaperStatistics.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java 2008-05-19 13:11:24 UTC (rev 901) @@ -0,0 +1,525 @@ +/** + * Copyright (C) 2007, 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.scripts; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; + +import org.dllearner.algorithms.gp.GP; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.OntologyFormat; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.Score; +import org.dllearner.kb.OWLFile; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.parser.ConfParser; +import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.utilities.Files; +import org.dllearner.utilities.Helper; +import org.dllearner.utilities.statistics.Stat; + +/** + * Utility script for creating statistics for publications. + * (Warning: Scripts may run for several hours. Results may change + * when core algorithms are modified.) + * + * @author Jens Lehmann + * + */ +public class PaperStatistics { + + /** + * Points to the current statistic generation function. + * + * @param args None. + */ + public static void main(String[] args) { + createStatistics(); + } + + @SuppressWarnings("unused") + private static void createStatistics() { + + // experimental setup: + + // algorithms: refinement, GP, hybrid GP (YinYang) + // settings GP: + // - average over 10 runs + // ... + // settings Hybrid GP: + // - average over 10 runs + // ... + // settings refinement: + // - single run + // ... + + // observations: + // - correctness + // - concept length + // - runtime + + // learning examples: + // - trains + // - arches + // - moral (simple) + // - moral (complex) + // - poker (pair) + // - poker (straight) + // - uncle (FORTE) + // - more? + + String exampleBaseDir = "examples/"; + String gnuplotBaseDir = "log/gnuplot/"; + String statBaseDir = "log/stat/"; + + File[] confFiles = new File[7]; + confFiles[0] = new File(exampleBaseDir + "trains", "trains_owl.conf"); + confFiles[1] = new File(exampleBaseDir + "arch", "arch_owl.conf"); + confFiles[2] = new File(exampleBaseDir + "moral_reasoner", "moral_43examples_owl.conf"); + confFiles[3] = new File(exampleBaseDir + "moral_reasoner", "moral_43examples_complex_owl.conf"); + confFiles[4] = new File(exampleBaseDir + "poker", "pair_owl.conf"); + confFiles[5] = new File(exampleBaseDir + "poker", "straight_owl.conf"); + confFiles[6] = new File(exampleBaseDir + "forte", "forte_uncle_owl.conf"); + + String[] examples = new String[7]; + examples[0] = "trains"; + examples[1] = "arches"; + examples[2] = "moral reasoner (43 examples, simple)"; + examples[3] = "moral reasoner (43 examples, complex)"; + examples[4] = "poker (49 examples, pair)"; + examples[5] = "poker (55 examples, straight)"; + examples[6] = "uncle (FORTE data set)"; + int startExampleNr = 0; + + String[] algorithms = new String[3]; + algorithms[0] = "refinement"; + algorithms[1] = "gp"; + algorithms[2] = "hybrid"; + + int[] algorithmRuns = {1,10,10}; + int startAlgorithmNr = 0; + + // Config.GP.maxConceptLength = 30; + // Config.writeDIGProtocol = true; + // Config.digProtocolFile = new File(statBaseDir, "dig.log"); + + // do not plot anything + // File[][][] gnuplotFiles = new File[examples.length][algorithms.length][3]; + // for(int i=0; i<examples.length; i++) { + // for(int j=0; j<algorithms.length; j++) { + // gnuplotFiles[i][j][0] = new File(gnuplotBaseDir, examples[i] + "_classification_" + algorithms[j] + ".data"); + // gnuplotFiles[i][j][1] = new File(gnuplotBaseDir, examples[i] + "_length_" + algorithms[j] + ".data"); + // gnuplotFiles[i][j][2] = new File(gnuplotBaseDir, examples[i] + "_runtime_" + algorithms[j] + ".data"); + // } + //} + + File statFile = new File(statBaseDir, "statistics.txt"); + File statDetailsFile = new File(statBaseDir, "statistics_details.txt"); + String statString = "**automatically generated statistics**\n\n"; + String statDetailsString = statString; + + ComponentManager cm = ComponentManager.getInstance(); + + // just set default options +// ConfigurationManager confMgr = new ConfigurationManager(); +// confMgr.applyOptions(); + + for(int exampleNr=startExampleNr; exampleNr < examples.length; exampleNr++) { + + // parse current conf file + ConfParser learner = ConfParser.parseFile(confFiles[exampleNr]); + + String baseDir = confFiles[exampleNr].getParent(); + + // read which files were imported (internal KB is ignored) and initialise reasoner + Map<URL, OntologyFormat> imports = getImports(learner.getFunctionCalls(), confFiles[exampleNr]); + //Map<URL, Class<? extends KnowledgeSource>> imports = Start.getImportedFiles(learner, baseDir); + + // detect specified positive and negative examples + SortedSet<String> positiveExamples = learner.getPositiveExamples(); + SortedSet<String> negativeExamples = learner.getNegativeExamples(); + int nrOfExamples = positiveExamples.size() + negativeExamples.size(); + + statString += "example: " + examples[exampleNr] + "\n\n"; + + for(int algorithmNr=startAlgorithmNr; algorithmNr < algorithms.length; algorithmNr++) { + // reset algorithm number (next example starts with first algorithm) + startAlgorithmNr = 0; + + Stat classification = new Stat(); + Stat length = new Stat(); + Stat runtime = new Stat(); + + for(int runNr=0; runNr < algorithmRuns[algorithmNr]; runNr++) { + + // create reasoner (this has to be done in this inner loop to + // ensure that none of the algorithm benefits from e.g. caching + // of previous reasoning requests + // Reasoner reasoner = Main.createReasoner(new KB(), imports); + // TODO: needs fixing + KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + ReasonerComponent reasoner = cm.reasoner(DIGReasoner.class, ks); + ReasoningService rs = new ReasoningService(reasoner); + + // System.out.println(positiveExamples); + // System.out.println(negativeExamples); + // System.exit(0); + + // create learning problem + // LearningProblem learningProblem = new LearningProblem(rs, positiveExamples, negativeExamples); + LearningProblem learningProblem = cm.learningProblem(PosNegDefinitionLP.class, rs); + + // prepare reasoner for using subsumption and role hierarchy + // TODO: currently, it is a small unfairness that each algorithm + // uses the same reasoning object (e.g. the second algorithm may + // have a small advantage if the reasoner cached reasoning requests + // of the first algorithm) +// Helper.autoDetectConceptsAndRoles(rs); +// try { +// reasoner.prepareSubsumptionHierarchy(); +// reasoner.prepareRoleHierarchy(); +// // improving the subsumption hierarchy makes only sense +// // for the refinement based algorithm +// if(algorithmNr==0) +// reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); +// } catch (ReasoningMethodUnsupportedException e) { +// e.printStackTrace(); +// } + + LearningAlgorithm learningAlgorithm = null; + if(algorithmNr==0) { + // Config.algorithm = Algorithm.REFINEMENT; + // Config.Refinement.heuristic = Config.Refinement.Heuristic.FLEXIBLE; +// Config.Refinement.horizontalExpansionFactor = 0.6; +// Config.Refinement.quiet = true; + // Config.percentPerLengthUnit = 0.05; + // learningAlgorithm = new ROLearner(learningProblem); + // learningAlgorithm = cm.learningAlgorithm(ROLearner.class, learningProblem); + } else if(algorithmNr==1) { + // Config.algorithm = Algorithm.GP; +// Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; +//// Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; +// Config.GP.generations = 50; +// Config.GP.useFixedNumberOfGenerations = true; +// Config.GP.numberOfIndividuals = 201; + // if(exampleNr == 3 || exampleNr == 4) + // Config.GP.numberOfIndividuals = 51; +// Config.GP.refinementProbability = 0; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.8; +// Config.GP.hillClimbingProbability = 0; + // Config.percentPerLengthUnit = 0.005; + // give GP a chance to find the long solution of the + // uncle problem + // if(exampleNr==3 || exampleNr==5 || exampleNr == 6) + // Config.percentPerLengthUnit = 0.002; + // learningAlgorithm = new GP(learningProblem); + try { + learningAlgorithm = cm.learningAlgorithm(GP.class, learningProblem, rs); + } catch (LearningProblemUnsupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else if(algorithmNr==2) { + // Config.algorithm = Algorithm.HYBRID_GP; +// Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; +// Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; +// Config.GP.generations = 50; +// Config.GP.useFixedNumberOfGenerations = true; +// Config.GP.numberOfIndividuals = 201; + //if(exampleNr == 3 || exampleNr == 4) + // Config.GP.numberOfIndividuals = 51; +// Config.GP.refinementProbability = 0.65; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.2; +// Config.GP.hillClimbingProbability = 0; + // Config.percentPerLengthUnit = 0.005; + // if(exampleNr == 3 || exampleNr==5 || exampleNr==6) +// Config.percentPerLengthUnit = 0.002; + // learningAlgorithm = new GP(learningProblem); + try { + learningAlgorithm = cm.learningAlgorithm(GP.class, learningProblem, rs); + } catch (LearningProblemUnsupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + // rs.resetStatistics(); + + long algorithmStartTime = System.nanoTime(); + learningAlgorithm.start(); + long algorithmTime = System.nanoTime() - algorithmStartTime; + // long algorithmTimeSeconds = algorithmTime / 1000000000; + + int conceptLength = learningAlgorithm.getBestSolution().getLength(); + Score bestScore = learningAlgorithm.getSolutionScore(); + int misClassifications = bestScore.getCoveredNegatives().size() + + bestScore.getNotCoveredPositives().size(); + double classificationRatePercent = 100 * ((nrOfExamples - misClassifications) / (double) nrOfExamples); + + classification.addNumber(classificationRatePercent); + length.addNumber(conceptLength); + runtime.addNumber(algorithmTime); + + // free knowledge base to avoid memory leaks + ((DIGReasoner) reasoner).releaseKB(); + + statDetailsString += "example: " + examples[exampleNr] + "\n"; + statDetailsString += "algorithm: " + algorithms[algorithmNr] + "\n"; + statDetailsString += "learned concept: " + learningAlgorithm.getBestSolution() + "\n"; + statDetailsString += "classification: " + classificationRatePercent + "%\n"; + statDetailsString += "concept length: " + conceptLength + "\n"; + statDetailsString += "runtime: " + Helper.prettyPrintNanoSeconds(algorithmTime) + "\n\n"; + + Files.createFile(statDetailsFile, statDetailsString); + + } // end run loop + + statString += "algorithm: " + algorithms[algorithmNr] + " (runs: " + algorithmRuns[algorithmNr] + ")\n"; + statString += "classification: " + classification.getMean() + "% (standard deviation: " + classification.getStandardDeviation() + "%)\n"; + statString += "concept length: " + length.getMean() + " (standard deviation: " + length.getStandardDeviation() + ")\n"; + statString += "runtime: " + Helper.prettyPrintNanoSeconds(Math.round(runtime.getMean())) + " (standard deviation: " + Helper.prettyPrintNanoSeconds(Math.round(runtime.getStandardDeviation())) + ")\n\n"; + + Files.createFile(statFile, statString); + + } // end algorithm loop + + } // end example loop + + } + + private static Map<URL, OntologyFormat> getImports(Map<String,List<List<String>>> functionCalls, File confFile) { + Map<URL, OntologyFormat> importedFiles = new HashMap<URL, OntologyFormat>(); + + OntologyFormat format = null; + URL url = null; + + List<List<String>> imports = functionCalls.get("import"); + + for (List<String> call : imports) { + + //if(call.get(0).equals("import")) { + + try { + String fileString = call.get(1); + if(fileString.startsWith("http:")) { + url = new URL(fileString); + } else { + File f = new File(confFile.getParent(), call.get(1)); + url = f.toURI().toURL(); + } + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if (call.size() == 2) + // falls nichts angegeben, dann wird RDF/XML gewählt + importedFiles.put(url, OntologyFormat.RDF_XML); + else { + String formatString = call.get(2); + if (formatString.equals("RDF/XML")) + format = OntologyFormat.RDF_XML; + else + format = OntologyFormat.N_TRIPLES; + importedFiles.put(url, format); + } + // } + } + + return importedFiles; + } + + // erzeugt Statistiken für MLDM-Paper zur Verarbeitung mit GnuPlot + // Vorsicht: Laufzeit von mehreren Stunden + + /** + * Has been used to create the statistics for the MLDM 2007 paper. + * Warning: this method runs for several hours + * + * @todo: This method has not been fully adapted to the base structure + * changes. To reproduce the results, the method has to be implemented + * properly. + */ + @SuppressWarnings("unused") + public static void createStatisticsMLDMPaper(PosNegDefinitionLP learningProblem, String baseDir) { + // Algorithmus 1: hybrid GP (100% refinement) + // Algorithmus 2: 50% refinement, 40% crossover, 1% mutation + // Algorithmus 3: 80% crossover, 2% mutation + + // Diagramm 1: Prozentzahl richtig klassifiziert + // Diagramm 2: Konzeptlänge + // Diagramm 3: Laufzeit + + int runs = 9; + GP gp; + long algorithmStartTime; + int nrOfExamples = learningProblem.getPositiveExamples().size() + + learningProblem.getNegativeExamples().size(); + + Stat[][] statAr = new Stat[4][3]; + File[][] fileAr = new File[4][3]; + StringBuilder[][] exportString = new StringBuilder[4][3]; + // initialise export strings + for (int j = 0; j < 4; j++) { + for (int k = 0; k < 3; k++) { + exportString[j][k] = new StringBuilder(); + } + } + + fileAr[0][0] = new File(baseDir, "gnuplot/hybrid100classification.data"); + fileAr[0][1] = new File(baseDir, "gnuplot/hybrid100length.data"); + fileAr[0][2] = new File(baseDir, "gnuplot/hybrid100runtime.data"); + fileAr[1][0] = new File(baseDir, "gnuplot/hybrid50classification.data"); + fileAr[1][1] = new File(baseDir, "gnuplot/hybrid50length.data"); + fileAr[1][2] = new File(baseDir, "gnuplot/hybrid50runtime.data"); + fileAr[2][0] = new File(baseDir, "gnuplot/gpclassification.data"); + fileAr[2][1] = new File(baseDir, "gnuplot/gplength.data"); + fileAr[2][2] = new File(baseDir, "gnuplot/gpruntime.data"); + + // Extra-Test + fileAr[3][0] = new File(baseDir, "gnuplot/extraclassification.data"); + fileAr[3][1] = new File(baseDir, "gnuplot/extralength.data"); + fileAr[3][2] = new File(baseDir, "gnuplot/extraruntime.data"); + + ComponentManager cm = ComponentManager.getInstance(); + + long overallTimeStart = System.nanoTime(); + + // allgemeine Einstellungen + // Config.GP.elitism = true; + + for (int i = 700; i <= 700; i += 100) { + // initialise statistics array + for (int j = 0; j < 4; j++) { + for (int k = 0; k < 3; k++) { + statAr[j][k] = new Stat(); + } + } + + for (int run = 0; run < runs; run++) { + System.out.println("============="); + System.out.println("i " + i + " run " + run); + System.out.println("============="); + + // nur ein Test durchlaufen + for (int j = 0; j < 3; j++) { + + // Reasoner neu erstellen um Speicherprobleme zu vermeiden + // reasoner = new DIGReasoner(kb, Config.digReasonerURL, importedFiles); + // TODO: set up knowledge source + KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + ReasonerComponent reasoner = cm.reasoner(DIGReasoner.class, ks); + // reasoner.prepareSubsumptionHierarchy(); + // rs = new ReasoningService(reasoner); + ReasoningService rs = cm.reasoningService(reasoner); + // learningProblem = new LearningProblem(rs, posExamples, negExamples); + learningProblem = cm.learningProblem(PosNegDefinitionLP.class, rs); + + // TODO: set up pos/neg examples + cm.applyConfigEntry(learningProblem, "positiveExamples", null); + cm.applyConfigEntry(learningProblem, "negativeExamples", null); + + if (j == 0) { + // Config.algorithm = Algorithm.HYBRID_GP; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0.85; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.05; +// Config.GP.hillClimbingProbability = 0; + } else if (j == 1) { + // Config.algorithm = Algorithm.HYBRID_GP; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0.4; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.4; +// Config.GP.hillClimbingProbability = 0; + } else if (j == 2) { + // Config.algorithm = Algorithm.GP; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.8; +// Config.GP.hillClimbingProbability = 0; + } else if (j == 3) { + // Config.algorithm = Algorithm.HYBRID_GP; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0.7; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.1; +// Config.GP.hillClimbingProbability = 0; + } + + algorithmStartTime = System.nanoTime(); +// gp = new GP(learningProblem); + long algorithmTime = System.nanoTime() - algorithmStartTime; + long algorithmTimeSeconds = algorithmTime / 1000000000; + + // Release, damit Pellet (hoffentlich) Speicher wieder + // freigibt + ((DIGReasoner) reasoner).releaseKB(); + +// int conceptLength = gp.getBestSolution().getLength(); +// Score bestScore = gp.getSolutionScore(); +// int misClassifications = bestScore.getCoveredNegatives().size() +// + bestScore.getNotCoveredPositives().size(); +// double classificationRatePercent = 100 * ((nrOfExamples - misClassifications) / (double) nrOfExamples); +// +// statAr[j][0].addNumber(classificationRatePercent); +// statAr[j][1].addNumber(conceptLength); +// statAr[j][2].addNumber(algorithmTimeSeconds); + + } + } + + for (int j = 0; j < 3; j++) { + for (int k = 0; k < 3; k++) { + exportString[j][k].append(i + " " + statAr[j][k].getMean() + " " + + statAr[j][k].getStandardDeviation() + "\n"); + } + } + + // Daten werden nach jeder Populationserhöhung geschrieben, nicht + // nur + // am Ende => man kann den Test also auch zwischendurch abbrechen + for (int j = 0; j < 3; j++) { + for (int k = 0; k < 3; k++) { + Files.createFile(fileAr[j][k], exportString[j][k].toString()); + } + } + } + + long overallTime = System.nanoTime() - overallTimeStart; + System.out.println("\noverall time: " + + Helper.prettyPrintNanoSeconds(overallTime)); + } + +} Deleted: trunk/src/dl-learner/org/dllearner/utilities/statistics/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/PaperStatistics.java 2008-05-19 12:57:31 UTC (rev 900) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/PaperStatistics.java 2008-05-19 13:11:24 UTC (rev 901) @@ -1,524 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.utilities.statistics; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedSet; - -import org.dllearner.algorithms.gp.GP; -import org.dllearner.core.ComponentManager; -import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.LearningProblem; -import org.dllearner.core.LearningProblemUnsupportedException; -import org.dllearner.core.OntologyFormat; -import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasoningService; -import org.dllearner.core.Score; -import org.dllearner.kb.OWLFile; -import org.dllearner.learningproblems.PosNegDefinitionLP; -import org.dllearner.parser.ConfParser; -import org.dllearner.reasoning.DIGReasoner; -import org.dllearner.utilities.Files; -import org.dllearner.utilities.Helper; - -/** - * Utility script for creating statistics for publications. - * (Warning: Scripts may run for several hours. Results may change - * when core algorithms are modified.) - * - * @author Jens Lehmann - * - */ -public class PaperStatistics { - - /** - * Points to the current statistic generation function. - * - * @param args None. - */ - public static void main(String[] args) { - createStatistics(); - } - - @SuppressWarnings("unused") - private static void createStatistics() { - - // experimental setup: - - // algorithms: refinement, GP, hybrid GP (YinYang) - // settings GP: - // - average over 10 runs - // ... - // settings Hybrid GP: - // - average over 10 runs - // ... - // settings refinement: - // - single run - // ... - - // observations: - // - correctness - // - concept length - // - runtime - - // learning examples: - // - trains - // - arches - // - moral (simple) - // - moral (complex) - // - poker (pair) - // - poker (straight) - // - uncle (FORTE) - // - more? - - String exampleBaseDir = "examples/"; - String gnuplotBaseDir = "log/gnuplot/"; - String statBaseDir = "log/stat/"; - - File[] confFiles = new File[7]; - confFiles[0] = new File(exampleBaseDir + "trains", "trains_owl.conf"); - confFiles[1] = new File(exampleBaseDir + "arch", "arch_owl.conf"); - confFiles[2] = new File(exampleBaseDir + "moral_reasoner", "moral_43examples_owl.conf"); - confFiles[3] = new File(exampleBaseDir + "moral_reasoner", "moral_43examples_complex_owl.conf"); - confFiles[4] = new File(exampleBaseDir + "poker", "pair_owl.conf"); - confFiles[5] = new File(exampleBaseDir + "poker", "straight_owl.conf"); - confFiles[6] = new File(exampleBaseDir + "forte", "forte_uncle_owl.conf"); - - String[] examples = new String[7]; - examples[0] = "trains"; - examples[1] = "arches"; - examples[2] = "moral reasoner (43 examples, simple)"; - examples[3] = "moral reasoner (43 examples, complex)"; - examples[4] = "poker (49 examples, pair)"; - examples[5] = "poker (55 examples, straight)"; - examples[6] = "uncle (FORTE data set)"; - int startExampleNr = 0; - - String[] algorithms = new String[3]; - algorithms[0] = "refinement"; - algorithms[1] = "gp"; - algorithms[2] = "hybrid"; - - int[] algorithmRuns = {1,10,10}; - int startAlgorithmNr = 0; - - // Config.GP.maxConceptLength = 30; - // Config.writeDIGProtocol = true; - // Config.digProtocolFile = new File(statBaseDir, "dig.log"); - - // do not plot anything - // File[][][] gnuplotFiles = new File[examples.length][algorithms.length][3]; - // for(int i=0; i<examples.length; i++) { - // for(int j=0; j<algorithms.length; j++) { - // gnuplotFiles[i][j][0] = new File(gnuplotBaseDir, examples[i] + "_classification_" + algorithms[j] + ".data"); - // gnuplotFiles[i][j][1] = new File(gnuplotBaseDir, examples[i] + "_length_" + algorithms[j] + ".data"); - // gnuplotFiles[i][j][2] = new File(gnuplotBaseDir, examples[i] + "_runtime_" + algorithms[j] + ".data"); - // } - //} - - File statFile = new File(statBaseDir, "statistics.txt"); - File statDetailsFile = new File(statBaseDir, "statistics_details.txt"); - String statString = "**automatically generated statistics**\n\n"; - String statDetailsString = statString; - - ComponentManager cm = ComponentManager.getInstance(); - - // just set default options -// ConfigurationManager confMgr = new ConfigurationManager(); -// confMgr.applyOptions(); - - for(int exampleNr=startExampleNr; exampleNr < examples.length; exampleNr++) { - - // parse current conf file - ConfParser learner = ConfParser.parseFile(confFiles[exampleNr]); - - String baseDir = confFiles[exampleNr].getParent(); - - // read which files were imported (internal KB is ignored) and initialise reasoner - Map<URL, OntologyFormat> imports = getImports(learner.getFunctionCalls(), confFiles[exampleNr]); - //Map<URL, Class<? extends KnowledgeSource>> imports = Start.getImportedFiles(learner, baseDir); - - // detect specified positive and negative examples - SortedSet<String> positiveExamples = learner.getPositiveExamples(); - SortedSet<String> negativeExamples = learner.getNegativeExamples(); - int nrOfExamples = positiveExamples.size() + negativeExamples.size(); - - statString += "example: " + examples[exampleNr] + "\n\n"; - - for(int algorithmNr=startAlgorithmNr; algorithmNr < algorithms.length; algorithmNr++) { - // reset algorithm number (next example starts with first algorithm) - startAlgorithmNr = 0; - - Stat classification = new Stat(); - Stat length = new Stat(); - Stat runtime = new Stat(); - - for(int runNr=0; runNr < algorithmRuns[algorithmNr]; runNr++) { - - // create reasoner (this has to be done in this inner loop to - // ensure that none of the algorithm benefits from e.g. caching - // of previous reasoning requests - // Reasoner reasoner = Main.createReasoner(new KB(), imports); - // TODO: needs fixing - KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); - ReasonerComponent reasoner = cm.reasoner(DIGReasoner.class, ks); - ReasoningService rs = new ReasoningService(reasoner); - - // System.out.println(positiveExamples); - // System.out.println(negativeExamples); - // System.exit(0); - - // create learning problem - // LearningProblem learningProblem = new LearningProblem(rs, positiveExamples, negativeExamples); - LearningProblem learningProblem = cm.learningProblem(PosNegDefinitionLP.class, rs); - - // prepare reasoner for using subsumption and role hierarchy - // TODO: currently, it is a small unfairness that each algorithm - // uses the same reasoning object (e.g. the second algorithm may - // have a small advantage if the reasoner cached reasoning requests - // of the first algorithm) -// Helper.autoDetectConceptsAndRoles(rs); -// try { -// reasoner.prepareSubsumptionHierarchy(); -// reasoner.prepareRoleHierarchy(); -// // improving the subsumption hierarchy makes only sense -// // for the refinement based algorithm -// if(algorithmNr==0) -// reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); -// } catch (ReasoningMethodUnsupportedException e) { -// e.printStackTrace(); -// } - - LearningAlgorithm learningAlgorithm = null; - if(algorithmNr==0) { - // Config.algorithm = Algorithm.REFINEMENT; - // Config.Refinement.heuristic = Config.Refinement.Heuristic.FLEXIBLE; -// Config.Refinement.horizontalExpansionFactor = 0.6; -// Config.Refinement.quiet = true; - // Config.percentPerLengthUnit = 0.05; - // learningAlgorithm = new ROLearner(learningProblem); - // learningAlgorithm = cm.learningAlgorithm(ROLearner.class, learningProblem); - } else if(algorithmNr==1) { - // Config.algorithm = Algorithm.GP; -// Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; -//// Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; -// Config.GP.generations = 50; -// Config.GP.useFixedNumberOfGenerations = true; -// Config.GP.numberOfIndividuals = 201; - // if(exampleNr == 3 || exampleNr == 4) - // Config.GP.numberOfIndividuals = 51; -// Config.GP.refinementProbability = 0; -// Config.GP.mutationProbability = 0.02; -// Config.GP.crossoverProbability = 0.8; -// Config.GP.hillClimbingProbability = 0; - // Config.percentPerLengthUnit = 0.005; - // give GP a chance to find the long solution of the - // uncle problem - // if(exampleNr==3 || exampleNr==5 || exampleNr == 6) - // Config.percentPerLengthUnit = 0.002; - // learningAlgorithm = new GP(learningProblem); - try { - learningAlgorithm = cm.learningAlgorithm(GP.class, learningProblem, rs); - } catch (LearningProblemUnsupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else if(algorithmNr==2) { - // Config.algorithm = Algorithm.HYBRID_GP; -// Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; -// Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; -// Config.GP.generations = 50; -// Config.GP.useFixedNumberOfGenerations = true; -// Config.GP.numberOfIndividuals = 201; - //if(exampleNr == 3 || exampleNr == 4) - // Config.GP.numberOfIndividuals = 51; -// Config.GP.refinementProbability = 0.65; -// Config.GP.mutationProbability = 0.02; -// Config.GP.crossoverProbability = 0.2; -// Config.GP.hillClimbingProbability = 0; - // Config.percentPerLengthUnit = 0.005; - // if(exampleNr == 3 || exampleNr==5 || exampleNr==6) -// Config.percentPerLengthUnit = 0.002; - // learningAlgorithm = new GP(learningProblem); - try { - learningAlgorithm = cm.learningAlgorithm(GP.class, learningProblem, rs); - } catch (LearningProblemUnsupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - // rs.resetStatistics(); - - long algorithmStartTime = System.nanoTime(); - learningAlgorithm.start(); - long algorithmTime = System.nanoTime() - algorithmStartTime; - // long algorithmTimeSeconds = algorithmTime / 1000000000; - - int conceptLength = learningAlgorithm.getBestSolution().getLength(); - Score bestScore = learningAlgorithm.getSolutionScore(); - int misClassifications = bestScore.getCoveredNegatives().size() - + bestScore.getNotCoveredPositives().size(); - double classificationRatePercent = 100 * ((nrOfExamples - misClassifications) / (double) nrOfExamples); - - classification.addNumber(classificationRatePercent); - length.addNumber(conceptLength); - runtime.addNumber(algorithmTime); - - // free knowledge base to avoid memory leaks - ((DIGReasoner) reasoner).releaseKB(); - - statDetailsString += "example: " + examples[exampleNr] + "\n"; - statDetailsString += "algorithm: " + algorithms[algorithmNr] + "\n"; - statDetailsString += "learned concept: " + learningAlgorithm.getBestSolution() + "\n"; - statDetailsString += "classification: " + classificationRatePercent + "%\n"; - statDetailsString += "concept length: " + conceptLength + "\n"; - statDetailsString += "runtime: " + Helper.prettyPrintNanoSeconds(algorithmTime) + "\n\n"; - - Files.createFile(statDetailsFile, statDetailsString); - - } // end run loop - - statString += "algorithm: " + algorithms[algorithmNr] + " (runs: " + algorithmRuns[algorithmNr] + ")\n"; - statString += "classification: " + classification.getMean() + "% (standard deviation: " + classification.getStandardDeviation() + "%)\n"; - statString += "concept length: " + length.getMean() + " (standard deviation: " + length.getStandardDeviation() + ")\n"; - statString += "runtime: " + Helper.prettyPrintNanoSeconds(Math.round(runtime.getMean())) + " (standard deviation: " + Helper.prettyPrintNanoSeconds(Math.round(runtime.getStandardDeviation())) + ")\n\n"; - - Files.createFile(statFile, statString); - - } // end algorithm loop - - } // end example loop - - } - - private static Map<URL, OntologyFormat> getImports(Map<String,List<List<String>>> functionCalls, File confFile) { - Map<URL, OntologyFormat> importedFiles = new HashMap<URL, OntologyFormat>(); - - OntologyFormat format = null; - URL url = null; - - List<List<String>> imports = functionCalls.get("import"); - - for (List<String> call : imports) { - - //if(call.get(0).equals("import")) { - - try { - String fileString = call.get(1); - if(fileString.startsWith("http:")) { - url = new URL(fileString); - } else { - File f = new File(confFile.getParent(), call.get(1)); - url = f.toURI().toURL(); - } - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - if (call.size() == 2) - // falls nichts angegeben, dann wird RDF/XML gewählt - importedFiles.put(url, OntologyFormat.RDF_XML); - else { - String formatString = call.get(2); - if (formatString.equals("RDF/XML")) - format = OntologyFormat.RDF_XML; - else - format = OntologyFormat.N_TRIPLES; - importedFiles.put(url, format); - } - // } - } - - return importedFiles; - } - - // erzeugt Statistiken für MLDM-Paper zur Verarbeitung mit GnuPlot - // Vorsicht: Laufzeit von mehreren Stunden - - /** - * Has been used to create the statistics for the MLDM 2007 paper. - * Warning: this method runs for several hours - * - * @todo: This method has not been fully adapted to the base structure - * changes. To reproduce the results, the method has to be implemented - * properly. - */ - @SuppressWarnings("unused") - public static void createStatisticsMLDMPaper(PosNegDefinitionLP learningProblem, String baseDir) { - // Algorithmus 1: hybrid GP (100% refinement) - // Algorithmus 2: 50% refinement, 40% crossover, 1% mutation - // Algorithmus 3: 80% crossover, 2% mutation - - // Diagramm 1: Prozentzahl richtig klassifiziert - // Diagramm 2: Konzeptlänge - // Diagramm 3: Laufzeit - - int runs = 9; - GP gp; - long algorithmStartTime; - int nrOfExamples = learningProblem.getPositiveExamples().size() - + learningProblem.getNegativeExamples().size(); - - Stat[][] statAr = new Stat[4][3]; - File[][] fileAr = new File[4][3]; - StringBuilder[][] exportString = new StringBuilder[4][3]; - // initialise export strings - for (int j = 0; j < 4; j++) { - for (int k = 0; k < 3; k++) { - exportString[j][k] = new StringBuilder(); - } - } - - fileAr[0][0] = new File(baseDir, "gnuplot/hybrid100classification.data"); - fileAr[0][1] = new File(baseDir, "gnuplot/hybrid100length.data"); - fileAr[0][2] = new File(baseDir, "gnuplot/hybrid100runtime.data"); - fileAr[1][0] = new File(baseDir, "gnuplot/hybrid50classification.data"); - fileAr[1][1] = new File(baseDir, "gnuplot/hybrid50length.data"); - fileAr[1][2] = new File(baseDir, "gnuplot/hybrid50runtime.data"); - fileAr[2][0] = new File(baseDir, "gnuplot/gpclassification.data"); - fileAr[2][1] = new File(baseDir, "gnuplot/gplength.data"); - fileAr[2][2] = new File(baseDir, "gnuplot/gpruntime.data"); - - // Extra-Test - fileAr[3][0] = new File(baseDir, "gnuplot/extraclassification.data"); - fileAr[3][1] = new File(baseDir, "gnuplot/extralength.data"); - fileAr[3][2] = new File(baseDir, "gnuplot/extraruntime.data"); - - ComponentManager cm = ComponentManager.getInstance(); - - long overallTimeStart = System.nanoTime(); - - // allgemeine Einstellungen - // Config.GP.elitism = true; - - for (int i = 700; i <= 700; i += 100) { - // initialise statistics array - for (int j = 0; j < 4; j++) { - for (int k = 0; k < 3; k++) { - statAr[j][k] = new Stat(); - } - } - - for (int run = 0; run < runs; run++) { - System.out.println("============="); - System.out.println("i " + i + " run " + run); - System.out.println("============="); - - // nur ein Test durchlaufen - for (int j = 0; j < 3; j++) { - - // Reasoner neu erstellen um Speicherprobleme zu vermeiden - // reasoner = new DIGReasoner(kb, Config.digReasonerURL, importedFiles); - // TODO: set up knowledge source - KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); - ReasonerComponent reasoner = cm.reasoner(DIGReasoner.class, ks); - // reasoner.prepareSubsumptionHierarchy(); - // rs = new ReasoningService(reasoner); - ReasoningService rs = cm.reasoningService(reasoner); - // learningProblem = new LearningProblem(rs, posExamples, negExamples); - learningProblem = cm.learningProblem(PosNegDefinitionLP.class, rs); - - // TODO: set up pos/neg examples - cm.applyConfigEntry(learningProblem, "positiveExamples", null); - cm.applyConfigEntry(learningProblem, "negativeExamples", null); - - if (j == 0) { - // Config.algorithm = Algorithm.HYBRID_GP; -// Config.GP.numberOfIndividuals = i + 1; -// Config.GP.refinementProbability = 0.85; -// Config.GP.mutationProbability = 0.02; -// Config.GP.crossoverProbability = 0.05; -// Config.GP.hillClimbingProbability = 0; - } else if (j == 1) { - // Config.algorithm = Algorithm.HYBRID_GP; -// Config.GP.numberOfIndividuals = i + 1; -// Config.GP.refinementProbability = 0.4; -// Config.GP.mutationProbability = 0.02; -// Config.GP.crossoverProbability = 0.4; -// Config.GP.hillClimbingProbability = 0; - } else if (j == 2) { - // Config.algorithm = Algorithm.GP; -// Config.GP.numberOfIndividuals = i + 1; -// Config.GP.refinementProbability = 0; -// Config.GP.mutationProbability = 0.02; -// Config.GP.crossoverProbability = 0.8; -// Config.GP.hillClimbingProbability = 0; - } else if (j == 3) { - // Config.algorithm = Algorithm.HYBRID_GP; -// Config.GP.numberOfIndividuals = i + 1; -// Config.GP.refinementProbability = 0.7; -// Config.GP.mutationProbability = 0.02; -// Config.GP.crossoverProbability = 0.1; -// Config.GP.hillClimbingProbability = 0; - } - - algorithmStartTime = System.nanoTime(); -// gp = new GP(learningProblem); - long algorithmTime = System.nanoTime() - algorithmStartTime; - long algorithmTimeSeconds = algorithmTime / 1000000000; - - // Release, damit Pellet (hoffentlich) Speicher wieder - // freigibt - ((DIGReasoner) reasoner).releaseKB(); - -// int conceptLength = gp.getBestSolution().getLength(); -// Score bestScore = gp.getSolutionScore(); -// int misClassifications = bestScore.getCoveredNegatives().size() -// + bestScore.getNotCoveredPositives().size(); -// double classificationRatePercent = 100 * ((nrOfExamples - misClassifications) / (double) nrOfExamples); -// -// statAr[j][0].addNumber(classificationRatePercent); -// statAr[j][1].addNumber(conceptLength); -// statAr[j][2].addNumber(algorithmTimeSeconds); - - } - } - - for (int j = 0; j < 3; j++) { - for (int k = 0; k < 3; k++) { - exportString[j][k].append(i + " " + statAr[j][k].getMean() + " " - + statAr[j][k].getStandardDeviation() + "\n"); - } - } - - // Daten werden nach jeder Populationserhöhung geschrieben, nicht - // nur - // am Ende => man kann den Test also auch zwischendurch abbrechen - for (int j = 0; j < 3; j++) { - for (int k = 0; k < 3; k++) { - Files.createFile(fileAr[j][k], exportString[j][k].toString()); - } - } - } - - long overallTime = System.nanoTime() - overallTimeStart; - System.out.println("\noverall time: " - + Helper.prettyPrintNanoSeconds(overallTime)); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-05-19 12:57:41
|
Revision: 900 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=900&view=rev Author: jenslehmann Date: 2008-05-19 05:57:31 -0700 (Mon, 19 May 2008) Log Message: ----------- moved some classes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/FlexibleHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/LexicographicHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/Node.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator2.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparatorStable.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderRolesSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderSKOSSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderSPARQL.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/TestValidation.java trunk/src/dl-learner/org/dllearner/utilities/Logging.java trunk/src/dl-learner/org/dllearner/utilities/datastructures/JenaResultSetConvenience.java trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptComparator.java trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java trunk/src/dl-learner/org/dllearner/utilities/owl/ManchesterOWLSyntaxParser.java trunk/src/dl-learner/org/dllearner/utilities/owl/RoleComparator.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java trunk/src/dl-learner/org/dllearner/utilities/ConceptTransformation.java trunk/src/dl-learner/org/dllearner/utilities/JenaResultSetConvenience.java trunk/src/dl-learner/org/dllearner/utilities/ManchesterOWLSyntaxParser.java trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Logging.java trunk/src/dl-learner/org/dllearner/utilities/statistics/TestValidation.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-05-19 12:57:31 UTC (rev 900) @@ -11,8 +11,8 @@ import org.dllearner.learningproblems.PosNegLP; import org.dllearner.refinementoperators.PsiDown; import org.dllearner.refinementoperators.PsiUp; -import org.dllearner.utilities.ConceptComparator; -import org.dllearner.utilities.ConceptTransformation; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.ConceptTransformation; public class Psi implements GeneticRefinementOperator { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-05-19 12:57:31 UTC (rev 900) @@ -27,7 +27,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-19 12:57:31 UTC (rev 900) @@ -44,10 +44,10 @@ import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.refinementoperators.RhoDRDown; -import org.dllearner.utilities.ConceptComparator; -import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.ConceptTransformation; /** * Implements the example based refinement operator learning Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/FlexibleHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/FlexibleHeuristic.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/FlexibleHeuristic.java 2008-05-19 12:57:31 UTC (rev 900) @@ -20,7 +20,7 @@ package org.dllearner.algorithms.refexamples; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * This heuristic compares two nodes by computing a score Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/LexicographicHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/LexicographicHeuristic.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/LexicographicHeuristic.java 2008-05-19 12:57:31 UTC (rev 900) @@ -20,7 +20,7 @@ package org.dllearner.algorithms.refexamples; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; public class LexicographicHeuristic implements ExampleBasedHeuristic { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-05-19 12:57:31 UTC (rev 900) @@ -24,7 +24,7 @@ import org.dllearner.core.owl.DatatypeSomeRestriction; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Thing; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * This heuristic combines the following criteria to assign a Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java 2008-05-19 12:57:31 UTC (rev 900) @@ -22,7 +22,7 @@ import java.util.Comparator; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * This comparator is stable, because it only takes covered examples, concept Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java 2008-05-19 12:57:31 UTC (rev 900) @@ -4,7 +4,7 @@ import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Description; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; public class SubsumptionComparator implements Comparator<Description> { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/Node.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/Node.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/Node.java 2008-05-19 12:57:31 UTC (rev 900) @@ -4,7 +4,7 @@ import java.util.TreeSet; import org.dllearner.core.owl.Description; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; public class Node { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator.java 2008-05-19 12:57:31 UTC (rev 900) @@ -1,6 +1,6 @@ package org.dllearner.algorithms.refinement; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; public class NodeComparator implements Heuristic { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator2.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator2.java 2008-05-19 12:57:31 UTC (rev 900) @@ -20,7 +20,7 @@ package org.dllearner.algorithms.refinement; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * This heuristic compares two nodes by computing a score Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparatorStable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparatorStable.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparatorStable.java 2008-05-19 12:57:31 UTC (rev 900) @@ -2,7 +2,7 @@ import java.util.Comparator; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * Der Comparator ist stable, weil er nur nach covered negatives, Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-05-19 12:57:31 UTC (rev 900) @@ -35,10 +35,10 @@ import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.refinementoperators.RhoDown; -import org.dllearner.utilities.ConceptComparator; -import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.ConceptTransformation; public class ROLearner extends LearningAlgorithm { Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-19 12:57:31 UTC (rev 900) @@ -83,11 +83,11 @@ import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.FastRetrievalReasoner; import org.dllearner.reasoning.OWLAPIReasoner; -import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.RoleComparator; import org.dllearner.utilities.datastructures.Datastructures; import org.dllearner.utilities.datastructures.StringTuple; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.RoleComparator; /** * Startup file for Command Line Interface. Modified: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java 2008-05-19 12:57:31 UTC (rev 900) @@ -26,7 +26,7 @@ import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * @author Jens Lehmann Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java 2008-05-19 12:57:31 UTC (rev 900) @@ -24,7 +24,7 @@ import java.util.TreeMap; import java.util.TreeSet; -import org.dllearner.utilities.RoleComparator; +import org.dllearner.utilities.owl.RoleComparator; /** * Represents a hierarchy of datatype properties. Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java 2008-05-19 12:57:31 UTC (rev 900) @@ -24,7 +24,7 @@ import java.util.TreeMap; import java.util.TreeSet; -import org.dllearner.utilities.RoleComparator; +import org.dllearner.utilities.owl.RoleComparator; /** * Represents a hierarchy of roles. Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-19 12:57:31 UTC (rev 900) @@ -24,7 +24,7 @@ import java.util.TreeMap; import java.util.TreeSet; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * Represents a subsumption hierarchy (ignoring equivalent concepts). Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java 2008-05-19 12:57:31 UTC (rev 900) @@ -27,9 +27,9 @@ import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.Union; -import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Helper; import org.dllearner.utilities.datastructures.SortedSetTuple; +import org.dllearner.utilities.owl.ConceptComparator; /** * Caches results of previous concept evaluation to speed up Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-05-19 12:57:31 UTC (rev 900) @@ -54,10 +54,10 @@ import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.core.owl.Thing; -import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.RoleComparator; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.RoleComparator; import org.kr.dl.dig.v1_1.Concepts; import org.kr.dl.dig.v1_1.Csynonyms; import org.kr.dl.dig.v1_1.IdType; Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-05-19 12:57:31 UTC (rev 900) @@ -59,8 +59,8 @@ import org.dllearner.core.owl.UntypedConstant; import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; -import org.dllearner.utilities.ConceptComparator; -import org.dllearner.utilities.RoleComparator; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.RoleComparator; import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.inference.OWLReasoner; import org.semanticweb.owl.inference.OWLReasonerException; Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java 2008-05-19 12:57:31 UTC (rev 900) @@ -28,7 +28,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.Union; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * Math operations related to refinement operators. Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java 2008-05-19 12:57:31 UTC (rev 900) @@ -21,7 +21,7 @@ import org.dllearner.core.owl.ObjectQuantorRestriction; import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; /** * Operatoren Psi-Down und Psi-Up müssen noch so umgeschrieben werden, dass sie Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java 2008-05-19 12:57:31 UTC (rev 900) @@ -21,7 +21,7 @@ import org.dllearner.core.owl.ObjectQuantorRestriction; import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.owl.ConceptComparator; public class PsiUp implements RefinementOperator { Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-05-19 12:57:31 UTC (rev 900) @@ -58,9 +58,9 @@ import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.Union; -import org.dllearner.utilities.ConceptComparator; -import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Helper; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.ConceptTransformation; /** * A downward refinement operator, which makes use of domains Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java 2008-05-19 12:57:31 UTC (rev 900) @@ -46,8 +46,8 @@ import org.dllearner.core.owl.ObjectQuantorRestriction; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.ValueRestriction; -import org.dllearner.utilities.ConceptComparator; -import org.dllearner.utilities.ConceptTransformation; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.ConceptTransformation; /** * Implementation of the downward refinement operator in the DL-Learner refinement Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-19 12:57:31 UTC (rev 900) @@ -17,7 +17,7 @@ import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.utilities.JenaResultSetConvenience; +import org.dllearner.utilities.datastructures.JenaResultSetConvenience; import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.examples.AutomaticExampleFinderSKOSSPARQL; import org.dllearner.utilities.learn.LearnSparql; Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-19 12:57:31 UTC (rev 900) @@ -14,7 +14,7 @@ import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.utilities.JenaResultSetConvenience; +import org.dllearner.utilities.datastructures.JenaResultSetConvenience; import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.examples.AutomaticExampleFinderSPARQL; import org.dllearner.utilities.learn.LearnSparql; Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-05-19 12:57:31 UTC (rev 900) @@ -13,7 +13,7 @@ import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.utilities.JenaResultSetConvenience; +import org.dllearner.utilities.datastructures.JenaResultSetConvenience; import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.examples.AutomaticExampleFinderRolesSPARQL; import org.dllearner.utilities.examples.AutomaticExampleFinderSPARQL; Copied: trunk/src/dl-learner/org/dllearner/scripts/TestValidation.java (from rev 899, trunk/src/dl-learner/org/dllearner/utilities/statistics/TestValidation.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/TestValidation.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/TestValidation.java 2008-05-19 12:57:31 UTC (rev 900) @@ -0,0 +1,75 @@ +/** + * 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.scripts; + +import java.io.File; +import java.util.Set; + +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; +import org.dllearner.cli.Start; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.Score; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; + +/** + * @author Jens Lehmann + * + */ +public class TestValidation { + + private static Logger logger = Logger.getRootLogger(); + + public static void main(String args[]) throws ComponentInitException { + + // create logger (a simple logger which outputs + // its messages to the console) + SimpleLayout layout = new SimpleLayout(); + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + logger.removeAllAppenders(); + logger.addAppender(consoleAppender); + logger.setLevel(Level.DEBUG); + + String filenameTrain = args[0]; + String filenameTest = args[1]; + + Start start = new Start(new File(filenameTrain)); + start.start(false); + Description solution = start.getLearningAlgorithm().getBestSolution(); + + logger.setLevel(Level.WARN); + + Start startTest = new Start(new File(filenameTest)); + ReasoningService rs = startTest.getReasoningService(); + LearningProblem lp = startTest.getLearningProblem(); + + Set<Individual> result = rs.retrieval(solution); + System.out.println("retrieval result: " + result); + + Score score = lp.computeScore(solution); + System.out.println(score); + } + +} Modified: trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java 2008-05-19 12:57:31 UTC (rev 900) @@ -12,7 +12,7 @@ import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.utilities.JenaResultSetConvenience; +import org.dllearner.utilities.datastructures.JenaResultSetConvenience; import org.dllearner.utilities.statistics.SimpleClock; import com.hp.hpl.jena.query.ResultSet; Deleted: trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java 2008-05-19 12:57:31 UTC (rev 900) @@ -1,273 +0,0 @@ -package org.dllearner.utilities; - -import java.util.Comparator; -import java.util.Set; - -import org.dllearner.core.owl.BooleanValueRestriction; -import org.dllearner.core.owl.DatatypeProperty; -import org.dllearner.core.owl.DatatypeSomeRestriction; -import org.dllearner.core.owl.DoubleMaxValue; -import org.dllearner.core.owl.DoubleMinValue; -import org.dllearner.core.owl.ObjectAllRestriction; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.Nothing; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.ObjectCardinalityRestriction; -import org.dllearner.core.owl.ObjectMaxCardinalityRestriction; -import org.dllearner.core.owl.ObjectMinCardinalityRestriction; -import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.SimpleDoubleDataRange; -import org.dllearner.core.owl.Union; -import org.dllearner.core.owl.Negation; -import org.dllearner.core.owl.ObjectQuantorRestriction; -import org.dllearner.core.owl.Thing; - -// Comparator ist momentan inkonsistent mit equals für Konzepte, d.h. es kann sein, dass -// zwei Konzepte nicht als gleich deklariert werden (momentan gelten Konzepte immer als -// unterschiedlich, wenn sie nicht das gleiche Objekt im Speicher sind), aber in der -// compare-Funktion trotzdem 0 zurückgegeben wird -public class ConceptComparator implements Comparator<Description> { - - RoleComparator rc = new RoleComparator(); - - // private List<AtomicConcept> atomicConcepts = new LinkedList<AtomicConcept>(); - - public ConceptComparator() { - - } - - // Liste von atomaren Konzepten wird übergeben, damit eine Ordnung - // auf atomaren Konzepten festgelegt werden kann; also keine Stringvergleiche - // auf diesen Konzepten notwendig sind - // TODO: erstmal nur mit Stringvergleichen, da diese bei atomaren Konzepten - // schnell sein könnten, und dann testen, ob vorgegebene Ordnung Geschwindigkeitsvorteile - // bringt - public ConceptComparator(Set<NamedClass> atomicConcepts) { - - } - - // es werden Annahmen über Konzepte gemacht: - // 1. bestehen aus Top, Bottom, AtomicConcept, Negation, MultiConjunction, MultiDisjunction, - // Exists, All - // 2. MultiConjunction und MultiDisjunction haben min. 2 Kinder - // - // beachte: z.B. (male AND female) und (female AND male) sind ungleich; sie sind aber - // gleich, wenn sie vorher in ordered negation normal form umgewandelt worden, da - // dadurch die Anordnung der Kinder festgelegt wird - // 1: Konzept 1 ist größer - // - // Ordnung für atomare Konzepte: Stringvergleich - // Ordnung für atomare Rollen: Stringvergleich - public int compare(Description concept1, Description concept2) { - // classes higher up are in the source code have lower value - // (they appear first in class descriptions, because sorted sets - // usually use an ascending order) - if(concept1 instanceof Nothing) { - if(concept2 instanceof Nothing) - return 0; - else - return -1; - } else if(concept1 instanceof NamedClass) { - if(concept2 instanceof Nothing) - return 1; - else if(concept2 instanceof NamedClass) - return ((NamedClass)concept1).getName().compareTo(((NamedClass)concept2).getName()); - else - return -1; - } else if(concept1 instanceof BooleanValueRestriction) { - if(concept2 instanceof Nothing || concept2 instanceof NamedClass) { - return 1; - } else if(concept2 instanceof BooleanValueRestriction) { - // first criterion: name of the properties - int cmp = rc.compare(((BooleanValueRestriction)concept1).getRestrictedPropertyExpresssion(), ((BooleanValueRestriction)concept2).getRestrictedPropertyExpresssion()); - - // second criterion: value of the properties (it should rarely happen that - // both boolean values are present since this is a contradiction or superfluous) - if(cmp == 0) { - boolean val1 = ((BooleanValueRestriction)concept1).getBooleanValue(); - boolean val2 = ((BooleanValueRestriction)concept2).getBooleanValue(); - if(val1) { - if(val2) - return 0; - else - return 1; - } else { - if(val2) - return -1; - else - return 0; - } - } else - return cmp; - } else - return -1; - } else if(concept1 instanceof DatatypeSomeRestriction) { - if(concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction) { - return 1; - } else if(concept2 instanceof DatatypeSomeRestriction) { - DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) concept1; - DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); - DatatypeSomeRestriction dsr2 = (DatatypeSomeRestriction) concept2; - DatatypeProperty dp2 = (DatatypeProperty) dsr2.getRestrictedPropertyExpression(); - - // first criterion: name of the properties - int cmp = rc.compare(dp, dp2); - - if(cmp == 0) { - SimpleDoubleDataRange dr = (SimpleDoubleDataRange) dsr.getDataRange(); - SimpleDoubleDataRange dr2 = (SimpleDoubleDataRange) dsr2.getDataRange(); - - // equal classes - if((dr instanceof DoubleMaxValue && dr2 instanceof DoubleMaxValue) - || (dr instanceof DoubleMinValue && dr2 instanceof DoubleMinValue)) { - double val1 = dr.getValue(); - double val2 = dr2.getValue(); - if(val1 > val2) - return 1; - else if(val1 == val2) - return 0; - else - return -1; - - } else if(dr instanceof DoubleMaxValue) - return 1; - else - return -1; - } else - return cmp; - } else - return -1; - } else if(concept1 instanceof Thing) { - if(concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction || concept2 instanceof DatatypeSomeRestriction) - return 1; - else if(concept2 instanceof Thing) - return 0; - else - return -1; - } else if(concept1 instanceof Negation) { - if(concept2.getChildren().size()<1) - return 1; - else if(concept2 instanceof Negation) - return compare(concept1.getChild(0), concept2.getChild(0)); - else - return -1; - } else if(concept1 instanceof ObjectSomeRestriction) { - if(concept2.getChildren().size()<1 || concept2 instanceof Negation) - return 1; - else if(concept2 instanceof ObjectSomeRestriction) { - int roleCompare = rc.compare(((ObjectQuantorRestriction)concept1).getRole(), ((ObjectQuantorRestriction)concept2).getRole()); - if(roleCompare == 0) - return compare(concept1.getChild(0), concept2.getChild(0)); - else - return roleCompare; - } - else - return -1; - } else if(concept1 instanceof ObjectAllRestriction) { - if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectSomeRestriction) - return 1; - else if(concept2 instanceof ObjectAllRestriction) { - int roleCompare = rc.compare(((ObjectQuantorRestriction)concept1).getRole(), ((ObjectQuantorRestriction)concept2).getRole()); - if(roleCompare == 0) - return compare(concept1.getChild(0), concept2.getChild(0)); - else - return roleCompare; - } else - return -1; - } else if(concept1 instanceof ObjectMinCardinalityRestriction) { - if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction) - return 1; - // first criterion: object property - // second criterion: number - // third criterion: children - else if(concept2 instanceof ObjectMinCardinalityRestriction) { - int roleCompare = rc.compare(((ObjectCardinalityRestriction)concept1).getRole(), ((ObjectCardinalityRestriction)concept2).getRole()); - if(roleCompare == 0) { - Integer number1 = ((ObjectCardinalityRestriction)concept1).getNumber(); - Integer number2 = ((ObjectCardinalityRestriction)concept2).getNumber(); - int numberCompare = number1.compareTo(number2); - if(numberCompare == 0) - return compare(concept1.getChild(0), concept2.getChild(0)); - else - return numberCompare; - } else - return roleCompare; - } else - return -1; - } else if(concept1 instanceof ObjectMaxCardinalityRestriction) { - if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction || concept2 instanceof ObjectMinCardinalityRestriction) - return 1; - // first criterion: object property - // second criterion: number - // third criterion: children - else if(concept2 instanceof ObjectMaxCardinalityRestriction) { - int roleCompare = rc.compare(((ObjectCardinalityRestriction)concept1).getRole(), ((ObjectCardinalityRestriction)concept2).getRole()); - if(roleCompare == 0) { - Integer number1 = ((ObjectCardinalityRestriction)concept1).getNumber(); - Integer number2 = ((ObjectCardinalityRestriction)concept2).getNumber(); - int numberCompare = number1.compareTo(number2); - if(numberCompare == 0) - return compare(concept1.getChild(0), concept2.getChild(0)); - else - return numberCompare; - } else - return roleCompare; - } else - return -1; - } else if(concept1 instanceof Intersection) { - if(concept2.getChildren().size()<2) - return 1; - else if(concept2 instanceof Intersection) { - int nrOfChildrenConcept1 = concept1.getChildren().size(); - int nrOfChildrenConcept2 = concept2.getChildren().size(); - - if(nrOfChildrenConcept1>nrOfChildrenConcept2) - return 1; - else if(nrOfChildrenConcept1==nrOfChildrenConcept2) { - for(int i=0; i<nrOfChildrenConcept1; i++) { - int compareValue = compare(concept1.getChild(i),concept2.getChild(i)); - if(compareValue>0) - return 1; - else if(compareValue<0) - return -1; - } - return 0; - } else - return -1; - } else - return -1; - } else if(concept1 instanceof Union) { - if(concept2.getChildren().size()<2 || concept2 instanceof Intersection) - return 1; - else if(concept2 instanceof Union) { - int nrOfChildrenConcept1 = concept1.getChildren().size(); - int nrOfChildrenConcept2 = concept2.getChildren().size(); - - if(nrOfChildrenConcept1>nrOfChildrenConcept2) - return 1; - else if(nrOfChildrenConcept1==nrOfChildrenConcept2) { - for(int i=0; i<nrOfChildrenConcept1; i++) { - int compareValue = compare(concept1.getChild(i),concept2.getChild(i)); - if(compareValue>0) - return 1; - else if(compareValue<0) - return -1; - } - return 0; - } else - return -1; - } else - return -1; - } else - throw new RuntimeException(concept1.toString()); - } - - // TODO: Vergleich zwischen ConceptComparators: immer identisch - // (testen, ob das bessere Performance bringt) - @Override - public boolean equals(Object o) { - return (o instanceof ConceptComparator); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/utilities/ConceptTransformation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/ConceptTransformation.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/utilities/ConceptTransformation.java 2008-05-19 12:57:31 UTC (rev 900) @@ -1,389 +0,0 @@ -package org.dllearner.utilities; - -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.core.owl.ObjectAllRestriction; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.Nothing; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.Union; -import org.dllearner.core.owl.Negation; -import org.dllearner.core.owl.ObjectPropertyExpression; -import org.dllearner.core.owl.ObjectQuantorRestriction; -import org.dllearner.core.owl.Thing; - -// ev. kann man diese Klasse später in ein anderes Paket ziehen, da sie nicht direkt mit -// refinement zu tun hat -public class ConceptTransformation { - - public static long cleaningTimeNs = 0; - private static long cleaningTimeNsStart = 0; - public static long onnfTimeNs = 0; - private static long onnfTimeNsStart = 0; - public static long shorteningTimeNs = 0; - private static long shorteningTimeNsStart = 0; - - public static void cleanConceptNonRecursive(Description concept) { - // cleaningTimeNsStart = System.nanoTime(); - - if(concept instanceof Intersection || concept instanceof Union) { - - List<Description> deleteChilds = new LinkedList<Description>(); - - for(Description child : concept.getChildren()) { - if((concept instanceof Intersection && child instanceof Intersection) - || (concept instanceof Union && child instanceof Union)) { - deleteChilds.add(child); - } - } - - for(Description dc : deleteChilds) { - // alle Kinder des zu löschenden Konzeptes hinzufügen - for(Description dcChild : dc.getChildren()) { - concept.addChild(dcChild); - } - // Konzept selber löschen - concept.removeChild(dc); - } - - } - - // cleaningTimeNs += System.nanoTime() - cleaningTimeNsStart; - } - - - - // eliminiert Disjunktionen in Disjunktionen bzw. Konjunktionen in Konjunktionen - public static void cleanConcept(Description concept) { - - // Rekursion (verändert Eingabekonzept) - for(Description child : concept.getChildren()) { - cleanConcept(child); - } - - cleaningTimeNsStart = System.nanoTime(); - /* - if(concept instanceof Bottom || concept instanceof Top || concept instanceof AtomicConcept) - return concept; - else if(concept instanceof Negation) - return new Negation(concept.getChild(0)); - else if(concept instanceof Exists) - return new Exists(((Quantification)concept).getRole(),cleanConcept(concept.getChild(0))); - else if(concept instanceof All) - return new All(((Quantification)concept).getRole(),cleanConcept(concept.getChild(0))); - */ - if(concept instanceof Intersection || concept instanceof Union) { - - List<Description> deleteChilds = new LinkedList<Description>(); - - for(Description child : concept.getChildren()) { - if((concept instanceof Intersection && child instanceof Intersection) - || (concept instanceof Union && child instanceof Union)) { - deleteChilds.add(child); - } - } - - for(Description dc : deleteChilds) { - // alle Kinder des zu löschenden Konzeptes hinzufügen - for(Description dcChild : dc.getChildren()) { - concept.addChild(dcChild); - } - // Konzept selber löschen - concept.removeChild(dc); - } - - } - cleaningTimeNs += System.nanoTime() - cleaningTimeNsStart; - - } - - // wandelt ein Konzept in Negationsnormalform um - public static Description transformToNegationNormalForm(Description concept) { - if(concept instanceof Negation) { - Description child = concept.getChild(0); - - if(child.getChildren().size()==0) { - // NOT TOP = BOTTOM - if(child instanceof Thing) - return new Nothing(); - // NOT BOTTOM = TOP - else if(child instanceof Nothing) - return new Thing(); - // atomares Konzept: NOT A wird zurückgegeben - else if(child instanceof NamedClass) - return concept; - else - throw new RuntimeException("Conversion to negation normal form not supported for " + concept); - } else { - if(child instanceof Negation) { - // doppelte Negation hebt sich auf - return transformToNegationNormalForm(child.getChild(0)); - } else if(child instanceof ObjectQuantorRestriction) { - ObjectPropertyExpression r = ((ObjectQuantorRestriction)child).getRole(); - // Negation nach innen - Description c = new Negation(child.getChild(0)); - // Exists - if(child instanceof ObjectSomeRestriction) - return new ObjectAllRestriction(r,transformToNegationNormalForm(c)); - // All - else - return new ObjectSomeRestriction(r,transformToNegationNormalForm(c)); - } else if(child instanceof Intersection) { - // wg. Negation wird Konjunktion zu Disjunktion - Union md = new Union(); - for(Description c : child.getChildren()) { - md.addChild(transformToNegationNormalForm(new Negation(c))); - } - return md; - } else if(child instanceof Union) { - Intersection mc = new Intersection(); - for(Description c : child.getChildren()) { - mc.addChild(transformToNegationNormalForm(new Negation(c))); - } - return mc; - } else - throw new RuntimeException("Conversion to negation normal form not supported for " + concept); - } - // keine Negation - } else { - - Description conceptClone = (Description) concept.clone(); - conceptClone.getChildren().clear(); - - for(Description c : concept.getChildren()) { - conceptClone.addChild(transformToNegationNormalForm(c)); - } - - return conceptClone; - } - } - - - @SuppressWarnings("unused") - private boolean containsTop(Description concept) { - for(Description c : concept.getChildren()) { - if(c instanceof Thing) - return true; - } - return false; - } - - @SuppressWarnings("unused") - private boolean containsBottom(Description concept) { - for(Description c : concept.getChildren()) { - if(c instanceof Nothing) - return true; - } - return false; - } - - // nimmt Konzept in Negationsnormalform und wendet äquivalenzerhaltende - // Regeln an, die TOP und BOTTOM aus Disjunktion/Konjunktion entfernen - public static Description applyEquivalenceRules(Description concept) { - - Description conceptClone = (Description) concept.clone(); - conceptClone.getChildren().clear(); - - for(Description c : concept.getChildren()) { - conceptClone.addChild(applyEquivalenceRules(c)); - } - - // return conceptClone; - - // TOP, BOTTOM in Disjunktion entfernen - if(concept instanceof Union) { - Iterator<Description> it = conceptClone.getChildren().iterator(); - while(it.hasNext()) { - Description c = it.next(); - // for(Concept c : concept.getChildren()) { - // TOP in Disjunktion => ganze Disjunktion äquivalent zu Top - if(c instanceof Thing) - return new Thing(); - // BOTTOM in Disjunktion => entfernen - else if(c instanceof Nothing) - it.remove(); - - } - - // falls nur noch ein Kind übrig bleibt, dann entfällt - // MultiDisjunction - if(conceptClone.getChildren().size()==1) - return conceptClone.getChild(0); - - // falls keine Kinder übrig bleiben, dann war das letzte Kind - // BOTTOM - if(conceptClone.getChildren().size()==0) - return new Nothing(); - - } else if(concept instanceof Intersection) { - Iterator<Description> it = conceptClone.getChildren().iterator(); - while(it.hasNext()) { - Description c = it.next(); - // TOP in Konjunktion => entfernen - if(c instanceof Thing) - it.remove(); - // BOTTOM in Konjunktion => alles äquivalent zu BOTTOM - else if(c instanceof Nothing) - return new Nothing(); - } - - if(conceptClone.getChildren().size()==1) - return conceptClone.getChild(0); - - // falls keine Kinder übrig bleiben, dann war das letzte Kind - // TOP - if(conceptClone.getChildren().size()==0) - return new Thing(); - } - - return conceptClone; - } - - // TODO: aus Effizienzgründen könnte man noch eine nicht-rekursive Methode entwickeln, die - // nur die obere Ebene umwandelt - public static void transformToOrderedNegationNormalFormNonRecursive(Description concept, Comparator<Description> conceptComparator) { - // onnfTimeNsStart = System.nanoTime(); - - // Liste der Kinder sortieren - Collections.sort(concept.getChildren(), conceptComparator); - - // onnfTimeNs += System.nanoTime() - onnfTimeNsStart; - } - - // wandelt ein Konzept in geordnete Negationsnormalform um; - // es wird angenommen, dass das Eingabekonzept in Negationsnormalform und - // "sauber" ist - public static void transformToOrderedNegationNormalForm(Description concept, Comparator<Description> conceptComparator) { - - // alle Kinderkonzepte in geordnete Negationsnormalform bringen - for(Description child : concept.getChildren()) { - transformToOrderedNegationNormalForm(child, conceptComparator); - } - - onnfTimeNsStart = System.nanoTime(); - // Liste der Kinder sortieren - Collections.sort(concept.getChildren(), conceptComparator); - - // Konvertierung von Liste in Array => Array sortieren => Rekonvertierung in Liste - // List<Concept> childList = concept.getChildren(); - // Concept[] childArray = (Concept[]) childList.toArray(); - // Arrays.sort(childArray, conceptComparator); - // childList = Arrays.asList(childArray); - onnfTimeNs += System.nanoTime() - onnfTimeNsStart; - } - /* - public static Description transformToMultiClean(Description concept) { - concept = transformToMulti(concept); - cleanConcept(concept); - return concept; - } - - // ersetzt einfache Disjunktionen/Konjunktionen durch Multi - public static Description transformToMulti(Description concept) { - // alle Kinderkonzepte in geordnete Negationsnormalform bringen - List<Description> multiChildren = new LinkedList<Description>(); - - // es müssen veränderte Kinder entfernt und neu hinzugefügt werden - // (einfache Zuweisung mit = funktioniert nicht, da die Pointer die gleichen - // bleiben) - Iterator<Description> it = concept.getChildren().iterator(); - while(it.hasNext()) { - Description child = it.next(); - multiChildren.add(transformToMulti(child)); - it.remove(); - } - - for(Description multiChild : multiChildren) - concept.addChild(multiChild); - - if(concept instanceof Disjunction) - return new MultiDisjunction(concept.getChildren()); - - if(concept instanceof Conjunction) - return new MultiConjunction(concept.getChildren()); - - return concept; - } - */ - // liefert ein ev. verkürztes Konzept, wenn in Disjunktionen bzw. - // Konjunktionen Elemente mehrfach vorkommen - // (erstmal nicht-rekursiv implementiert) - public static Description getShortConceptNonRecursive(Description concept, ConceptComparator conceptComparator) { - if(concept instanceof Union || concept instanceof Intersection) { - // Verkürzung geschieht einfach durch einfügen in eine geordnete Menge - Set<Description> newChildren = new TreeSet<Description>(conceptComparator); - newChildren.addAll(concept.getChildren()); - // ev. geht das noch effizienter, wenn man keine neue Liste erstellen - // muss(?) => Listen erstellen dürfte allerdings sehr schnell gehen - if(concept instanceof Intersection) - return new Intersection(new LinkedList<Description>(newChildren)); - else - return new Union(new LinkedList<Description>(newChildren)); - } else - return concept; - } - - public static Description getShortConcept(Description concept, ConceptComparator conceptComparator) { - shorteningTimeNsStart = System.nanoTime(); - // deep copy des Konzepts, da es nicht verändert werden darf - // (Nachteil ist, dass auch Konzepte kopiert werden, bei denen sich gar - // nichts ändert) - Description clone = (Description) concept.clone(); - clone = getShortConcept(clone, conceptComparator, 0); - // return getShortConcept(concept, conceptComparator, 0); - shorteningTimeNs += System.nanoTime() - shorteningTimeNsStart; - return clone; - } - - // das Eingabekonzept darf nicht modifiziert werden - private static Description getShortConcept(Description concept, ConceptComparator conceptComparator, int recDepth) { - - //if(recDepth==0) - // System.out.println(concept); - - // Kinder schrittweise ersetzen - // TODO: effizienter wäre nur zu ersetzen, wenn sich etwas geändert hat - List<Description> tmp = new LinkedList<Description>(); - Iterator<Description> it = concept.getChildren().iterator(); - while(it.hasNext()) { - Description c = it.next(); - // concept.addChild(getShortConcept(c, conceptComparator)); - Description newChild = getShortConcept(c, conceptComparator,recDepth+1); - // Vergleich, ob es sich genau um die gleichen Objekte handelt - // (es wird explizit == statt equals verwendet) - if(c != newChild) { - tmp.add(newChild); - it.remove(); - } - } - for(Description child : tmp) - concept.addChild(child); - - if(concept instanceof Union || concept instanceof Intersection) { - // Verkürzung geschieht einfach durch einfügen in eine geordnete Menge - SortedSet<Description> newChildren = new TreeSet<Description>(conceptComparator); - newChildren.addAll(concept.getChildren()); - // falls sich Kinderliste auf ein Element reduziert hat, dann gebe nur - // dieses Element zurück (umschließende Konjunktion/Disjunktion entfällt) - if(newChildren.size()==1) - return newChildren.first(); - // ev. geht das noch effizienter, wenn man keine neue Liste erstellen - // muss(?) => Listen erstellen dürfte allerdings sehr schnell gehen - if(concept instanceof Intersection) - return new Intersection(new LinkedList<Description>(newChildren)); - else - return new Union(new LinkedList<Description>(newChildren)); - } else - return concept; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/utilities/JenaResultSetConvenience.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/JenaResultSetConvenience.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/utilities/JenaResultSetConvenience.java 2008-05-19 12:57:31 UTC (rev 900) @@ -1,37 +0,0 @@ -package org.dllearner.utilities; - -import java.util.List; -import java.util.SortedSet; -import java.util.TreeSet; - -import com.hp.hpl.jena.query.ResultSet; -import com.hp.hpl.jena.query.ResultSetFormatter; -import com.hp.hpl.jena.sparql.core.ResultBinding; - -public class JenaResultSetConvenience { - ResultSet rs; - - public JenaResultSetConvenience(ResultSet rs) { - super(); - this.rs = rs; - } - - @SuppressWarnings("unchecked") - public SortedSet<String> getStringListForVariable(String var){ - SortedSet<String> result = new TreeSet<String>(); - - //String s=ResultSetFormatter.asXMLString(this.rs); - List<ResultBinding> l = ResultSetFormatter.toList(this.rs); - - for (ResultBinding resultBinding : l) { - - result.add(resultBinding.get(var).toString()); - - } - - return result; - - } - - -} Copied: trunk/src/dl-learner/org/dllearner/utilities/Logging.java (from rev 899, trunk/src/dl-learner/org/dllearner/utilities/statistics/Logging.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Logging.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/Logging.java 2008-05-19 12:57:31 UTC (rev 900) @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.utilities; + +import java.util.Enumeration; + +import org.apache.log4j.Appender; +import org.apache.log4j.Level; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.log4j.spi.LoggerRepository; + +/** + * Logging centered utility class. + * + * @author Jens Lehmann + * + */ +public class Logging { + + /** + * Prints the currently available log4j loggers to system out. + */ + @SuppressWarnings({"unchecked"}) + public static void printCurrentLoggers() { + LoggerRepository rep = LogManager.getLoggerRepository(); + Enumeration<Logger> e = rep.getCurrentLoggers(); + while(e.hasMoreElements()) { + Logger l = e.nextElement(); + String name = l.getName(); + Level level = l.getLevel(); + Enumeration<Appender> appenders = l.getAllAppenders(); + + if(appenders.hasMoreElements()) + System.out.println("APPENDER: " + appenders.nextElement()); + + System.out.println("name : " + name); + System.out.println("level: " + level); + System.out.println("appenders: " + appenders); + System.out.println(); + } + } + +} Deleted: trunk/src/dl-learner/org/dllearner/utilities/ManchesterOWLSyntaxParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/ManchesterOWLSyntaxParser.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/utilities/ManchesterOWLSyntaxParser.java 2008-05-19 12:57:31 UTC (rev 900) @@ -1,48 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.utilities; - -import org.coode.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser; -import org.semanticweb.owl.apibinding.OWLManager; -import org.semanticweb.owl.expression.ParserException; -import org.semanticweb.owl.model.OWLDescription; -import org.semanticweb.owl.model.OWLOntologyManager; - -/** - * Parser for Manchester Syntax strings (interface to OWL API parser). - * TODO: Currently, this outputs an OWL API OWLDescription, but there - * is no converter from OWL API descriptions to DL-Learner descriptions - * at the moment. - * - * @author Jens Lehmann - * - */ -public class ManchesterOWLSyntaxParser { - - public OWLDescription getDescription(String manchesterSyntaxDescription) throws ParserException { - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - - ManchesterOWLSyntaxEditorParser parser = new - ManchesterOWLSyntaxEditorParser(manager.getOWLDataFactory(), manchesterSyntaxDescription); - - return parser.parseDescription(); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java 2008-05-19 12:28:20 UTC (rev 899) +++ trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java 2008-05-19 12:57:31 UTC (rev 900) @@ -1,69 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This fi... [truncated message content] |
From: <ku...@us...> - 2008-05-19 12:28:24
|
Revision: 899 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=899&view=rev Author: kurzum Date: 2008-05-19 05:28:20 -0700 (Mon, 19 May 2008) Log Message: ----------- Fixed some warnings added jamon-2.7.jar (update classpath) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderSKOSSPARQL.java Added Paths: ----------- trunk/lib/jamon-2.7.jar Added: trunk/lib/jamon-2.7.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/jamon-2.7.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-05-19 10:26:10 UTC (rev 898) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-05-19 12:28:20 UTC (rev 899) @@ -20,12 +20,9 @@ package org.dllearner.algorithms; import java.util.Collection; -import java.util.Iterator; import java.util.LinkedList; -import java.util.SortedSet; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; -import org.dllearner.algorithms.refexamples.ExampleBasedROLearner; import org.dllearner.core.ComponentInitException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; @@ -36,11 +33,9 @@ import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.DoubleConfigOption; -import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-19 10:26:10 UTC (rev 898) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-19 12:28:20 UTC (rev 899) @@ -25,7 +25,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; -import java.util.SortedSet; import org.apache.log4j.Level; import org.apache.log4j.Logger; Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-05-19 10:26:10 UTC (rev 898) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-05-19 12:28:20 UTC (rev 899) @@ -22,7 +22,6 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; -import java.util.SortedSet; import org.dllearner.core.owl.Description; Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java 2008-05-19 10:26:10 UTC (rev 898) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java 2008-05-19 12:28:20 UTC (rev 899) @@ -26,11 +26,9 @@ import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.utilities.JenaResultSetConvenience; import org.dllearner.utilities.datastructures.StringTuple; import com.hp.hpl.jena.query.ResultSet; -import com.hp.hpl.jena.query.ResultSetFormatter; /** * Used to manipulate retrieved tupels, identify blanknodes, etc. Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java 2008-05-19 10:26:10 UTC (rev 898) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java 2008-05-19 12:28:20 UTC (rev 899) @@ -30,7 +30,6 @@ import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.kb.sparql.SparqlQueryMaker; import org.dllearner.utilities.datastructures.StringTuple; -import org.dllearner.utilities.statistics.SimpleClock; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-05-19 10:26:10 UTC (rev 898) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-05-19 12:28:20 UTC (rev 899) @@ -32,7 +32,6 @@ import org.apache.log4j.Logger; import org.dllearner.core.KnowledgeSource; -import org.dllearner.utilities.statistics.SimpleClock; import org.dllearner.utilities.statistics.Statistics; /** Modified: trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java 2008-05-19 10:26:10 UTC (rev 898) +++ trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java 2008-05-19 12:28:20 UTC (rev 899) @@ -2,7 +2,7 @@ import java.util.SortedSet; -public class ResultCompare implements Comparable { +public class ResultCompare implements Comparable<ResultCompare> { String concept; SortedSet<String> instances; double accuracy; @@ -30,8 +30,8 @@ - public int compareTo(Object in) { - ResultCompare obj =(ResultCompare) in; + public int compareTo(ResultCompare in) { + ResultCompare obj = in; if(obj.accuracy > this.accuracy) return 1; else if(obj.accuracy == this.accuracy){ @@ -64,6 +64,7 @@ } + @Override public String toString(){ String ret=""; ret+="concept\t"+concept+"\n"; Modified: trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderSKOSSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderSKOSSPARQL.java 2008-05-19 10:26:10 UTC (rev 898) +++ trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderSKOSSPARQL.java 2008-05-19 12:28:20 UTC (rev 899) @@ -1,7 +1,5 @@ package org.dllearner.utilities.examples; -import java.net.URL; -import java.net.URLEncoder; import java.util.SortedSet; import java.util.TreeSet; @@ -11,7 +9,6 @@ import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; -import org.dllearner.kb.sparql.SparqlQueryThreaded; import org.dllearner.utilities.JenaResultSetConvenience; import org.dllearner.utilities.datastructures.SetManipulation; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-19 10:26:15
|
Revision: 898 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=898&view=rev Author: kurzum Date: 2008-05-19 03:26:10 -0700 (Mon, 19 May 2008) Log Message: ----------- new utility structure Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java trunk/src/dl-learner/org/dllearner/cli/ConfFileOption.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java trunk/src/dl-learner/org/dllearner/examples/KRK.java trunk/src/dl-learner/org/dllearner/examples/KRKModular.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryInterface.java trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/RoleLearning.java trunk/src/dl-learner/org/dllearner/parser/ConfParser.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/scripts/CloseOntology.java trunk/src/dl-learner/org/dllearner/scripts/CrossValidation.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java trunk/src/dl-learner/org/dllearner/utilities/Helper.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/utilities/datastructures/ trunk/src/dl-learner/org/dllearner/utilities/datastructures/Datastructures.java trunk/src/dl-learner/org/dllearner/utilities/datastructures/SetManipulation.java trunk/src/dl-learner/org/dllearner/utilities/datastructures/SortedSetTuple.java trunk/src/dl-learner/org/dllearner/utilities/datastructures/StringTuple.java trunk/src/dl-learner/org/dllearner/utilities/examples/ trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderRolesSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderSKOSSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticExampleFinderSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/learn/ trunk/src/dl-learner/org/dllearner/utilities/learn/ConfWriter.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java trunk/src/dl-learner/org/dllearner/utilities/owl/ trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyClassRewriter.java trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyCloser.java trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyCloserOWLAPI.java trunk/src/dl-learner/org/dllearner/utilities/statistics/ trunk/src/dl-learner/org/dllearner/utilities/statistics/Logging.java trunk/src/dl-learner/org/dllearner/utilities/statistics/PaperStatistics.java trunk/src/dl-learner/org/dllearner/utilities/statistics/SimpleClock.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Statistics.java trunk/src/dl-learner/org/dllearner/utilities/statistics/TestValidation.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderRolesSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/ConfWriter.java trunk/src/dl-learner/org/dllearner/utilities/Datastructures.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java trunk/src/dl-learner/org/dllearner/utilities/Logging.java trunk/src/dl-learner/org/dllearner/utilities/OntologyClassRewriter.java trunk/src/dl-learner/org/dllearner/utilities/OntologyCloser.java trunk/src/dl-learner/org/dllearner/utilities/OntologyCloserOWLAPI.java trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java trunk/src/dl-learner/org/dllearner/utilities/SetManipulation.java trunk/src/dl-learner/org/dllearner/utilities/SimpleClock.java trunk/src/dl-learner/org/dllearner/utilities/SortedSetTuple.java trunk/src/dl-learner/org/dllearner/utilities/Stat.java trunk/src/dl-learner/org/dllearner/utilities/Statistics.java trunk/src/dl-learner/org/dllearner/utilities/StringTuple.java trunk/src/dl-learner/org/dllearner/utilities/TestValidation.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2008-05-19 10:26:10 UTC (rev 898) @@ -27,7 +27,7 @@ import org.dllearner.reasoning.FastRetrieval; import org.dllearner.reasoning.ReasonerType; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.SortedSetTuple; +import org.dllearner.utilities.datastructures.SortedSetTuple; /** Modified: trunk/src/dl-learner/org/dllearner/cli/ConfFileOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/ConfFileOption.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/cli/ConfFileOption.java 2008-05-19 10:26:10 UTC (rev 898) @@ -23,7 +23,7 @@ import java.util.List; import java.util.Set; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; /** * Represents one configuration option in a conf file, e.g. Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-19 10:26:10 UTC (rev 898) @@ -84,10 +84,10 @@ import org.dllearner.reasoning.FastRetrievalReasoner; import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.ConceptComparator; -import org.dllearner.utilities.Datastructures; import org.dllearner.utilities.Helper; import org.dllearner.utilities.RoleComparator; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.Datastructures; +import org.dllearner.utilities.datastructures.StringTuple; /** * Startup file for Command Line Interface. Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-05-19 10:26:10 UTC (rev 898) @@ -35,7 +35,7 @@ import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.reasoning.ReasonerType; -import org.dllearner.utilities.SortedSetTuple; +import org.dllearner.utilities.datastructures.SortedSetTuple; /** * Reasoner Interface. Lists all available reasoning methods. Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-05-19 10:26:10 UTC (rev 898) @@ -37,7 +37,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.SubsumptionHierarchy; -import org.dllearner.utilities.SortedSetTuple; +import org.dllearner.utilities.datastructures.SortedSetTuple; /** * @author Jens Lehmann Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-05-19 10:26:10 UTC (rev 898) @@ -37,7 +37,7 @@ import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.reasoning.ReasonerType; -import org.dllearner.utilities.SortedSetTuple; +import org.dllearner.utilities.datastructures.SortedSetTuple; /** * The reasoning service is the interface to the used reasoner. Basically, Modified: trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java 2008-05-19 10:26:10 UTC (rev 898) @@ -21,7 +21,7 @@ import java.util.List; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; /** * A list if string tuples, for instance for specifying several parameters or Modified: trunk/src/dl-learner/org/dllearner/examples/KRK.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/KRK.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/examples/KRK.java 2008-05-19 10:26:10 UTC (rev 898) @@ -31,7 +31,7 @@ import org.dllearner.core.owl.SymmetricObjectPropertyAxiom; import org.dllearner.core.owl.TransitiveObjectPropertyAxiom; import org.dllearner.reasoning.OWLAPIReasoner; -import org.dllearner.utilities.OntologyCloser; +import org.dllearner.utilities.owl.OntologyCloser; /* * Structure Modified: trunk/src/dl-learner/org/dllearner/examples/KRKModular.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2008-05-19 10:26:10 UTC (rev 898) @@ -35,7 +35,7 @@ import org.dllearner.parser.KBParser; import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.OWLAPIReasoner; -import org.dllearner.utilities.SimpleClock; +import org.dllearner.utilities.statistics.SimpleClock; /* * Structure Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-05-19 10:26:10 UTC (rev 898) @@ -45,7 +45,7 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.StringTupleListConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; /** * Panel for option StringTupleList, defined in Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java 2008-05-19 10:26:10 UTC (rev 898) @@ -25,7 +25,7 @@ import java.util.Set; import java.util.Vector; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; /** * Is a node in the graph, that is a class. Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-05-19 10:26:10 UTC (rev 898) @@ -25,7 +25,7 @@ import java.util.Set; import java.util.Vector; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; /** * A node in the graph that is an instance. Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java 2008-05-19 10:26:10 UTC (rev 898) @@ -28,7 +28,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQueryType; -import org.dllearner.utilities.Statistics; +import org.dllearner.utilities.statistics.Statistics; /** * An object of this class encapsulates everything. Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java 2008-05-19 10:26:10 UTC (rev 898) @@ -27,7 +27,7 @@ import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.utilities.JenaResultSetConvenience; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java 2008-05-19 10:26:10 UTC (rev 898) @@ -25,7 +25,7 @@ import java.util.Set; import java.util.Vector; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; /** * Property node, has connection to a and b part Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java 2008-05-19 10:26:10 UTC (rev 898) @@ -29,8 +29,8 @@ import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.kb.sparql.SparqlQueryMaker; -import org.dllearner.utilities.SimpleClock; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; +import org.dllearner.utilities.statistics.SimpleClock; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java 2008-05-19 10:26:10 UTC (rev 898) @@ -25,7 +25,7 @@ import java.util.Set; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryInterface.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryInterface.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryInterface.java 2008-05-19 10:26:10 UTC (rev 898) @@ -22,7 +22,7 @@ import java.net.URI; import java.util.Set; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; /** * Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-05-19 10:26:10 UTC (rev 898) @@ -32,8 +32,8 @@ import org.apache.log4j.Logger; import org.dllearner.core.KnowledgeSource; -import org.dllearner.utilities.SimpleClock; -import org.dllearner.utilities.Statistics; +import org.dllearner.utilities.statistics.SimpleClock; +import org.dllearner.utilities.statistics.Statistics; /** * SPARQL query cache to avoid possibly expensive multiple queries. The queries Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-05-19 10:26:10 UTC (rev 898) @@ -49,8 +49,8 @@ import org.dllearner.parser.KBParser; import org.dllearner.reasoning.DIGConverter; import org.dllearner.reasoning.JenaOWLDIGConverter; -import org.dllearner.utilities.SimpleClock; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; +import org.dllearner.utilities.statistics.SimpleClock; /** * Represents the SPARQL Endpoint Component. Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java 2008-05-19 10:26:10 UTC (rev 898) @@ -29,7 +29,7 @@ import org.dllearner.core.owl.Union; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.SortedSetTuple; +import org.dllearner.utilities.datastructures.SortedSetTuple; /** * Caches results of previous concept evaluation to speed up Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2008-05-19 10:26:10 UTC (rev 898) @@ -35,7 +35,7 @@ import org.dllearner.core.owl.Negation; import org.dllearner.reasoning.ReasonerType; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.SortedSetTuple; +import org.dllearner.utilities.datastructures.SortedSetTuple; /** * @author Jens Lehmann Modified: trunk/src/dl-learner/org/dllearner/learningproblems/RoleLearning.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/RoleLearning.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/learningproblems/RoleLearning.java 2008-05-19 10:26:10 UTC (rev 898) @@ -27,7 +27,7 @@ import org.dllearner.core.Score; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; /** * Here are just some code snippets, which can be used The basic algorithm is Modified: trunk/src/dl-learner/org/dllearner/parser/ConfParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/ConfParser.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/parser/ConfParser.java 2008-05-19 10:26:10 UTC (rev 898) @@ -21,6 +21,7 @@ import org.dllearner.cli.*; import org.dllearner.utilities.*; +import org.dllearner.utilities.datastructures.StringTuple; public @SuppressWarnings("all") class ConfParser implements ConfParserConstants { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java 2008-05-19 10:26:10 UTC (rev 898) @@ -15,7 +15,7 @@ import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.Thing; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.SortedSetTuple; +import org.dllearner.utilities.datastructures.SortedSetTuple; public class FastRetrieval { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-05-19 10:26:10 UTC (rev 898) @@ -21,7 +21,7 @@ import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.SortedSetTuple; +import org.dllearner.utilities.datastructures.SortedSetTuple; public class FastRetrievalReasoner extends ReasonerComponent { Modified: trunk/src/dl-learner/org/dllearner/scripts/CloseOntology.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/CloseOntology.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/scripts/CloseOntology.java 2008-05-19 10:26:10 UTC (rev 898) @@ -8,7 +8,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.kb.OWLFile; import org.dllearner.reasoning.OWLAPIReasoner; -import org.dllearner.utilities.OntologyCloserOWLAPI; +import org.dllearner.utilities.owl.OntologyCloserOWLAPI; /** * Script for closing an ontology OWLAPI produces extensive filesizes, when Modified: trunk/src/dl-learner/org/dllearner/scripts/CrossValidation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/CrossValidation.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/scripts/CrossValidation.java 2008-05-19 10:26:10 UTC (rev 898) @@ -42,9 +42,9 @@ import org.dllearner.core.owl.Individual; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyLP; -import org.dllearner.utilities.Datastructures; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.Stat; +import org.dllearner.utilities.datastructures.Datastructures; +import org.dllearner.utilities.statistics.Stat; /** * Performs cross validation for the given problem. Supports Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-19 10:26:10 UTC (rev 898) @@ -17,11 +17,11 @@ import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.utilities.AutomaticExampleFinderSKOSSPARQL; import org.dllearner.utilities.JenaResultSetConvenience; -import org.dllearner.utilities.LearnSparql; -import org.dllearner.utilities.SetManipulation; -import org.dllearner.utilities.SimpleClock; +import org.dllearner.utilities.datastructures.SetManipulation; +import org.dllearner.utilities.examples.AutomaticExampleFinderSKOSSPARQL; +import org.dllearner.utilities.learn.LearnSparql; +import org.dllearner.utilities.statistics.SimpleClock; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-19 10:26:10 UTC (rev 898) @@ -14,12 +14,12 @@ import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.utilities.AutomaticExampleFinderSPARQL; import org.dllearner.utilities.JenaResultSetConvenience; -import org.dllearner.utilities.LearnSparql; -import org.dllearner.utilities.SetManipulation; -import org.dllearner.utilities.SimpleClock; -import org.dllearner.utilities.Statistics; +import org.dllearner.utilities.datastructures.SetManipulation; +import org.dllearner.utilities.examples.AutomaticExampleFinderSPARQL; +import org.dllearner.utilities.learn.LearnSparql; +import org.dllearner.utilities.statistics.SimpleClock; +import org.dllearner.utilities.statistics.Statistics; import com.hp.hpl.jena.query.ResultSet; Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-05-19 10:26:10 UTC (rev 898) @@ -13,14 +13,14 @@ import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.utilities.AutomaticExampleFinderRolesSPARQL; -import org.dllearner.utilities.AutomaticExampleFinderSPARQL; -import org.dllearner.utilities.ConfWriter; import org.dllearner.utilities.JenaResultSetConvenience; -import org.dllearner.utilities.LearnSparql; -import org.dllearner.utilities.SetManipulation; -import org.dllearner.utilities.SimpleClock; -import org.dllearner.utilities.Statistics; +import org.dllearner.utilities.datastructures.SetManipulation; +import org.dllearner.utilities.examples.AutomaticExampleFinderRolesSPARQL; +import org.dllearner.utilities.examples.AutomaticExampleFinderSPARQL; +import org.dllearner.utilities.learn.ConfWriter; +import org.dllearner.utilities.learn.LearnSparql; +import org.dllearner.utilities.statistics.SimpleClock; +import org.dllearner.utilities.statistics.Statistics; import com.hp.hpl.jena.query.ResultSet; Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-05-19 10:26:10 UTC (rev 898) @@ -67,8 +67,8 @@ import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGReasoner; import org.dllearner.reasoning.OWLAPIReasoner; -import org.dllearner.utilities.Datastructures; import org.dllearner.utilities.Helper; +import org.dllearner.utilities.datastructures.Datastructures; import com.hp.hpl.jena.query.ResultSet; Modified: trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java 2008-05-19 10:26:10 UTC (rev 898) @@ -13,7 +13,7 @@ import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.utilities.JenaResultSetConvenience; -import org.dllearner.utilities.SimpleClock; +import org.dllearner.utilities.statistics.SimpleClock; import com.hp.hpl.jena.query.ResultSet; Modified: trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java 2008-05-19 10:26:10 UTC (rev 898) @@ -28,7 +28,7 @@ import org.dllearner.kb.extraction.Manipulator; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQueryType; -import org.dllearner.utilities.StringTuple; +import org.dllearner.utilities.datastructures.StringTuple; /** * Test class, uses the whole thing Deleted: trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderRolesSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderRolesSPARQL.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderRolesSPARQL.java 2008-05-19 10:26:10 UTC (rev 898) @@ -1,123 +0,0 @@ -package org.dllearner.utilities; - -import java.util.SortedSet; -import java.util.TreeSet; - -import org.apache.log4j.Logger; -import org.dllearner.core.ComponentManager; -import org.dllearner.kb.sparql.Cache; -import org.dllearner.kb.sparql.SparqlEndpoint; -import org.dllearner.kb.sparql.SparqlQuery; - -import com.hp.hpl.jena.query.ResultSet; - -public class AutomaticExampleFinderRolesSPARQL { - - private static Logger logger = Logger - .getLogger(ComponentManager.class); - - private Cache c; - private SparqlEndpoint se; - private SortedSet<String> posExamples; - private SortedSet<String> negExamples; - private int roleLimit=1000; - - - public AutomaticExampleFinderRolesSPARQL(SparqlEndpoint se){ - this.c=new Cache("cachetemp"); - this.se=se; - posExamples = new TreeSet<String>(); - negExamples = new TreeSet<String>(); - } - - public void initDomainRange(String role, int poslimit, int neglimit) { - makePositiveExamplesAsDomain( role); - SortedSet<String> keepForClean = new TreeSet<String>(); - keepForClean.addAll(this.posExamples); - this.posExamples = SetManipulation.fuzzyShrink(this.posExamples, poslimit); - logger.trace("shrinking: pos Example size: "+posExamples.size()); - - makeNegativeExamplesAsRange( role); - - - //clean - negExamples.removeAll(keepForClean); - logger.trace("neg Example size after cleaning: "+negExamples.size()); - this.negExamples = SetManipulation.fuzzyShrink(negExamples, neglimit); - logger.debug("pos Example size after shrinking: "+posExamples.size()); - logger.debug("neg Example size after shrinking: "+negExamples.size()); - logger.debug("Finished examples for role: "+role); - } - - - - - private void makePositiveExamplesAsDomain(String role){ - logger.debug("making Positive Examples from Role as Domain: "+role); - this.posExamples.addAll(getDomain( role, roleLimit)); - logger.debug(" pos Example size: "+posExamples.size()); - } - - private void makeNegativeExamplesAsRange(String role){ - logger.debug("making Negative Examples from Role as Range: "+role); - this.negExamples.addAll(getRange( role, roleLimit)); - logger.debug(" neg Example size: "+negExamples.size()); - } - - private SortedSet<String> getDomain(String role,int limit){ - - String query = "" + - "SELECT DISTINCT ?domain " + - "WHERE { \n" + - "?domain <" + role + "> " + " ?o. \n" + - "?domain a []\n." + - "FILTER (!isLiteral(?domain))." + - "}\n" + - "LIMIT "+limit; - - - String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); - JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); - return rsc.getStringListForVariable("domain"); - - } - - private SortedSet<String> getRange(String role,int limit){ - - String query = "" + - "SELECT DISTINCT ?range " + - "WHERE { \n" + - "?s <" + role + "> " + " ?range. \n" + - "?range a [].\n" + - "FILTER (!isLiteral(?range))." + - "}\n" + - "LIMIT "+limit; - - - String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); - JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); - return rsc.getStringListForVariable("range"); - - } - - - - - - - public SortedSet<String> getPosExamples() { - return posExamples; - } - - public SortedSet<String> getNegExamples() { - return negExamples; - } - - - - - - -} Deleted: trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-19 10:26:10 UTC (rev 898) @@ -1,412 +0,0 @@ -package org.dllearner.utilities; - -import java.net.URL; -import java.net.URLEncoder; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.apache.log4j.Logger; -import org.dllearner.core.ComponentManager; -import org.dllearner.kb.sparql.Cache; -import org.dllearner.kb.sparql.SparqlEndpoint; -import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; -import org.dllearner.kb.sparql.SparqlQueryThreaded; - -import com.hp.hpl.jena.query.ResultSet; - -public class AutomaticExampleFinderSKOSSPARQL { - - private static Logger logger = Logger - .getLogger(ComponentManager.class); - - private Cache c; - private SparqlEndpoint se; - private SortedSet<String> posExamples= new TreeSet<String>();; - private SortedSet<String> negExamples= new TreeSet<String>();; - public SortedSet<String> totalSKOSset= new TreeSet<String>();; - public SortedSet<String> rest= new TreeSet<String>();; - private int limit=2000; - - - public AutomaticExampleFinderSKOSSPARQL(SparqlEndpoint se){ - this.c=new Cache("cacheExamplesValidation"); - this.se=se; - posExamples = new TreeSet<String>(); - negExamples = new TreeSet<String>(); - } - - public void initDBpediaSKOS(String concept, double percent, boolean useRelated,boolean useParallelClasses) { - dbpediaMakePositiveExamplesFromConcept( concept); - SortedSet<String> keepForClean = new TreeSet<String>(); - keepForClean.addAll(this.posExamples); - totalSKOSset.addAll(this.posExamples); - rest.addAll(totalSKOSset); - int poslimit=(int)Math.round(percent*totalSKOSset.size()); - int neglimit=(int)Math.round(poslimit); - /*while (this.posExamples.size()>poslimit) { - this.posExamples.remove(posExamples.last()); - }*/ - this.posExamples = SetManipulation.fuzzyShrink(this.posExamples, poslimit); - - rest.removeAll(this.posExamples); - - logger.debug("pos Example size: "+posExamples.size()); - logger.debug("totalSKOSset: "+totalSKOSset.size()); - logger.debug("rest: "+rest.size()); - - if(useRelated) { - dbpediaMakeNegativeExamplesFromRelatedInstances(this.posExamples); - } - - if(useParallelClasses) { - int limit = this.posExamples.size(); - makeNegativeExamplesFromClassesOfInstances(limit); - } - //clean - negExamples.removeAll(keepForClean); - logger.debug("neg Example size after cleaning: "+negExamples.size()); - this.negExamples = SetManipulation.fuzzyShrink(negExamples, neglimit); - logger.debug("pos Example size after shrinking: "+posExamples.size()); - logger.debug("neg Example size after shrinking: "+negExamples.size()); - logger.debug("Finished examples for concept: "+concept); - } - -/* public void init(String concept, String namespace, boolean useRelated, boolean useSuperclasses,boolean useParallelClasses, int poslimit, int neglimit) { - makePositiveExamplesFromConcept( concept); - SortedSet<String> keepForClean = new TreeSet<String>(); - keepForClean.addAll(this.posExamples); - this.posExamples = SetManipulation.fuzzyShrink(this.posExamples, poslimit); - logger.trace("shrinking: pos Example size: "+posExamples.size()); - - if(useRelated) { - makeNegativeExamplesFromRelatedInstances(this.posExamples,namespace); - } - if(useSuperclasses) { - makeNegativeExamplesFromSuperClasses(concept); - } - if(useParallelClasses) { - makeNegativeExamplesFromClassesOfInstances(); - } - //clean - negExamples.removeAll(keepForClean); - logger.debug("neg Example size after cleaning: "+negExamples.size()); - this.negExamples = SetManipulation.fuzzyShrink(negExamples, neglimit); - logger.debug("pos Example size after shrinking: "+posExamples.size()); - logger.debug("neg Example size after shrinking: "+negExamples.size()); - logger.debug("Finished examples for concept: "+concept); - }*/ - - - - public SortedSet<String> dbpediaGetPosOnly(String concept, int limit){ - dbpediaMakePositiveExamplesFromConcept( concept); - return SetManipulation.fuzzyShrink(this.posExamples, limit); - } - - public SortedSet<String> getPosOnly(String concept, int limit){ - makePositiveExamplesFromConcept( concept); - return SetManipulation.fuzzyShrink(this.posExamples, limit); - } - - private void dbpediaMakePositiveExamplesFromConcept(String concept){ - logger.debug("making Positive Examples from Concept: "+concept); - if(concept.contains("http://dbpedia.org/resource/Category:")) { - this.posExamples = new JenaResultSetConvenience(dbpediaQuerySKOSConcept(concept,limit)) - .getStringListForVariable("subject"); - }else { - this.posExamples = new JenaResultSetConvenience(queryConcept(concept,limit)) - .getStringListForVariable("subject"); - } - logger.debug("pos Example size: "+posExamples.size()); - } - - private void makePositiveExamplesFromConcept(String concept){ - logger.debug("making Positive Examples from Concept: "+concept); - this.posExamples = new JenaResultSetConvenience(queryConcept(concept,0)) - .getStringListForVariable("subject"); - logger.debug(" pos Example size: "+posExamples.size()); - } - - - - /*private void makePositiveExamplesFromConcept(String concept){ - logger.debug("making Positive Examples from Concept: "+concept); - if(concept.contains("http://dbpedia.org/resource/Category:")) { - this.posExamples = new JenaResultSetConvenience(querySKOSConcept(concept,0)) - .getStringListForVariable("subject"); - }else { - this.posExamples = new JenaResultSetConvenience(queryConcept(concept,0)) - .getStringListForVariable("subject"); - } - logger.debug(" pos Example size: "+posExamples.size()); - }*/ - - - - - - private void dbpediaMakeNegativeExamplesFromRelatedInstances(SortedSet<String> subject) { - logger.debug("making examples from related instances"); - for (String string : subject) { - dbpediaMakeNegativeExamplesFromRelatedInstances(string); - } - logger.debug(" negExample size: "+negExamples.size()); - } - - private void makeNegativeExamplesFromRelatedInstances(SortedSet<String> subject, String namespace) { - logger.debug("making examples from related instances"); - for (String string : subject) { - makeNegativeExamplesFromRelatedInstances(string,namespace); - } - logger.debug(" negExample size: "+negExamples.size()); - } - - - /** - * - * @param subject - * @return - */ - private void dbpediaMakeNegativeExamplesFromRelatedInstances(String subject) { - // SortedSet<String> result = new TreeSet<String>(); - - String query = "SELECT * WHERE { \n" + "<" + subject + "> " + "?p ?o. \n" - + "FILTER (REGEX(str(?o), 'http://dbpedia.org/resource/')).\n" - + "FILTER (!REGEX(str(?p), 'http://www.w3.org/2004/02/skos'))\n" - + "}"; - - String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); - JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); - this.negExamples.addAll(rsc.getStringListForVariable("o")); - - - } - - private void makeNegativeExamplesFromRelatedInstances(String subject, String namespace) { - // SortedSet<String> result = new TreeSet<String>(); - - String query = "SELECT * WHERE { \n" + "<" + subject + "> " + "?p ?o. \n" - + "FILTER (REGEX(str(?o), '"+namespace+"')).\n" - + "}"; - - String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); - JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); - this.negExamples.addAll(rsc.getStringListForVariable("o")); - - - } - - - private void makeNegativeExamplesFromSuperClasses(String concept) { - - SortedSet<String> superClasses = new TreeSet<String>(); - superClasses.add(concept.replace("\"", "")); - //logger.debug("before"+superClasses); - superClasses = getSuperClasses( superClasses, 4); - logger.debug("making neg Examples from "+superClasses.size()+" superclasses"); - JenaResultSetConvenience rsc; - for (String oneSuperClass : superClasses) { - logger.debug(oneSuperClass); - rsc = new JenaResultSetConvenience(queryConcept("\""+oneSuperClass+"\"", limit)); - this.negExamples.addAll(rsc.getStringListForVariable("subject")); - } - logger.debug(" neg Example size: "+negExamples.size()); - } - - - - private void makeNegativeExamplesFromClassesOfInstances(int limit) { - logger.debug("making neg Examples from parallel classes"); - SortedSet<String> classes = new TreeSet<String>(); - //superClasses.add(concept.replace("\"", "")); - //logger.debug("before"+superClasses); - //superClasses = dbpediaGetSuperClasses( superClasses, 4); - //logger.debug("getting negExamples from "+superClasses.size()+" superclasses"); - JenaResultSetConvenience rsc; - ResultSet rs=null; - for (String instance : posExamples) { - //System.out.println(instance); - rs = getClassesForInstance(instance); - //System.out.println(ResultSetFormatter.asXMLString(rs)); - rsc = new JenaResultSetConvenience(rs); - classes.addAll(rsc.getStringListForVariable("subject")); - //System.out.println(classes); - } - logger.debug("getting negExamples from "+classes.size()+" parallel classes"); - for (String oneClass : classes) { - logger.debug(oneClass); - rsc = new JenaResultSetConvenience(queryConcept("\""+oneClass+"\"",limit)); - this.negExamples.addAll(rsc.getStringListForVariable("subject")); - } - logger.debug("neg Example size: "+negExamples.size()); - - } - - private SortedSet<String> getSuperClasses(SortedSet<String> superClasses, int depth) { - SortedSet<String> ret = new TreeSet<String>(); - SortedSet<String> tmpset = new TreeSet<String>(); - ret.addAll(superClasses); - //logger.debug(superClasses); - JenaResultSetConvenience rsc; - - String query = ""; - for (; depth != 0 ; depth--) { - for (String oneSuperClass : superClasses) { - - //tmp = oneSuperClass.replace("\"", ""); - query = "SELECT * WHERE { \n" + "<" + oneSuperClass + "> " - + "<http://www.w3.org/2000/01/rdf-schema#subClassOf> ?superclass. \n" - + "}"; - - String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); - rsc = new JenaResultSetConvenience(rs); - tmpset.addAll(rsc.getStringListForVariable("superclass")); - - } - ret.addAll(tmpset); - //logger.debug(ret); - superClasses.clear(); - superClasses.addAll(tmpset); - tmpset.clear(); - } - //logger.debug(concept); - //logger.debug(query); - return ret; - } - - - - public ResultSet queryConcept(String concept,int limit) { - ResultSet rs = null; - try { - String query = SparqlQueryDescriptionConvertVisitor - .getSparqlQuery(concept,limit); - - SparqlQuery sq = new SparqlQuery(query, se); - String JSON = c.executeSparqlQuery(sq); - //System.out.println("JSON:\n"+JSON); - rs = SparqlQuery.JSONtoResultSet(JSON); - - } catch (Exception e) { - e.printStackTrace(); - } - - return rs; - } - - public SortedSet<String> queryConceptAsStringSet(String concept,int limit) { - ResultSet rs = null; - try { - String query = SparqlQueryDescriptionConvertVisitor - .getSparqlQuery(concept,limit); - - SparqlQuery sq = new SparqlQuery(query, se); - //System.out.println(query); - String JSON = c.executeSparqlQuery(sq); - //System.out.println("JSON:\n"+JSON); - rs = SparqlQuery.JSONtoResultSet(JSON); - - } catch (Exception e) { - e.printStackTrace(); - } - return new JenaResultSetConvenience(rs).getStringListForVariable("subject"); - - } - - public ResultSet dbpediaQuerySKOSConcept(String SKOSconcept,int limit) { - if(limit==0)limit=99999; - // - ResultSet rs = null; - try { - - String query = "SELECT * WHERE { \n " + - "?subject " + - "<http://www.w3.org/2004/02/skos/core#subject> " + - "<" + SKOSconcept + "> \n" + - "} LIMIT "+limit; - SparqlQuery sq = new SparqlQuery(query, se); - String JSON = c.executeSparqlQuery(sq); - //System.out.println(JSON); - rs = SparqlQuery.JSONtoResultSet(JSON); - - } catch (Exception e) { - e.printStackTrace(); - } - - return rs; - } - - public ResultSet getClassesForInstance(String instance) { - ResultSet rs = null; - try { - - String query = "SELECT ?subject WHERE { \n " + - "<" + instance + ">"+ - " a " + - "?subject " + - "\n" + - "} LIMIT 200"; - SparqlQuery sq = new SparqlQuery(query, se); - //System.out.println(query); - String JSON = c.executeSparqlQuery(sq); - //System.out.println(JSON); - rs = SparqlQuery.JSONtoResultSet(JSON); - - } catch (Exception e) { - e.printStackTrace(); - } - - return rs; - } - - public SortedSet<String> getPosExamples() { - return posExamples; - } - - public SortedSet<String> getNegExamples() { - return negExamples; - } - - - /** - * NOT WORKING - * @param description - */ - public void getSubClasses(String description) { - ResultSet rs = null; - try { - String query = SparqlQueryDescriptionConvertVisitor - .getSparqlSubclassQuery(description.replace("\"", "")); - - rs = new SparqlQuery(query, se).send(); - System.out.println(query); - //System.out.println(SparqlQuery.getAsXMLString(rs)); - System.out.println(rs.getResultVars()); - SortedSet<String> remainingClasses = new JenaResultSetConvenience(rs).getStringListForVariable("subject"); - SortedSet<String> alreadyQueried = new TreeSet<String>(); - alreadyQueried.add(description); - while (remainingClasses.size()!=0){ - String tmp = remainingClasses.first(); - remainingClasses.remove(tmp); - query = SparqlQueryDescriptionConvertVisitor - .getSparqlSubclassQuery(tmp); - alreadyQueried.add(tmp); - rs = new SparqlQuery(query, se).send(); - remainingClasses.addAll(new JenaResultSetConvenience(rs).getStringListForVariable("subject")); - } - //System.out.println(JSON); - System.out.println(alreadyQueried); - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - - -} Deleted: trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSPARQL.java 2008-05-19 10:20:14 UTC (rev 897) +++ trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSPARQL.java 2008-05-19 10:26:10 UTC (rev 898) @@ -1,381 +0,0 @@ -package org.dllearner.utilities; - -import java.util.SortedSet; -import java.util.TreeSet; - -import org.apache.log4j.Logger; -import org.dllearner.core.ComponentManager; -import org.dllearner.kb.sparql.Cache; -import org.dllearner.kb.sparql.SparqlEndpoint; -import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; - -import com.hp.hpl.jena.query.ResultSet; - -public class AutomaticExampleFinderSPARQL { - - private static Logger logger = Logger - .getLogger(ComponentManager.class); - - private Cache c; - private SparqlEndpoint se; - private SortedSet<String> posExamples; - private SortedSet<String> negExamples; - public SortedSet<String> totalSKOSset; - private int limit=1000; - - - public AutomaticExampleFinderSPARQL(SparqlEndpoint se){ - this.c=new Cache("cachetemp"); - this.se=se; - posExamples = new TreeSet<String>(); - negExamples = new TreeSet<String>(); - } - - public void initDBpedia(String concept, boolean useRelated, boolean useSuperclasses,boolean useParallelClasses, int poslimit, int neglimit) { - dbpediaMakePositiveExamplesFromConcept( concept); - SortedSet<String> keepForClean = new TreeSet<String>(); - keepForClean.addAll(this.posExamples); - - this.posExamples = SetManipulation.fuzzyShrink(this.posExamples, poslimit); - - - logger.trace("shrinking: pos Example size: "+posExamples.size()); - - if(useRelated) { - dbpediaMakeNegativeExamplesFromRelatedInstances(this.posExamples); - } - if(useSuperclasses) { - makeNegativeExamplesFromSuperClasses(concept); - } - if(useParallelClasses) { - makeNegativeExamplesFromClassesOfInstances(); - } - //clean - negExamples.removeAll(keepForClean); - logger.trace("neg Example size after cleaning: "+negExamples.size()); - this.negExamples = SetManipulation.fuzzyShrink(negExamples, neglimit); - logger.debug("pos Example size after shrinking: "+posExamples.size()); - logger.debug("neg Example size after shrinking: "+negExamples.size()); - logger.debug("Finished examples for concept: "+concept); - } - - public void init(String concept, String namespace, boolean useRelated, boolean useSuperclasses,boolean useParallelClasses, int poslimit, int neglimit) { - makePositiveExamplesFromConcept( concept); - SortedSet<String> keepForClean = new TreeSet<String>(); - keepForClean.addAll(this.posExamples); - this.posExamples = SetManipulation.fuzzyShrink(this.posExamples, poslimit); - logger.trace("shrinking: pos Example size: "+posExamples.size()); - - if(useRelated) { - makeNegativeExamplesFromRelatedInstances(this.posExamples,namespace); - } - if(useSuperclasses) { - makeNegativeExamplesFromSuperClasses(concept); - } - if(useParallelClasses) { - makeNegativeExamplesFromClassesOfInstances(); - } - //clean - negExamples.removeAll(keepForClean); - logger.trace("neg Example size after cleaning: "+negExamples.size()); - this.negExamples = SetManipulation.fuzzyShrink(negExamples, neglimit); - logger.debug("pos Example size after shrinking: "+posExamples.size()); - logger.debug("neg Example size after shrinking: "+negExamples.size()); - logger.debug("Finished examples for concept: "+concept); - } - - - - public SortedSet<String> dbpediaGetPosOnly(String concept, int limit){ - dbpediaMakePositiveExamplesFromConcept( concept); - return SetManipulation.fuzzyShrink(this.posExamples, limit); - } - - public SortedSet<String> getPosOnly(String concept, int limit){ - makePositiveExamplesFromConcept( concept); - return SetManipulation.fuzzyShrink(this.posExamples, limit); - } - - private void dbpediaMakePositiveExamplesFromConcept(String concept){ - logger.debug("making Positive Examples from Concept: "+concept); - if(concept.contains("http://dbpedia.org/resource/Category:")) { - this.posExamples = new JenaResultSetConvenience(dbpediaQuerySKOSConcept(concept,limit)) - .getStringListForVariable("subject"); - }else { - this.posExamples = new JenaResultSetConvenience(queryConcept(concept,limit)) - .getStringListForVariable("subject"); - } - logger.debug(" pos Example size: "+posExamples.size()); - } - - private void makePositiveExamplesFromConcept(String concept){ - logger.debug("making Positive Examples from Concept: "+concept); - this.posExamples = new JenaResultSetConvenience(queryConcept(concept,0)) - .getStringListForVariable("subject"); - logger.debug(" pos Example size: "+posExamples.size()); - } - - - - /*private void makePositiveExamplesFromConcept(String concept){ - logger.debug("making Positive Examples from Concept: "+concept); - if(concept.contains("http://dbpedia.org/resource/Category:")) { - this.posExamples = new JenaResultSetConvenience(querySKOSConcept(concept,0)) - .getStringListForVariable("subject"); - }else { - this.posExamples = new JenaResultSetConvenience(queryConcept(concept,0)) - .getStringListForVariable("subject"); - } - logger.debug(" pos Example size: "+posExamples.size()); - }*/ - - - - - - private void dbpediaMakeNegativeExamplesFromRelatedInstances(SortedSet<String> subject) { - logger.debug("making examples from related instances"); - for (String string : subject) { - dbpediaMakeNegativeExamplesFromRelatedInstances(string); - } - logger.debug(" negExample size: "+negExamples.size()); - } - - private void makeNegativeExamplesFromRelatedInstances(SortedSet<String> subject, String namespace) { - logger.debug("making examples from related instances"); - for (String string : subject) { - makeNegativeExamplesFromRelatedInstances(string,namespace); - } - logger.debug(" negExample size: "+negExamples.size()); - } - - - /** - * - * @param subject - * @return - */ - private void dbpediaMakeNegativeExamplesFromRelatedInstances(String subject) { - // SortedSet<String> result = new TreeSet<String>(); - - String query = "SELECT * WHERE { \n" + "<" + subject + "> " + "?p ?o. \n" - + "FILTER (REGEX(str(?o), 'http://dbpedia.org/resource/')).\n" - + "FILTER (!REGEX(str(?p), 'http://www.w3.org/2004/02/skos'))\n" - + "}"; - - String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); - JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); - this.negExamples.addAll(rsc.getStringListForVariable("o")); - - - } - - private void makeNegativeExamplesFromRelatedInstances(String subject, String namespace) { - // SortedSet<String> result = new TreeSet<String>(); - - String query = "SELECT * WHERE { \n" + "<" + subject + "> " + "?p ?o. \n" - + "FILTER (REGEX(str(?o), '"+namespace+"')).\n" - + "}"; - - String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); - JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); - this.negExamples.addAll(rsc.getStringListForVariable("o")); - - - } - - - private void makeNegativeExamplesFromSuperClasses(String concept) { - - SortedSet<String> superClasses = new TreeSet<String>(); - superClasses.add(concept.replace("\"", "")); - //logger.debug("before"+superClasses); - superClasses = getSuperClasses( superClasses, 4); - logger.debug("making neg Examples from "+superClasses.size()+" superclasses"); - JenaResultSetConvenience rsc; - for (String oneSuperClass : superClasses) { - logger.debug(oneSuperClass); - rsc = new JenaResultSetConvenience(queryConcept("\""+oneSuperClass+"\"", limit)); - this.negExamples.addAll(rsc.getStringListForVariable("subject")); - } - logger.debug(" neg Example size: "+negExamples.size()); - } - - - - private void makeNegativeExamplesFromClassesOfInstances() { - logger.debug("making neg Examples from parallel classes"); - SortedSet<String> classes = new TreeSet<String>(); - //superClasses.add(concept.replace("\"", "")); - //logger.debug("before"+superClasses); - //superClasses = dbpediaGetSuperClasses( superClasses, 4); - //logger.debug("getting negExamples from "+superClasses.size()+" superclasses"); - JenaResultSetConvenience rsc; - ResultSet rs=null; - for (String instance : posExamples) { - //System.out.println(instance); - rs = getClassesForInstance(instance); - //System.out.println(ResultSetFormatter.asXMLString(rs)); - rsc = new JenaResultSetConvenience(rs); - classes.addAll(rsc.getStringListForVariable("subject")); - //System.out.println(classes); - } - logger.debug("getting negExamples from "+classes.size()+" parallel classes"); - for (String oneClass : classes) { - logger.debug(oneClass); - rsc = new JenaResultSetConvenience(queryConcept("\""+oneClass+"\"",limit)); - this.negExamples.addAll(rsc.getStringListForVariable("subject")); - } - logger.debug("neg Example size: "+negExamples.size()); - - } - - private SortedSet<String> getSuperClasses(SortedSet<String> superClasses, int depth) { - SortedSet<String> ret = new TreeSet<String>(); - SortedSet<String> tmpset = new TreeSet<String>(); - ret.addAll(superClasses); - //logger.debug(superClasses); - JenaResultSetConvenience rsc; - - String query = ""; - for (; depth != 0 ; depth--) { - for (String oneSuperClass : superClasses) { - - //tmp = oneSuperClass.replace("\"", ""); - query = "SELECT * WHERE { \n" + "<" + oneSuperClass + "> " - + "<http://www.w3.org/2000/01/rdf-schema#subClassOf> ?superclass. \n" - + "}"; - - String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); - rsc = new JenaResultSetConvenience(rs); - tmpset.addAll(rsc.getStringListForVariable("superclass")); - - } - ret.addAll(tmpset); - //logger.debug(ret); - superClasses.clear(); - superClasses.addAll(tmpset); - tmpset.clear(); - } - //logger.debug(concept); - //logger.debug(query); - return ret; - } - - - - public ResultSet queryConcept(String concept,int limit) { - ResultSet rs = null; - try { - String query = SparqlQueryDescriptionConvertVisitor - .getSparqlQuery(concept,limit); - - SparqlQuery sq = new SparqlQuery(query, se); - String JSON = c.executeSparqlQuery(sq); - //System.out.println("JSON:\n"+JSON); - rs = SparqlQuery.JSONtoResultSet(JSON); - - } catch (Exception e) { - e.printStackTrace(); - } - - return rs; - } - - public ResultSet dbpediaQuerySKOSConcept(String SKOSconcept,int limit) { - if(limit==0)limit=99999; - // - ResultSet rs = null; - try { - - String query = "SELECT * WHERE { \n " + - "?subject " + - "<http://www.w3.org/2004/02/skos/core#subject> " + - "<" + SKOSconcept + "> \n" + - "} LIMIT "+limit; - SparqlQuery sq = new SparqlQuery(query, se); - String JSON = c.executeSparqlQuery(sq); - //System.out.println(JSON); - rs = SparqlQuery.JSONtoResultSet(JSON); - - } catch (Exception e) { - e.printStackTrace(); - } - - return rs; - } - - public ResultSet getClassesForInstance(String instance) { - ResultSet rs = null; - try { - - String query = "SELECT ?subject WHERE { \n " + - "<" + instance + ">"+ - " a " + - "?subject " + - "\n" + - "} LIMIT "+limit; - SparqlQuery sq = new SparqlQuery(query, se); - //System.out.println(query); - String JSON = c.executeSparqlQuery(sq); - //System.out.println(JSON); - rs = SparqlQuery.JSONtoResultSet(JSON); - - } catch (Exception e) { - e.printStackTrace(); - } - - return rs; - } - - public SortedSet<String> getPosExamples() { - return posExamples; - } - - public SortedSet<String> getNegExamples() { - return negExamples; - } - - - /** - * NOT WORKING - * @param description - */ - public void getSubClasses(String description) { - ResultSet rs = null; - try { - String query = SparqlQueryDescriptionConvertVisitor - .getSparqlSubclassQuery(description.replace("\"", "")); - - rs = new ... [truncated message content] |
From: <ku...@us...> - 2008-05-19 10:20:26
|
Revision: 897 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=897&view=rev Author: kurzum Date: 2008-05-19 03:20:14 -0700 (Mon, 19 May 2008) Log Message: ----------- new extraction structure (will be modified a little bit more later on) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java trunk/src/dl-learner/org/dllearner/test/JenaQueryToResultSpeedTest.java trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderRolesSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSPARQL.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/kb/extraction/ trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryInterface.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryType.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQueryClasses.java trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQueryInterface.java trunk/src/dl-learner/org/dllearner/kb/sparql/configuration/ trunk/src/dl-learner/org/dllearner/kb/sparql/datastructure/ Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-19 10:14:48 UTC (rev 896) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-19 10:20:14 UTC (rev 897) @@ -70,8 +70,8 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; +import org.dllearner.kb.extraction.TypedSparqlQuery; import org.dllearner.kb.sparql.SparqlKnowledgeSource; -import org.dllearner.kb.sparql.TypedSparqlQuery; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/datastructure/ClassNode.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,115 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.net.URI; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.Vector; + +import org.dllearner.utilities.StringTuple; + +/** + * Is a node in the graph, that is a class. + * + * @author Sebastian Hellmann + */ +public class ClassNode extends Node { + Set<PropertyNode> properties = new HashSet<PropertyNode>(); + + public ClassNode(URI u) { + super(u); + } + + // expands all directly connected nodes + @Override + public Vector<Node> expand(TypedSparqlQueryInterface tsq, Manipulator m) { + + Set<StringTuple> s = tsq.getTupelForResource(this.uri); + // see manipulator + s = m.check(s, this); + Vector<Node> Nodes = new Vector<Node>(); + Iterator<StringTuple> it = s.iterator(); + while (it.hasNext()) { + StringTuple t = (StringTuple) it.next(); + try { + // substitute rdf:type with owl:subclassof + if (t.a.equals(m.type) || t.a.equals(m.subclass)) { + ClassNode tmp = new ClassNode(new URI(t.b)); + properties.add(new PropertyNode(new URI(m.subclass), this, + tmp)); + Nodes.add(tmp); + } else { + // further expansion stops here + // Nodes.add(tmp); is missing on purpose + ClassNode tmp = new ClassNode(new URI(t.b)); + properties.add(new PropertyNode(new URI(t.a), this, tmp)); + // System.out.println(m.blankNodeIdentifier); + // System.out.println("XXXXX"+t.b); + + // if o is a blank node expand further + // TODO this needs a lot more work + if (t.b.startsWith(m.blankNodeIdentifier)) { + tmp.expand(tsq, m); + System.out.println(m.blankNodeIdentifier); + System.out.println("XXXXX" + t.b); + } + // Nodes.add(tmp); + } + } catch (Exception e) { + System.out.println(t); + e.printStackTrace(); + } + + } + return Nodes; + } + + // gets the types for properties recursively + @Override + public void expandProperties(TypedSparqlQueryInterface tsq, Manipulator m) { + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.kb.sparql.datastructure.Node#toNTriple() + */ + @Override + public Set<String> toNTriple() { + Set<String> s = new HashSet<String>(); + s.add("<" + this.uri + "><" + rdftype + "><" + classns + ">."); + + for (PropertyNode one : properties) { + s.add("<" + this.uri + "><" + one.getURI() + "><" + + one.getB().getURI() + ">."); + s.addAll(one.getB().toNTriple()); + } + + return s; + } + + @Override + public int compareTo(Node n) { + return super.compareTo(n); + } + +} Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/configuration/Configuration.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,99 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.kb.sparql.SparqlQueryType; + +/** + * Stores all configuration settings. this class collects all configuration + * information see the other classes, which are used as attributes here + * + * @author Sebastian Hellmann + */ +public class Configuration { + + private SparqlEndpoint endpoint; + private SparqlQueryType sparqlQueryType; + private Manipulator manipulator; + // the following needs to be moved to + // class extraction algorithm or manipulator + private int recursiondepth; + private boolean getAllSuperClasses = true; + private boolean closeAfterRecursion = true; + public int numberOfUncachedSparqlQueries = 0; + public int numberOfCachedSparqlQueries = 0; + public String cacheDir="cache"; + + public Configuration(SparqlEndpoint specificSparqlEndpoint, + SparqlQueryType sparqlQueryType, Manipulator manipulator, + int recursiondepth, boolean getAllSuperClasses, + boolean closeAfterRecursion, String cacheDir) { + this.endpoint = specificSparqlEndpoint; + this.sparqlQueryType = sparqlQueryType; + this.manipulator = manipulator; + this.recursiondepth = recursiondepth; + this.getAllSuperClasses = getAllSuperClasses; + this.closeAfterRecursion = closeAfterRecursion; + this.cacheDir=cacheDir; + + } + + public Configuration changeQueryType(SparqlQueryType sqt) { + // TODO must clone here + return new Configuration(this.endpoint, sqt, this.manipulator, + this.recursiondepth, this.getAllSuperClasses, + this.closeAfterRecursion, this.cacheDir); + + } + + public Manipulator getManipulator() { + return this.manipulator; + } + + public SparqlEndpoint getSparqlEndpoint() { + return endpoint; + } + + public SparqlQueryType getSparqlQueryType() { + return sparqlQueryType; + } + + public boolean isGetAllSuperClasses() { + return getAllSuperClasses; + } + + public boolean isCloseAfterRecursion() { + return closeAfterRecursion; + } + + public int getRecursiondepth() { + return recursiondepth; + } + + public void increaseNumberOfuncachedSparqlQueries() { + numberOfUncachedSparqlQueries++; + } + + public void increaseNumberOfCachedSparqlQueries() { + numberOfCachedSparqlQueries++; + } + +} Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,177 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.net.URI; +import java.util.HashSet; +import java.util.Vector; + +import org.apache.log4j.Logger; +import org.dllearner.core.KnowledgeSource; + +/** + * This class is used to extract the information . + * + * @author Sebastian Hellmann + */ +public class ExtractionAlgorithm { + + private Configuration configuration; + private Manipulator manipulator; + private int recursionDepth = 1; + // private boolean getAllSuperClasses = true; + // private boolean closeAfterRecursion = true; + private static Logger logger = Logger + .getLogger(KnowledgeSource.class); + + public ExtractionAlgorithm(Configuration Configuration) { + this.configuration = Configuration; + this.manipulator = Configuration.getManipulator(); + this.recursionDepth = Configuration.getRecursiondepth(); + // this.getAllSuperClasses = Configuration.isGetAllSuperClasses(); + // this.closeAfterRecursion=Configuration.isCloseAfterRecursion(); + } + + public Node getFirstNode(URI u) { + return new InstanceNode(u); + } + + public Vector<Node> expandAll(URI[] u, TypedSparqlQuery tsp) { + Vector<Node> v = new Vector<Node>(); + for (URI one : u) { + v.add(expandNode(one, tsp)); + } + return v; + } + + /** + * most important function expands one example cave: the recursion is not a + * recursion anymore, it was transformed to an iteration + * + * @param uri + * @param typedSparqlQuery + * @return + */ + public Node expandNode(URI uri, TypedSparqlQuery typedSparqlQuery) { + //System.out.println(uri.toString()); + //System.out.println(manipulator); + //System.out.println(this.configuration); + long time = System.currentTimeMillis(); + Node n = getFirstNode(uri); + System.out.println(n); + Vector<Node> v = new Vector<Node>(); + v.add(n); + logger.info("StartVector: " + v); + // n.expand(tsp, this.Manipulator); + // Vector<Node> second= + for (int x = 1; x <= recursionDepth; x++) { + + Vector<Node> tmp = new Vector<Node>(); + while (v.size() > 0) { + Node tmpNode = v.remove(0); + logger.info("Expanding " + tmpNode); + // System.out.println(this.Manipulator); + // these are the new not expanded nodes + // the others are saved in connection with the original node + Vector<Node> tmpVec = tmpNode.expand(typedSparqlQuery, + manipulator); + //System.out.println(tmpVec); + tmp.addAll(tmpVec); + } + v = tmp; + logger.info("Recursion counter: " + x + " with " + v.size() + + " Nodes remaining, needed: " + + (System.currentTimeMillis() - time) + "ms"); + time = System.currentTimeMillis(); + } + + HashSet<String> hadAlready = new HashSet<String>(); + + //p(configuration.toString()); + // gets All Class Nodes and expands them further + if (this.configuration.isGetAllSuperClasses()) { + logger.info("Get all superclasses"); + // Set<Node> classes = new TreeSet<Node>(); + Vector<Node> classes = new Vector<Node>(); + + Vector<Node> instances = new Vector<Node>(); + for (Node one : v) { + if (one instanceof ClassNode) { + classes.add(one); + } + if (one instanceof InstanceNode) { + instances.add(one); + } + + } + // System.out.println(instances.size()); + TypedSparqlQueryClasses tsqc = new TypedSparqlQueryClasses( + configuration); + if (this.configuration.isCloseAfterRecursion()) { + while (instances.size() > 0) { + logger.trace("Getting classes for remaining instances: " + + instances.size()); + Node next = instances.remove(0); + logger.trace("Getting classes for: " + next); + classes.addAll(next.expand(tsqc, manipulator)); + if (classes.size() >= manipulator.breakSuperClassRetrievalAfter) { + break; + } + } + } + Vector<Node> tmp = new Vector<Node>(); + int i = 0; + while (classes.size() > 0) { + logger.trace("Remaining classes: " + classes.size()); + // Iterator<Node> it=classes.iterator(); + // Node next =(Node) it.next(); + // classes.remove(next); + Node next = classes.remove(0); + + if (!hadAlready.contains(next.getURI().toString())) { + logger.trace("Getting SuperClass for: " + next); + // System.out.println(hadAlready.size()); + hadAlready.add(next.getURI().toString()); + tmp = next.expand(typedSparqlQuery, manipulator); + classes.addAll(tmp); + tmp = new Vector<Node>(); + // if(i % 50==0)System.out.println("got "+i+" extra classes, + // max: "+manipulator.breakSuperClassRetrievalAfter); + i++; + if (i >= manipulator.breakSuperClassRetrievalAfter) { + break; + } + } + // System.out.println("Skipping"); + + // if + // (classes.size()>=manipulator.breakSuperClassRetrievalAfter){break;} + + } + // System.out.println((System.currentTimeMillis()-time)+""); + + } + return n; + + } + + + +} Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/datastructure/InstanceNode.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,120 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.net.URI; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.Vector; + +import org.dllearner.utilities.StringTuple; + +/** + * A node in the graph that is an instance. + * + * @author Sebastian Hellmann + * + */ +public class InstanceNode extends Node { + + Set<ClassNode> classes = new HashSet<ClassNode>(); + Set<StringTuple> datatypes = new HashSet<StringTuple>(); + Set<PropertyNode> properties = new HashSet<PropertyNode>(); + + public InstanceNode(URI u) { + super(u); + // this.type = "instance"; + + } + + // expands all directly connected nodes + @Override + public Vector<Node> expand(TypedSparqlQueryInterface tsq, Manipulator m) { + + Set<StringTuple> s = tsq.getTupelForResource(uri); + // see Manipulator + m.check(s, this); + // System.out.println("fffffff"+m); + Vector<Node> Nodes = new Vector<Node>(); + + Iterator<StringTuple> it = s.iterator(); + while (it.hasNext()) { + StringTuple t = (StringTuple) it.next(); + //RBC + if(!t.b.startsWith("http:"))continue; + + // basically : if p is rdf:type then o is a class + // else it is an instance + try { + if (t.a.equals(m.type)) { + ClassNode tmp = new ClassNode(new URI(t.b)); + classes.add(tmp); + Nodes.add(tmp); + } else { + InstanceNode tmp = new InstanceNode(new URI(t.b)); + properties.add(new PropertyNode(new URI(t.a), this, tmp)); + Nodes.add(tmp); + + } + } catch (Exception e) { + System.out.println("Problem with: " + t); + e.printStackTrace(); + } + + } + expanded = true; + return Nodes; + } + + // gets the types for properties recursively + @Override + public void expandProperties(TypedSparqlQueryInterface tsq, Manipulator m) { + for (PropertyNode one : properties) { + one.expandProperties(tsq, m); + } + + } + + @Override + public Set<String> toNTriple() { + Set<String> s = new HashSet<String>(); + s.add("<" + uri + "><" + rdftype + "><" + thing + ">."); + for (ClassNode one : classes) { + s.add("<" + uri + "><" + rdftype + "><" + one.getURI() + ">."); + s.addAll(one.toNTriple()); + } + for (PropertyNode one : properties) { + s.add("<" + uri + "><" + one.getURI() + "><" + one.getB().getURI() + + ">."); + s.addAll(one.toNTriple()); + s.addAll(one.getB().toNTriple()); + } + + return s; + } + + @Override + public int compareTo(Node n) { + return super.compareTo(n); + // + } + +} Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,155 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.net.URI; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.apache.log4j.Logger; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.kb.sparql.SparqlQueryType; +import org.dllearner.utilities.Statistics; + +/** + * An object of this class encapsulates everything. + * + * @author Sebastian Hellmann + * + */ +public class Manager { + + private Configuration configuration; + private TypedSparqlQuery typedSparqlQuery; + private ExtractionAlgorithm extractionAlgorithm; + + private static Logger logger = Logger + .getLogger(KnowledgeSource.class); + + + public void useConfiguration(SparqlQueryType SparqlQueryType, + SparqlEndpoint SparqlEndpoint, Manipulator manipulator, + int recursiondepth, boolean getAllSuperClasses, + boolean closeAfterRecursion, String cacheDir) { + + this.configuration = new Configuration(SparqlEndpoint, SparqlQueryType, + manipulator, recursiondepth, getAllSuperClasses, + closeAfterRecursion, cacheDir); + //System.out.println(this.configuration); + this.typedSparqlQuery = new TypedSparqlQuery(configuration); + this.extractionAlgorithm = new ExtractionAlgorithm(configuration); + + } + + public String extract(URI uri) { + // this.TypedSparqlQuery.query(uri); + // System.out.println(ExtractionAlgorithm.getFirstNode(uri)); + System.out.println("Start extracting"); + + Node n = extractionAlgorithm.expandNode(uri, typedSparqlQuery); + Set<String> s = n.toNTriple(); + String nt = ""; + for (String str : s) { + nt += str + "\n"; + } + return nt; + } + + public String extract(Set<String> instances) { + // this.TypedSparqlQuery.query(uri); + // System.out.println(ExtractionAlgorithm.getFirstNode(uri)); + System.out.println("Start extracting"); + SortedSet<String> ret = new TreeSet<String>(); + int progress=0; + for (String one : instances) { + progress++; + logger.info("Progress: "+progress+" of "+instances.size()+" finished"); + try { + Node n = extractionAlgorithm.expandNode(new URI(one), + typedSparqlQuery); + ret.addAll(n.toNTriple()); + } catch (Exception e) { + e.printStackTrace(); + } + } + System.out.println("Finished extracting, start conversion"); + StringBuffer nt = new StringBuffer(); + Object[] arr = ret.toArray(); + for (int i = 0; i < arr.length; i++) { + nt.append((String) arr[i] + "\n"); + if (i % 1000 == 0) + System.out.println(i + " of " + arr.length + " triples done"); + } + System.out.println(arr.length + " of " + arr.length + " triples done"); + /* + * String tmp=""; while ( ret.size() > 0) { tmp=ret.first(); nt+=tmp; + * ret.remove(tmp); System.out.println(ret.size()); } /*for (String str : + * ret) { nt += str + "\n"; } + */ + Statistics.addTriples(ret.size()); + return nt.toString(); + } + + public void addPredicateFilter(String str) { + this.configuration.getSparqlQueryType().addPredicateFilter(str); + + } + + public Configuration getConfiguration() { + return configuration; + } + + /* + * public void calculateSubjects(String label, int limit) { + * System.out.println("SparqlModul: Collecting Subjects"); + * oldSparqlOntologyCollector oc = new oldSparqlOntologyCollector(url); try { + * subjects = oc.getSubjectsFromLabel(label, limit); } catch (IOException e) { + * subjects = new String[1]; subjects[0] = "[Error]Sparql Endpoint could not + * be reached."; } System.out.println("SparqlModul: ****Finished"); } + * + * /** TODO SparqlOntologyCollector needs to be removed @param subject + */ + /* + * public void calculateTriples(String subject) { + * System.out.println("SparqlModul: Collecting Triples"); + * oldSparqlOntologyCollector oc = new oldSparqlOntologyCollector(url); try { + * triples = oc.collectTriples(subject); } catch (IOException e) { triples = + * new String[1]; triples[0] = "[Error]Sparql Endpoint could not be + * reached."; } System.out.println("SparqlModul: ****Finished"); } + */ + /** + * TODO SparqlOntologyCollector needs to be removed + * + * @param concept + */ + + /* + * public void calculateConceptSubjects(String concept) { + * System.out.println("SparqlModul: Collecting Subjects"); + * oldSparqlOntologyCollector oc = new oldSparqlOntologyCollector(url); try { + * conceptSubjects = oc.getSubjectsFromConcept(concept); } catch + * (IOException e) { conceptSubjects = new String[1]; conceptSubjects[0] = + * "[Error]Sparql Endpoint could not be reached."; } + * System.out.println("SparqlModul: ****Finished"); } + */ + +} \ No newline at end of file Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Manipulator.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,163 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Set; + +import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.utilities.JenaResultSetConvenience; +import org.dllearner.utilities.StringTuple; + +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.ResultSetFormatter; + +/** + * Used to manipulate retrieved tupels, identify blanknodes, etc. + * + * @author Sebastian Hellmann + * + */ +public class Manipulator { + public final String subclass = "http://www.w3.org/2000/01/rdf-schema#subClassOf"; + public final String type = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; + final String objectProperty = "http://www.w3.org/2002/07/owl#ObjectProperty"; + final String classns = "http://www.w3.org/2002/07/owl#Class"; + final String thing = "http://www.w3.org/2002/07/owl#Thing"; + + public String blankNodeIdentifier = "bnode"; + public int breakSuperClassRetrievalAfter = 200; + public LinkedList<StringTuple> replacePredicate; + public LinkedList<StringTuple> replaceObject; + + // Set<String> classproperties; + + public Manipulator(String blankNodeIdentifier, + int breakSuperClassRetrievalAfter, + LinkedList<StringTuple> replacePredicate, + LinkedList<StringTuple> replaceObject) { + this.blankNodeIdentifier = blankNodeIdentifier; + this.replaceObject = replaceObject; + this.replacePredicate = replacePredicate; + this.breakSuperClassRetrievalAfter = breakSuperClassRetrievalAfter; + // Set<String> classproperties = new HashSet<String>(); + // classproperties.add(subclass); + + } + + /** + * this checks for consistency and manipulates the tuples, before they get + * triple + * + * @param tuples + * tuples for the node + * @param node + * @return + */ + public Set<StringTuple> check(Set<StringTuple> tuples, Node node) { + Set<StringTuple> toRemove = new HashSet<StringTuple>(); + Iterator<StringTuple> it = tuples.iterator(); + while (it.hasNext()) { + StringTuple t = (StringTuple) it.next(); + + //HACK +// if(t.a.equals("http://www.holygoat.co.uk/owl/redwood/0.1/tags/taggedWithTag")) { +// //hackGetLabel(t.b); +// +// } + + // GovTrack hack + // => we convert a string literal to a URI + // => TODO: introduce an option for converting literals for certain + // properties into URIs +// String sp = "http://purl.org/dc/elements/1.1/subject"; +// if(t.a.equals(sp)) { +// System.out.println(t); +// System.exit(0); +// } + + replacePredicate(t); + replaceObject(t); + + + // remove <rdf:type, owl:class> + // this is done to avoid transformation to owl:subclassof + if (t.a.equals(type) && t.b.equals(classns) + && node instanceof ClassNode) { + toRemove.add(t); + } + + // all with type class + if (t.b.equals(classns) && node instanceof ClassNode) { + toRemove.add(t); + } + + // remove all instances with owl:type thing + if (t.a.equals(type) && t.b.equals(thing) + && node instanceof InstanceNode) { + toRemove.add(t); + } + + } + tuples.removeAll(toRemove); + + return tuples; + } + + private void replacePredicate(StringTuple t) { + for (StringTuple rep : replacePredicate) { + if (rep.a.equals(t.a)) { + t.a = rep.b; + } + } + } + + private void replaceObject(StringTuple t) { + for (StringTuple rep : replaceObject) { + if (rep.a.equals(t.a)) { + t.a = rep.b; + } + } + } + + //HACK + private String hackGetLabel(String resname){ + String query="" + + "SELECT ?o \n" + + "WHERE { \n" + + "<"+resname+"> "+ " <http://www.holygoat.co.uk/owl/redwood/0.1/tags/tagName> ?o " + + "}"; + + System.out.println(query); + //http://dbtune.org/musicbrainz/sparql?query= + //SELECT ?o WHERE { <http://dbtune.org/musicbrainz/resource/tag/1391> <http://www.holygoat.co.uk/owl/redwood/0.1/tags/tagName> ?o } + SparqlQuery s=new SparqlQuery(query,SparqlEndpoint.EndpointMusicbrainz()); + ResultSet rs=s.send(); + while (rs.hasNext()){ + rs.nextBinding(); + } + //System.out.println("AAA"+s.getAsXMLString(s.send()) ); + return ""; + } + +} Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/datastructure/Node.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,98 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.net.URI; +import java.util.Set; +import java.util.Vector; + + +/** + * Abstract class. defines functions to expand the nodes + * + * @author Sebastian Hellmann + * + */ +public abstract class Node implements Comparable<Node> { + + final String subclass = "http://www.w3.org/2000/01/rdf-schema#subClassOf"; + final String rdftype = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; + final String objectProperty = "http://www.w3.org/2002/07/owl#ObjectProperty"; + final String classns = "http://www.w3.org/2002/07/owl#Class"; + final String thing = "http://www.w3.org/2002/07/owl#Thing"; + + URI uri; + // protected String type; + protected boolean expanded = false; + + public Node(URI u) { + this.uri = u; + } + + /** + * Nodes are expanded with a certain context, given by the typedSparqlQuery + * and the manipulator + * + * @param typedSparqlQuery + * @param manipulator + * @return Vector<Node> all Nodes that are new because of expansion + */ + public abstract Vector<Node> expand( + TypedSparqlQueryInterface typedSparqlQuery, Manipulator manipulator); + + /** + * gets type defs for properties like rdf:type SymmetricProperties + * + * @param typedSparqlQuery + * @param manipulator + * @return Vector<Node> + */ + public abstract void expandProperties( + TypedSparqlQueryInterface typedSparqlQuery, Manipulator manipulator); + + /** + * output + * + * @return a set of n-triple + */ + public abstract Set<String> toNTriple(); + + @Override + public String toString() { + return "Node: " + uri + ":" + this.getClass().getSimpleName(); + + } + + public URI getURI() { + return uri; + } + + public boolean equals(Node n) { + if (this.uri.equals(n.uri)) + return true; + else + return false; + } + + public int compareTo(Node n) { + return this.uri.toString().compareTo(n.uri.toString()); + } + +} Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/datastructure/PropertyNode.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,119 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.net.URI; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.Vector; + +import org.dllearner.utilities.StringTuple; + +/** + * Property node, has connection to a and b part + * + * @author Sebastian Hellmann + * + */ + +public class PropertyNode extends Node { + + // the a and b part of a property + private Node a; + private Node b; + // specialtypes like owl:symmetricproperty + private Set<String> specialTypes; + + public PropertyNode(URI u, Node a, Node b) { + super(u); + // this.type = "property"; + this.a = a; + this.b = b; + this.specialTypes = new HashSet<String>(); + } + + // Property Nodes are normally not expanded, + // this function is never called + @Override + public Vector<Node> expand(TypedSparqlQueryInterface tsq, Manipulator m) { + return null; + } + + // gets the types for properties recursively + @Override + public void expandProperties(TypedSparqlQueryInterface tsq, Manipulator m) { + b.expandProperties(tsq, m); + Set<StringTuple> s = tsq.getTupelForResource(uri); + + Iterator<StringTuple> it = s.iterator(); + while (it.hasNext()) { + StringTuple t = (StringTuple) it.next(); + try { + if (t.a.equals(m.type)) { + specialTypes.add(t.b); + } + } catch (Exception e) { + System.out.println(t); + e.printStackTrace(); + } + + } + + } + + public Node getA() { + return a; + } + + public Node getB() { + return b; + } + + @Override + public Set<String> toNTriple() { + Set<String> s = new HashSet<String>(); + s.add("<" + uri + "><" + + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + + "http://www.w3.org/2002/07/owl#ObjectProperty" + ">."); + for (String one : specialTypes) { + s.add("<" + uri + "><" + + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + + one + ">."); + + } + + return s; + } + + @Override + public boolean equals(Node n) { + if (this.uri.equals(n.uri)) + return true; + else + return false; + } + + @Override + public int compareTo(Node n) { + return super.compareTo(n); + } + +} Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,249 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.net.URI; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.log4j.Logger; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.kb.sparql.Cache; +import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.kb.sparql.SparqlQueryMaker; +import org.dllearner.utilities.SimpleClock; +import org.dllearner.utilities.StringTuple; + +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.ResultSetFormatter; +import com.hp.hpl.jena.sparql.core.ResultBinding; + +/** + * Can execute different queries. + * + * @author Sebastian Hellmann + * + */ +public class TypedSparqlQuery implements TypedSparqlQueryInterface { + + private static Logger logger = Logger.getLogger(KnowledgeSource.class); + + + boolean print_flag = false; + protected Configuration configuration; + private SparqlQueryMaker sparqlQueryMaker; + Cache cache; + + // boolean debug_no_cache = false;// true means no cache is used + // private SparqlHTTPRequest SparqlHTTPRequest; + // private SparqlQuery sparqlQuery; + // private CachedSparqlQuery cachedSparqlQuery; + + public TypedSparqlQuery(Configuration Configuration) { + this.configuration = Configuration; + this.sparqlQueryMaker = new SparqlQueryMaker(Configuration + .getSparqlQueryType()); + + this.cache = new Cache(configuration.cacheDir); + // this.sparqlQuery=new SparqlQuery(configuration.getSparqlEndpoint()); + // this.cachedSparqlQuery=new + // CachedSparqlQuery(this.sparqlQuery,this.cache); + } + + // standard query get a tupels (p,o) for subject s + /** + * uses a cache and gets the result tuples for a resource u + * + * @param uri + * the resource + * @param sparqlQueryString + * @param a + * the name of the first bound variable for xml parsing, normally + * predicate + * @param b + * the name of the second bound variable for xml parsing, + * normally object + * @return + */ + @SuppressWarnings({"unchecked"}) + public Set<StringTuple> getTupelForResource(URI uri) { + Set<StringTuple> s = new HashSet<StringTuple>(); + + String a = "predicate"; + String b = "object"; + // getQuery + String sparqlQueryString = sparqlQueryMaker + .makeSubjectQueryUsingFilters(uri.toString()); + +// CachedSparqlQuery csq = new CachedSparqlQuery(configuration +// .getSparqlEndpoint(), cache, uri.toString(), sparqlQueryString); + + SparqlQuery query = new SparqlQuery(sparqlQueryString, configuration.getSparqlEndpoint()); + query.extraDebugInfo=uri.toString(); + String JSON = cache.executeSparqlQuery(query); + + ResultSet rs = SparqlQuery.JSONtoResultSet(JSON); + + List<ResultBinding> l = ResultSetFormatter.toList(rs); + + p(l.toString()); + for (ResultBinding resultBinding : l) { + + s.add(new StringTuple(resultBinding.get(a).toString(), + resultBinding.get(b).toString())); + } + return s; + } + + /*@Deprecated + private Set<StringTuple> cachedSparql(URI uri, String sparqlQueryString, + String a, String b) { + return null; + /* + * OLD CODE FOLLOWING keep until Jena is working String FromCache = + * cache.get(u.toString(), sparqlQueryString); if (debug_no_cache) { + * //FromCache = null; } String xml = null; // if not in cache get it + * from EndPoint if (FromCache == null) { + * configuration.increaseNumberOfuncachedSparqlQueries(); // try { xml = + * sendAndReceiveSPARQL(sparqlQueryString); + * + * //} catch (IOException e) {e.printStackTrace();} + * + * p(sparqlQueryString); // System.out.println(xml); if + * (!debug_no_cache) { cache.put(uri.toString(), sparqlQueryString, + * xml); } // System.out.print("\n"); } else { + * configuration.increaseNumberOfCachedSparqlQueries(); xml = FromCache; // + * System.out.println("FROM CACHE"); } + */ + // System.out.println(sparql); + // System.out.println(xml); + // process XML + //} + + /** + * TODO old XML processing, can be removed, once Jena is done + * + * @param xml + * @param a + * @param b + * @return a Set of Tuples <a|b> + */ + @Deprecated + public Set<StringTuple> processResult(String xml, String a, String b) { + + Set<StringTuple> ret = new HashSet<StringTuple>(); + // TODO if result is empty, catch exceptions + String resEnd = "</result>"; + String one = "binding name=\"" + a + "\""; + String two = "binding name=\"" + b + "\""; + String endbinding = "binding"; + String uri = "uri"; + // String uridel = "<uri>"; + String bnode = "<bnode>"; + // String uriend = "</uri>"; + String predtmp = ""; + String objtmp = ""; + // System.out.println(getNextResult(xml)); + String nextResult = ""; + while ((nextResult = getNextResult(xml)) != null) { + // System.out.println(xml.indexOf(resEnd)); + // System.out.println(xml); + if (nextResult.indexOf(bnode) != -1) { + xml = xml.substring(xml.indexOf(resEnd) + resEnd.length()); + continue; + } + // get pred + // predtmp = nextResult.substring(nextResult.indexOf(one) + + // one.length()); + predtmp = getinTag(nextResult, one, endbinding); + predtmp = getinTag(predtmp, uri, uri); + // System.out.println(predtmp); + + // getobj + objtmp = getinTag(nextResult, two, endbinding); + objtmp = getinTag(objtmp, uri, uri); + // System.out.println(objtmp); + + StringTuple st = new StringTuple(predtmp, objtmp); + // System.out.println(st); + ret.add(st); + xml = xml.substring(xml.indexOf(resEnd) + resEnd.length()); + + } + /* + * while (xml.indexOf(one) != -1) { + * + * + * // System.out.println(new Tupel(predtmp,objtmp)); } + */ + + return ret; + + } + + /** + * TODO used by old XML processing, can be removed once Jena is done + * + * @param xml + * @return + */ + @Deprecated + private String getNextResult(String xml) { + String res1 = "<result>"; + String res2 = "</result>"; + if (xml.indexOf(res1) == -1) + return null; + xml = xml.substring(xml.indexOf(res1) + res1.length()); + xml = xml.substring(0, xml.indexOf(res2)); + // System.out.println(xml); + return xml; + } + + /** + * TODO used by old XML processing, can be removed once Jena is done + * + * @param xml + * @param starttag + * @param endtag + * @return + */ + @Deprecated + private String getinTag(String xml, String starttag, String endtag) { + String res1 = "<" + starttag + ">"; + // System.out.println(res1); + String res2 = "</" + endtag + ">"; + if (xml.indexOf(res1) == -1) + return null; + xml = xml.substring(xml.indexOf(res1) + res1.length()); + // System.out.println(xml); + xml = xml.substring(0, xml.indexOf(res2)); + // System.out.println(xml); + + return xml; + } + + public void p(String str) { + if (print_flag) { + System.out.println(str); + } + } + +} Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQueryClasses.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,79 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.net.URI; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.utilities.StringTuple; + +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.ResultSetFormatter; +import com.hp.hpl.jena.sparql.core.ResultBinding; + +/** + * Can execute different queries. + * + * @author Sebastian Hellmann + * + */ +public class TypedSparqlQueryClasses extends TypedSparqlQuery implements + TypedSparqlQueryInterface { + + public TypedSparqlQueryClasses(Configuration configuration) { + super(configuration); + } + + /* + * Special TypedSparqlQuery which returns superclasses of classes + * (non-Javadoc) + * + * @see org.dllearner.kb.sparql.TypedSparqlQuery#getTupelForResource(java.net.URI) + */ + @Override + @SuppressWarnings({"unchecked"}) + public Set<StringTuple> getTupelForResource(URI uri) { + Set<StringTuple> s = new HashSet<StringTuple>(); + String a = "predicate"; + String b = "object"; + // getQuery for all super classes of classes only + String sparqlQueryString = "SELECT ?predicate ?object " + "WHERE {" + + "<" + uri.toString() + "> ?predicate ?object;" + + "a ?object . " + + " FILTER (!regex(str(?object),'http://xmlns.com/foaf/0.1/'))" + + "}"; + + SparqlQuery query = new SparqlQuery(sparqlQueryString, configuration.getSparqlEndpoint()); + query.extraDebugInfo=uri.toString(); + ResultSet rs = SparqlQuery.JSONtoResultSet(cache.executeSparqlQuery(query)); + + List<ResultBinding> l = ResultSetFormatter.toList(rs); + for (ResultBinding resultBinding : l) { + + s.add(new StringTuple(resultBinding.get(a).toString(), + resultBinding.get(b).toString())); + } + return s; + } + +} Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryInterface.java (from rev 895, trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQueryInterface.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryInterface.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryInterface.java 2008-05-19 10:20:14 UTC (rev 897) @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.extraction; + +import java.net.URI; +import java.util.Set; + +import org.dllearner.utilities.StringTuple; + +/** + * + * Typed SPARQL query interface. The typing means that they all have the same + * input and the same output: They are fn: resource -> ( a | b ) where a + * normally is a predicate and b an object + * + * @author Sebastian Hellmann + * + */ +public interface TypedSparqlQueryInterface { + + public Set<StringTuple> getTupelForResource(URI u); +} Deleted: trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java 2008-05-19 10:14:48 UTC (rev 896) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java 2008-05-19 10:20:14 UTC (rev 897) @@ -1,181 +0,0 @@ -/** - * Copyright (C) 2007, Sebastian Hellmann - * - * 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.net.URI; -import java.util.HashSet; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.dllearner.core.KnowledgeSource; -import org.dllearner.kb.sparql.configuration.Configuration; -import org.dllearner.kb.sparql.datastructure.ClassNode; -import org.dllearner.kb.sparql.datastructure.InstanceNode; -import org.dllearner.kb.sparql.datastructure.Node; - -/** - * This class is used to extract the information . - * - * @author Sebastian Hellmann - */ -public class ExtractionAlgorithm { - - private Configuration configuration; - private Manipulator manipulator; - private int recursionDepth = 1; - // private boolean getAllSuperClasses = true; - // private boolean closeAfterRecursion = true; - private static Logger logger = Logger - .getLogger(KnowledgeSource.class); - - public ExtractionAlgorithm(Configuration Configuration) { - this.configuration = Configuration; - this.manipulator = Configuration.getManipulator(); - this.recursionDepth = Configuration.getRecursiondepth(); - // this.getAllSuperClasses = Configuration.isGetAllSuperClasses(); - // this.closeAfterRecursion=Configuration.isCloseAfterRecursion(); - } - - public Node getFirstNode(URI u) { - return new InstanceNode(u); - } - - public Vector<Node> expandAll(URI[] u, TypedSparqlQuery tsp) { - Vector<Node> v = new Vector<Node>(); - for (URI one : u) { - v.add(expandNode(one, tsp)); - } - return v; - } - - /** - * most important function expands one example cave: the recursion is not a - * recursion anymore, it was transformed to an iteration - * - * @param uri - * @param typedSparqlQuery - * @return - */ - public Node expandNode(URI uri, TypedSparqlQuery typedSparqlQuery) { - //System.out.println(uri.toString()); - //System.out.println(manipulator); - //System.out.println(this.configuration); - long time = System.currentTimeMillis(); - Node n = getFirstNode(uri); - System.out.println(n); - Vector<Node> v = new Vector<Node>(); - v.add(n); - logger.info("StartVector: " + v); - // n.expand(tsp, this.Manipulator); - // Vector<Node> second= - for (int x = 1; x <= recursionDepth; x++) { - - Vector<Node> tmp = new Vector<Node>(); - while (v.size() > 0) { - Node tmpNode = v.remove(0); - logger.info("Expanding " + tmpNode); - // System.out.println(this.Manipulator); - // these are the new not expanded nodes - // the others are saved in connection with the original node - Vector<Node> tmpVec = tmpNode.expand(typedSparqlQuery, - manipulator); - //System.out.println(tmpVec); - tmp.addAll(tmpVec); - } - v = tmp; - logger.info("Recursion counter: " + x + " with " + v.size() - + " Nodes remaining, needed: " - + (System.currentTimeMillis() - time) + "ms"); - time = System.currentTimeMillis(); - } - - HashSet<String> hadAlready = new HashSet<String>(); - - //p(configuration.toString()); - // gets All Class Nodes and expands them further - if (this.configuration.isGetAllSuperClasses()) { - logger.info("Get all superclasses"); - // Set<Node> classes = new TreeSet<Node>(); - Vector<Node> classes = new Vector<Node>(); - - Vector<Node> instances = new Vector<Node>(); - for (Node one : v) { - if (one instanceof ClassNode) { - classes.add(one); - } - if (one instanceof InstanceNode) { - instances.add(one); - } - - } - // System.out.println(instances.size()); - TypedSparqlQueryClasses tsqc = new TypedSparqlQueryClasses( - configuration); - if (this.configuration.isCloseAfterRecursion()) { - while (instances.size() > 0) { - logger.trace("Getting classes for remaining instances: " - + instances.size()); - Node next = instances.remove(0); - logger.trace("Getting classes for: " + next); - classes.addAll(next.expand(tsqc, manipulator)); - if (classes.size() >= manipulator.breakSuperClassRetrievalAfter) { - break; - } - } - } - Vector<Node> tmp = new Vector<Node>(); - int i = 0; - while (classes.size() > 0) { - logger.trace("Remaining classes: " + classes.size()); - // Iterator<Node> it=classes.iterator(); - // Node next =(Node) it.next(); - // classes.remove(next); - Node next = classes.remove(0); - - if (!hadAlready.contains(next.getURI().toString())) { - logger.trace("Getting SuperClass for: " + next); - // System.out.println(hadAlready.size()); - hadAlready.add(next.getURI().toString()); - tmp = next.expand(typedSparqlQuery, manipulator); - classes.addAll(tmp); - tmp = new Vector<Node>(); - // if(i % 50==0)System.out.println("got "+i+" extra classes, - // max: "+manipulator.breakSuperClassRetrievalAfter); - i++; - if (i >= manipulator.breakSuperClassRetrievalAfter) { - break; - } - } - // System.out.println("Skipping"); - - // if - // (classes.size()>=manipulator.breakSuperClassRetrievalAfter){break;} - - } - // System.out.println((System.currentTimeMillis()-time)+""); - - } - return n; - - } - - - -} Deleted: trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java 2008-05-19 10:14:48 UTC (rev 896) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java 2008-05-19 10:20:14 UTC (rev 897) @@ -1,157 +0,0 @@ -/** - * Copyright (C) 2007, Sebastian Hellmann - * - * 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.net.URI; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.apache.log4j.Logger; -import org.dllearner.core.KnowledgeSource; -import org.dllearner.kb.sparql.configuration.Configuration; -import org.dllearner.kb.sparql.configuration.SparqlEndpoint; -import org.dllearner.kb.sparql.configuration.SparqlQueryType; -import org.dllearner.kb.sparql.datastructure.Node; -import org.dllearner.utilities.Statistics; - -/** - * An object of this class encapsulates everything. - * - * @author Sebastian Hellmann - * - */ -public class Manager { - - private Configuration configuration; - private TypedSparqlQuery typedSparqlQuery; - private ExtractionAlgorithm extractionAlgorithm; - - private static Logger logger = Logger - .getLogger(KnowledgeSource.class); - - - public void useConfiguration(SparqlQueryType SparqlQueryType, - SparqlEndpoint SparqlEndpoint, Manipulator manipulator, - int recursiondepth, boolean getAllSuperClasses, - boolean closeAfterRecursion, String cacheDir) { - - this.configuration = new Configuration(SparqlEndpoint, SparqlQueryType, - manipulator, recursiondepth, getAllSuperClasses, - closeAfterRecursion, cacheDir); - //System.out.println(this.configuration); - this.typedSparqlQuery = new TypedSparqlQuery(configuration); - this.extractionAlgorithm = new ExtractionAlgorithm(configuration); - - } - - public String extract(URI uri) { - // this.TypedSparqlQuery.query(uri); - // System.out.println(ExtractionAlgorithm.getFirstNode(uri)); - System.out.println("Start extracting"); - - Node n = extractionAlgorithm.expandNode(uri, typedSparqlQuery); - Set<String> s = n.toNTriple(); - String nt = ""; - for (String str : s) { - nt += str + "\n"; - } - return nt; - } - - public String extract(Set<String> instances) { - // this.TypedSparqlQuery.query(uri); - // System.out.println(ExtractionAlgorithm.getFirstNode(uri)); - System.out.println("Start extracting"); - SortedSet<String> ret = new TreeSet<String>(); - int progress=0; - for (String one : instances) { - progress++; - logger.info("Progress: "+progress+" of "+instances.size()+" finished"); - try { - Node n = extractionAlgorithm.expandNode(new URI(one), - typedSparqlQuery); - ret.addAll(n.toNTriple()); - } catch (Exc... [truncated message content] |
From: <ku...@us...> - 2008-05-19 10:14:54
|
Revision: 896 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=896&view=rev Author: kurzum Date: 2008-05-19 03:14:48 -0700 (Mon, 19 May 2008) Log Message: ----------- commit before cleanup Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-17 05:20:45 UTC (rev 895) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-19 10:14:48 UTC (rev 896) @@ -387,7 +387,7 @@ //HACK @Override - public SortedSet<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ + public List<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ return this.algorithm.getBestSolutionsAsKBSyntax(nrOfSolutions); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-17 05:20:45 UTC (rev 895) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-19 10:14:48 UTC (rev 896) @@ -1071,9 +1071,9 @@ } //HACK - public SortedSet<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ + public List<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ if(nrOfSolutions==0)nrOfSolutions=99999; - SortedSet<String> result = new TreeSet<String>(); + List<String> result = new LinkedList<String>(); for (Description d : solutions) { result.add(d.toKBSyntaxString()); Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-05-17 05:20:45 UTC (rev 895) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-05-19 10:14:48 UTC (rev 896) @@ -65,7 +65,7 @@ } //HACK - public SortedSet<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ + public List<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ return null; } Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 05:20:45 UTC (rev 895) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-19 10:14:48 UTC (rev 896) @@ -74,10 +74,10 @@ static boolean closeAfterRecursion=true; static boolean randomizeCache=false; - static int resultsize=50; + static int resultsize=20; static double noise=15; static int limit=200; - static double percentage=0.7; + static double percentage=0.3; /** * @param args @@ -113,18 +113,19 @@ String award=("http://dbpedia.org/resource/Category:Best_Actor_Academy_Award_winners"); - double acc1=0.0; - for (int i = 0; i < 5; i++) { - acc1+=DBpediaSKOS(prim); - } - System.out.println("accprim"+(acc1/5)); + System.out.println(DBpediaSKOS(prim)); +// double acc1=0.0; +// for (int i = 0; i < 5; i++) { +// acc1+=DBpediaSKOS(prim); +// } +// System.out.println("accprim"+(acc1/5)); +// +// double acc2=0.0; +// for (int i = 0; i < 5; i++) { +// acc2+=DBpediaSKOS(award); +// } +// System.out.println("accprim"+(acc2/5)); - double acc2=0.0; - for (int i = 0; i < 5; i++) { - acc2+=DBpediaSKOS(award); - } - System.out.println("accprim"+(acc2/5)); - // DBpediaSKOS(concepts.first()); // DBpediaSKOS(concepts.first()); // concepts.remove(concepts.first()); @@ -190,7 +191,7 @@ //igno.add(oneConcept.replaceAll("\"", "")); - SortedSet<String> conceptresults= ls.learnDBpediaSKOS(posExamples, negExamples, url,new TreeSet<String>(),recursiondepth, closeAfterRecursion,randomizeCache,resultsize,noise); + List<String> conceptresults= ls.learnDBpediaSKOS(posExamples, negExamples, url,new TreeSet<String>(),recursiondepth, closeAfterRecursion,randomizeCache,resultsize,noise); System.out.println("concepts"+conceptresults); //System.exit(0); @@ -242,12 +243,12 @@ double accuracy= (double)i/rest.size(); double accuracy2= (double)a/totalSKOSset.size(); - res.add(new ResultCompare(oneConcept,instances,accuracy,accuracy2,instances.size(), - coveredInRest,possibleNewCandidates,notCoveredInTotal)); + logger.debug((new ResultCompare(oneConcept,instances,accuracy,accuracy2,instances.size(), + coveredInRest,possibleNewCandidates,notCoveredInTotal)).toStringFull()); //if(instances.size()>=0)System.out.println("size of instances "+instances.size()); //if(instances.size()>=0 && instances.size()<100) System.out.println("instances"+instances); - }catch (Exception e) {} + }catch (Exception e) {e.printStackTrace();} } // System.out.println(res.last()); @@ -259,24 +260,24 @@ // //double percent=0.80*(double)res.size();; - double acc=res.first().accuracy; - logger.debug(res.first().toStringFull()); - res.remove(res.first()); - logger.debug(res.first().toStringFull()); - res.remove(res.first()); - int i=0; - while (res.size()>0){ - logger.debug(res.first()); - res.remove(res.first()); - //if(res.size()<=percent)break; - if(i>50)break; - i++; - - } +// double acc=res.first().accuracy; +// logger.debug(res.first().toStringFull()); +// res.remove(res.first()); +// logger.debug(res.first().toStringFull()); +// res.remove(res.first()); +// int i=0; +// while (res.size()>0){ +// logger.debug(res.first()); +// res.remove(res.first()); +// //if(res.size()<=percent)break; +// if(i>50)break; +// i++; +// +// } +// + return 0.0; - return acc; - //System.out.println("AAAAAAAA"); //System.exit(0); //"relearned concept: "; Modified: trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-17 05:20:45 UTC (rev 895) +++ trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-19 10:14:48 UTC (rev 896) @@ -43,7 +43,7 @@ totalSKOSset.addAll(this.posExamples); rest.addAll(totalSKOSset); int poslimit=(int)Math.round(percent*totalSKOSset.size()); - int neglimit=(int)Math.round(2*poslimit); + int neglimit=(int)Math.round(poslimit); /*while (this.posExamples.size()>poslimit) { this.posExamples.remove(posExamples.last()); }*/ Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-17 05:20:45 UTC (rev 895) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-19 10:14:48 UTC (rev 896) @@ -1,6 +1,7 @@ package org.dllearner.utilities; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -110,7 +111,7 @@ //System.out.println( la.getBestSolution());; } - public SortedSet<String> learnDBpediaSKOS(SortedSet<String> posExamples,SortedSet<String> negExamples, + public List<String> learnDBpediaSKOS(SortedSet<String> posExamples,SortedSet<String> negExamples, String uri, SortedSet<String> ignoredConcepts, int recursiondepth, boolean closeAfterRecursion, boolean randomizeCache, int resultsize, double noise){ @@ -168,7 +169,7 @@ cm.applyConfigEntry(la,"useCardinalityRestrictions",false); cm.applyConfigEntry(la,"useNegation",false); cm.applyConfigEntry(la,"minExecutionTimeInSeconds",0); - cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",150); + cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",30); cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",40); cm.applyConfigEntry(la,"writeSearchTree",true); cm.applyConfigEntry(la,"searchTreeFile","log/SKOS.txt"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-17 05:20:48
|
Revision: 895 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=895&view=rev Author: kurzum Date: 2008-05-16 22:20:45 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 05:03:25 UTC (rev 894) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 05:20:45 UTC (rev 895) @@ -75,7 +75,7 @@ static boolean randomizeCache=false; static int resultsize=50; - static double noise=5; + static double noise=15; static int limit=200; static double percentage=0.7; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-17 05:03:33
|
Revision: 894 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=894&view=rev Author: kurzum Date: 2008-05-16 22:03:25 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 04:50:37 UTC (rev 893) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 05:03:25 UTC (rev 894) @@ -121,7 +121,7 @@ double acc2=0.0; for (int i = 0; i < 5; i++) { - acc2+=DBpediaSKOS(prim); + acc2+=DBpediaSKOS(award); } System.out.println("accprim"+(acc2/5)); @@ -191,7 +191,9 @@ //igno.add(oneConcept.replaceAll("\"", "")); SortedSet<String> conceptresults= ls.learnDBpediaSKOS(posExamples, negExamples, url,new TreeSet<String>(),recursiondepth, closeAfterRecursion,randomizeCache,resultsize,noise); - //System.out.println("concepts"+conceptresults); + + System.out.println("concepts"+conceptresults); + //System.exit(0); logger.debug("found nr of concepts:"+conceptresults.size()); SortedSet<ResultCompare> res=new TreeSet<ResultCompare>(); for (String oneConcept : conceptresults) { Modified: trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-17 04:50:37 UTC (rev 893) +++ trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-17 05:03:25 UTC (rev 894) @@ -43,7 +43,7 @@ totalSKOSset.addAll(this.posExamples); rest.addAll(totalSKOSset); int poslimit=(int)Math.round(percent*totalSKOSset.size()); - int neglimit=(int)Math.round(1.4*poslimit); + int neglimit=(int)Math.round(2*poslimit); /*while (this.posExamples.size()>poslimit) { this.posExamples.remove(posExamples.last()); }*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-17 04:50:40
|
Revision: 893 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=893&view=rev Author: kurzum Date: 2008-05-16 21:50:37 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 04:35:22 UTC (rev 892) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 04:50:37 UTC (rev 893) @@ -77,7 +77,7 @@ static int resultsize=50; static double noise=5; static int limit=200; - static double percentage=0.3; + static double percentage=0.7; /** * @param args This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-17 04:35:26
|
Revision: 892 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=892&view=rev Author: kurzum Date: 2008-05-16 21:35:22 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 02:10:38 UTC (rev 891) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 04:35:22 UTC (rev 892) @@ -75,9 +75,9 @@ static boolean randomizeCache=false; static int resultsize=50; - static double noise=10; + static double noise=5; static int limit=200; - static double percentage=0.7; + static double percentage=0.3; /** * @param args @@ -109,18 +109,30 @@ // } SortedSet<String> concepts = new TreeSet<String>(); - concepts.add("http://dbpedia.org/resource/Category:Prime_Ministers_of_the_United_Kingdom"); - concepts.add("http://dbpedia.org/resource/Category:German_women_in_politics"); - concepts.add("http://dbpedia.org/resource/Category:Best_Actor_Academy_Award_winners"); + String prim="http://dbpedia.org/resource/Category:Prime_Ministers_of_the_United_Kingdom"; - DBpediaSKOS(concepts.first()); - DBpediaSKOS(concepts.first()); - concepts.remove(concepts.first()); - DBpediaSKOS(concepts.first()); - DBpediaSKOS(concepts.first()); - concepts.remove(concepts.first()); - DBpediaSKOS(concepts.first()); - DBpediaSKOS(concepts.first()); + String award=("http://dbpedia.org/resource/Category:Best_Actor_Academy_Award_winners"); + + double acc1=0.0; + for (int i = 0; i < 5; i++) { + acc1+=DBpediaSKOS(prim); + } + System.out.println("accprim"+(acc1/5)); + + double acc2=0.0; + for (int i = 0; i < 5; i++) { + acc2+=DBpediaSKOS(prim); + } + System.out.println("accprim"+(acc2/5)); + +// DBpediaSKOS(concepts.first()); +// DBpediaSKOS(concepts.first()); +// concepts.remove(concepts.first()); +// DBpediaSKOS(concepts.first()); +// DBpediaSKOS(concepts.first()); +// concepts.remove(concepts.first()); +// DBpediaSKOS(concepts.first()); +// DBpediaSKOS(concepts.first()); //algorithm="refinement"; //roles(); @@ -137,7 +149,7 @@ - static void DBpediaSKOS(String concept){ + static double DBpediaSKOS(String concept){ se = SparqlEndpoint.EndpointLOCALDBpedia(); //se = SparqlEndpoint.EndpointDBpedia(); String url = "http://dbpedia.openlinksw.com:8890/sparql"; @@ -245,9 +257,11 @@ // //double percent=0.80*(double)res.size();; - + double acc=res.first().accuracy; logger.debug(res.first().toStringFull()); res.remove(res.first()); + logger.debug(res.first().toStringFull()); + res.remove(res.first()); int i=0; while (res.size()>0){ logger.debug(res.first()); @@ -258,9 +272,9 @@ } + return acc; - //System.out.println("AAAAAAAA"); //System.exit(0); //"relearned concept: "; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-17 02:10:40
|
Revision: 891 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=891&view=rev Author: kurzum Date: 2008-05-16 19:10:38 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-17 02:03:29 UTC (rev 890) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-17 02:10:38 UTC (rev 891) @@ -1077,10 +1077,10 @@ for (Description d : solutions) { result.add(d.toKBSyntaxString()); - if(result.size()==nrOfSolutions)return result; + if(result.size()==nrOfSolutions)break; //if(result.size()==nrOfSolutions)break; } - /*if(result.size()<nrOfSolutions){ + if(result.size()==0){ for(ExampleBasedNode n : candidatesStable.descendingSet()) { @@ -1089,7 +1089,7 @@ return result; } - }*/ + } return result; } Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 02:03:29 UTC (rev 890) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 02:10:38 UTC (rev 891) @@ -253,7 +253,7 @@ logger.debug(res.first()); res.remove(res.first()); //if(res.size()<=percent)break; - if(i>6)break; + if(i>50)break; i++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-17 02:03:33
|
Revision: 890 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=890&view=rev Author: kurzum Date: 2008-05-16 19:03:29 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 01:55:42 UTC (rev 889) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 02:03:29 UTC (rev 890) @@ -248,11 +248,13 @@ logger.debug(res.first().toStringFull()); res.remove(res.first()); - + int i=0; while (res.size()>0){ logger.debug(res.first()); res.remove(res.first()); //if(res.size()<=percent)break; + if(i>6)break; + i++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-17 01:55:45
|
Revision: 889 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=889&view=rev Author: kurzum Date: 2008-05-16 18:55:42 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java Modified: trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java 2008-05-17 01:46:45 UTC (rev 888) +++ trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java 2008-05-17 01:55:42 UTC (rev 889) @@ -49,7 +49,7 @@ - public String toString(){ + public String toStringFull(){ String ret=""; ret+="concept\t"+concept+"\n"; ret+="instances\t"+instances+"\n"; @@ -64,4 +64,19 @@ } + public String toString(){ + String ret=""; + ret+="concept\t"+concept+"\n"; + //ret+="instances\t"+instances+"\n"; + ret+="accuracy\t"+accuracy+"\n"; + ret+="nrOfInstances\t"+nrOfInstances+"\n"; + ret+="accuracy2\t"+accuracy2+"\n"; + //ret+="coveredInRest("+coveredInRest.size()+")\t"+coveredInRest+"\n"; + //ret+="possibleNewCandidates("+possibleNewCandidates.size()+")\t"+possibleNewCandidates+"\n"; + //ret+="notCoveredInTotal("+notCoveredInTotal.size()+")\t"+notCoveredInTotal+"\n"; + + return ret; + + } + } Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 01:46:45 UTC (rev 888) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 01:55:42 UTC (rev 889) @@ -246,6 +246,8 @@ //double percent=0.80*(double)res.size();; + logger.debug(res.first().toStringFull()); + res.remove(res.first()); while (res.size()>0){ logger.debug(res.first()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-17 01:46:53
|
Revision: 888 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=888&view=rev Author: kurzum Date: 2008-05-16 18:46:45 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-16 21:16:09 UTC (rev 887) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-17 01:46:45 UTC (rev 888) @@ -1072,9 +1072,12 @@ //HACK public SortedSet<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ + if(nrOfSolutions==0)nrOfSolutions=99999; SortedSet<String> result = new TreeSet<String>(); for (Description d : solutions) { + result.add(d.toKBSyntaxString()); + if(result.size()==nrOfSolutions)return result; //if(result.size()==nrOfSolutions)break; } /*if(result.size()<nrOfSolutions){ Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-05-16 21:16:09 UTC (rev 887) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-05-17 01:46:45 UTC (rev 888) @@ -95,10 +95,10 @@ logger.trace(rs.getResultVars().toString()); } catch (Exception e){ sendException=new SparqlQueryException(e.getMessage()); - logger.error(e.getMessage()); - e.printStackTrace(); - logger.error("Exception when querying Sparql Endpoint in " + this.getClass()); - logger.error(queryString); + logger.debug(e.getMessage()); + //e.printStackTrace(); + logger.debug("Exception when querying Sparql Endpoint in " + this.getClass()); + logger.debug(queryString); } isRunning = false; return rs; Added: trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/ResultCompare.java 2008-05-17 01:46:45 UTC (rev 888) @@ -0,0 +1,67 @@ +package org.dllearner.scripts; + +import java.util.SortedSet; + +public class ResultCompare implements Comparable { + String concept; + SortedSet<String> instances; + double accuracy; + double accuracy2; + int nrOfInstances; + SortedSet<String> coveredInRest; + SortedSet<String> possibleNewCandidates; + SortedSet<String> notCoveredInTotal; + + + public ResultCompare(String concept, SortedSet<String> instances, double accuracy, + double accuracy2, int nrOfInstances, SortedSet<String> coveredInRest, + SortedSet<String> possibleNewCandidates, SortedSet<String> notCoveredInTotal) { + super(); + this.concept = concept; + this.instances = instances; + this.accuracy = accuracy; + this.accuracy2 = accuracy2; + this.nrOfInstances = nrOfInstances; + this.coveredInRest = coveredInRest; + this.possibleNewCandidates = possibleNewCandidates; + this.notCoveredInTotal = notCoveredInTotal; + } + + + + + public int compareTo(Object in) { + ResultCompare obj =(ResultCompare) in; + if(obj.accuracy > this.accuracy) return 1; + else if(obj.accuracy == this.accuracy){ + + if(obj.nrOfInstances<this.nrOfInstances)return 1; + else if(obj.nrOfInstances>this.nrOfInstances)return -1; + else return 1; + //if(obj.nrOfInstances==this.nrOfInstances)return 0; + } + else {//if(obj.accuracy < this.accuracy){ + return -1; + } + + } + + + + + public String toString(){ + String ret=""; + ret+="concept\t"+concept+"\n"; + ret+="instances\t"+instances+"\n"; + ret+="accuracy\t"+accuracy+"\n"; + ret+="nrOfInstances\t"+nrOfInstances+"\n"; + ret+="accuracy2\t"+accuracy2+"\n"; + ret+="coveredInRest("+coveredInRest.size()+")\t"+coveredInRest+"\n"; + ret+="possibleNewCandidates("+possibleNewCandidates.size()+")\t"+possibleNewCandidates+"\n"; + ret+="notCoveredInTotal("+notCoveredInTotal.size()+")\t"+notCoveredInTotal+"\n"; + + return ret; + + } + +} Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 21:16:09 UTC (rev 887) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-17 01:46:45 UTC (rev 888) @@ -1,5 +1,6 @@ package org.dllearner.scripts; +import java.util.LinkedList; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; @@ -10,9 +11,11 @@ import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Union; import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import org.dllearner.utilities.AutomaticExampleFinderSKOSSPARQL; import org.dllearner.utilities.JenaResultSetConvenience; @@ -67,25 +70,57 @@ static int poslimit = 10; static int neglimit = 20; + static int recursiondepth=1; + static boolean closeAfterRecursion=true; + static boolean randomizeCache=false; + + static int resultsize=50; + static double noise=10; + static int limit=200; + static double percentage=0.7; + /** * @param args */ public static void main(String[] args) { init(); //logger.setLevel(Level.TRACE); - Logger.getLogger(KnowledgeSource.class).setLevel(Level.INFO); + Logger.getLogger(KnowledgeSource.class).setLevel(Level.WARN); //System.out.println(Logger.getLogger(SparqlQuery.class).getLevel()); SimpleClock sc=new SimpleClock(); - standardSettings=standardSettingsRefexamples+standardDBpedia; - //standardSettings=standardSettingsRefinement+standardDBpedia; se = SparqlEndpoint.EndpointLOCALDBpedia(); - String t="\"http://dbpedia.org/class/yago/Fiction106367107\""; - t="\"http://www.w3.org/2004/02/skos/core#subject\""; - getSubClasses(t); +// String t="\"http://dbpedia.org/class/yago/Fiction106367107\""; +// t="(\"http://dbpedia.org/class/yago/HeadOfState110164747\" AND (\"http://dbpedia.org/class/yago/Negotiator110351874\" AND \"http://dbpedia.org/class/yago/Representative110522035\"))"; +// //System.out.println(t); +// //t="\"http://www.w3.org/2004/02/skos/core#subject\""; +// //conceptRewrite(t); +// //getSubClasses(t); +// +// AutomaticExampleFinderSKOSSPARQL ae= new AutomaticExampleFinderSKOSSPARQL( se); +// try{ +// System.out.println("oneconcept: "+t); +// SortedSet<String> instances = ae.queryConceptAsStringSet(conceptRewrite(t), 200); +// if(instances.size()>=0)System.out.println("size of instances "+instances.size()); +// if(instances.size()>=0 && instances.size()<100) System.out.println("instances"+instances); +// }catch (Exception e) { +// e.printStackTrace(); +// } + SortedSet<String> concepts = new TreeSet<String>(); - //DBpediaSKOS(); + concepts.add("http://dbpedia.org/resource/Category:Prime_Ministers_of_the_United_Kingdom"); + concepts.add("http://dbpedia.org/resource/Category:German_women_in_politics"); + concepts.add("http://dbpedia.org/resource/Category:Best_Actor_Academy_Award_winners"); + + DBpediaSKOS(concepts.first()); + DBpediaSKOS(concepts.first()); + concepts.remove(concepts.first()); + DBpediaSKOS(concepts.first()); + DBpediaSKOS(concepts.first()); + concepts.remove(concepts.first()); + DBpediaSKOS(concepts.first()); + DBpediaSKOS(concepts.first()); //algorithm="refinement"; //roles(); @@ -102,15 +137,12 @@ - static void DBpediaSKOS(){ + static void DBpediaSKOS(String concept){ se = SparqlEndpoint.EndpointLOCALDBpedia(); //se = SparqlEndpoint.EndpointDBpedia(); String url = "http://dbpedia.openlinksw.com:8890/sparql"; url = "http://139.18.2.37:8890/sparql"; - SortedSet<String> concepts = new TreeSet<String>(); - - concepts.add("http://dbpedia.org/resource/Category:Prime_Ministers_of_the_United_Kingdom"); //concepts.add("http://dbpedia.org/resource/Category:Grammy_Award_winners"); //concepts.add("EXISTS \"http://dbpedia.org/property/grammyawards\".TOP"); @@ -121,15 +153,11 @@ //HashMap<String, String> result2 = new HashMap<String, String>(); //System.out.println(concepts.first()); //logger.setLevel(Level.TRACE); - String concept=concepts.first(); + AutomaticExampleFinderSKOSSPARQL ae= new AutomaticExampleFinderSKOSSPARQL( se); - useRelated = false; - useParallelClasses = true; - int recursiondepth=1; - boolean closeAfterRecursion=true; - boolean randomizeCache=false; - ae.initDBpediaSKOS(concept, 0.1, useRelated, useParallelClasses); + + ae.initDBpediaSKOS(concept,percentage , useRelated, useParallelClasses); posExamples = ae.getPosExamples(); negExamples = ae.getNegExamples(); @@ -142,25 +170,93 @@ } SortedSet<String> totalSKOSset= ae.totalSKOSset; SortedSet<String> rest= ae.rest; - + logger.debug(totalSKOSset); + logger.debug(rest); LearnSparql ls = new LearnSparql(); //igno.add(oneConcept.replaceAll("\"", "")); - SortedSet<String> conceptresults= ls.learnDBpediaSKOS(posExamples, negExamples, url,new TreeSet<String>(),recursiondepth, closeAfterRecursion,randomizeCache); - System.out.println(conceptresults); - System.out.println(conceptresults.size()); - for (String string : conceptresults) { - System.out.println(string); - SortedSet<String> instances = ae.queryConceptAsStringSet(string, 0); - if(instances.size()>=0)System.out.println("size "+instances.size()); - if(instances.size()>=0 && instances.size()>0) System.out.println(instances); + SortedSet<String> conceptresults= ls.learnDBpediaSKOS(posExamples, negExamples, url,new TreeSet<String>(),recursiondepth, closeAfterRecursion,randomizeCache,resultsize,noise); + //System.out.println("concepts"+conceptresults); + logger.debug("found nr of concepts:"+conceptresults.size()); + SortedSet<ResultCompare> res=new TreeSet<ResultCompare>(); + for (String oneConcept : conceptresults) { + try{ + System.out.println("oneconcept: "+oneConcept); + SortedSet<String> instances = ae.queryConceptAsStringSet(conceptRewrite(oneConcept), 200); + SortedSet<String> coveredInRest = new TreeSet<String>(); + SortedSet<String> possibleNewCandidates = new TreeSet<String>(); + SortedSet<String> notCoveredInTotal = new TreeSet<String>(); + + int i=0; + int a=0; + for (String oneinst : instances) { + boolean inRest=false; + boolean inTotal=false; + for (String onerest : rest) { + if(onerest.equalsIgnoreCase(oneinst)) + { i++; inRest=true; break;} + + } + if (inRest){coveredInRest.add(oneinst);}; + + for (String onetotal : totalSKOSset) { + if(onetotal.equalsIgnoreCase(oneinst)) + { a++; inTotal=true; break;} + } + if(!inRest && !inTotal){ + possibleNewCandidates.add(oneinst); + } + } + + for (String onetotal : totalSKOSset) { + boolean mm=false; + for (String oneinst : instances) { + if(onetotal.equalsIgnoreCase(oneinst)){ + mm=true;break; + } + + } + if(!mm)notCoveredInTotal.add(onetotal); + + } + + + + double accuracy= (double)i/rest.size(); + double accuracy2= (double)a/totalSKOSset.size(); + + res.add(new ResultCompare(oneConcept,instances,accuracy,accuracy2,instances.size(), + coveredInRest,possibleNewCandidates,notCoveredInTotal)); + + //if(instances.size()>=0)System.out.println("size of instances "+instances.size()); + //if(instances.size()>=0 && instances.size()<100) System.out.println("instances"+instances); + }catch (Exception e) {} } +// System.out.println(res.last()); +// res.remove(res.last()); +// System.out.println(res.last()); +// res.remove(res.last()); +// System.out.println(res.last()); +// res.remove(res.last()); +// + //double percent=0.80*(double)res.size();; + + while (res.size()>0){ + logger.debug(res.first()); + res.remove(res.first()); + //if(res.size()<=percent)break; + + } + + + + //System.out.println("AAAAAAAA"); //System.exit(0); //"relearned concept: "; @@ -172,34 +268,6 @@ } - /*************************************************************************** - * *********************OLDCODE String - * conj="(\"http://dbpedia.org/class/yago/Person100007846\" AND - * \"http://dbpedia.org/class/yago/Head110162991\")"; - * - * - * concepts.add("EXISTS \"http://dbpedia.org/property/disambiguates\".TOP"); - * concepts.add("EXISTS - * \"http://dbpedia.org/property/successor\".\"http://dbpedia.org/class/yago/Person100007846\""); - * concepts.add("EXISTS \"http://dbpedia.org/property/successor\"."+conj); - * //concepts.add("ALL \"http://dbpedia.org/property/disambiguates\".TOP"); - * //concepts.add("ALL - * \"http://dbpedia.org/property/successor\".\"http://dbpedia.org/class/yago/Person100007846\""); - * concepts.add("\"http://dbpedia.org/class/yago/Person100007846\""); - * concepts.add(conj); - * concepts.add("(\"http://dbpedia.org/class/yago/Person100007846\" OR - * \"http://dbpedia.org/class/yago/Head110162991\")"); - * - * //concepts.add("NOT \"http://dbpedia.org/class/yago/Person100007846\""); - * - * for (String kbsyntax : concepts) { - * result.put(kbsyntax,queryConcept(kbsyntax)); } - * System.out.println("************************"); for (String string : - * result.keySet()) { System.out.println("KBSyntayString: "+string); - * System.out.println("Query:\n"+result.get(string).hasNext()); - * System.out.println("************************"); } - **************************************************************************/ - @@ -238,10 +306,11 @@ /** - * NOT WORKING + * * @param description */ - public static SortedSet<String> getSubClasses(String description) { + public static SortedSet<String> getSubClasses(String description, int limit) { + if(limit==0)limit=10; ResultSet rs = null; //System.out.println(description); SortedSet<String> alreadyQueried = new TreeSet<String>(); @@ -249,38 +318,43 @@ String query = getSparqlSubclassQuery(description.replaceAll("\"", "")); String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); rs =SparqlQuery.JSONtoResultSet(JSON); - SortedSet<String> remainingClasses = new TreeSet<String>(); + LinkedList<String> remainingClasses = new LinkedList<String>(); - remainingClasses.addAll(getSubclassesFromResultSet(rs)); + //make back + //remainingClasses.addAll(getSubclassesFromResultSet(rs)); alreadyQueried = new TreeSet<String>(); alreadyQueried.add(description.replaceAll("\"", "")); - + alreadyQueried.addAll(getSubclassesFromResultSet(rs)); + //remainingClasses.addAll(alreadyQueried); + return alreadyQueried; //SortedSet<String> remainingClasses = new JenaResultSetConvenience(rs).getStringListForVariable("subject"); - while (remainingClasses.size()!=0){ - SortedSet<String> tmpSet = new TreeSet<String>(); - String tmp = remainingClasses.first(); - remainingClasses.remove(tmp); - query = SparqlQueryDescriptionConvertVisitor - .getSparqlSubclassQuery(tmp); - alreadyQueried.add(tmp); - JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - rs =SparqlQuery.JSONtoResultSet(JSON); - tmpSet=getSubclassesFromResultSet(rs); - for (String string : tmpSet) { - if(!alreadyQueried.contains(string)) - remainingClasses.add(string); - } - } +// while (remainingClasses.size()!=0){ +// SortedSet<String> tmpSet = new TreeSet<String>(); +// String tmp = remainingClasses.removeFirst(); +// //remainingClasses.remove(tmp); +// query = SparqlQueryDescriptionConvertVisitor +// .getSparqlSubclassQuery(tmp); +// alreadyQueried.add(tmp); +// if(alreadyQueried.size()==limit)break; +// JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); +// rs =SparqlQuery.JSONtoResultSet(JSON); +// tmpSet=getSubclassesFromResultSet(rs); +// for (String string : tmpSet) { +// if(!alreadyQueried.contains(string)) +// remainingClasses.add(string); +// } +// } //System.out.println(JSON); } catch (Exception e) { - e.printStackTrace(); + } - //System.out.println(alreadyQueried); + System.out.println("subclasses "+alreadyQueried); + System.out.println("nr of subclasses :"+alreadyQueried.size()); return alreadyQueried; } @@ -309,6 +383,44 @@ return ret; } + public static String conceptRewrite(String description) + { String quote = "\""; + String ret=""; + String currentconcept=""; + int lastPos=0; + SortedSet<String> subclasses=new TreeSet<String>(); + + while ((lastPos=description.lastIndexOf(quote))!=-1){ + ret=description.substring(lastPos+1,description.length())+ret; + description=description.substring(0,lastPos); + //System.out.println(description); + lastPos=description.lastIndexOf(quote); + currentconcept=description.substring(lastPos+1,description.length()); + description=description.substring(0,lastPos); + //replace + //currentconcept="\"blabla\""; + //System.out.println(currentconcept); + + + subclasses = getSubClasses( currentconcept, 0); + + if (subclasses.size()==1)currentconcept="\""+currentconcept+"\""; + else { + LinkedList<Description> nc = new LinkedList<Description>(); + for (String one : subclasses) { + nc.add(new NamedClass(one)); + } + currentconcept=new Union(nc).toKBSyntaxString(); + } + + ret=currentconcept+ret; + //ret+=description; + } + ret=description+ret; + //System.out.println(ret); + return ret; + } + } Modified: trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-16 21:16:09 UTC (rev 887) +++ trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-17 01:46:45 UTC (rev 888) @@ -1,5 +1,7 @@ package org.dllearner.utilities; +import java.net.URL; +import java.net.URLEncoder; import java.util.SortedSet; import java.util.TreeSet; @@ -8,6 +10,7 @@ import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; +import org.dllearner.kb.sparql.SparqlQueryThreaded; import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import com.hp.hpl.jena.query.ResultSet; @@ -27,7 +30,7 @@ public AutomaticExampleFinderSKOSSPARQL(SparqlEndpoint se){ - this.c=new Cache("cachetemp"); + this.c=new Cache("cacheExamplesValidation"); this.se=se; posExamples = new TreeSet<String>(); negExamples = new TreeSet<String>(); @@ -40,7 +43,7 @@ totalSKOSset.addAll(this.posExamples); rest.addAll(totalSKOSset); int poslimit=(int)Math.round(percent*totalSKOSset.size()); - int neglimit=2*poslimit; + int neglimit=(int)Math.round(1.4*poslimit); /*while (this.posExamples.size()>poslimit) { this.posExamples.remove(posExamples.last()); }*/ @@ -302,6 +305,7 @@ .getSparqlQuery(concept,limit); SparqlQuery sq = new SparqlQuery(query, se); + //System.out.println(query); String JSON = c.executeSparqlQuery(sq); //System.out.println("JSON:\n"+JSON); rs = SparqlQuery.JSONtoResultSet(JSON); @@ -345,7 +349,7 @@ " a " + "?subject " + "\n" + - "}"; + "} LIMIT 200"; SparqlQuery sq = new SparqlQuery(query, se); //System.out.println(query); String JSON = c.executeSparqlQuery(sq); Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 21:16:09 UTC (rev 887) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-17 01:46:45 UTC (rev 888) @@ -112,7 +112,7 @@ public SortedSet<String> learnDBpediaSKOS(SortedSet<String> posExamples,SortedSet<String> negExamples, String uri, SortedSet<String> ignoredConcepts, int recursiondepth, - boolean closeAfterRecursion, boolean randomizeCache){ + boolean closeAfterRecursion, boolean randomizeCache, int resultsize, double noise){ ComponentManager cm = ComponentManager.getInstance(); @@ -168,12 +168,12 @@ cm.applyConfigEntry(la,"useCardinalityRestrictions",false); cm.applyConfigEntry(la,"useNegation",false); cm.applyConfigEntry(la,"minExecutionTimeInSeconds",0); - cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",50); - cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",15); + cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",150); + cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",40); cm.applyConfigEntry(la,"writeSearchTree",true); cm.applyConfigEntry(la,"searchTreeFile","log/SKOS.txt"); cm.applyConfigEntry(la,"replaceSearchTree",true); - //cm.applyConfigEntry(la,"noisePercentage",0.15); + cm.applyConfigEntry(la,"noisePercentage",noise); //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); @@ -189,7 +189,7 @@ sc.setTime(); la.start(); Statistics.addTimeLearning(sc.getTime()); - return la.getBestSolutionsAsKBSyntax(0); + return la.getBestSolutionsAsKBSyntax(resultsize); //if(sc.getTime()/1000 >= 20)System.out.println("XXXMAX time reached"); //System.out.println("best"+la(20)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 21:16:48
|
Revision: 887 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=887&view=rev Author: kurzum Date: 2008-05-16 14:16:09 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 19:44:28 UTC (rev 886) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 21:16:09 UTC (rev 887) @@ -93,8 +93,8 @@ for (int a = 0; a < 1; a++) { - poslimit+=30; - neglimit+=30; + poslimit+=15; + neglimit+=15; printProgress(0, concepts.size(),0, "beginning",total.getTime()); int concount=0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 19:44:41
|
Revision: 886 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=886&view=rev Author: kurzum Date: 2008-05-16 12:44:28 -0700 (Fri, 16 May 2008) Log Message: ----------- rdfs inferencing so far in SKOS7030 Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-05-16 16:40:20 UTC (rev 885) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-05-16 19:44:28 UTC (rev 886) @@ -175,7 +175,7 @@ public static ResultSet JSONtoResultSet(String json) { ByteArrayInputStream bais = new ByteArrayInputStream(json .getBytes(Charset.forName("UTF-8"))); - System.out.println("JSON " + json); + //System.out.println("JSON " + json); return ResultSetFactory.fromJSON(bais); } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java 2008-05-16 16:40:20 UTC (rev 885) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java 2008-05-16 19:44:28 UTC (rev 886) @@ -81,9 +81,9 @@ } public static String getSparqlSubclassQuery(String description) - { String ret = "SELECT ?subject \n"; + { String ret = "SELECT * \n"; ret+= "WHERE {\n"; - ret+=" ?subject <http://www.w3.org/2000/01/rdf-schema#subClassOf> <"+description+"> \n"; + ret+=" ?subject ?predicate <"+description+"> \n"; ret+="}\n"; return ret; Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 16:40:20 UTC (rev 885) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 19:44:28 UTC (rev 886) @@ -1,5 +1,6 @@ package org.dllearner.scripts; +import java.util.List; import java.util.SortedSet; import java.util.TreeSet; @@ -11,6 +12,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import org.dllearner.utilities.AutomaticExampleFinderSKOSSPARQL; import org.dllearner.utilities.JenaResultSetConvenience; @@ -19,6 +21,8 @@ import org.dllearner.utilities.SimpleClock; import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.ResultSetFormatter; +import com.hp.hpl.jena.sparql.core.ResultBinding; public class SKOS7030 { @@ -76,7 +80,12 @@ standardSettings=standardSettingsRefexamples+standardDBpedia; //standardSettings=standardSettingsRefinement+standardDBpedia; - DBpediaSKOS(); + se = SparqlEndpoint.EndpointLOCALDBpedia(); + String t="\"http://dbpedia.org/class/yago/Fiction106367107\""; + t="\"http://www.w3.org/2004/02/skos/core#subject\""; + getSubClasses(t); + + //DBpediaSKOS(); //algorithm="refinement"; //roles(); @@ -95,9 +104,9 @@ static void DBpediaSKOS(){ se = SparqlEndpoint.EndpointLOCALDBpedia(); - se = SparqlEndpoint.EndpointDBpedia(); + //se = SparqlEndpoint.EndpointDBpedia(); String url = "http://dbpedia.openlinksw.com:8890/sparql"; - //url = "http://139.18.2.37:8890/sparql"; + url = "http://139.18.2.37:8890/sparql"; SortedSet<String> concepts = new TreeSet<String>(); @@ -228,5 +237,78 @@ } + /** + * NOT WORKING + * @param description + */ + public static SortedSet<String> getSubClasses(String description) { + ResultSet rs = null; + //System.out.println(description); + SortedSet<String> alreadyQueried = new TreeSet<String>(); + try { + String query = getSparqlSubclassQuery(description.replaceAll("\"", "")); + String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); + rs =SparqlQuery.JSONtoResultSet(JSON); + SortedSet<String> remainingClasses = new TreeSet<String>(); + + remainingClasses.addAll(getSubclassesFromResultSet(rs)); + + alreadyQueried = new TreeSet<String>(); + alreadyQueried.add(description.replaceAll("\"", "")); + + + //SortedSet<String> remainingClasses = new JenaResultSetConvenience(rs).getStringListForVariable("subject"); + + while (remainingClasses.size()!=0){ + SortedSet<String> tmpSet = new TreeSet<String>(); + String tmp = remainingClasses.first(); + remainingClasses.remove(tmp); + query = SparqlQueryDescriptionConvertVisitor + .getSparqlSubclassQuery(tmp); + alreadyQueried.add(tmp); + JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); + rs =SparqlQuery.JSONtoResultSet(JSON); + tmpSet=getSubclassesFromResultSet(rs); + for (String string : tmpSet) { + if(!alreadyQueried.contains(string)) + remainingClasses.add(string); + } + } + //System.out.println(JSON); + + } catch (Exception e) { + e.printStackTrace(); + } + //System.out.println(alreadyQueried); + return alreadyQueried; + } + + public static SortedSet<String> getSubclassesFromResultSet(ResultSet rs) + { + SortedSet<String> result = new TreeSet<String>(); + List<ResultBinding> l = ResultSetFormatter.toList(rs); + String p="",s=""; + for (ResultBinding resultBinding : l) { + + s=((resultBinding.get("subject").toString())); + p=((resultBinding.get("predicate").toString())); + if(p.equalsIgnoreCase("http://www.w3.org/2000/01/rdf-schema#subClassOf")){ + result.add(s); + } + } + return result; + } + + public static String getSparqlSubclassQuery(String description) + { String ret = "SELECT * \n"; + ret+= "WHERE {\n"; + ret+=" ?subject ?predicate <"+description+"> \n"; + ret+="}\n"; + + return ret; + } + + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-05-16 16:40:32
|
Revision: 885 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=885&view=rev Author: jenslehmann Date: 2008-05-16 09:40:20 -0700 (Fri, 16 May 2008) Log Message: ----------- small additions to reproduce filter bug Modified Paths: -------------- trunk/examples/sparql/govtrack.conf trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java Added Paths: ----------- trunk/examples/sparql/scrobble.kb Modified: trunk/examples/sparql/govtrack.conf =================================================================== --- trunk/examples/sparql/govtrack.conf 2008-05-16 15:53:49 UTC (rev 884) +++ trunk/examples/sparql/govtrack.conf 2008-05-16 16:40:20 UTC (rev 885) @@ -1,6 +1,7 @@ -sparql.recursionDepth = 2; +sparql.recursionDepth = 3; sparql.predefinedEndpoint = "GOVTRACK"; +sparql.useLits = true; algorithm = refexamples; reasoner = owlAPI; Added: trunk/examples/sparql/scrobble.kb =================================================================== --- trunk/examples/sparql/scrobble.kb (rev 0) +++ trunk/examples/sparql/scrobble.kb 2008-05-16 16:40:20 UTC (rev 885) @@ -0,0 +1,6 @@ +// english implies british +"http://dbtune.org/musicbrainz/resource/tag/1391" SUBCLASSOF "http://dbtune.org/musicbrainz/resource/tag/171". +// Britain = UK +"http://dbtune.org/musicbrainz/resource/tag/171" = "http://dbtune.org/musicbrainz/resource/tag/237". +// progressive rock is rock +"http://dbtune.org/musicbrainz/resource/tag/29" SUBCLASSOF "http://dbtune.org/musicbrainz/resource/tag/7". Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java 2008-05-16 15:53:49 UTC (rev 884) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java 2008-05-16 16:40:20 UTC (rev 885) @@ -83,11 +83,21 @@ StringTuple t = (StringTuple) it.next(); //HACK - if(t.a.equals("http://www.holygoat.co.uk/owl/redwood/0.1/tags/taggedWithTag")) { - //hackGetLabel(t.b); - - } +// if(t.a.equals("http://www.holygoat.co.uk/owl/redwood/0.1/tags/taggedWithTag")) { +// //hackGetLabel(t.b); +// +// } + // GovTrack hack + // => we convert a string literal to a URI + // => TODO: introduce an option for converting literals for certain + // properties into URIs +// String sp = "http://purl.org/dc/elements/1.1/subject"; +// if(t.a.equals(sp)) { +// System.out.println(t); +// System.exit(0); +// } + replacePredicate(t); replaceObject(t); Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-05-16 15:53:49 UTC (rev 884) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-05-16 16:40:20 UTC (rev 885) @@ -95,7 +95,10 @@ logger.trace(rs.getResultVars().toString()); } catch (Exception e){ sendException=new SparqlQueryException(e.getMessage()); - logger.error("Exception when querying Sparql Endpoint"); + logger.error(e.getMessage()); + e.printStackTrace(); + logger.error("Exception when querying Sparql Endpoint in " + this.getClass()); + logger.error(queryString); } isRunning = false; return rs; @@ -172,6 +175,7 @@ public static ResultSet JSONtoResultSet(String json) { ByteArrayInputStream bais = new ByteArrayInputStream(json .getBytes(Charset.forName("UTF-8"))); + System.out.println("JSON " + json); return ResultSetFactory.fromJSON(bais); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 15:53:56
|
Revision: 884 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=884&view=rev Author: kurzum Date: 2008-05-16 08:53:49 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java 2008-05-16 13:26:51 UTC (rev 883) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Manipulator.java 2008-05-16 15:53:49 UTC (rev 884) @@ -24,11 +24,16 @@ import java.util.LinkedList; import java.util.Set; +import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import org.dllearner.kb.sparql.datastructure.ClassNode; import org.dllearner.kb.sparql.datastructure.InstanceNode; import org.dllearner.kb.sparql.datastructure.Node; +import org.dllearner.utilities.JenaResultSetConvenience; import org.dllearner.utilities.StringTuple; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.ResultSetFormatter; + /** * Used to manipulate retrieved tupels, identify blanknodes, etc. * @@ -76,9 +81,17 @@ Iterator<StringTuple> it = tuples.iterator(); while (it.hasNext()) { StringTuple t = (StringTuple) it.next(); + + //HACK + if(t.a.equals("http://www.holygoat.co.uk/owl/redwood/0.1/tags/taggedWithTag")) { + //hackGetLabel(t.b); + + } + replacePredicate(t); replaceObject(t); + // remove <rdf:type, owl:class> // this is done to avoid transformation to owl:subclassof if (t.a.equals(type) && t.b.equals(classns) @@ -118,5 +131,25 @@ } } } + + //HACK + private String hackGetLabel(String resname){ + String query="" + + "SELECT ?o \n" + + "WHERE { \n" + + "<"+resname+"> "+ " <http://www.holygoat.co.uk/owl/redwood/0.1/tags/tagName> ?o " + + "}"; + + System.out.println(query); + //http://dbtune.org/musicbrainz/sparql?query= + //SELECT ?o WHERE { <http://dbtune.org/musicbrainz/resource/tag/1391> <http://www.holygoat.co.uk/owl/redwood/0.1/tags/tagName> ?o } + SparqlQuery s=new SparqlQuery(query,SparqlEndpoint.EndpointMusicbrainz()); + ResultSet rs=s.send(); + while (rs.hasNext()){ + rs.nextBinding(); + } + //System.out.println("AAA"+s.getAsXMLString(s.send()) ); + return ""; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 12:56:54
|
Revision: 882 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=882&view=rev Author: kurzum Date: 2008-05-16 05:56:51 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 12:23:14 UTC (rev 881) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 12:56:51 UTC (rev 882) @@ -91,10 +91,10 @@ SortedSet<String> posExamples = new TreeSet<String>(); SortedSet<String> negExamples = new TreeSet<String>(); - for (int a = 0; a < 3; a++) { + for (int a = 0; a < 1; a++) { - poslimit+=5; - neglimit+=5; + poslimit+=30; + neglimit+=30; printProgress(0, concepts.size(),0, "beginning",total.getTime()); int concount=0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-05-16 12:18:42
|
Revision: 880 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=880&view=rev Author: jenslehmann Date: 2008-05-16 05:18:39 -0700 (Fri, 16 May 2008) Log Message: ----------- initial version of last FM band analysing example Added Paths: ----------- trunk/examples/sparql/scrobble.conf Added: trunk/examples/sparql/scrobble.conf =================================================================== --- trunk/examples/sparql/scrobble.conf (rev 0) +++ trunk/examples/sparql/scrobble.conf 2008-05-16 12:18:39 UTC (rev 880) @@ -0,0 +1,39 @@ +/** + * Scroble - analyse the bands of the last songs heard by a user + * (http://dbtune.org/last-fm/$username) + * + * => last FM links to Zitgist which links to MusicBrainz (owl:sameAs), + * so we could obtain the examples + * => tags have to be converted to classes for this example to work + * => negative examples are choosen randomly (in this case we picked them from + * recent bands of other users) + * => in this case the user listened to British Rock and Pop + * + */ + +sparql.recursionDepth = 3; +sparql.predefinedEndpoint = "MUSICBRAINZ"; + +// sparql.useLits=true; + +algorithm = refexamples; +reasoner = fastInstanceChecker; + +import("http://dbtune.org/musicbrainz/sparql","SPARQL"); + +sparql.instances = { +"http://dbtune.org/musicbrainz/page/artist/8e3fcd7d-bda1-4ca0-b987-b8528d2ee74e", +"http://dbtune.org/musicbrainz/page/artist/9a5cf59b-5da0-4021-b885-b6b78dd6886e", +"http://dbtune.org/musicbrainz/page/artist/79239441-bfd5-4981-a70c-55c3f15c1287", +"http://dbtune.org/musicbrainz/page/artist/bfcc6d75-a6a5-4bc6-8282-47aec8531818" +}; + +// Genesis ++"http://dbtune.org/musicbrainz/page/artist/8e3fcd7d-bda1-4ca0-b987-b8528d2ee74e" +// IQ ++"http://dbtune.org/musicbrainz/page/artist/9a5cf59b-5da0-4021-b885-b6b78dd6886e" + +// Madonna +-"http://dbtune.org/musicbrainz/page/artist/79239441-bfd5-4981-a70c-55c3f15c1287" +// Cher +-"http://dbtune.org/musicbrainz/page/artist/bfcc6d75-a6a5-4bc6-8282-47aec8531818" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 11:50:39
|
Revision: 879 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=879&view=rev Author: kurzum Date: 2008-05-16 04:50:38 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 11:22:54 UTC (rev 878) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 11:50:38 UTC (rev 879) @@ -142,10 +142,12 @@ SortedSet<String> conceptresults= ls.learnDBpediaSKOS(posExamples, negExamples, url,new TreeSet<String>(),recursiondepth, closeAfterRecursion,randomizeCache); System.out.println(conceptresults); + System.out.println(conceptresults.size()); for (String string : conceptresults) { + System.out.println(string); SortedSet<String> instances = ae.queryConceptAsStringSet(string, 0); - if(instances.size()>0)System.out.println("size "+instances.size()); - if(instances.size()<=15 && instances.size()>0) System.out.println(instances); + if(instances.size()>=0)System.out.println("size "+instances.size()); + if(instances.size()>=0 && instances.size()>0) System.out.println(instances); } Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 11:22:54 UTC (rev 878) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 11:50:38 UTC (rev 879) @@ -207,11 +207,11 @@ concepts.add("http://dbpedia.org/class/yago/DataStructure105728493"); concepts.add("http://dbpedia.org/class/yago/Disappearance100053609"); concepts.add("http://dbpedia.org/class/yago/Flintstone114871268"); - concepts.add("http://dbpedia.org/class/yago/Form105930736"); - concepts.add("http://dbpedia.org/class/yago/Hypochondriac110195487"); - concepts.add("http://dbpedia.org/class/yago/Industrialist110204177"); - concepts.add("http://dbpedia.org/class/yago/Lifeboat103662601"); - concepts.add("http://dbpedia.org/class/yago/Particulate114839439"); +// concepts.add("http://dbpedia.org/class/yago/Form105930736"); +// concepts.add("http://dbpedia.org/class/yago/Hypochondriac110195487"); +// concepts.add("http://dbpedia.org/class/yago/Industrialist110204177"); +// concepts.add("http://dbpedia.org/class/yago/Lifeboat103662601"); +// concepts.add("http://dbpedia.org/class/yago/Particulate114839439"); // concepts.add("http://dbpedia.org/class/yago/Patriot110407310"); // concepts.add("http://dbpedia.org/class/yago/Reservation108587174"); // concepts.add("http://dbpedia.org/class/yago/Schoolteacher110560352"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 11:23:05
|
Revision: 878 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=878&view=rev Author: kurzum Date: 2008-05-16 04:22:54 -0700 (Fri, 16 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 11:04:35 UTC (rev 877) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 11:22:54 UTC (rev 878) @@ -95,8 +95,9 @@ static void DBpediaSKOS(){ se = SparqlEndpoint.EndpointLOCALDBpedia(); + se = SparqlEndpoint.EndpointDBpedia(); String url = "http://dbpedia.openlinksw.com:8890/sparql"; - url = "http://139.18.2.37:8890/sparql"; + //url = "http://139.18.2.37:8890/sparql"; SortedSet<String> concepts = new TreeSet<String>(); Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 11:04:35 UTC (rev 877) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 11:22:54 UTC (rev 878) @@ -199,7 +199,7 @@ concepts.add("http://dbpedia.org/class/yago/AirLane108492546"); concepts.add("http://dbpedia.org/class/yago/AlphaBlocker102698769"); concepts.add("http://dbpedia.org/class/yago/Articulation107131854"); - concepts.add("http://dbpedia.org/class/yago/Patriot110407310"); + concepts.add("http://dbpedia.org/class/yago/Ceremony107450842"); concepts.add("http://dbpedia.org/class/yago/CookingOil107673145"); concepts.add("http://dbpedia.org/class/yago/Corticosteroid114751417"); @@ -212,10 +212,11 @@ concepts.add("http://dbpedia.org/class/yago/Industrialist110204177"); concepts.add("http://dbpedia.org/class/yago/Lifeboat103662601"); concepts.add("http://dbpedia.org/class/yago/Particulate114839439"); - concepts.add("http://dbpedia.org/class/yago/Reservation108587174"); - concepts.add("http://dbpedia.org/class/yago/Schoolteacher110560352"); - concepts.add("http://dbpedia.org/class/yago/Singer110599806"); - concepts.add("http://dbpedia.org/class/yago/SupremeCourt108336188"); +// concepts.add("http://dbpedia.org/class/yago/Patriot110407310"); +// concepts.add("http://dbpedia.org/class/yago/Reservation108587174"); +// concepts.add("http://dbpedia.org/class/yago/Schoolteacher110560352"); +// concepts.add("http://dbpedia.org/class/yago/Singer110599806"); +// concepts.add("http://dbpedia.org/class/yago/SupremeCourt108336188"); return concepts; } Modified: trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-16 11:04:35 UTC (rev 877) +++ trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-16 11:22:54 UTC (rev 878) @@ -41,10 +41,10 @@ rest.addAll(totalSKOSset); int poslimit=(int)Math.round(percent*totalSKOSset.size()); int neglimit=2*poslimit; - while (this.posExamples.size()>poslimit) { + /*while (this.posExamples.size()>poslimit) { this.posExamples.remove(posExamples.last()); - } - //this.posExamples = SetManipulation.fuzzyShrink(this.posExamples, poslimit); + }*/ + this.posExamples = SetManipulation.fuzzyShrink(this.posExamples, poslimit); rest.removeAll(this.posExamples); Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 11:04:35 UTC (rev 877) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 11:22:54 UTC (rev 878) @@ -189,7 +189,7 @@ sc.setTime(); la.start(); Statistics.addTimeLearning(sc.getTime()); - return la.getBestSolutionsAsKBSyntax(15); + return la.getBestSolutionsAsKBSyntax(0); //if(sc.getTime()/1000 >= 20)System.out.println("XXXMAX time reached"); //System.out.println("best"+la(20)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |