From: <jen...@us...> - 2013-09-04 10:04:18
|
Revision: 4055 http://sourceforge.net/p/dl-learner/code/4055 Author: jenslehmann Date: 2013-09-04 10:04:14 +0000 (Wed, 04 Sep 2013) Log Message: ----------- ISLE / CELOE comparison extended Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/ISLE.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java Added Paths: ----------- trunk/test/isle/father/ontology.owl Removed Paths: ------------- trunk/test/isle/father/father_labeled.owl Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2013-09-04 09:56:41 UTC (rev 4054) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2013-09-04 10:04:14 UTC (rev 4055) @@ -149,9 +149,11 @@ private int expressionTests = 0; private int minHorizExp = 0; private int maxHorizExp = 0; + private long totalRuntimeNs; // TODO: turn those into config options + // important: do not initialise those with empty sets // null = no settings for allowance / ignorance // empty set = allow / ignore nothing (it is often not desired to allow no class!) @@ -536,7 +538,8 @@ if (stop) { logger.info("Algorithm stopped ("+expressionTests+" descriptions tested). " + nodes.size() + " nodes in the search tree.\n"); } else { - logger.info("Algorithm terminated successfully (time: " + Helper.prettyPrintNanoSeconds(System.nanoTime()-nanoStartTime) + ", "+expressionTests+" descriptions tested, " + nodes.size() + " nodes in the search tree).\n"); + totalRuntimeNs = System.nanoTime()-nanoStartTime; + logger.info("Algorithm terminated successfully (time: " + Helper.prettyPrintNanoSeconds(totalRuntimeNs) + ", "+expressionTests+" descriptions tested, " + nodes.size() + " nodes in the search tree).\n"); logger.info(reasoner.toString()); } @@ -897,6 +900,10 @@ } } + public TreeSet<OENode> getNodes() { + return nodes; + } + public int getMaximumHorizontalExpansion() { return maxHorizExp; } @@ -1102,6 +1109,10 @@ this.stopOnFirstDefinition = stopOnFirstDefinition; } + public long getTotalRuntimeNs() { + return totalRuntimeNs; + } + public static void main(String[] args) throws Exception{ AbstractKnowledgeSource ks = new OWLFile("../examples/family/father_oe.owl"); ks.init(); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/ISLE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/ISLE.java 2013-09-04 09:56:41 UTC (rev 4054) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/ISLE.java 2013-09-04 10:04:14 UTC (rev 4055) @@ -146,6 +146,7 @@ private int expressionTests = 0; private int minHorizExp = 0; private int maxHorizExp = 0; + private long totalRuntimeNs; // TODO: turn those into config options @@ -533,7 +534,8 @@ if (stop) { logger.info("Algorithm stopped ("+expressionTests+" descriptions tested). " + nodes.size() + " nodes in the search tree.\n"); } else { - logger.info("Algorithm terminated successfully (time: " + Helper.prettyPrintNanoSeconds(System.nanoTime()-nanoStartTime) + ", "+expressionTests+" descriptions tested, " + nodes.size() + " nodes in the search tree).\n"); + totalRuntimeNs = System.nanoTime()-nanoStartTime; + logger.info("Algorithm terminated successfully (time: " + Helper.prettyPrintNanoSeconds(totalRuntimeNs) + ", "+expressionTests+" descriptions tested, " + nodes.size() + " nodes in the search tree).\n"); logger.info(reasoner.toString()); } @@ -1099,4 +1101,12 @@ this.stopOnFirstDefinition = stopOnFirstDefinition; } + public long getTotalRuntimeNs() { + return totalRuntimeNs; + } + + public TreeSet<OENode> getNodes() { + return nodes; + } + } Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java 2013-09-04 09:56:41 UTC (rev 4054) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java 2013-09-04 10:04:14 UTC (rev 4055) @@ -5,6 +5,7 @@ import java.io.File; import java.io.IOException; +import java.text.DecimalFormat; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -28,6 +29,7 @@ import org.dllearner.kb.OWLAPIOntology; import org.dllearner.learningproblems.ClassLearningProblem; import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.Helper; import org.junit.Before; import org.junit.Test; import org.semanticweb.owlapi.apibinding.OWLManager; @@ -66,7 +68,7 @@ */ public ISLETest() throws Exception{ manager = OWLManager.createOWLOntologyManager(); - ontology = manager.loadOntologyFromOntologyDocument(new File(testFolder + "father_labeled.owl")); + ontology = manager.loadOntologyFromOntologyDocument(new File(testFolder + "ontology.owl")); cls = new NamedClass("http://example.com/father#father"); textRetriever = new RDFSLabelEntityTextRetriever(ontology); syntacticIndex = new OWLOntologyLuceneSyntacticIndexCreator(ontology, df.getRDFSLabel(), searchField).buildIndex(); @@ -189,6 +191,16 @@ celoe.setReplaceSearchTree(true); celoe.init(); celoe.start(); + System.out.println(); + + DecimalFormat df = new DecimalFormat("000.00"); + System.out.println("Summary ISLE vs. CELOE"); + System.out.println("======================"); + System.out.println("accuracy: " + df.format(100*isle.getCurrentlyBestAccuracy())+"% vs. " + df.format(100*celoe.getCurrentlyBestAccuracy())+"%"); + System.out.println("expressions tested: " + isle.getClassExpressionTests() + " vs. " + celoe.getClassExpressionTests()); + System.out.println("search tree nodes: " + isle.getNodes().size() + " vs. " + celoe.getNodes().size()); + System.out.println("runtime: " + Helper.prettyPrintMilliSeconds(isle.getTotalRuntimeNs()) + " vs. " + Helper.prettyPrintMilliSeconds(celoe.getTotalRuntimeNs())); + } } Deleted: trunk/test/isle/father/father_labeled.owl =================================================================== --- trunk/test/isle/father/father_labeled.owl 2013-09-04 09:56:41 UTC (rev 4054) +++ trunk/test/isle/father/father_labeled.owl 2013-09-04 10:04:14 UTC (rev 4055) @@ -1,169 +0,0 @@ -<?xml version="1.0"?> - - -<!DOCTYPE rdf:RDF [ - <!ENTITY father "http://example.com/father#" > - <!ENTITY owl "http://www.w3.org/2002/07/owl#" > - <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > - <!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" > - <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" > - <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" > -]> - - -<rdf:RDF xmlns="http://example.com/father#" - xml:base="http://example.com/father" - xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" - xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#" - xmlns:owl="http://www.w3.org/2002/07/owl#" - xmlns:xsd="http://www.w3.org/2001/XMLSchema#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:father="http://example.com/father#"> - <owl:Ontology rdf:about="http://example.com/father"/> - - - - <!-- - /////////////////////////////////////////////////////////////////////////////////////// - // - // Object Properties - // - /////////////////////////////////////////////////////////////////////////////////////// - --> - - - - - <!-- http://example.com/father#hasChild --> - - <owl:ObjectProperty rdf:about="&father;hasChild"> - <rdfs:label xml:lang="en">has child</rdfs:label> - <rdfs:domain rdf:resource="&father;person"/> - <rdfs:range rdf:resource="&father;person"/> - </owl:ObjectProperty> - - - - <!-- - /////////////////////////////////////////////////////////////////////////////////////// - // - // Classes - // - /////////////////////////////////////////////////////////////////////////////////////// - --> - - - - - <!-- http://example.com/father#father --> - - <owl:Class rdf:about="&father;father"> - <rdfs:label xml:lang="en">person which has at least 1 child</rdfs:label> - <rdfs:subClassOf rdf:resource="&father;male"/> - </owl:Class> - - - - <!-- http://example.com/father#female --> - - <owl:Class rdf:about="&father;female"> - <rdfs:label xml:lang="en">female</rdfs:label> - <rdfs:subClassOf rdf:resource="&father;person"/> - <owl:disjointWith rdf:resource="&father;male"/> - </owl:Class> - - - - <!-- http://example.com/father#male --> - - <owl:Class rdf:about="&father;male"> - <rdfs:label xml:lang="en">male</rdfs:label> - <rdfs:subClassOf rdf:resource="&father;person"/> - </owl:Class> - - - - <!-- http://example.com/father#person --> - - <owl:Class rdf:about="&father;person"> - <rdfs:label xml:lang="en">Person</rdfs:label> - <rdfs:subClassOf rdf:resource="&owl;Thing"/> - </owl:Class> - - - - <!-- http://www.w3.org/2002/07/owl#Thing --> - - <owl:Class rdf:about="&owl;Thing"/> - - - - <!-- - /////////////////////////////////////////////////////////////////////////////////////// - // - // Individuals - // - /////////////////////////////////////////////////////////////////////////////////////// - --> - - - - - <!-- http://example.com/father#anna --> - - <owl:NamedIndividual rdf:about="&father;anna"> - <rdf:type rdf:resource="&father;female"/> - <hasChild rdf:resource="&father;heinz"/> - </owl:NamedIndividual> - - - - <!-- http://example.com/father#heinz --> - - <owl:NamedIndividual rdf:about="&father;heinz"> - <rdf:type rdf:resource="&father;male"/> - </owl:NamedIndividual> - - - - <!-- http://example.com/father#markus --> - - <owl:NamedIndividual rdf:about="&father;markus"> - <rdf:type rdf:resource="&father;father"/> - <rdf:type rdf:resource="&father;male"/> - <hasChild rdf:resource="&father;anna"/> - </owl:NamedIndividual> - - - - <!-- http://example.com/father#martin --> - - <owl:NamedIndividual rdf:about="&father;martin"> - <rdf:type rdf:resource="&father;father"/> - <rdf:type rdf:resource="&father;male"/> - <hasChild rdf:resource="&father;heinz"/> - </owl:NamedIndividual> - - - - <!-- http://example.com/father#michelle --> - - <owl:NamedIndividual rdf:about="&father;michelle"> - <rdf:type rdf:resource="&father;female"/> - </owl:NamedIndividual> - - - - <!-- http://example.com/father#stefan --> - - <owl:NamedIndividual rdf:about="&father;stefan"> - <rdf:type rdf:resource="&father;father"/> - <rdf:type rdf:resource="&father;male"/> - <hasChild rdf:resource="&father;markus"/> - </owl:NamedIndividual> -</rdf:RDF> - - - -<!-- Generated by the OWL API (version 3.4.2) http://owlapi.sourceforge.net --> - Copied: trunk/test/isle/father/ontology.owl (from rev 4046, trunk/test/isle/father/father_labeled.owl) =================================================================== --- trunk/test/isle/father/ontology.owl (rev 0) +++ trunk/test/isle/father/ontology.owl 2013-09-04 10:04:14 UTC (rev 4055) @@ -0,0 +1,169 @@ +<?xml version="1.0"?> + + +<!DOCTYPE rdf:RDF [ + <!ENTITY father "http://example.com/father#" > + <!ENTITY owl "http://www.w3.org/2002/07/owl#" > + <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > + <!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" > + <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" > + <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" > +]> + + +<rdf:RDF xmlns="http://example.com/father#" + xml:base="http://example.com/father" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:father="http://example.com/father#"> + <owl:Ontology rdf:about="http://example.com/father"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Object Properties + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://example.com/father#hasChild --> + + <owl:ObjectProperty rdf:about="&father;hasChild"> + <rdfs:label xml:lang="en">has child</rdfs:label> + <rdfs:domain rdf:resource="&father;person"/> + <rdfs:range rdf:resource="&father;person"/> + </owl:ObjectProperty> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Classes + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://example.com/father#father --> + + <owl:Class rdf:about="&father;father"> + <rdfs:label xml:lang="en">person which has at least 1 child</rdfs:label> + <rdfs:subClassOf rdf:resource="&father;male"/> + </owl:Class> + + + + <!-- http://example.com/father#female --> + + <owl:Class rdf:about="&father;female"> + <rdfs:label xml:lang="en">female</rdfs:label> + <rdfs:subClassOf rdf:resource="&father;person"/> + <owl:disjointWith rdf:resource="&father;male"/> + </owl:Class> + + + + <!-- http://example.com/father#male --> + + <owl:Class rdf:about="&father;male"> + <rdfs:label xml:lang="en">male</rdfs:label> + <rdfs:subClassOf rdf:resource="&father;person"/> + </owl:Class> + + + + <!-- http://example.com/father#person --> + + <owl:Class rdf:about="&father;person"> + <rdfs:label xml:lang="en">Person</rdfs:label> + <rdfs:subClassOf rdf:resource="&owl;Thing"/> + </owl:Class> + + + + <!-- http://www.w3.org/2002/07/owl#Thing --> + + <owl:Class rdf:about="&owl;Thing"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Individuals + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://example.com/father#anna --> + + <owl:NamedIndividual rdf:about="&father;anna"> + <rdf:type rdf:resource="&father;female"/> + <hasChild rdf:resource="&father;heinz"/> + </owl:NamedIndividual> + + + + <!-- http://example.com/father#heinz --> + + <owl:NamedIndividual rdf:about="&father;heinz"> + <rdf:type rdf:resource="&father;male"/> + </owl:NamedIndividual> + + + + <!-- http://example.com/father#markus --> + + <owl:NamedIndividual rdf:about="&father;markus"> + <rdf:type rdf:resource="&father;father"/> + <rdf:type rdf:resource="&father;male"/> + <hasChild rdf:resource="&father;anna"/> + </owl:NamedIndividual> + + + + <!-- http://example.com/father#martin --> + + <owl:NamedIndividual rdf:about="&father;martin"> + <rdf:type rdf:resource="&father;father"/> + <rdf:type rdf:resource="&father;male"/> + <hasChild rdf:resource="&father;heinz"/> + </owl:NamedIndividual> + + + + <!-- http://example.com/father#michelle --> + + <owl:NamedIndividual rdf:about="&father;michelle"> + <rdf:type rdf:resource="&father;female"/> + </owl:NamedIndividual> + + + + <!-- http://example.com/father#stefan --> + + <owl:NamedIndividual rdf:about="&father;stefan"> + <rdf:type rdf:resource="&father;father"/> + <rdf:type rdf:resource="&father;male"/> + <hasChild rdf:resource="&father;markus"/> + </owl:NamedIndividual> +</rdf:RDF> + + + +<!-- Generated by the OWL API (version 3.4.2) http://owlapi.sourceforge.net --> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |