From: <ku...@us...> - 2008-05-15 16:32:53
|
Revision: 851 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=851&view=rev Author: kurzum Date: 2008-05-15 09:32:46 -0700 (Thu, 15 May 2008) Log Message: ----------- Modified Paths: -------------- 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/JenaHTTPTest.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 15:12:35 UTC (rev 850) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-05-15 16:32:46 UTC (rev 851) @@ -1,5 +1,8 @@ package org.dllearner.scripts; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.SortedSet; import java.util.TreeSet; @@ -31,12 +34,12 @@ //static String algorithm="refexamples"; //vars - static boolean useRelated = true; + static boolean useRelated = false; static boolean useSuperClasses = true; static boolean useParallelClasses = true; - static int poslimit = 5; - static int neglimit = 5; - static boolean randomizeCache = false; + static int poslimit = 0; + static int neglimit = 0; + static boolean randomizeCache = true; /** * @param args @@ -86,11 +89,14 @@ SortedSet<String> posExamples = new TreeSet<String>(); SortedSet<String> negExamples = new TreeSet<String>(); + for (int a = 0; a < 3; a++) { + + poslimit+=5; + neglimit+=5; - for (String oneConcept : concepts) { int recursiondepth=0; - boolean closeAfterRecursion=false; + boolean closeAfterRecursion=true; System.out.println(oneConcept); AutomaticExampleFinderSPARQL ae= new AutomaticExampleFinderSPARQL( se); @@ -101,16 +107,18 @@ negExamples = ae.getNegExamples(); for(int i=0;i<3;i++) { - if(i==0){;} + /*if(i==0){;} else if(closeAfterRecursion) { closeAfterRecursion=false; recursiondepth++; } else { closeAfterRecursion=true; - } - Statistics.setCurrentLabel(recursiondepth+""+((closeAfterRecursion)?"+":"")); + }*/ + //Statistics.setCurrentLabel(recursiondepth+""+((closeAfterRecursion)?"+":"")); + Statistics.setCurrentLabel(recursiondepth+""+((closeAfterRecursion)?"":"")); + Statistics.print(number); System.out.println("currently at label "+Statistics.getCurrentLabel()+"||i: "+i); @@ -125,6 +133,19 @@ } } Statistics.print(number); + String pre="log/gnu_"; + String comment1="# "+poslimit+neglimit+"examples\n"; + String f1=pre+"1avgtrip_"+poslimit+neglimit+"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"; + writeToFile(f2, comment2+Statistics.getAVGTimeCollecting(number)); + String comment3="# "+poslimit+neglimit+"examples\n"; + String f3=pre+"2avgTimeLearning_"+poslimit+neglimit+"example"+concepts.size()+"classes"; + writeToFile(f3, comment3+Statistics.getAVGTimeLearning(number)); + + + }//outer } @@ -164,8 +185,8 @@ 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/Caliphate108550766"); + concepts.add("http://dbpedia.org/class/yago/Articulation107131854"); + concepts.add("http://dbpedia.org/class/yago/Caliphate108550766"); concepts.add("http://dbpedia.org/class/yago/Ceremony107450842"); concepts.add("http://dbpedia.org/class/yago/CookingOil107673145"); concepts.add("http://dbpedia.org/class/yago/Corticosteroid114751417"); @@ -182,10 +203,25 @@ 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; } + protected static void writeToFile(String filename, String content) { + // create the file we want to use + File file = new File( filename); + + try { + file.createNewFile(); + FileOutputStream fos = new FileOutputStream(filename, false); + // ObjectOutputStream o = new ObjectOutputStream(fos); + fos.write(content.getBytes()); + fos.flush(); + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-05-15 15:12:35 UTC (rev 850) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-05-15 16:32:46 UTC (rev 851) @@ -282,6 +282,7 @@ 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); Modified: trunk/src/dl-learner/org/dllearner/test/JenaHTTPTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/JenaHTTPTest.java 2008-05-15 15:12:35 UTC (rev 850) +++ trunk/src/dl-learner/org/dllearner/test/JenaHTTPTest.java 2008-05-15 16:32:46 UTC (rev 851) @@ -10,12 +10,39 @@ import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; public class JenaHTTPTest { + + static String query1="SELECT DISTINCT ?object\n"+ + "FROM <http://dbpedia.org>\n"+ + "WHERE { <http://dbpedia.org/resource/Leipzig> <http://www.w3.org/2000/01/rdf-schema#label> ?object}\n"; + + + static String query2 = "SELECT * WHERE { \n"+ + "<http://dbpedia.org/resource/County_Route_G7_%28California%29> ?predicate ?object. \n"+ + " FILTER( \n"+ + " (!isLiteral(?object))\n"+ + " &&( !regex(str(?predicate), 'http://dbpedia.org/property/relatedInstance') )\n"+ + " &&( !regex(str(?predicate), 'http://dbpedia.org/property/website') )\n"+ + " &&( !regex(str(?predicate), 'http://dbpedia.org/property/owner') )\n"+ + " &&( !regex(str(?predicate), 'http://dbpedia.org/property/wikiPageUsesTemplate') )\n"+ + " &&( !regex(str(?predicate), 'http://www.w3.org/2002/07/owl#sameAs') )\n"+ + " &&( !regex(str(?predicate), 'http://xmlns.com/foaf/0.1/') )\n"+ + " &&( !regex(str(?predicate), 'http://dbpedia.org/property/standard') )\n"+ + " &&( !regex(str(?predicate), 'http://dbpedia.org/property/wikipage') )\n"+ + " &&( !regex(str(?predicate), 'http://dbpedia.org/property/reference') )\n"+ + " &&( !regex(str(?predicate), 'http://www.w3.org/2004/02/skos/core') )\n"+ + " &&( !regex(str(?object), 'http://xmlns.com/foaf/0.1/') )\n"+ + " &&( !regex(str(?object), 'http://upload.wikimedia.org/wikipedia') )\n"+ + " &&( !regex(str(?object), 'http://www4.wiwiss.fu-berlin.de/flickrwrappr') )\n"+ + " &&( !regex(str(?object), 'http://dbpedia.org/resource/Template') )\n"+ + " &&( !regex(str(?object), 'http://upload.wikimedia.org/wikipedia/commons') )\n"+ + " &&( !regex(str(?object), 'http://www.w3.org/2006/03/wn/wn20/instances/synset') )\n"+ + " &&( !regex(str(?object), 'http://dbpedia.org/resource/Category:') )\n"+ + " &&( !regex(str(?object), 'http://www.w3.org/2004/02/skos/core') )\n"+ + " &&( !regex(str(?object), 'http://www.geonames.org') )).}\n"; + public static void main(String[] args) throws Exception{ - String query="SELECT DISTINCT ?object\n"+ - "FROM <http://dbpedia.org>\n"+ - "WHERE { <http://dbpedia.org/resource/Leipzig> <http://www.w3.org/2000/01/rdf-schema#label> ?object}\n"; - + String query=query2; double time=0; /*for (int i=0; i<101; i++) { @@ -27,6 +54,7 @@ time=0; for (int i=0; i<101; i++) { + if (i%20 ==0)System.out.println(i); if (i!=0) time+=JenaHTTPTest.jenaQuery(query); } time=time/100; @@ -35,10 +63,20 @@ time=0; for (int i=0; i<101; i++) { + if (i%20 ==0)System.out.println(i); if (i!=0) time+=JenaHTTPTest.jenaLocalQuery(query); } time=time/100; System.out.println("Durchschnittliche Zeit f�r eine Anfrage per DBpedia LOCAL: "+time); + + time=0; + for (int i=0; i<101; i++) + { + if (i%20 ==0)System.out.println(i); + if (i!=0) time+=JenaHTTPTest.jenaQuery(query); + } + time=time/100; + System.out.println("Durchschnittliche Zeit f�r eine Anfrage DBpedia: "+time); } private static double jenaQuery(String query) Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 15:12:35 UTC (rev 850) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-15 16:32:46 UTC (rev 851) @@ -56,7 +56,7 @@ ks.init(); Statistics.addTimeCollecting(sc.getTime()); sources.add(ks); - if (true)return; + //if (true)return; //System.out.println(ks.getNTripleURL()); // @@ -80,7 +80,8 @@ cm.applyConfigEntry(la,"useCardinalityRestrictions",false); cm.applyConfigEntry(la,"useNegation",false); cm.applyConfigEntry(la,"minExecutionTimeInSeconds",0); - cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",10); + cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",20); + //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); cm.applyConfigEntry(la,"logLevel","TRACE"); @@ -91,9 +92,10 @@ la.init(); System.out.println("start learning"); + sc.setTime(); la.start(); + Statistics.addTimeLearning(sc.getTime()); - //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 15:12:35 UTC (rev 850) +++ trunk/src/dl-learner/org/dllearner/utilities/Statistics.java 2008-05-15 16:32:46 UTC (rev 851) @@ -11,6 +11,8 @@ private static LinkedList<String> order = new LinkedList<String>(); 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, Integer> numberOfSparqlQueries = new HashMap<String, Integer>(); private static HashMap<String, Integer> numberOfCachedSparqlQueries = new HashMap<String, Integer>(); @@ -37,6 +39,15 @@ } } + public static void addTimeLearning(long value) { + Long current = timeLearning.get(currentLabel); + if(current==null) + timeLearning.put(currentLabel, new Long(value)); + else { + timeLearning.put(currentLabel, new Long(current.longValue()+value)); + } + } + public static void increaseCachedQuery() { Integer current = numberOfCachedSparqlQueries.get(currentLabel); if(current==null) @@ -58,19 +69,23 @@ public static void print(int number){ - printInt(numberOfTriples,"triples"); - printIntAVG(numberOfTriples,number,"triples avg"); + System.out.println("*****************TRIPLES"); + printInt(numberOfTriples,"triples\t"); + printIntAVG(numberOfTriples,number,"triples avg\t"); System.out.println("*****************TIME"); - printLong(timeCollecting); - printLongAVG(timeCollecting,number); + printLong(timeCollecting, "collecting\t"); + printLongAVG(timeCollecting,number,"collecting avg\t"); + printLong(timeLearning, "collecting\t"); + printLongAVG(timeLearning,number,"collecting avg\t"); System.out.println("*****************Queries"); - printInt(numberOfCachedSparqlQueries,"cached queries"); - printInt(numberOfSparqlQueries,"total queries"); + printInt(numberOfCachedSparqlQueries,"cached queries\t"); + printInt(numberOfSparqlQueries,"total queries\t"); + //printIntAVG(numberOfTriples,number,"triples avg\t"); @@ -78,14 +93,50 @@ + } + + + public static String getAVGTriplesForRecursionDepth(int number){ + + String ret="#Label, i.e. rec depth \t avg number of triples\n"; + for (int i = 0; i < order.size(); i++) { + String label=order.get(i); + try { + ret+=label+"\t"+ (numberOfTriples.get(label).intValue()/number)+"\n"; + } catch (Exception e) { } + } + return ret; + } + + public static String getAVGTimeLearning(int number){ + String ret="#Label, i.e. rec depth \t avg time for learning including reasoning\n"; + for (int i = 0; i < order.size(); i++) { + String label=order.get(i); + try { + ret+=label+"\t"+ (timeLearning.get(label).longValue()/number)+"\n"; + } catch (Exception e) { } + } + return ret; +} + + public static String getAVGTimeCollecting(int number){ + + String ret="#Label, i.e. rec depth \t avg time for extraction\n"; + for (int i = 0; i < order.size(); i++) { + String label=order.get(i); + try { + ret+=label+"\t"+ (timeCollecting.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); try { - System.out.println(str+" "+label+"|"+ (hm.get(label).intValue()/number)); + System.out.println(str+""+label+" "+ (hm.get(label).intValue()/number)); } catch (Exception e) { } } } @@ -94,25 +145,25 @@ 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+" "+hm.get(label)); } catch (Exception e) { } } } - public static void printLongAVG(HashMap<String, Long> hm, int number){ + public static void printLongAVG(HashMap<String, Long> hm, int number, String str){ for (int i = 0; i < order.size(); i++) { String label=order.get(i); try { - System.out.println("timeCollect avg "+label+"|"+ (hm.get(label).intValue()/number)); + System.out.println(str+label+" "+ (hm.get(label).intValue()/number)); } catch (Exception e) { } } } - public static void printLong(HashMap<String, Long> hm){ + public static void printLong(HashMap<String, Long> hm,String str){ for (int i = 0; i < order.size(); i++) { String label=order.get(i); try { - System.out.println("timeCollect "+label+"|"+hm.get(label)); + System.out.println(str+label+"|"+hm.get(label)); } catch (Exception e) { } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |