From: <jen...@us...> - 2009-04-15 13:50:58
|
Revision: 1703 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1703&view=rev Author: jenslehmann Date: 2009-04-15 13:33:41 +0000 (Wed, 15 Apr 2009) Log Message: ----------- extended example unit test Modified Paths: -------------- trunk/examples/sparql/README.txt trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java Added Paths: ----------- trunk/examples/sparql/britishPrimeMinisters.conf Removed Paths: ------------- trunk/examples/sparql/britishPrimeMinisters_local.conf Modified: trunk/examples/sparql/README.txt =================================================================== --- trunk/examples/sparql/README.txt 2009-04-15 09:22:46 UTC (rev 1702) +++ trunk/examples/sparql/README.txt 2009-04-15 13:33:41 UTC (rev 1703) @@ -4,8 +4,8 @@ When using the SPARQL component, files are written into the directory /cache to avoid performing the same queries more than once. +Predefined Filters: -***predefined Filters all predefined filters remove references to hompage, etc during the extraction YAGO allows yago, SKOS allows skos, Copied: trunk/examples/sparql/britishPrimeMinisters.conf (from rev 1697, trunk/examples/sparql/britishPrimeMinisters_local.conf) =================================================================== --- trunk/examples/sparql/britishPrimeMinisters.conf (rev 0) +++ trunk/examples/sparql/britishPrimeMinisters.conf 2009-04-15 13:33:41 UTC (rev 1703) @@ -0,0 +1,75 @@ +/** + * Some people which are/were Prime Ministers of the UK and some random negative Examples. + * Note: DBpedia is always subject to change, solutions will change over time + + * Possible Solutions: + +1: (http://dbpedia.org/class/yago/PrimeMinistersOfTheUnitedKingdom OR EXISTS http://dbpedia.org/property/termStart.TOP) (length 5, depth 3) +2: (http://dbpedia.org/class/yago/LeadersOfTheBritishConservativeParty OR EXISTS http://dbpedia.org/property/termStart.TOP) (length 5, depth 3) + + * + */ + +// SPARQL options +sparql.recursionDepth = 1; + + +//for a list of predefined Filters and Endpoints see examples/sparql/README.txt +sparql.predefinedFilter = "YAGO"; +sparql.predefinedEndpoint = "DBPEDIA"; +// sparql.predefinedEndpoint = "LOCALDBPEDIA"; + +// import("http://139.18.2.37:8890/sparql","SPARQL"); +import("http://dbpedia.org/sparql","SPARQL"); +algorithm = refexamples; +reasoner = fastInstanceChecker; + +refexamples.useAllConstructor = false; +refexamples.useExistsConstructor = true; +refexamples.useCardinalityRestrictions = false; +refexamples.useNegation = false; +refexamples.maxExecutionTimeInSeconds = 10; + +//refexamples.ignoredConcepts={"http://dbpedia.org/class/yago/Abstainer109758173"}; + +sparql.instances = { + "http://dbpedia.org/resource/Benjamin_Netanyahu" + ,"http://dbpedia.org/resource/Brant_Brown" + ,"http://dbpedia.org/resource/David_Blunkett" + ,"http://dbpedia.org/resource/Democritus" + ,"http://dbpedia.org/resource/Dick_Grayson" + ,"http://dbpedia.org/resource/Edward_Marjoribanks%2C_2nd_Baron_Tweedmouth" + ,"http://dbpedia.org/resource/Elizabeth_Dole" + ,"http://dbpedia.org/resource/Franklin_Pierce" + ,"http://dbpedia.org/resource/Kurt_Waldheim" + ,"http://dbpedia.org/resource/Lamberto_Dini" + ,"http://dbpedia.org/resource/Laurence_Foley" + ,"http://dbpedia.org/resource/Philip_Stanhope%2C_4th_Earl_of_Chesterfield" + ,"http://dbpedia.org/resource/Alec_Douglas-Home" + ,"http://dbpedia.org/resource/Andrew_Bonar_Law" + ,"http://dbpedia.org/resource/Anthony_Eden" + ,"http://dbpedia.org/resource/Anthony_Eden_hat" + ,"http://dbpedia.org/resource/Archibald_Primrose%2C_5th_Earl_of_Rosebery" +,"http://dbpedia.org/resource/Arthur_Balfour" +}; + + + +-"http://dbpedia.org/resource/Benjamin_Netanyahu" +-"http://dbpedia.org/resource/Brant_Brown" +-"http://dbpedia.org/resource/David_Blunkett" +-"http://dbpedia.org/resource/Democritus" +-"http://dbpedia.org/resource/Dick_Grayson" +-"http://dbpedia.org/resource/Edward_Marjoribanks%2C_2nd_Baron_Tweedmouth" +-"http://dbpedia.org/resource/Elizabeth_Dole" +-"http://dbpedia.org/resource/Franklin_Pierce" +-"http://dbpedia.org/resource/Kurt_Waldheim" +-"http://dbpedia.org/resource/Lamberto_Dini" +-"http://dbpedia.org/resource/Laurence_Foley" +-"http://dbpedia.org/resource/Philip_Stanhope%2C_4th_Earl_of_Chesterfield" ++"http://dbpedia.org/resource/Alec_Douglas-Home" ++"http://dbpedia.org/resource/Andrew_Bonar_Law" ++"http://dbpedia.org/resource/Anthony_Eden" ++"http://dbpedia.org/resource/Anthony_Eden_hat" ++"http://dbpedia.org/resource/Archibald_Primrose%2C_5th_Earl_of_Rosebery" ++"http://dbpedia.org/resource/Arthur_Balfour" Deleted: trunk/examples/sparql/britishPrimeMinisters_local.conf =================================================================== --- trunk/examples/sparql/britishPrimeMinisters_local.conf 2009-04-15 09:22:46 UTC (rev 1702) +++ trunk/examples/sparql/britishPrimeMinisters_local.conf 2009-04-15 13:33:41 UTC (rev 1703) @@ -1,72 +0,0 @@ -/** - * Some people which are/were Prime Ministers of the UK and some random negative Examples. - * Note: DBpedia is always subject to change, solutions will change over time - - * Possible Solutions: - -1: (http://dbpedia.org/class/yago/PrimeMinistersOfTheUnitedKingdom OR EXISTS http://dbpedia.org/property/termStart.TOP) (length 5, depth 3) -2: (http://dbpedia.org/class/yago/LeadersOfTheBritishConservativeParty OR EXISTS http://dbpedia.org/property/termStart.TOP) (length 5, depth 3) - - * - */ - -// SPARQL options -sparql.recursionDepth = 1; - - -//for a list of predefined Filters and Endpoints see examples/sparql/README.txt -sparql.predefinedFilter = "YAGO"; -sparql.predefinedEndpoint = "LOCALDBPEDIA"; - -import("http://139.18.2.37:8890/sparql","SPARQL"); -algorithm = refexamples; -reasoner = fastInstanceChecker; - -refexamples.useAllConstructor = false; -refexamples.useExistsConstructor = true; -refexamples.useCardinalityRestrictions = false; -refexamples.useNegation = false; - -//refexamples.ignoredConcepts={"http://dbpedia.org/class/yago/Abstainer109758173"}; - -sparql.instances = { - "http://dbpedia.org/resource/Benjamin_Netanyahu" - ,"http://dbpedia.org/resource/Brant_Brown" - ,"http://dbpedia.org/resource/David_Blunkett" - ,"http://dbpedia.org/resource/Democritus" - ,"http://dbpedia.org/resource/Dick_Grayson" - ,"http://dbpedia.org/resource/Edward_Marjoribanks%2C_2nd_Baron_Tweedmouth" - ,"http://dbpedia.org/resource/Elizabeth_Dole" - ,"http://dbpedia.org/resource/Franklin_Pierce" - ,"http://dbpedia.org/resource/Kurt_Waldheim" - ,"http://dbpedia.org/resource/Lamberto_Dini" - ,"http://dbpedia.org/resource/Laurence_Foley" - ,"http://dbpedia.org/resource/Philip_Stanhope%2C_4th_Earl_of_Chesterfield" - ,"http://dbpedia.org/resource/Alec_Douglas-Home" - ,"http://dbpedia.org/resource/Andrew_Bonar_Law" - ,"http://dbpedia.org/resource/Anthony_Eden" - ,"http://dbpedia.org/resource/Anthony_Eden_hat" - ,"http://dbpedia.org/resource/Archibald_Primrose%2C_5th_Earl_of_Rosebery" -,"http://dbpedia.org/resource/Arthur_Balfour" -}; - - - --"http://dbpedia.org/resource/Benjamin_Netanyahu" --"http://dbpedia.org/resource/Brant_Brown" --"http://dbpedia.org/resource/David_Blunkett" --"http://dbpedia.org/resource/Democritus" --"http://dbpedia.org/resource/Dick_Grayson" --"http://dbpedia.org/resource/Edward_Marjoribanks%2C_2nd_Baron_Tweedmouth" --"http://dbpedia.org/resource/Elizabeth_Dole" --"http://dbpedia.org/resource/Franklin_Pierce" --"http://dbpedia.org/resource/Kurt_Waldheim" --"http://dbpedia.org/resource/Lamberto_Dini" --"http://dbpedia.org/resource/Laurence_Foley" --"http://dbpedia.org/resource/Philip_Stanhope%2C_4th_Earl_of_Chesterfield" -+"http://dbpedia.org/resource/Alec_Douglas-Home" -+"http://dbpedia.org/resource/Andrew_Bonar_Law" -+"http://dbpedia.org/resource/Anthony_Eden" -+"http://dbpedia.org/resource/Anthony_Eden_hat" -+"http://dbpedia.org/resource/Archibald_Primrose%2C_5th_Earl_of_Rosebery" -+"http://dbpedia.org/resource/Arthur_Balfour" Modified: trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java 2009-04-15 09:22:46 UTC (rev 1702) +++ trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java 2009-04-15 13:33:41 UTC (rev 1703) @@ -22,8 +22,13 @@ import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Random; import java.util.Set; import java.util.TreeSet; @@ -57,6 +62,12 @@ */ @Test public void testAllConfFiles() throws ComponentInitException { + + // if true, then examples are executed in random order (avoids the problem + // that the same examples are tested first on several runs); otherwise + // it runs the examples in alphabetical order + boolean randomize = true; + // we use a logger, which outputs few messages (warnings, errors) SimpleLayout layout = new SimpleLayout(); ConsoleAppender consoleAppender = new ConsoleAppender(layout); @@ -71,6 +82,20 @@ File f = new File(exampleDir); QuickStart.getAllConfs(f, exampleDir, confFiles); + // put all examples in a flat list + List<String> examples = new LinkedList<String>(); + for(Map.Entry<String,ArrayList<String>> entry : confFiles.entrySet()) { + for(String file : entry.getValue()) { + examples.add(entry.getKey() + file + ".conf"); + } + } + + if(randomize) { + Collections.shuffle(examples, new Random()); + } else { + Collections.sort(examples); + } + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); // ignore list (examples which are temporarily not working due @@ -99,41 +124,50 @@ //also working fine ignore.add("./examples/sparql/SilentBobWorking2.conf"); // Out of Memory Error // ignore.add("./examples/sparql/difference/DBPediaSKOS_kohl_vs_angela.conf"); // Pellet: literal cannot be cast to individual // ignore.add("./examples/family-benchmark/Aunt.conf"); // did not terminate so far (waited 45 minutes) => disallowing ALL helps (TODO find out details) - ignore.add("./examples/krk/KRK_ZERO_against_1to5_fastInstance.conf"); // Out of Memory Error + ignore.add("examples/krk/KRK_ZERO_against_1to5_fastInstance.conf"); // stack overflow + ignore.add("examples/krk/KRK_ONE_ZERO_fastInstance.conf"); // stack overflow + ignore.add("examples/krk/"); // too many stack overflows int failedCounter = 0; - for (String path : confFiles.keySet()) { - for (String file : confFiles.get(path)) { - String conf = path + file + ".conf"; - if(ignore.contains(conf)) { - System.out.println("Skipping " + conf + " (is on ignore list)."); - } else { - System.out.println("Testing " + conf + " (time: " + sdf.format(new Date()) + ")."); - long startTime = System.nanoTime(); - boolean success = false; - try { - // start example - Start start = new Start(new File(conf)); - start.start(false); - // test is successful if a concept was learned - assert (start.getLearningAlgorithm().getCurrentlyBestDescription() != null); - start.getReasonerComponent().releaseKB(); - success = true; - } catch (Exception e) { - // unit test not succesful (exceptions are caught explicitly to find - assert ( false ); - e.printStackTrace(); - failedCounter++; - } - long timeNeeded = System.nanoTime() - startTime; - ComponentManager.getInstance().freeAllComponents(); - if(!success) { - System.out.println("TEST FAILED."); - } - System.out.println("Test of " + conf + " completed in " + Helper.prettyPrintNanoSeconds(timeNeeded) + "."); + int counter = 1; + int total = examples.size(); + for(String conf : examples) { + if(ignore.contains(conf)) { + System.out.println("Skipping " + conf + " (is on ignore list)."); + } else { + System.out.println("Testing " + conf + " (example " + counter + " of " + total + ", time: " + sdf.format(new Date()) + ")."); + long startTime = System.nanoTime(); + boolean success = false; + try { + // start example + Start start = new Start(new File(conf)); + start.start(false); + // test is successful if a concept was learned + assert (start.getLearningAlgorithm().getCurrentlyBestDescription() != null); + start.getReasonerComponent().releaseKB(); + success = true; + } catch (Exception e) { + // unit test not succesful (exceptions are caught explicitly to find + assert ( false ); + e.printStackTrace(); + failedCounter++; } - } + long timeNeeded = System.nanoTime() - startTime; + ComponentManager.getInstance().freeAllComponents(); + if(!success) { + System.out.println("TEST FAILED."); + } + System.out.println("Test of " + conf + " completed in " + Helper.prettyPrintNanoSeconds(timeNeeded) + "."); + } + counter++; } + +// for (String path : confFiles.keySet()) { +// for (String file : confFiles.get(path)) { +// String conf = path + file + ".conf"; +// +// } +// } System.out.println("Finished. " + failedCounter + " tests failed."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |