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. |