From: <ku...@us...> - 2008-05-15 16:44:10
|
Revision: 852 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=852&view=rev Author: kurzum Date: 2008-05-15 09:43:44 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/Statistics.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-15 16:32:46 UTC (rev 851) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-15 16:43:44 UTC (rev 852) @@ -74,7 +74,7 @@ for(Description c : allowedConceptsInSubsumptionHierarchy) { // schauen, ob es mehrere allgemeinere Nachbarn gibt SortedSet<Description> moreGeneral = subsumptionHierarchyUp.get(c); - //RBC + //RBC //HACK if(moreGeneral != null && moreGeneral.size()>0) { //System.out.println(moreGeneral); Description chosenParent = moreGeneral.first(); @@ -85,7 +85,8 @@ // for(Concept c : allowedConceptsInSubsumptionHierarchy) { for(Description c : allowedConceptsInSubsumptionHierarchy) { SortedSet<Description> moreSpecial = subsumptionHierarchyDown.get(c); - if(moreSpecial != null) { + //RBC //HACK + if(moreSpecial != null && moreSpecial.size()>0) { Description chosenParent = moreSpecial.first(); hierarchyUpNew.get(chosenParent).add(c); } Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 16:32:46 UTC (rev 851) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 16:43:44 UTC (rev 852) @@ -125,7 +125,9 @@ LearnSparql ls = new LearnSparql(); TreeSet<String> igno = new TreeSet<String>(); - System.out.println(oneConcept); + igno.add(oneConcept.replaceAll("\"", "")); + //igno.add("\""+oneConcept+"\""); + //System.out.println(oneConcept); ls.learnDBpedia(posExamples, negExamples, url,igno,recursiondepth, closeAfterRecursion,randomizeCache); Modified: trunk/src/dl-learner/org/dllearner/utilities/Statistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-15 16:32:46 UTC (rev 851) +++ trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-15 16:43:44 UTC (rev 852) @@ -77,8 +77,8 @@ printLong(timeCollecting, "collecting\t"); printLongAVG(timeCollecting,number,"collecting avg\t"); - printLong(timeLearning, "collecting\t"); - printLongAVG(timeLearning,number,"collecting avg\t"); + printLong(timeLearning, "learning\t"); + printLongAVG(timeLearning,number,"learning avg\t"); System.out.println("*****************Queries"); printInt(numberOfCachedSparqlQueries,"cached queries\t"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-15 19:24:28
|
Revision: 854 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=854&view=rev Author: kurzum Date: 2008-05-15 12:24:02 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java trunk/src/dl-learner/org/dllearner/utilities/Statistics.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 16:54:43 UTC (rev 853) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 19:24:02 UTC (rev 854) @@ -93,8 +93,11 @@ poslimit+=5; neglimit+=5; - + System.out.println("XXX examplesize "+(poslimit+neglimit)); + int concount=0; for (String oneConcept : concepts) { + System.out.println("XXX "+concount+" of "+concepts.size()+""+oneConcept);concount++; + int recursiondepth=0; boolean closeAfterRecursion=true; @@ -106,7 +109,8 @@ posExamples = ae.getPosExamples(); negExamples = ae.getNegExamples(); - for(recursiondepth=0;recursiondepth<5;recursiondepth++) { + for(recursiondepth=0;recursiondepth<4;recursiondepth++) { + System.out.println("XXX recursiondepth "+recursiondepth+" con "+oneConcept); /*if(i==0){;} else if(closeAfterRecursion) { @@ -138,17 +142,18 @@ } Statistics.print(number); String pre="log/gnu_"; - String comment1="# "+poslimit+neglimit+"examples\n"; - String f1=pre+"1avgtrip_"+poslimit+neglimit+"example"+concepts.size()+"classes"; + int examples=poslimit+neglimit; + String comment1="# "+examples+"examples\n"; + String f1=pre+"1avgtrip_"+examples+"example"+concepts.size()+"classes"; writeToFile(f1, comment1+Statistics.getAVGTriplesForRecursionDepth(number)); - String comment2="# "+poslimit+neglimit+"examples\n"; - String f2=pre+"2avgTimeExtraction_"+poslimit+neglimit+"example"+concepts.size()+"classes"; + String comment2="# "+examples+"examples\n"; + String f2=pre+"2avgTimeExtraction_"+examples+"example"+concepts.size()+"classes"; writeToFile(f2, comment2+Statistics.getAVGTimeCollecting(number)); - String comment3="# "+poslimit+neglimit+"examples\n"; - String f3=pre+"2avgTimeLearning_"+poslimit+neglimit+"example"+concepts.size()+"classes"; + String comment3="# "+examples+"examples\n"; + String f3=pre+"2avgTimeLearning_"+examples+"example"+concepts.size()+"classes"; writeToFile(f3, comment3+Statistics.getAVGTimeLearning(number)); + Statistics.reset(); - }//outer } Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 16:54:43 UTC (rev 853) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 19:24:02 UTC (rev 854) @@ -95,6 +95,7 @@ sc.setTime(); la.start(); Statistics.addTimeLearning(sc.getTime()); + if(sc.getTime()/1000 >= 20)System.out.println("XXXMAX time reached"); //System.out.println("best"+la(20)); //((ExampleBasedROLComponent)la).printBestSolutions(10000); Modified: trunk/src/dl-learner/org/dllearner/utilities/Statistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-15 16:54:43 UTC (rev 853) +++ trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-15 19:24:02 UTC (rev 854) @@ -178,6 +178,17 @@ return currentLabel; } + public static void reset(){ + currentLabel=""; + order = new LinkedList<String>(); + numberOfTriples = new HashMap<String, Integer>(); + timeCollecting = new HashMap<String, Long>(); + timeLearning = new HashMap<String, Long>(); + + numberOfSparqlQueries = new HashMap<String, Integer>(); + numberOfCachedSparqlQueries = new HashMap<String, Integer>(); + + } //stats This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-15 20:50:53
|
Revision: 855 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=855&view=rev Author: kurzum Date: 2008-05-15 13:50:51 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-05-15 19:24:02 UTC (rev 854) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-05-15 20:50:51 UTC (rev 855) @@ -440,4 +440,6 @@ System.out.println(); } }*/ + + } Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 19:24:02 UTC (rev 854) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 20:50:51 UTC (rev 855) @@ -61,6 +61,7 @@ static void LocalDBpediaEvaluation(){ boolean local=true; + SimpleClock total =new SimpleClock(); String url=""; if(local){ se = SparqlEndpoint.EndpointLOCALDBpedia(); @@ -93,11 +94,12 @@ poslimit+=5; neglimit+=5; - System.out.println("XXX examplesize "+(poslimit+neglimit)); - int concount=0; + printProgress(0, concepts.size(),0, "beginning",total.getTime()); + + int concount=1; for (String oneConcept : concepts) { - System.out.println("XXX "+concount+" of "+concepts.size()+""+oneConcept);concount++; + printProgress(concount, concepts.size(),0, oneConcept,total.getTime()); int recursiondepth=0; boolean closeAfterRecursion=true; @@ -110,8 +112,8 @@ negExamples = ae.getNegExamples(); for(recursiondepth=0;recursiondepth<4;recursiondepth++) { - System.out.println("XXX recursiondepth "+recursiondepth+" con "+oneConcept); + printProgress(concount, concepts.size(),recursiondepth, oneConcept,total.getTime()); /*if(i==0){;} else if(closeAfterRecursion) { closeAfterRecursion=false; @@ -232,5 +234,15 @@ } } + public static void printProgress(int con, int consize,int recdepth, String conceptname, long needed){ + int ex=poslimit+neglimit; + System.out.println("" + + "XXX num ex : "+ex+ " \n" + + "concept :"+con+"/"+consize+ " \n" + + "recursion : "+recdepth+" " + + "conceptname : "+conceptname+ "\n" + + "needed total: "+needed); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-15 21:35:13
|
Revision: 856 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=856&view=rev Author: kurzum Date: 2008-05-15 14:34:50 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/Statistics.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 20:50:51 UTC (rev 855) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 21:34:50 UTC (rev 856) @@ -49,7 +49,7 @@ System.out.println("Start"); //logger.setLevel(Level.TRACE); logger.setLevel(Level.WARN); - Logger.getLogger(SparqlKnowledgeSource.class).setLevel(Level.WARN); + Logger.getLogger(SparqlKnowledgeSource.class).setLevel(Level.TRACE); //System.out.println(Logger.getLogger(SparqlQuery.class).getLevel()); SimpleClock sc=new SimpleClock(); LocalDBpediaEvaluation(); @@ -238,8 +238,8 @@ int ex=poslimit+neglimit; System.out.println("" + "XXX num ex : "+ex+ " \n" + - "concept :"+con+"/"+consize+ " \n" + - "recursion : "+recdepth+" " + + "concept : "+con+"/"+consize+ " \n" + + "recursion : "+recdepth+" \n" + "conceptname : "+conceptname+ "\n" + "needed total: "+needed); } Modified: trunk/src/dl-learner/org/dllearner/utilities/Statistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-15 20:50:51 UTC (rev 855) +++ trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-15 21:34:50 UTC (rev 856) @@ -136,7 +136,7 @@ for (int i = 0; i < order.size(); i++) { String label=order.get(i); try { - System.out.println(str+""+label+" "+ (hm.get(label).intValue()/number)); + System.out.println(str+""+label+"\t"+ (hm.get(label).intValue()/number)); } catch (Exception e) { } } } @@ -145,7 +145,7 @@ for (int i = 0; i < order.size(); i++) { String label=order.get(i); try { - System.out.println(str+""+label+" "+hm.get(label)); + System.out.println(str+""+label+"\t"+hm.get(label)); } catch (Exception e) { } } } @@ -154,7 +154,7 @@ for (int i = 0; i < order.size(); i++) { String label=order.get(i); try { - System.out.println(str+label+" "+ (hm.get(label).intValue()/number)); + System.out.println(str+label+"\t"+ (hm.get(label).intValue()/number)); } catch (Exception e) { } } } @@ -163,7 +163,7 @@ for (int i = 0; i < order.size(); i++) { String label=order.get(i); try { - System.out.println(str+label+"|"+hm.get(label)); + System.out.println(str+label+"\t"+hm.get(label)); } catch (Exception e) { } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-15 21:39:02
|
Revision: 857 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=857&view=rev Author: kurzum Date: 2008-05-15 14:38:20 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 21:34:50 UTC (rev 856) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 21:38:20 UTC (rev 857) @@ -12,7 +12,6 @@ import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; import org.dllearner.kb.sparql.Cache; -import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import org.dllearner.utilities.AutomaticExampleFinderSPARQL; @@ -49,7 +48,7 @@ System.out.println("Start"); //logger.setLevel(Level.TRACE); logger.setLevel(Level.WARN); - Logger.getLogger(SparqlKnowledgeSource.class).setLevel(Level.TRACE); + //Logger.getLogger(SparqlKnowledgeSource.class).setLevel(Level.TRACE); //System.out.println(Logger.getLogger(SparqlQuery.class).getLevel()); SimpleClock sc=new SimpleClock(); LocalDBpediaEvaluation(); @@ -236,7 +235,7 @@ public static void printProgress(int con, int consize,int recdepth, String conceptname, long needed){ int ex=poslimit+neglimit; - System.out.println("" + + System.out.println("**********************STAT\n" + "XXX num ex : "+ex+ " \n" + "concept : "+con+"/"+consize+ " \n" + "recursion : "+recdepth+" \n" + Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 21:34:50 UTC (rev 856) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 21:38:20 UTC (rev 857) @@ -46,7 +46,7 @@ cm.applyConfigEntry(ks, "recursionDepth",recursiondepth); cm.applyConfigEntry(ks, "closeAfterRecursion",closeAfterRecursion); cm.applyConfigEntry(ks, "predefinedFilter","YAGO"); - cm.applyConfigEntry(ks, "predefinedEndpoint","DBPEDIA"); + cm.applyConfigEntry(ks, "predefinedEndpoint","LOCALDBPEDIA"); if(randomizeCache) cm.applyConfigEntry(ks, "cacheDir","cache/"+System.currentTimeMillis()+""); else {} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-15 22:09:23
|
Revision: 859 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=859&view=rev Author: kurzum Date: 2008-05-15 15:07:25 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-15 21:45:15 UTC (rev 858) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-15 22:07:25 UTC (rev 859) @@ -460,7 +460,8 @@ } logger.debug("size of candidate set: " + candidates.size()); - printBestSolutions(0); + boolean showOrderedSolutions = false; + printBestSolutions(20,showOrderedSolutions); printStatistics(true); if(stop) @@ -1059,7 +1060,7 @@ } - public void printBestSolutions(int nrOfSolutions){ + public void printBestSolutions(int nrOfSolutions, boolean showOrderedSolutions){ if(!logger.isTraceEnabled()) return; // if(!logger.getLevel().toString().equalsIgnoreCase("TRACE"))return; @@ -1074,8 +1075,8 @@ i++; } - boolean showOrderedSolutions = true; + if(showOrderedSolutions) { logger.trace("ordered by generality (most special solutions first):"); SubsumptionComparator sc = new SubsumptionComparator(rs); Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 21:45:15 UTC (rev 858) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 22:07:25 UTC (rev 859) @@ -38,7 +38,7 @@ static boolean useParallelClasses = true; static int poslimit = 0; static int neglimit = 0; - static boolean randomizeCache = true; + static boolean randomizeCache = false; /** * @param args @@ -95,10 +95,10 @@ neglimit+=5; printProgress(0, concepts.size(),0, "beginning",total.getTime()); - int concount=1; + int concount=0; for (String oneConcept : concepts) { - - printProgress(concount++, concepts.size(),0, oneConcept,total.getTime()); + concount++; + printProgress(concount, concepts.size(),0, oneConcept,total.getTime()); int recursiondepth=0; boolean closeAfterRecursion=true; @@ -121,10 +121,7 @@ else { closeAfterRecursion=true; }*/ - //Statistics.setCurrentLabel(recursiondepth+""+((closeAfterRecursion)?"+":"")); - //Statistics.setCurrentLabel(recursiondepth+""+((closeAfterRecursion)?"":"")); - Statistics.setCurrentLabel(recursiondepth+""); Statistics.print(number); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-15 22:39:04
|
Revision: 860 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=860&view=rev Author: kurzum Date: 2008-05-15 15:36:48 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java trunk/src/dl-learner/org/dllearner/utilities/Statistics.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-15 22:07:25 UTC (rev 859) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-15 22:36:48 UTC (rev 860) @@ -1061,8 +1061,10 @@ public void printBestSolutions(int nrOfSolutions, boolean showOrderedSolutions){ + System.out.println("alogger is "+logger.isTraceEnabled()+"||"); if(!logger.isTraceEnabled()) return; + System.out.println("blogger is "+logger.isTraceEnabled()+"||"); // if(!logger.getLevel().toString().equalsIgnoreCase("TRACE"))return; if(nrOfSolutions==0) nrOfSolutions=candidatesStable.size(); Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-15 22:07:25 UTC (rev 859) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-15 22:36:48 UTC (rev 860) @@ -75,10 +75,15 @@ // schauen, ob es mehrere allgemeinere Nachbarn gibt SortedSet<Description> moreGeneral = subsumptionHierarchyUp.get(c); //RBC //HACK - if(moreGeneral != null && moreGeneral.size()>0) { + //if(moreGeneral != null && moreGeneral.size()>0) { + if(moreGeneral != null ) { //System.out.println(moreGeneral); - Description chosenParent = moreGeneral.first(); - hierarchyDownNew.get(chosenParent).add(c); + if(moreGeneral.size()==0) { + hierarchyDownNew.get(new Thing()).add(c); + }else { + Description chosenParent = moreGeneral.first(); + hierarchyDownNew.get(chosenParent).add(c); + } } } @@ -86,9 +91,16 @@ for(Description c : allowedConceptsInSubsumptionHierarchy) { SortedSet<Description> moreSpecial = subsumptionHierarchyDown.get(c); //RBC //HACK - if(moreSpecial != null && moreSpecial.size()>0) { - Description chosenParent = moreSpecial.first(); - hierarchyUpNew.get(chosenParent).add(c); + //if(moreSpecial != null && moreSpecial.size()>0) { + if(moreSpecial != null ) { + if(moreSpecial.size()==0){ + hierarchyUpNew.get(new Nothing()).add(c); + } + else { + Description chosenParent = moreSpecial.first(); + hierarchyUpNew.get(chosenParent).add(c); + } + } } Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 22:07:25 UTC (rev 859) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 22:36:48 UTC (rev 860) @@ -112,6 +112,7 @@ for(recursiondepth=0;recursiondepth<4;recursiondepth++) { + Statistics.setCurrentLabel(recursiondepth+""); printProgress(concount, concepts.size(),recursiondepth, oneConcept,total.getTime()); /*if(i==0){;} else if(closeAfterRecursion) { @@ -125,7 +126,7 @@ Statistics.print(number); - System.out.println("currently at label "+Statistics.getCurrentLabel()+"||i: "+recursiondepth); + //System.out.println("currently at label "+Statistics.getCurrentLabel()+"||i: "+recursiondepth); LearnSparql ls = new LearnSparql(); TreeSet<String> igno = new TreeSet<String>(); Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 22:07:25 UTC (rev 859) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 22:36:48 UTC (rev 860) @@ -83,7 +83,7 @@ cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",20); //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); - cm.applyConfigEntry(la,"logLevel","TRACE"); + cm.applyConfigEntry(la,"logLevel","DEBUG"); //cm.applyConfigEntry(la,"quiet",false); //System.out.println(ignoredConcepts.first());; @@ -95,6 +95,7 @@ sc.setTime(); la.start(); Statistics.addTimeLearning(sc.getTime()); + if(sc.getTime()/1000 >= 20)System.out.println("XXXMAX time reached"); //System.out.println("best"+la(20)); Modified: trunk/src/dl-learner/org/dllearner/utilities/Statistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-15 22:07:25 UTC (rev 859) +++ trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-15 22:36:48 UTC (rev 860) @@ -37,6 +37,7 @@ else { timeCollecting.put(currentLabel, new Long(current.longValue()+value)); } + } public static void addTimeLearning(long value) { @@ -85,6 +86,7 @@ printInt(numberOfSparqlQueries,"total queries\t"); + //printIntAVG(numberOfTriples,number,"triples avg\t"); @@ -187,6 +189,7 @@ numberOfSparqlQueries = new HashMap<String, Integer>(); numberOfCachedSparqlQueries = new HashMap<String, Integer>(); + System.out.println("xxxRESET"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-15 23:30:26
|
Revision: 863 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=863&view=rev Author: kurzum Date: 2008-05-15 16:30:00 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-15 22:56:02 UTC (rev 862) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-15 23:30:00 UTC (rev 863) @@ -359,7 +359,7 @@ lastPrintTime = currentTime; logger.debug("--- loop " + loop + " started ---"); } - + logger.debug("--- loop " + loop + " started ---"); // traverse the current search tree to find a solution if(useTreeTraversal && (currentTime - lastTreeTraversalTime > traversalInterval)) { traverseTree(); Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 22:56:02 UTC (rev 862) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 23:30:00 UTC (rev 863) @@ -191,13 +191,13 @@ public static SortedSet<String> initConcepts(){ SortedSet<String> concepts = new TreeSet<String>(); - concepts.add("http://dbpedia.org/class/yago/AirLane108492546"); + /*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/Ceremony107450842");*/ concepts.add("http://dbpedia.org/class/yago/CookingOil107673145"); - concepts.add("http://dbpedia.org/class/yago/Corticosteroid114751417"); + /*concepts.add("http://dbpedia.org/class/yago/Corticosteroid114751417"); concepts.add("http://dbpedia.org/class/yago/Curlew102033561"); concepts.add("http://dbpedia.org/class/yago/DataStructure105728493"); concepts.add("http://dbpedia.org/class/yago/Disappearance100053609"); @@ -211,7 +211,7 @@ 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/AirLane108492546"); + concepts.add("http://dbpedia.org/class/yago/AirLane108492546");*/ return concepts; } Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 22:56:02 UTC (rev 862) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 23:30:00 UTC (rev 863) @@ -80,10 +80,10 @@ cm.applyConfigEntry(la,"useCardinalityRestrictions",false); cm.applyConfigEntry(la,"useNegation",false); cm.applyConfigEntry(la,"minExecutionTimeInSeconds",0); - cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",400); + cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",30); //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); - cm.applyConfigEntry(la,"logLevel","DEBUG"); + cm.applyConfigEntry(la,"logLevel","TRACE"); //cm.applyConfigEntry(la,"quiet",false); //System.out.println(ignoredConcepts.first());; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 00:07:41
|
Revision: 864 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=864&view=rev Author: kurzum Date: 2008-05-15 17:07:39 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-15 23:30:00 UTC (rev 863) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-16 00:07:39 UTC (rev 864) @@ -48,6 +48,7 @@ import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; +import org.dllearner.utilities.SimpleClock; /** * Implements the example based refinement operator learning @@ -279,6 +280,8 @@ public void start() { runtime=System.currentTimeMillis(); + //RBC many comments can be removed + //SimpleClock sc =new SimpleClock(); // TODO: write a JUnit test for this problem (long-lasting or infinite loops because // redundant children of a node are called recursively after when the node is extended // twice) @@ -359,12 +362,15 @@ lastPrintTime = currentTime; logger.debug("--- loop " + loop + " started ---"); } + //RBC logger.debug("--- loop " + loop + " started ---"); + //sc.printAndSet("before Traverse"); // traverse the current search tree to find a solution if(useTreeTraversal && (currentTime - lastTreeTraversalTime > traversalInterval)) { traverseTree(); lastTreeTraversalTime = System.nanoTime(); } + //sc.printAndSet("Traverse"); // reduce candidates to focus on promising concepts if(useCandidateReduction && (currentTime - lastReductionTime > reductionInterval)) { @@ -373,6 +379,7 @@ // Logger.getRootLogger().setLevel(Level.TRACE); } + //sc.printAndSet("candidates"); // System.out.println("next expanded: " + candidates.last().getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI)); // chose best node according to heuristics bestNode = candidates.last(); @@ -387,6 +394,7 @@ candidates.addAll(newCandidates); candidatesStable.addAll(newCandidates); + //sc.printAndSet("after candidates"); // System.out.println("done"); if(writeSearchTree) { @@ -407,7 +415,7 @@ else Files.appendFile(searchTreeFile, treeString); } - + //sc.printAndSet("before posonly"); // special situation for positive only learning: the expanded node can become a solution (see explanations // for maxPosOnlyExpansion above) if(posOnly && (bestNode.getHorizontalExpansion() - bestNode.getConcept().getLength() >= maxPosOnlyExpansion)) { @@ -424,8 +432,10 @@ } } + //sc.printAndSet("before stopping"); // handle termination criteria handleStoppingConditions(); + //sc.printAndSet("after stopping"); //logger.info(minExecutionTimeReached()+"aaaaaaa "+solutions.size()+"::"+guaranteeXgoodDescriptions); //logger.info(solutionFound+"aaaaaaa "+stop); Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-15 23:30:00 UTC (rev 863) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-16 00:07:39 UTC (rev 864) @@ -41,6 +41,8 @@ public SubsumptionHierarchy(Set<NamedClass> atomicConcepts, TreeMap<Description,TreeSet<Description>> subsumptionHierarchyUp , TreeMap<Description,TreeSet<Description>> subsumptionHierarchyDown) { this.subsumptionHierarchyUp = subsumptionHierarchyUp; + //System.out.println(subsumptionHierarchyDown); + //System.out.println(subsumptionHierarchyUp); this.subsumptionHierarchyDown = subsumptionHierarchyDown; allowedConceptsInSubsumptionHierarchy = new TreeSet<Description>(conceptComparator); allowedConceptsInSubsumptionHierarchy.addAll(atomicConcepts); @@ -80,6 +82,7 @@ //System.out.println(moreGeneral); if(moreGeneral.size()==0) { hierarchyDownNew.get(new Thing()).add(c); + moreGeneral.add(new Thing()); }else { Description chosenParent = moreGeneral.first(); hierarchyDownNew.get(chosenParent).add(c); @@ -95,6 +98,7 @@ if(moreSpecial != null ) { if(moreSpecial.size()==0){ hierarchyUpNew.get(new Nothing()).add(c); + moreSpecial.add(new Nothing()); } else { Description chosenParent = moreSpecial.first(); Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 23:30:00 UTC (rev 863) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 00:07:39 UTC (rev 864) @@ -38,7 +38,7 @@ static boolean useParallelClasses = true; static int poslimit = 0; static int neglimit = 0; - static boolean randomizeCache = false; + static boolean randomizeCache = true; /** * @param args @@ -47,7 +47,7 @@ init(); System.out.println("Start"); //logger.setLevel(Level.TRACE); - logger.setLevel(Level.WARN); + logger.setLevel(Level.TRACE); //Logger.getLogger(SparqlKnowledgeSource.class).setLevel(Level.TRACE); //System.out.println(Logger.getLogger(SparqlQuery.class).getLevel()); SimpleClock sc=new SimpleClock(); @@ -191,13 +191,13 @@ public static SortedSet<String> initConcepts(){ SortedSet<String> concepts = new TreeSet<String>(); - /*concepts.add("http://dbpedia.org/class/yago/AirLane108492546"); + 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/Ceremony107450842"); concepts.add("http://dbpedia.org/class/yago/CookingOil107673145"); - /*concepts.add("http://dbpedia.org/class/yago/Corticosteroid114751417"); + concepts.add("http://dbpedia.org/class/yago/Corticosteroid114751417"); concepts.add("http://dbpedia.org/class/yago/Curlew102033561"); concepts.add("http://dbpedia.org/class/yago/DataStructure105728493"); concepts.add("http://dbpedia.org/class/yago/Disappearance100053609"); @@ -211,7 +211,7 @@ 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/AirLane108492546");*/ + concepts.add("http://dbpedia.org/class/yago/AirLane108492546"); return concepts; } Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 23:30:00 UTC (rev 863) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 00:07:39 UTC (rev 864) @@ -81,7 +81,12 @@ cm.applyConfigEntry(la,"useNegation",false); cm.applyConfigEntry(la,"minExecutionTimeInSeconds",0); cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",30); + cm.applyConfigEntry(la,"writeSearchTree",false); + cm.applyConfigEntry(la,"searchTreeFile","log/search.txt"); + cm.applyConfigEntry(la,"replaceSearchTree",true); + cm.applyConfigEntry(la,"noisePercentage",0.15); + //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); cm.applyConfigEntry(la,"logLevel","TRACE"); @@ -96,7 +101,7 @@ la.start(); Statistics.addTimeLearning(sc.getTime()); - if(sc.getTime()/1000 >= 20)System.out.println("XXXMAX time reached"); + //if(sc.getTime()/1000 >= 20)System.out.println("XXXMAX time reached"); //System.out.println("best"+la(20)); //((ExampleBasedROLComponent)la).printBestSolutions(10000); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 00:15:50
|
Revision: 865 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=865&view=rev Author: kurzum Date: 2008-05-15 17:15:47 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.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 00:07:39 UTC (rev 864) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-16 00:15:47 UTC (rev 865) @@ -363,7 +363,7 @@ logger.debug("--- loop " + loop + " started ---"); } //RBC - logger.debug("--- loop " + loop + " started ---"); + //logger.debug("--- loop " + loop + " started ---"); //sc.printAndSet("before Traverse"); // traverse the current search tree to find a solution if(useTreeTraversal && (currentTime - lastTreeTraversalTime > traversalInterval)) { @@ -1071,11 +1071,9 @@ public void printBestSolutions(int nrOfSolutions, boolean showOrderedSolutions){ - System.out.println("alogger is "+logger.isTraceEnabled()+"||"); if(!logger.isTraceEnabled()) return; - System.out.println("blogger is "+logger.isTraceEnabled()+"||"); -// if(!logger.getLevel().toString().equalsIgnoreCase("TRACE"))return; + //if(!logger.getLevel().toString().equalsIgnoreCase("TRACE"))return; if(nrOfSolutions==0) nrOfSolutions=candidatesStable.size(); int i=0; Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 00:07:39 UTC (rev 864) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 00:15:47 UTC (rev 865) @@ -11,7 +11,9 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import org.dllearner.core.KnowledgeSource; import org.dllearner.kb.sparql.Cache; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import org.dllearner.utilities.AutomaticExampleFinderSPARQL; @@ -47,8 +49,9 @@ init(); System.out.println("Start"); //logger.setLevel(Level.TRACE); - logger.setLevel(Level.TRACE); - //Logger.getLogger(SparqlKnowledgeSource.class).setLevel(Level.TRACE); + logger.setLevel(Level.WARN); + //Logger.getLogger(SparqlKnowledgeSource.class).setLevel(Level.WARN); + //Logger.getLogger(KnowledgeSource.class).setLevel(Level.WARN); //System.out.println(Logger.getLogger(SparqlQuery.class).getLevel()); SimpleClock sc=new SimpleClock(); LocalDBpediaEvaluation(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 00:57:04
|
Revision: 868 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=868&view=rev Author: kurzum Date: 2008-05-15 17:56:53 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-16 00:40:54 UTC (rev 867) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-16 00:56:53 UTC (rev 868) @@ -71,6 +71,7 @@ import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; 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; @@ -126,7 +127,9 @@ logger.addAppender(consoleAppender); logger.addAppender(fileAppender); logger.setLevel(Level.TRACE); - //Logger.getLogger(KnowledgeSource.class).setLevel(Level.TRACE); + Logger.getLogger(KnowledgeSource.class).setLevel(Level.WARN); + Logger.getLogger(SparqlKnowledgeSource.class).setLevel(Level.WARN); + Logger.getLogger(TypedSparqlQuery.class).setLevel(Level.WARN); Start start = null; start = new Start(file); Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-16 00:40:54 UTC (rev 867) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-16 00:56:53 UTC (rev 868) @@ -77,6 +77,10 @@ // schauen, ob es mehrere allgemeinere Nachbarn gibt SortedSet<Description> moreGeneral = subsumptionHierarchyUp.get(c); //RBC //HACK + if(moreGeneral.size()==0){ + subsumptionHierarchyUp.remove(c); + moreGeneral=null; + } //if(moreGeneral != null && moreGeneral.size()>0) { if(moreGeneral != null ) { //System.out.println(moreGeneral); @@ -96,6 +100,10 @@ for(Description c : allowedConceptsInSubsumptionHierarchy) { SortedSet<Description> moreSpecial = subsumptionHierarchyDown.get(c); //RBC //HACK + if(moreSpecial.size()==0){ + subsumptionHierarchyDown.remove(c); + moreSpecial=null; + } //if(moreSpecial != null && moreSpecial.size()>0) { if(moreSpecial != null ) { if(moreSpecial.size()==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 01:08:49
|
Revision: 869 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=869&view=rev Author: kurzum Date: 2008-05-15 18:08:43 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java trunk/src/dl-learner/org/dllearner/utilities/Statistics.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-16 00:56:53 UTC (rev 868) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-16 01:08:43 UTC (rev 869) @@ -77,17 +77,15 @@ // schauen, ob es mehrere allgemeinere Nachbarn gibt SortedSet<Description> moreGeneral = subsumptionHierarchyUp.get(c); //RBC //HACK - if(moreGeneral.size()==0){ - subsumptionHierarchyUp.remove(c); - moreGeneral=null; - } //if(moreGeneral != null && moreGeneral.size()>0) { if(moreGeneral != null ) { //System.out.println(moreGeneral); if(moreGeneral.size()==0) { + subsumptionHierarchyUp.remove(c); + moreGeneral=null; //hierarchyDownNew.get(new Thing()).add(c); //moreGeneral.add(new Thing()); - subsumptionHierarchyUp.put(c, null); + //subsumptionHierarchyUp.put(c, null); }else { Description chosenParent = moreGeneral.first(); @@ -100,16 +98,15 @@ for(Description c : allowedConceptsInSubsumptionHierarchy) { SortedSet<Description> moreSpecial = subsumptionHierarchyDown.get(c); //RBC //HACK - if(moreSpecial.size()==0){ - subsumptionHierarchyDown.remove(c); - moreSpecial=null; - } + //if(moreSpecial != null && moreSpecial.size()>0) { if(moreSpecial != null ) { if(moreSpecial.size()==0){ - //hierarchyUpNew.get(new Nothing()).add(c); + subsumptionHierarchyDown.remove(c); + moreSpecial=null; + //hierarchyUpNew.get(new Nothing()).add(c); //moreSpecial.add(new Nothing()); - subsumptionHierarchyDown.put(c, null); + //subsumptionHierarchyDown.put(c, null); } else { Description chosenParent = moreSpecial.first(); Modified: trunk/src/dl-learner/org/dllearner/utilities/Statistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-16 00:56:53 UTC (rev 868) +++ trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-16 01:08:43 UTC (rev 869) @@ -41,6 +41,7 @@ } public static void addTimeLearning(long value) { + Long current = timeLearning.get(currentLabel); if(current==null) timeLearning.put(currentLabel, new Long(value)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 07:05:12
|
Revision: 872 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=872&view=rev Author: kurzum Date: 2008-05-16 00:05:09 -0700 (Fri, 16 May 2008) Log Message: ----------- 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/kb/sparql/Cache.java 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/SparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java Added 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/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-16 07:05:09 UTC (rev 872) @@ -25,6 +25,7 @@ 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; @@ -383,6 +384,12 @@ public synchronized List<Description> getBestSolutions(int nrOfSolutions) { return algorithm.getBestSolutions(nrOfSolutions); } + + //HACK + @Override + public SortedSet<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ + return this.algorithm.getBestSolutionsAsKBSyntax(nrOfSolutions); + } @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-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-16 07:05:09 UTC (rev 872) @@ -48,7 +48,6 @@ import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.SimpleClock; /** * Implements the example based refinement operator learning @@ -1061,6 +1060,7 @@ List<Description> best = new LinkedList<Description>(); int i=0; for(ExampleBasedNode n : candidatesStable.descendingSet()) { + best.add(n.getConcept()); if(i==nrOfSolutions) return best; @@ -1069,7 +1069,27 @@ return best; } + //HACK + public SortedSet<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ + SortedSet<String> result = new TreeSet<String>(); + for (Description d : solutions) { + result.add(d.toKBSyntaxString()); + //if(result.size()==nrOfSolutions)break; + } + /*if(result.size()<nrOfSolutions){ + + for(ExampleBasedNode n : candidatesStable.descendingSet()) { + + result.add(n.getConcept().toKBSyntaxString()); + if(result.size()>=nrOfSolutions) + return result; + + } + }*/ + return result; + } + public void printBestSolutions(int nrOfSolutions, boolean showOrderedSolutions){ if(!logger.isTraceEnabled()) return; Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-05-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-05-16 07:05:09 UTC (rev 872) @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; +import java.util.SortedSet; import org.dllearner.core.owl.Description; @@ -63,6 +64,11 @@ return single; } + //HACK + public SortedSet<String> getBestSolutionsAsKBSyntax(int nrOfSolutions){ + return null; + } + /** * Returns all learning problems supported by this component. */ Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-05-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-05-16 07:05:09 UTC (rev 872) @@ -31,6 +31,7 @@ import java.util.LinkedList; import org.apache.log4j.Logger; +import org.dllearner.core.KnowledgeSource; import org.dllearner.utilities.SimpleClock; import org.dllearner.utilities.Statistics; @@ -59,8 +60,9 @@ */ public class Cache implements Serializable { - private static Logger logger = Logger.getLogger(Cache.class); + private static Logger logger = Logger.getLogger(KnowledgeSource.class); + private static final long serialVersionUID = 843308736471742205L; // maps hash of a SPARQL queries to JSON representation Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java 2008-05-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java 2008-05-16 07:05:09 UTC (rev 872) @@ -24,6 +24,7 @@ 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; @@ -42,7 +43,7 @@ // private boolean getAllSuperClasses = true; // private boolean closeAfterRecursion = true; private static Logger logger = Logger - .getLogger(ExtractionAlgorithm.class); + .getLogger(KnowledgeSource.class); public ExtractionAlgorithm(Configuration Configuration) { this.configuration = Configuration; Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java 2008-05-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java 2008-05-16 07:05:09 UTC (rev 872) @@ -24,6 +24,8 @@ 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; @@ -42,7 +44,10 @@ 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, @@ -76,8 +81,10 @@ // 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); Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-05-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-05-16 07:05:09 UTC (rev 872) @@ -24,8 +24,8 @@ import java.nio.charset.Charset; import org.apache.log4j.Logger; +import org.dllearner.core.KnowledgeSource; import org.dllearner.kb.sparql.configuration.SparqlEndpoint; -import org.dllearner.utilities.SimpleClock; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFactory; @@ -42,7 +42,7 @@ */ public class SparqlQuery { - private static Logger logger = Logger.getLogger(SparqlKnowledgeSource.class); + private static Logger logger = Logger.getLogger(KnowledgeSource.class); public String extraDebugInfo = ""; private boolean isRunning = false; Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java 2008-05-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java 2008-05-16 07:05:09 UTC (rev 872) @@ -24,6 +24,8 @@ import java.util.List; import java.util.Set; +import org.apache.log4j.Logger; +import org.dllearner.core.KnowledgeSource; import org.dllearner.kb.sparql.configuration.Configuration; import org.dllearner.utilities.SimpleClock; import org.dllearner.utilities.StringTuple; @@ -39,6 +41,10 @@ * */ public class TypedSparqlQuery implements TypedSparqlQueryInterface { + + private static Logger logger = Logger.getLogger(KnowledgeSource.class); + + boolean print_flag = false; protected Configuration configuration; private SparqlQueryMaker sparqlQueryMaker; Added: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 07:05:09 UTC (rev 872) @@ -0,0 +1,221 @@ +package org.dllearner.scripts; + +import java.util.SortedSet; +import java.util.TreeSet; + +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.kb.sparql.Cache; +import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.kb.sparql.configuration.SparqlEndpoint; +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 com.hp.hpl.jena.query.ResultSet; + +public class SKOS7030 { + + static Cache c; + static SparqlEndpoint se; + private static Logger logger = Logger.getRootLogger(); + + static String standardSettings=""; + static String algorithm="refexamples"; + static String standardSettingsRefexamples = + "refexamples.minExecutionTimeInSeconds = 30;\n" + + "refexamples.maxExecutionTimeInSeconds = 30;\n" + + "//refexamples.guaranteeXgoodDescriptions = 10;\n" + + "refexamples.logLevel=\"TRACE\";\n" + + "refexamples.noisePercentage = 0.10;\n" + + "refexamples.writeSearchTree = false;\n" + + "refexamples.searchTreeFile = \"searchTree.txt\";\n" + + "refexamples.replaceSearchTree = true;\n\n" ; + + static String standardSettingsRefinement = + "refinement.minExecutionTimeInSeconds = 30;\n" + + "refinement.maxExecutionTimeInSeconds = 30;\n" + + "//refinement.guaranteeXgoodDescriptions = 10;\n" + + "refinement.logLevel=\"TRACE\";\n" + + "refinement.writeSearchTree = false;\n" + + "refinement.searchTreeFile = \"searchTree.txt\";\n" + + "refinement.replaceSearchTree = true;\n\n" ; + + + + static String standardDBpedia="" + + "sparql.recursionDepth = 1;\n" + + "sparql.predefinedFilter = \"YAGO\";\n" + + "sparql.predefinedEndpoint = \"DBPEDIA\";\n"; + //"sparql.logLevel = \"INFO\";\n"; + + + //vars + static boolean useRelated = false; + static boolean useSuperClasses = false; + static boolean useParallelClasses = true; + static int poslimit = 10; + static int neglimit = 20; + + /** + * @param args + */ + public static void main(String[] args) { + init(); + //logger.setLevel(Level.TRACE); + Logger.getLogger(KnowledgeSource.class).setLevel(Level.INFO); + //System.out.println(Logger.getLogger(SparqlQuery.class).getLevel()); + SimpleClock sc=new SimpleClock(); + + standardSettings=standardSettingsRefexamples+standardDBpedia; + //standardSettings=standardSettingsRefinement+standardDBpedia; + + DBpediaSKOS(); + //algorithm="refinement"; + //roles(); + + /*System.out.println(Level.DEBUG.getClass()); + System.out.println(Level.toLevel("INFO")); + System.out.println(Level.INFO);*/ + //System.exit(0); + + + + sc.printAndSet("Finished"); + + } + + + + static void DBpediaSKOS(){ + se = SparqlEndpoint.EndpointLOCALDBpedia(); + 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"); + + SortedSet<String> posExamples = new TreeSet<String>(); + SortedSet<String> negExamples = new TreeSet<String>(); + + //HashMap<String, ResultSet> result = new HashMap<String, ResultSet>(); + //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); + posExamples = ae.getPosExamples(); + negExamples = ae.getNegExamples(); + SortedSet<String> totalSKOSset= ae.totalSKOSset; + SortedSet<String> rest= ae.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); + for (String string : conceptresults) { + 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); + } + + + + //System.out.println("AAAAAAAA"); + //System.exit(0); + //"relearned concept: "; + //cf.writeSPARQL(confname, posExamples, negExamples, url, new TreeSet<String>(),standardSettings,algorithm); + // + + + //Statistics.print(); + } + + + /*************************************************************************** + * *********************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("************************"); } + **************************************************************************/ + + + + + + public static void init() { + + SimpleLayout layout = new SimpleLayout(); + // create logger (a simple logger which outputs + // its messages to the console) + FileAppender fileAppender =null; ; + try{ + fileAppender = new FileAppender(layout,"the_log.txt",false); + }catch (Exception e) {e.printStackTrace();} + + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + logger.removeAllAppenders(); + logger.addAppender(consoleAppender); + logger.addAppender(fileAppender); + logger.setLevel(Level.DEBUG); + c = new Cache("cachetemp"); + + + } + + public static SortedSet<String> selectDBpediaConcepts(int number){ + String query = "SELECT DISTINCT ?concept WHERE { \n" + + "[] a ?concept .FILTER (regex(str(?concept),'yago'))" + + " \n} \n"; //LIMIT "+number+" + + + String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); + ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); + JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); + return SetManipulation.fuzzyShrink(rsc.getStringListForVariable("concept"),number); + } + + + +} Added: trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSKOSSPARQL.java 2008-05-16 07:05:09 UTC (rev 872) @@ -0,0 +1,408 @@ +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.SparqlQuery; +import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; +import org.dllearner.kb.sparql.configuration.SparqlEndpoint; + +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("cachetemp"); + 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=2*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); + 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" + + "}"; + 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(); + } + + } + + + +} Modified: trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSPARQL.java 2008-05-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/utilities/AutomaticExampleFinderSPARQL.java 2008-05-16 07:05:09 UTC (rev 872) @@ -21,6 +21,7 @@ private SparqlEndpoint se; private SortedSet<String> posExamples; private SortedSet<String> negExamples; + public SortedSet<String> totalSKOSset; private int limit=2000; Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 01:23:08 UTC (rev 871) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 07:05:09 UTC (rev 872) @@ -110,6 +110,95 @@ //System.out.println( la.getBestSolution());; } + public SortedSet<String> learnDBpediaSKOS(SortedSet<String> posExamples,SortedSet<String> negExamples, + String uri, SortedSet<String> ignoredConcepts, int recursiondepth, + boolean closeAfterRecursion, boolean randomizeCache){ + + ComponentManager cm = ComponentManager.getInstance(); + LearningAlgorithm la = null; + ReasoningService rs = null; + LearningProblem lp = null; + SparqlKnowledgeSource ks =null; + try { + Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); + + ks = cm.knowledgeSource(SparqlKnowledgeSource.class); + + SortedSet<String> instances = new TreeSet<String>(); + instances.addAll(posExamples); + instances.addAll(negExamples); + cm.applyConfigEntry(ks, "instances",instances); + cm.applyConfigEntry(ks, "url",uri); + cm.applyConfigEntry(ks, "recursionDepth",recursiondepth); + cm.applyConfigEntry(ks, "closeAfterRecursion",closeAfterRecursion); + cm.applyConfigEntry(ks, "predefinedFilter","YAGO"); + cm.applyConfigEntry(ks, "predefinedEndpoint","LOCALDBPEDIA"); + if(randomizeCache) + cm.applyConfigEntry(ks, "cacheDir","cache/"+System.currentTimeMillis()+""); + else {cm.applyConfigEntry(ks, "cacheDir","cacheSKOS");} + //cm.applyConfigEntry(ks, "format","KB"); + + sc.setTime(); + ks.init(); + Statistics.addTimeCollecting(sc.getTime()); + sources.add(ks); + //if (true)return; + //System.out.println(ks.getNTripleURL()); + // + + ReasonerComponent r = new FastInstanceChecker(sources); + //cm.applyConfigEntry(r,"useAllConstructor",false); + //cm.applyConfigEntry(r,"useExistsConstructor",true); + r.init(); + rs = new ReasoningService(r); + + lp = new PosNegDefinitionLP(rs); + //cm.applyConfigEntry(lp, "positiveExamples",toInd(posExamples)); + ((PosNegLP) lp).setPositiveExamples(SetManipulation.stringToInd(posExamples)); + ((PosNegLP) lp).setNegativeExamples(SetManipulation.stringToInd(negExamples)); + //cm.applyConfigEntry(lp, "negativeExamples",toInd(negExamples)); + lp.init(); + + la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); + + cm.applyConfigEntry(la,"useAllConstructor",false); + cm.applyConfigEntry(la,"useExistsConstructor",true); + 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,"writeSearchTree",true); + cm.applyConfigEntry(la,"searchTreeFile","log/SKOS.txt"); + cm.applyConfigEntry(la,"replaceSearchTree",true); + //cm.applyConfigEntry(la,"noisePercentage",0.15); + + + //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); + cm.applyConfigEntry(la,"logLevel","TRACE"); + + //cm.applyConfigEntry(la,"quiet",false); + //System.out.println(ignoredConcepts.first());; + if(ignoredConcepts.size()>0) + cm.applyConfigEntry(la,"ignoredConcepts",ignoredConcepts); + la.init(); + + System.out.println("start learning"); + sc.setTime(); + la.start(); + Statistics.addTimeLearning(sc.getTime()); + return la.getBestSolutionsAsKBSyntax(15); + //if(sc.getTime()/1000 >= 20)System.out.println("XXXMAX time reached"); + + //System.out.println("best"+la(20)); + //((ExampleBasedROLComponent)la).printBestSolutions(10000); + + }catch (Exception e) {e.printStackTrace();} + return null; + //System.out.println( la.getBestSolution());; + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-05-16 08:19:29
|
Revision: 873 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=873&view=rev Author: jenslehmann Date: 2008-05-16 01:19:26 -0700 (Fri, 16 May 2008) Log Message: ----------- adjusted settings Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.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 07:05:09 UTC (rev 872) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-16 08:19:26 UTC (rev 873) @@ -124,7 +124,7 @@ // but the disadvantage of properness testing are additional reasoner // queries and a search bias towards ALL r.something because // ALL r.TOP is improper and automatically expanded further - private boolean testProperness = true; + private boolean testProperness = false; // tree traversal means to run through the most promising concepts // and connect them in an intersection to find a solution Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-05-16 07:05:09 UTC (rev 872) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-05-16 08:19:26 UTC (rev 873) @@ -77,11 +77,11 @@ // heuristic parameters private double expansionPenaltyFactor; private double gainBonusFactor; - private double nodeChildPenalty = 0.0001; + private double nodeChildPenalty = 0.0001; // (use higher values than 0.0001 for simple learning problems); private double startNodeBonus = 0.1; //was 2.0 // penalise errors on positive examples harder than on negative examples // (positive weight = 1) - private double negativeWeight = 0.8; + private double negativeWeight = 1.0; // was 0.8; // examples private int nrOfNegativeExamples; Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-16 07:05:09 UTC (rev 872) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-16 08:19:26 UTC (rev 873) @@ -76,45 +76,20 @@ for(Description c : allowedConceptsInSubsumptionHierarchy) { // schauen, ob es mehrere allgemeinere Nachbarn gibt SortedSet<Description> moreGeneral = subsumptionHierarchyUp.get(c); - //RBC //HACK - //if(moreGeneral != null && moreGeneral.size()>0) { - if(moreGeneral != null ) { - //System.out.println(moreGeneral); - if(moreGeneral.size()==0) { - subsumptionHierarchyUp.remove(c); - moreGeneral=null; - //hierarchyDownNew.get(new Thing()).add(c); - //moreGeneral.add(new Thing()); - //subsumptionHierarchyUp.put(c, null); - - }else { - Description chosenParent = moreGeneral.first(); - hierarchyDownNew.get(chosenParent).add(c); - } + if(moreGeneral != null && moreGeneral.size() != 0) { + Description chosenParent = moreGeneral.first(); + hierarchyDownNew.get(chosenParent).add(c); } } // for(Concept c : allowedConceptsInSubsumptionHierarchy) { for(Description c : allowedConceptsInSubsumptionHierarchy) { SortedSet<Description> moreSpecial = subsumptionHierarchyDown.get(c); - //RBC //HACK - - //if(moreSpecial != null && moreSpecial.size()>0) { - if(moreSpecial != null ) { - if(moreSpecial.size()==0){ - subsumptionHierarchyDown.remove(c); - moreSpecial=null; - //hierarchyUpNew.get(new Nothing()).add(c); - //moreSpecial.add(new Nothing()); - //subsumptionHierarchyDown.put(c, null); - } - else { - Description chosenParent = moreSpecial.first(); - hierarchyUpNew.get(chosenParent).add(c); - } - + if(moreSpecial != null && moreSpecial.size() != 0) { + Description chosenParent = moreSpecial.first(); + hierarchyUpNew.get(chosenParent).add(c); } - } + } subsumptionHierarchyDown = hierarchyDownNew; subsumptionHierarchyUp = hierarchyUpNew; Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 07:05:09 UTC (rev 872) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 08:19:26 UTC (rev 873) @@ -40,7 +40,7 @@ static boolean useParallelClasses = true; static int poslimit = 0; static int neglimit = 0; - static boolean randomizeCache = true; + static boolean randomizeCache = false; /** * @param args @@ -194,27 +194,27 @@ public static SortedSet<String> initConcepts(){ SortedSet<String> concepts = new TreeSet<String>(); - 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"); - concepts.add("http://dbpedia.org/class/yago/Curlew102033561"); - 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/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/AirLane108492546");*/ +// 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"); +// concepts.add("http://dbpedia.org/class/yago/Curlew102033561"); +// 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/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/AirLane108492546");*/ return concepts; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 08:49:25
|
Revision: 875 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=875&view=rev Author: kurzum Date: 2008-05-16 01:48:56 -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 trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java trunk/src/dl-learner/org/dllearner/utilities/Statistics.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 08:20:16 UTC (rev 874) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-16 08:48:56 UTC (rev 875) @@ -362,7 +362,8 @@ logger.debug("--- loop " + loop + " started ---"); } //RBC - //logger.debug("--- loop " + loop + " started ---"); + logger.debug("--- loop " + loop + " started ---"); + printStatistics(false); //sc.printAndSet("before Traverse"); // traverse the current search tree to find a solution if(useTreeTraversal && (currentTime - lastTreeTraversalTime > traversalInterval)) { Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 08:20:16 UTC (rev 874) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-05-16 08:48:56 UTC (rev 875) @@ -122,6 +122,14 @@ ae.initDBpediaSKOS(concept, 0.1, useRelated, useParallelClasses); posExamples = ae.getPosExamples(); negExamples = ae.getNegExamples(); + + for (String string2 : negExamples) { + logger.debug("-"+string2); + } + + for (String string2 : posExamples) { + logger.debug("+"+string2); + } SortedSet<String> totalSKOSset= ae.totalSKOSset; SortedSet<String> rest= ae.rest; Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 08:20:16 UTC (rev 874) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-16 08:48:56 UTC (rev 875) @@ -11,9 +11,7 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; -import org.dllearner.core.KnowledgeSource; import org.dllearner.kb.sparql.Cache; -import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import org.dllearner.utilities.AutomaticExampleFinderSPARQL; @@ -40,7 +38,7 @@ static boolean useParallelClasses = true; static int poslimit = 0; static int neglimit = 0; - static boolean randomizeCache = false; + static boolean randomizeCache = true; /** * @param args @@ -81,6 +79,7 @@ //System.out.println(selectDBpediaConcepts(10)); tmpSet=initConcepts(); int number=tmpSet.size(); + //System.out.println(number); //concepts.add("\"http://dbpedia.org/class/yago/Flamethrower103356559\""); for (String string : tmpSet) { //System.out.println("\""+string+"\","); @@ -154,6 +153,9 @@ String comment3="# "+examples+"examples\n"; String f3=pre+"2avgTimeLearning_"+examples+"example"+concepts.size()+"classes"; writeToFile(f3, comment3+Statistics.getAVGTimeLearning(number)); + String comment4="# "+examples+"examples\n"; + String f4=pre+"2avgTotalTime_"+examples+"example"+concepts.size()+"classes"; + writeToFile(f4, comment4+Statistics.getAVGtotalTime(number)); Statistics.reset(); }//outer @@ -194,27 +196,27 @@ public static SortedSet<String> initConcepts(){ SortedSet<String> concepts = new TreeSet<String>(); -// 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/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"); -// concepts.add("http://dbpedia.org/class/yago/Curlew102033561"); -// 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/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/AirLane108492546");*/ + concepts.add("http://dbpedia.org/class/yago/Curlew102033561"); + 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/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/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 08:20:16 UTC (rev 874) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 08:48:56 UTC (rev 875) @@ -84,7 +84,7 @@ cm.applyConfigEntry(la,"writeSearchTree",false); cm.applyConfigEntry(la,"searchTreeFile","log/search.txt"); cm.applyConfigEntry(la,"replaceSearchTree",true); - cm.applyConfigEntry(la,"noisePercentage",0.15); + //cm.applyConfigEntry(la,"noisePercentage",0.5); //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); @@ -152,6 +152,7 @@ //cm.applyConfigEntry(r,"useExistsConstructor",true); r.init(); rs = new ReasoningService(r); + //System.out.println("satisfy: "+rs.isSatisfiable()); lp = new PosNegDefinitionLP(rs); //cm.applyConfigEntry(lp, "positiveExamples",toInd(posExamples)); Modified: trunk/src/dl-learner/org/dllearner/utilities/Statistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-16 08:20:16 UTC (rev 874) +++ trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-16 08:48:56 UTC (rev 875) @@ -12,7 +12,9 @@ private static HashMap<String, Integer> numberOfTriples = new HashMap<String, Integer>(); private static HashMap<String, Long> timeCollecting = new HashMap<String, Long>(); private static HashMap<String, Long> timeLearning = new HashMap<String, Long>(); + private static HashMap<String, Long> timeTotal = new HashMap<String, Long>(); + private static HashMap<String, Integer> numberOfSparqlQueries = new HashMap<String, Integer>(); private static HashMap<String, Integer> numberOfCachedSparqlQueries = new HashMap<String, Integer>(); @@ -31,6 +33,7 @@ } public static void addTimeCollecting(long value) { + addTimeTotal(value); Long current = timeCollecting.get(currentLabel); if(current==null) timeCollecting.put(currentLabel, new Long(value)); @@ -38,9 +41,21 @@ timeCollecting.put(currentLabel, new Long(current.longValue()+value)); } + } + public static void addTimeTotal(long value) { + Long current = timeTotal.get(currentLabel); + if(current==null) + timeTotal.put(currentLabel, new Long(value)); + else { + timeTotal.put(currentLabel, new Long(current.longValue()+value)); + } + + } + public static void addTimeLearning(long value) { + addTimeTotal(value); Long current = timeLearning.get(currentLabel); if(current==null) @@ -135,6 +150,18 @@ return ret; } + public static String getAVGtotalTime(int number){ + + String ret="#Label, i.e. rec depth \t avg total time \n"; + for (int i = 0; i < order.size(); i++) { + String label=order.get(i); + try { + ret+=label+"\t"+ (timeTotal.get(label).longValue()/number)+"\n"; + } catch (Exception e) { } + } + return ret; + } + public static void printIntAVG(HashMap<String, Integer> hm, int number, String str){ for (int i = 0; i < order.size(); i++) { String label=order.get(i); @@ -187,6 +214,7 @@ numberOfTriples = new HashMap<String, Integer>(); timeCollecting = new HashMap<String, Long>(); timeLearning = new HashMap<String, Long>(); + timeTotal = new HashMap<String, Long>(); numberOfSparqlQueries = new HashMap<String, Integer>(); numberOfCachedSparqlQueries = new HashMap<String, Integer>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-05-16 09:59:31
|
Revision: 876 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=876&view=rev Author: kurzum Date: 2008-05-16 02:59:28 -0700 (Fri, 16 May 2008) Log Message: ----------- 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/owl/SubsumptionHierarchy.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-16 08:48:56 UTC (rev 875) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-16 09:59:28 UTC (rev 876) @@ -291,10 +291,10 @@ Helper.checkConcepts(rs, allowedConcepts); usedConcepts = allowedConcepts; } else if(ignoredConcepts != null) { - System.out.println(ignoredConcepts); + //System.out.println(ignoredConcepts); usedConcepts = Helper.computeConceptsUsingIgnoreList(rs, ignoredConcepts); //RBC - System.out.println(usedConcepts); + //System.out.println(usedConcepts); } else { usedConcepts = Helper.computeConcepts(rs); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-16 08:48:56 UTC (rev 875) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-16 09:59:28 UTC (rev 876) @@ -362,8 +362,8 @@ logger.debug("--- loop " + loop + " started ---"); } //RBC - logger.debug("--- loop " + loop + " started ---"); - printStatistics(false); + //logger.debug("--- loop " + loop + " started ---"); + //printStatistics(false); //sc.printAndSet("before Traverse"); // traverse the current search tree to find a solution if(useTreeTraversal && (currentTime - lastTreeTraversalTime > traversalInterval)) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-16 08:48:56 UTC (rev 875) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-16 09:59:28 UTC (rev 876) @@ -41,8 +41,7 @@ public SubsumptionHierarchy(Set<NamedClass> atomicConcepts, TreeMap<Description,TreeSet<Description>> subsumptionHierarchyUp , TreeMap<Description,TreeSet<Description>> subsumptionHierarchyDown) { this.subsumptionHierarchyUp = subsumptionHierarchyUp; - System.out.println(subsumptionHierarchyDown); - System.out.println(subsumptionHierarchyUp); + this.subsumptionHierarchyDown = subsumptionHierarchyDown; allowedConceptsInSubsumptionHierarchy = new TreeSet<Description>(conceptComparator); allowedConceptsInSubsumptionHierarchy.addAll(atomicConcepts); Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 08:48:56 UTC (rev 875) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-16 09:59:28 UTC (rev 876) @@ -88,7 +88,7 @@ //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); - cm.applyConfigEntry(la,"logLevel","TRACE"); + cm.applyConfigEntry(la,"logLevel","DEBUG"); //cm.applyConfigEntry(la,"quiet",false); //System.out.println(ignoredConcepts.first());; 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. |
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: <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-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 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-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-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: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: <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] |