You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(120) |
Sep
(36) |
Oct
(116) |
Nov
(17) |
Dec
(44) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(143) |
Feb
(192) |
Mar
(74) |
Apr
(84) |
May
(105) |
Jun
(64) |
Jul
(49) |
Aug
(120) |
Sep
(159) |
Oct
(156) |
Nov
(51) |
Dec
(28) |
2009 |
Jan
(17) |
Feb
(55) |
Mar
(33) |
Apr
(57) |
May
(54) |
Jun
(28) |
Jul
(6) |
Aug
(16) |
Sep
(38) |
Oct
(30) |
Nov
(26) |
Dec
(52) |
2010 |
Jan
(7) |
Feb
(91) |
Mar
(65) |
Apr
(2) |
May
(14) |
Jun
(25) |
Jul
(38) |
Aug
(48) |
Sep
(80) |
Oct
(70) |
Nov
(75) |
Dec
(77) |
2011 |
Jan
(68) |
Feb
(53) |
Mar
(51) |
Apr
(35) |
May
(65) |
Jun
(101) |
Jul
(29) |
Aug
(230) |
Sep
(95) |
Oct
(49) |
Nov
(110) |
Dec
(63) |
2012 |
Jan
(41) |
Feb
(42) |
Mar
(25) |
Apr
(46) |
May
(51) |
Jun
(44) |
Jul
(45) |
Aug
(29) |
Sep
(12) |
Oct
(9) |
Nov
(17) |
Dec
(2) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(7) |
Apr
(16) |
May
(54) |
Jun
(27) |
Jul
(11) |
Aug
(5) |
Sep
(85) |
Oct
(27) |
Nov
(37) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(29) |
Mar
(5) |
Apr
(3) |
May
(22) |
Jun
(3) |
Jul
(4) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <jen...@us...> - 2009-01-26 13:15:30
|
Revision: 1583 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1583&view=rev Author: jenslehmann Date: 2009-01-26 11:55:26 +0000 (Mon, 26 Jan 2009) Log Message: ----------- benchmarks with monitoring mostly deactivated Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -137,7 +137,7 @@ tree.addNodeToLevel(this, level); // simulation update - Monitor mon = MonitorFactory.start("simulation update"); +// Monitor mon = MonitorFactory.start("simulation update"); // the nodes, which need to be updated Set<ELDescriptionNode> update = new HashSet<ELDescriptionNode>(); @@ -188,7 +188,7 @@ // apply updates recursively top-down tree.updateSimulation(update); - mon.stop(); +// mon.stop(); // add all classes in label for(NamedClass nc : label) { @@ -350,7 +350,7 @@ // simulation update when extending or refining label // (same in both cases) private void labelSimulationUpdate() { - Monitor mon = MonitorFactory.start("simulation update"); +// Monitor mon = MonitorFactory.start("simulation update"); // compute the nodes, which need to be updated Set<ELDescriptionNode> update = new HashSet<ELDescriptionNode>(); @@ -411,13 +411,13 @@ // apply updates recursively top-down tree.updateSimulation(update); - mon.stop(); +// mon.stop(); } public void refineEdge(int edgeNumber, ObjectProperty op) { edges.get(edgeNumber).setLabel(op); - Monitor mon = MonitorFactory.start("simulation update"); +// Monitor mon = MonitorFactory.start("simulation update"); // compute the nodes, which need to be updated Set<ELDescriptionNode> update = new HashSet<ELDescriptionNode>(); update.add(this); @@ -451,7 +451,7 @@ // apply updates recursively top-down tree.updateSimulation(update); - mon.stop(); +// mon.stop(); } /** Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -42,9 +42,6 @@ import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.UnsupportedLanguageException; -import com.jamonapi.Monitor; -import com.jamonapi.MonitorFactory; - /** * Represents an EL description tree. Unlike {@link ELDescriptionNode}, this is * a tree-wide structure, i.e. it does not implement the tree structure itself, @@ -467,7 +464,7 @@ @Override @SuppressWarnings("unchecked") public ELDescriptionTree clone() { - Monitor mon = MonitorFactory.start("tree clone"); +// Monitor mon = MonitorFactory.start("tree clone"); // clone "global" tree ELDescriptionTree treeClone = new ELDescriptionTree(rs); @@ -553,7 +550,7 @@ treeClone.levelNodeMapping.put(i, newNodes); } - mon.stop(); +// mon.stop(); return treeClone; } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -51,8 +51,8 @@ import org.dllearner.core.owl.Thing; import org.dllearner.utilities.Helper; -import com.jamonapi.Monitor; -import com.jamonapi.MonitorFactory; +//import com.jamonapi.Monitor; +//import com.jamonapi.MonitorFactory; /** * EL downward refinement operator constructed by Jens Lehmann @@ -168,7 +168,7 @@ // operation 1: label extension private List<ELDescriptionTree> extendLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("extend label"); +// Monitor mon = MonitorFactory.start("extend label"); List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // the index is the range of role in the edge pointing to the parent of this node @@ -193,13 +193,13 @@ } } - mon.stop(); +// mon.stop(); return refinements; } // operation 2: label refinement private List<ELDescriptionTree> refineLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("refine label"); +// Monitor mon = MonitorFactory.start("refine label"); List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // loop through all classes in label @@ -220,13 +220,13 @@ } } } - mon.stop(); +// mon.stop(); return refinements; } // operation 3: refine edge private List<ELDescriptionTree> refineEdge(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("refine edge"); +// Monitor mon = MonitorFactory.start("refine edge"); List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); for(int edgeNumber = 0; edgeNumber < v.getEdges().size(); edgeNumber++) { @@ -251,13 +251,13 @@ } } } - mon.stop(); +// mon.stop(); return refinements; } // operation 4: attach tree private Collection<ELDescriptionTree> attachSubtree(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("attach tree"); +// Monitor mon = MonitorFactory.start("attach tree"); List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // compute the set of most general roles such that the domain of each role is not disjoint @@ -311,7 +311,7 @@ // we check equivalence by a minimality test (TODO: can we still do this?) boolean minimal = mergedTree.isMinimal(); - MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); +// MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); if(minimal) { logger.trace("Merged tree is minimal, i.e. not equivalent."); // it is not equivalent, i.e. we found a refinement @@ -321,7 +321,7 @@ // perform complex check in merged tree boolean check = asCheck(wClone); logger.trace("Result of complex check: " + check); - MonitorFactory.add("as.check", "boolean", check ? 1 : 0); +// MonitorFactory.add("as.check", "boolean", check ? 1 : 0); if(check) { // refine property @@ -331,9 +331,9 @@ // refine tree using recursive operator call logger.trace("Recursive Call"); // do not monitor recursive calls (counts time twice or more) - mon.stop(); +// mon.stop(); List<ELDescriptionTree> recRefs = refine(tp); - mon.start(); +// mon.start(); logger.trace("Recursive Call Done"); for(ELDescriptionTree tpp : recRefs) { m.add(new ELDescriptionEdge(r, tpp.getRootNode())); @@ -344,13 +344,13 @@ logger.trace("M: " + m); } } - mon.stop(); +// mon.stop(); return refinements; } // new version of as private Collection<ELDescriptionTree> attachSubtree2(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("attach tree"); +// Monitor mon = MonitorFactory.start("attach tree"); Set<ELDescriptionTree> refinements = new TreeSet<ELDescriptionTree>(treeComp); // create and initialise M @@ -401,13 +401,13 @@ ELDescriptionNode w = tpp.getNode(wPosition); boolean minimal = tpp.isMinimal(); - MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); +// MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); if(minimal) { refinements.add(tpp); // logger.trace("tree is minimal; added to T"); } else { boolean check = asCheck(w); - MonitorFactory.add("as.check", "boolean", check ? 1 : 0); +// MonitorFactory.add("as.check", "boolean", check ? 1 : 0); // logger.trace("tree is not minimal; result of complex check: " + check); if(check) { @@ -429,11 +429,11 @@ if(rppSet.size() != 0) { // recursive call - mon.stop(); +// mon.stop(); // logger.trace("recursive call start"); List<ELDescriptionTree> recRefs = refine(tp); // logger.trace("recursive call end"); - mon.start(); +// mon.start(); for(ELDescriptionTree tStar : recRefs) { m.add(new TreeAndRoleSet(tStar, rppSet)); @@ -443,14 +443,14 @@ } - mon.stop(); +// mon.stop(); return refinements; } // create a new tree which is obtained by attaching the new tree at the given node in the tree via role r private ELDescriptionTree mergeTrees(ELDescriptionTree tree, ELDescriptionNode node, int[] position, ObjectProperty r, ELDescriptionTree newTree) { - Monitor mon = MonitorFactory.start("as.merge trees"); +// Monitor mon = MonitorFactory.start("as.merge trees"); // System.out.println("merge start"); // System.out.println(tree); // System.out.println(newTree); @@ -497,13 +497,13 @@ // mon2.stop(); - mon.stop(); +// mon.stop(); return mergedTree; } // TODO: variables have been renamed in article public boolean asCheck(ELDescriptionNode v) { - Monitor mon = MonitorFactory.start("as.complex check"); +// Monitor mon = MonitorFactory.start("as.complex check"); // System.out.println("asCheck: " + v.getTree().toSimulationString()); // find all edges up to the root node @@ -541,7 +541,7 @@ } } - mon.stop(); +// mon.stop(); return true; } Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -86,43 +86,45 @@ "cton", // is ok at length 8 "earthrealm2", - // cannot even be read "fma_owl_dl_component_1.4.0", - // ontology file seems broken "iso_19115", - // ontology file seems broken "nci", // is ok at length 8 "process", - // takes too long to read in "pto", // is ok at length 8 "tambis", // ontology file seems broken "thesaurus", // is ok at length 8 - "transportation" + "transportation", + // takes too long to read in + "pto", + // ontology file seems broken "iso_19115", + // ontology file seems broken "nci", + // cannot even be read + "fma_owl_dl_component_1.4.0" }; for(String ont : onts) { String file = base + ont + ".owl"; rand = new Random(1); - testOntology(statDir, file, 100, 8); + testOntology(statDir, file, 100, 7); } // artificial ontology tests // - + /* // number of concepts and roles int[] conceptCounts = new int[] { 5, 10, 50, 100 }; //, 500, 1000 }; int[] roleCounts = new int[] { 5, 10, 50, 100, 500, 1000}; - base = "/home/jl/downloads/uni-leipzig/OTAGen-v1/generated/generated_"; + String base = "/home/jl/downloads/uni-leipzig/OTAGen-v1/generated/generated_"; // loop through all artificial ontologies for(int conceptCount : conceptCounts) { for(int roleCount : roleCounts) { String file = base + "c" + conceptCount + "_r" + roleCount + ".owl"; rand = new Random(1); - testOntology(statDir, file, 100, 9); + testOntology(statDir, file, 100, 7); } } System.exit(0); - + */ /* // number of applications of operator @@ -190,6 +192,7 @@ File statFile = new File(statDir + statFileName); String statString = ""; + int refinementMaxSizeOverall = 0; MonitorFactory.reset(); for(int loop = 0; loop < nrOfChains; loop++) { @@ -216,18 +219,32 @@ int sizeSum = 0; for(ELDescriptionTree tree : refinements) { // System.out.println(" " + tree.toDescriptionString()); - sizeSum += tree.getSize(); + int size = tree.getSize(); + sizeSum += size; + refinementMaxSizeOverall = Math.max(size, refinementMaxSizeOverall); } MonitorFactory.add("refinement size", "count", sizeSum/(double)refinements.size()); MonitorFactory.add("refinement size increase", "count", (sizeSum-refinements.size()*currTree.getSize())/(double)refinements.size()); System.out.println(" [has " + refinements.size() + " refinements]"); - // pick a refinement randomly (which is kind of slow for a set, but - // this does not matter here) + + // pick a refinement randomly - this has the disadvantage that we have huge + // variations over different runs int index = rand.nextInt(refinements.size()); -// currTree = new ArrayList<ELDescriptionTree>(refinements).get(index); currTree = refinements.get(index); + + // we pick a/the median of the refinements as next refinement +// ELDescriptionTreeComparator treeComp = new ELDescriptionTreeComparator(); +// TreeSet<ELDescriptionTree> refinementsSet = new TreeSet<ELDescriptionTree>(treeComp); +// refinementsSet.addAll(refinements); +// List<ELDescriptionTree> refinementList = new LinkedList<ELDescriptionTree>(refinements); + // sort by size (first criterion of comparator) +// Collections.sort(refinementList, treeComp); +// currTree = refinementList.get((int)(refinementList.size()*0.5)); +// System.out.println(rand.nextGaussian()); +// currTree = refinementList.get((int)(refinementList.size()*rand.nextGaussian())); + MonitorFactory.add("picked refinement size", "count", currTree.getSize()); } System.out.println("operator time: " + runtime.prettyPrint("ms")); @@ -246,23 +263,26 @@ statString += getMonitorDataCount(MonitorFactory.getMonitor("refinement count", "count")); statString += getMonitorDataCount(MonitorFactory.getMonitor("refinement size", "count")); + statString += "refinement max size overall: " + refinementMaxSizeOverall + "\n"; statString += getMonitorDataCount(MonitorFactory.getMonitor("picked refinement size", "count")); statString += getMonitorDataCount(MonitorFactory.getMonitor("refinement size increase", "count")); statString += "\n"; - statString += getMonitorData(MonitorFactory.getMonitor("extend label", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("refine label", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("refine edge", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("attach tree", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("as.merge trees", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("as.complex check", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("extend label", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("refine label", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("refine edge", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("attach tree", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("as.merge trees", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("as.complex check", "ms.")); // statString += getMonitorData(MonitorFactory.getMonitor("as.tmp", "ms.")); // statString += getMonitorData(MonitorFactory.getMonitor("el.tmp", "ms.")); - statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.minimal", "boolean")); - statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.check", "boolean")); - statString += getMonitorData(MonitorFactory.getMonitor("tree clone", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("simulation update", "ms.")); +// statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.minimal", "boolean")); +// statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.check", "boolean")); +// statString += getMonitorData(MonitorFactory.getMonitor("tree clone", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("simulation update", "ms.")); statString += getMonitorData(MonitorFactory.getMonitor("disjointness reasoning", "ms.")); + double reasoningPercentage = 100 * MonitorFactory.getMonitor("disjointness reasoning", "ms.").getTotal()/MonitorFactory.getMonitor("operator application time", "ms.").getTotal(); + statString += "disjointness reasoning percentage: " + df.format(reasoningPercentage) + "%\n"; Files.createFile(statFile, statString); @@ -278,6 +298,7 @@ return mon.getLabel() + ": av " + df.format(mon.getAvg()) + " (stddev " + df.format(mon.getStdDev()) + ", min " + df.format(mon.getMin()) + ", max " + df.format(mon.getMax()) + ", " + df.format(mon.getTotal()) + " total, " + (int)mon.getHits() + " hits)\n"; } + @SuppressWarnings("unused") private static String getMonitorDataBoolean(Monitor mon) { return mon.getLabel() + ": " + df.format(mon.getAvg()*100) + "%\n"; } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -66,6 +66,7 @@ */ public class ELDownTests { + @SuppressWarnings("unused") private static Logger logger = Logger.getLogger(ELDownTests.class); /** Modified: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -36,7 +36,7 @@ */ public final class TestOntologies { - public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES }; + public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE_NO_DR_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES }; public static ReasonerComponent getTestOntology(TestOntology ont) { String kbString = ""; @@ -70,6 +70,12 @@ kbString += "bird SUB animal.\n"; kbString += "cat SUB animal.\n"; kbString += "human SUB TOP.\n"; + } else if(ont.equals(TestOntology.SIMPLE_NO_DR_DISJOINT)) { + kbString += "Subrole(hasChild, has).\n"; + kbString += "Subrole(hasPet, has).\n"; + kbString += "bird SUB animal.\n"; + kbString += "cat SUB animal.\n"; + kbString += "human SUB TOP.\n"; } else if(ont.equals(TestOntology.SIMPLE2)) { kbString += "Subrole(r2,r3).\n"; kbString += "a1 SUB TOP.\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-25 19:16:40
|
Revision: 1582 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1582&view=rev Author: jenslehmann Date: 2009-01-25 19:16:38 +0000 (Sun, 25 Jan 2009) Log Message: ----------- some tests on large ontologies Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-25 14:15:39 UTC (rev 1581) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-25 19:16:38 UTC (rev 1582) @@ -79,13 +79,30 @@ // real world ontology tests // String base = "/home/jl/promotion/ontologien/el_benchmark/"; - String[] onts = new String[] {"galen2", "cton", "earthrealm", "fma_owl_dl_component_1.4.0", - "iso_19115", "nci", "process", "pto", "tambis", "thesaurus", "transportation"}; + String[] onts = new String[] { + // is ok at length 10 + "galen2", + // is ok at length 8 + "cton", + // is ok at length 8 + "earthrealm2", + // cannot even be read "fma_owl_dl_component_1.4.0", + // ontology file seems broken "iso_19115", + // ontology file seems broken "nci", + // is ok at length 8 + "process", + // takes too long to read in "pto", + // is ok at length 8 + "tambis", + // ontology file seems broken "thesaurus", + // is ok at length 8 + "transportation" + }; for(String ont : onts) { String file = base + ont + ".owl"; rand = new Random(1); - testOntology(statDir, file, 100, 10); + testOntology(statDir, file, 100, 8); } // artificial ontology tests // @@ -100,7 +117,7 @@ for(int roleCount : roleCounts) { String file = base + "c" + conceptCount + "_r" + roleCount + ".owl"; rand = new Random(1); - testOntology(statDir, file, 100, 10); + testOntology(statDir, file, 100, 9); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-25 14:15:48
|
Revision: 1581 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1581&view=rev Author: jenslehmann Date: 2009-01-25 14:15:39 +0000 (Sun, 25 Jan 2009) Log Message: ----------- operator benchmark ctd. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-24 20:02:30 UTC (rev 1580) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-25 14:15:39 UTC (rev 1581) @@ -400,11 +400,14 @@ wPosition[position.length] = v.getEdges().size(); ELDescriptionNode w = tpp.getNode(wPosition); - if(tpp.isMinimal()) { + boolean minimal = tpp.isMinimal(); + MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); + if(minimal) { refinements.add(tpp); // logger.trace("tree is minimal; added to T"); } else { boolean check = asCheck(w); + MonitorFactory.add("as.check", "boolean", check ? 1 : 0); // logger.trace("tree is not minimal; result of complex check: " + check); if(check) { Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-24 20:02:30 UTC (rev 1580) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-25 14:15:39 UTC (rev 1581) @@ -67,26 +67,47 @@ // create a directory for log files Date dt = new Date(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); - String dir = "log/el/" + df.format(dt) + "/"; - new File(dir).mkdir(); + String statDir = "log/el/" + df.format(dt) + "/"; + new File(statDir).mkdir(); - String example = "/home/jl/promotion/ontologien/galen2.owl"; -// example = "/home/jl/downloads/uni-leipzig/OTAGen-v1/generated/generatedOnt.owl"; + // single ontology test +// String example = "/home/jl/promotion/ontologien/galen2.owl"; +// for(int i=10; i<17; i++) { +// rand = new Random(1); +// testOntology(statDir, example, 100, i); +// } - for(int i=10; i<17; i++) { + // real world ontology tests // + String base = "/home/jl/promotion/ontologien/el_benchmark/"; + String[] onts = new String[] {"galen2", "cton", "earthrealm", "fma_owl_dl_component_1.4.0", + "iso_19115", "nci", "process", "pto", "tambis", "thesaurus", "transportation"}; + + for(String ont : onts) { + String file = base + ont + ".owl"; rand = new Random(1); - testOntology(dir, example, 100, i); + testOntology(statDir, file, 100, 10); } - System.exit(0); + // artificial ontology tests // - /* TEST ON ARTIFICIAL ONTOLOGIES - - // number of concepts and roles - int[] conceptCounts = new int[] { 5, 10 }; - int[] roleCounts = new int[] { 5, 10}; + int[] conceptCounts = new int[] { 5, 10, 50, 100 }; //, 500, 1000 }; + int[] roleCounts = new int[] { 5, 10, 50, 100, 500, 1000}; + base = "/home/jl/downloads/uni-leipzig/OTAGen-v1/generated/generated_"; + // loop through all artificial ontologies + for(int conceptCount : conceptCounts) { + for(int roleCount : roleCounts) { + String file = base + "c" + conceptCount + "_r" + roleCount + ".owl"; + rand = new Random(1); + testOntology(statDir, file, 100, 10); + } + } + + System.exit(0); + + /* + // number of applications of operator int opApplications = 10; @@ -218,7 +239,7 @@ statString += getMonitorData(MonitorFactory.getMonitor("attach tree", "ms.")); statString += getMonitorData(MonitorFactory.getMonitor("as.merge trees", "ms.")); statString += getMonitorData(MonitorFactory.getMonitor("as.complex check", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("as.tmp", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("as.tmp", "ms.")); // statString += getMonitorData(MonitorFactory.getMonitor("el.tmp", "ms.")); statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.minimal", "boolean")); statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.check", "boolean")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-24 20:02:36
|
Revision: 1580 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1580&view=rev Author: jenslehmann Date: 2009-01-24 20:02:30 +0000 (Sat, 24 Jan 2009) Log Message: ----------- new as method for EL operator 2 Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTreeComparator.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/algorithms/el/TreeAndRoleSet.java trunk/src/dl-learner/org/dllearner/algorithms/el/TreeAndRoleSetComparator.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2009-01-18 16:41:36 UTC (rev 1579) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2009-01-24 20:02:30 UTC (rev 1580) @@ -112,6 +112,7 @@ // this is the root node of the overall tree tree.rootNode = this; tree.addNodeToLevel(this, level); + tree.size += label.size(); } // convenience constructor @@ -194,6 +195,8 @@ extendLabel(nc); } + // 1 for the edge (labels are already taken care of by extendLabel) + tree.size += 1; } /** @@ -339,6 +342,9 @@ public void extendLabel(NamedClass newClass) { label.add(newClass); labelSimulationUpdate(); + tree.size += 1; +// System.out.println(tree); +// System.out.println(tree.size); } // simulation update when extending or refining label Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-18 16:41:36 UTC (rev 1579) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-24 20:02:30 UTC (rev 1580) @@ -65,6 +65,8 @@ // max level = 0 means that there is no tree at all // (max level = 1 means the root node exists) private int maxLevel = 0; + + protected int size = 1; protected ELDescriptionNode rootNode; @@ -533,6 +535,7 @@ // update global tree treeClone.rootNode = newRoot; treeClone.maxLevel = maxLevel; + treeClone.size = size; // nodes treeClone.nodes = new LinkedList<ELDescriptionNode>(); @@ -604,10 +607,10 @@ * @return The tree size. */ public int getSize() { - int size = nodes.size(); - for(ELDescriptionNode node : nodes) { - size += node.getLabel().size(); - } +// int size = nodes.size(); +// for(ELDescriptionNode node : nodes) { +// size += node.getLabel().size(); +// } return size; } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTreeComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTreeComparator.java 2009-01-18 16:41:36 UTC (rev 1579) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTreeComparator.java 2009-01-24 20:02:30 UTC (rev 1580) @@ -41,9 +41,15 @@ */ @Override public int compare(ELDescriptionTree tree1, ELDescriptionTree tree2) { - ELDescriptionNode node1 = tree1.getRootNode(); - ELDescriptionNode node2 = tree2.getRootNode(); - return nodeComp.compare(node1, node2); + // we use the size as first criterion to avoid many comparisons + int sizeDiff = tree1.size - tree2.size; + if(sizeDiff == 0) { + ELDescriptionNode node1 = tree1.getRootNode(); + ELDescriptionNode node2 = tree2.getRootNode(); + return nodeComp.compare(node1, node2); + } else { + return sizeDiff; + } } } Added: trunk/src/dl-learner/org/dllearner/algorithms/el/TreeAndRoleSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/TreeAndRoleSet.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/TreeAndRoleSet.java 2009-01-24 20:02:30 UTC (rev 1580) @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2007-2009, 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.algorithms.el; + +import java.util.Set; + +import org.dllearner.core.owl.ObjectProperty; + +/** + * Convenience class representing an EL description tree and a set of roles. + * + * @author Jens Lehmann + * + */ +public class TreeAndRoleSet { + + private ELDescriptionTree tree; + private Set<ObjectProperty> roles; + + public TreeAndRoleSet(ELDescriptionTree tree, Set<ObjectProperty> roles) { + this.tree = tree; + this.roles = roles; + } + + /** + * @return the tree + */ + public ELDescriptionTree getTree() { + return tree; + } + + /** + * @return the roles + */ + public Set<ObjectProperty> getRoles() { + return roles; + } + + @Override + public String toString() { + return "("+tree.toDescriptionString() + "," + roles.toString()+")"; + } + +} Added: trunk/src/dl-learner/org/dllearner/algorithms/el/TreeAndRoleSetComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/TreeAndRoleSetComparator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/TreeAndRoleSetComparator.java 2009-01-24 20:02:30 UTC (rev 1580) @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2007-2009, 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.algorithms.el; + +import java.util.Comparator; +import java.util.Iterator; +import java.util.Set; + +import org.dllearner.core.owl.ObjectProperty; + +/** + * A comparator implementation for the tree and role set convenience structure. + * + * @author Jens Lehmann + * + */ +public class TreeAndRoleSetComparator implements Comparator<TreeAndRoleSet> { + + private ELDescriptionTreeComparator treeComp = new ELDescriptionTreeComparator(); + + /* (non-Javadoc) + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + @Override + public int compare(TreeAndRoleSet o1, TreeAndRoleSet o2) { + int comp = treeComp.compare(o1.getTree(), o2.getTree()); + if(comp == 0) { + Set<ObjectProperty> op1 = o1.getRoles(); + Set<ObjectProperty> op2 = o2.getRoles(); + int sizeDiff = op1.size() - op2.size(); + if(sizeDiff == 0) { + Iterator<ObjectProperty> it1 = op1.iterator(); + Iterator<ObjectProperty> it2 = op2.iterator(); + while(it1.hasNext()) { + int stringComp = it1.next().compareTo(it2.next()); + if(stringComp != 0) { + return stringComp; + } + } + return 0; + } else { + return sizeDiff; + } + } else { + return comp; + } + } + +} Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-18 16:41:36 UTC (rev 1579) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-24 20:02:30 UTC (rev 1580) @@ -38,6 +38,9 @@ import org.dllearner.algorithms.el.ELDescriptionEdgeComparator; import org.dllearner.algorithms.el.ELDescriptionNode; import org.dllearner.algorithms.el.ELDescriptionTree; +import org.dllearner.algorithms.el.ELDescriptionTreeComparator; +import org.dllearner.algorithms.el.TreeAndRoleSet; +import org.dllearner.algorithms.el.TreeAndRoleSetComparator; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Intersection; @@ -95,7 +98,9 @@ private Utility utility; // comparators - ELDescriptionEdgeComparator edgeComp = new ELDescriptionEdgeComparator(); + private ELDescriptionTreeComparator treeComp = new ELDescriptionTreeComparator(); + private ELDescriptionEdgeComparator edgeComp = new ELDescriptionEdgeComparator(); + private TreeAndRoleSetComparator mComp = new TreeAndRoleSetComparator(); public ELDown2(ReasonerComponent rs) { this.rs = rs; @@ -155,7 +160,7 @@ refinements.addAll(extendLabel(tree, v, position)); refinements.addAll(refineLabel(tree, v, position)); refinements.addAll(refineEdge(tree, v, position)); - refinements.addAll(attachSubtree(tree, v, position)); + refinements.addAll(attachSubtree2(tree, v, position)); } return refinements; @@ -251,7 +256,7 @@ } // operation 4: attach tree - private List<ELDescriptionTree> attachSubtree(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + private Collection<ELDescriptionTree> attachSubtree(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { Monitor mon = MonitorFactory.start("attach tree"); List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); @@ -343,6 +348,103 @@ return refinements; } + // new version of as + private Collection<ELDescriptionTree> attachSubtree2(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + Monitor mon = MonitorFactory.start("attach tree"); + Set<ELDescriptionTree> refinements = new TreeSet<ELDescriptionTree>(treeComp); + + // create and initialise M + TreeSet<TreeAndRoleSet> m = new TreeSet<TreeAndRoleSet>(mComp); + ELDescriptionTree topTree = new ELDescriptionTree(rs, Thing.instance); + Description index = getIndex(v); + SortedSet<ObjectProperty> appOPs = utility.computeApplicableObjectProperties(index); + m.add(new TreeAndRoleSet(topTree, appOPs)); + +// logger.trace("M initialised: " + m); + + while(!m.isEmpty()) { + + // pick first element of M + TreeAndRoleSet tars = m.pollFirst(); + ELDescriptionTree tp = tars.getTree(); + Set<ObjectProperty> rSet = tars.getRoles(); +// logger.trace("selected first element of M: " + tars); + + + // init sets R' and R'' + // more efficient + SortedSet<ObjectProperty> rpSet = utility.computeMgr(appOPs); + rpSet.retainAll(rSet); +// SortedSet<ObjectProperty> rpSet = new TreeSet<ObjectProperty>(); +// for(ObjectProperty rEl : rSet) { +// if(!containsSuperProperty(rEl, rSet)) { +// rpSet.add(rEl); +// } +// } + +// logger.trace("R': " + rpSet); + Set<ObjectProperty> rppSet = new TreeSet<ObjectProperty>(); + + while(!rpSet.isEmpty()) { + // pick an element r from R' + Iterator<ObjectProperty> it = rpSet.iterator(); + ObjectProperty r = it.next(); + it.remove(); +// logger.trace("picked role r: " + r); + + ELDescriptionTree tpp = mergeTrees(tree, v, position, r, tp); +// logger.trace("merged tree:\n" + tpp); + // the position of w is the position of v + #edges outgoing from v + int[] wPosition = new int[position.length+1]; + System.arraycopy(position, 0, wPosition, 0, position.length); + wPosition[position.length] = v.getEdges().size(); + ELDescriptionNode w = tpp.getNode(wPosition); + + if(tpp.isMinimal()) { + refinements.add(tpp); +// logger.trace("tree is minimal; added to T"); + } else { + boolean check = asCheck(w); +// logger.trace("tree is not minimal; result of complex check: " + check); + + if(check) { + +// Monitor mon2 = MonitorFactory.start("as.tmp"); + // add role to R' if it is in R (allowed) + for(ObjectProperty subRole : rs.getSubProperties(r)) { + if(rSet.contains(subRole)) { + rpSet.add(subRole); + } + } + rppSet.add(r); +// logger.trace("updated R' to: " + rpSet); +// logger.trace("updated R'' to: " + rppSet); +// mon2.stop(); + } + } + } + + if(rppSet.size() != 0) { + // recursive call + mon.stop(); +// logger.trace("recursive call start"); + List<ELDescriptionTree> recRefs = refine(tp); +// logger.trace("recursive call end"); + mon.start(); + + for(ELDescriptionTree tStar : recRefs) { + m.add(new TreeAndRoleSet(tStar, rppSet)); + } +// logger.trace("M after recursion: " + m); + } + + } + + mon.stop(); + return refinements; + } + + // create a new tree which is obtained by attaching the new tree at the given node in the tree via role r private ELDescriptionTree mergeTrees(ELDescriptionTree tree, ELDescriptionNode node, int[] position, ObjectProperty r, ELDescriptionTree newTree) { Monitor mon = MonitorFactory.start("as.merge trees"); @@ -472,4 +574,23 @@ return i; } + private Description getIndex(ELDescriptionNode v) { + if(v.isRoot()) { + return Thing.instance; + } else { + return opRanges.get(v.getParentEdge().getLabel()); + } + } + + private boolean containsSuperProperty(ObjectProperty prop, Set<ObjectProperty> props) { + for(ObjectProperty p : props) { + if(!p.equals(prop)) { + if(opHierarchy.isSubpropertyOf(prop, p)) { + return true; + } + } + } + return false; + } + } Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-18 16:41:36 UTC (rev 1579) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-24 20:02:30 UTC (rev 1580) @@ -71,9 +71,10 @@ new File(dir).mkdir(); String example = "/home/jl/promotion/ontologien/galen2.owl"; +// example = "/home/jl/downloads/uni-leipzig/OTAGen-v1/generated/generatedOnt.owl"; for(int i=10; i<17; i++) { - rand = new Random(2); + rand = new Random(1); testOntology(dir, example, 100, i); } @@ -217,7 +218,7 @@ statString += getMonitorData(MonitorFactory.getMonitor("attach tree", "ms.")); statString += getMonitorData(MonitorFactory.getMonitor("as.merge trees", "ms.")); statString += getMonitorData(MonitorFactory.getMonitor("as.complex check", "ms.")); -// statString += getMonitorData(MonitorFactory.getMonitor("as.tmp", "ms.")); + statString += getMonitorData(MonitorFactory.getMonitor("as.tmp", "ms.")); // statString += getMonitorData(MonitorFactory.getMonitor("el.tmp", "ms.")); statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.minimal", "boolean")); statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.check", "boolean")); Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-18 16:41:36 UTC (rev 1579) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-24 20:02:30 UTC (rev 1580) @@ -82,6 +82,17 @@ System.out.println("TEST 1"); ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); +// ELDescriptionTree t = new ELDescriptionTree(rs); +// ObjectProperty p1 = new ObjectProperty("p1"); +// ObjectProperty p2 = new ObjectProperty("p2"); +// NamedClass a1 = new NamedClass("a1"); +// ELDescriptionNode n1 = new ELDescriptionNode(t, a1); +// ELDescriptionNode n2 = new ELDescriptionNode(n1, p1, a1); +// +// System.out.println(t); +// System.out.println(t.getSize()); +// System.exit(0); + // input description Description input = KBParser.parseConcept("(human AND EXISTS has.animal)"); System.out.println("refining: " + input.toString(KBParser.internalNamespace, null)); @@ -179,6 +190,7 @@ desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.human))"); desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.cat))"); desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.EXISTS has.TOP))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.(cat AND bird)))"); desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.cat))"); desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.EXISTS has.TOP))"); desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasChild.TOP))"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-18 16:41:39
|
Revision: 1579 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1579&view=rev Author: jenslehmann Date: 2009-01-18 16:41:36 +0000 (Sun, 18 Jan 2009) Log Message: ----------- comparator for EL description edges Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionEdgeComparator.java Added: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionEdgeComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionEdgeComparator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionEdgeComparator.java 2009-01-18 16:41:36 UTC (rev 1579) @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2007-2009, 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.algorithms.el; + +import java.util.Comparator; + +/** + * @author Jens Lehmann + * + */ +public class ELDescriptionEdgeComparator implements Comparator<ELDescriptionEdge> { + + private ELDescriptionNodeComparator nodeComp; + + public ELDescriptionEdgeComparator() { + nodeComp = new ELDescriptionNodeComparator(); + } + + @Override + public int compare(ELDescriptionEdge edge1, ELDescriptionEdge edge2) { + // perform string comparison on node labels + int comp = edge1.getLabel().compareTo(edge2.getLabel()); + if(comp==0) { + return nodeComp.compare(edge1.getNode(), edge2.getNode()); + } else { + return comp; + } + } + +} Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-17 18:27:07 UTC (rev 1578) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-18 16:41:36 UTC (rev 1579) @@ -35,6 +35,7 @@ import org.apache.log4j.Logger; import org.dllearner.algorithms.el.ELDescriptionEdge; +import org.dllearner.algorithms.el.ELDescriptionEdgeComparator; import org.dllearner.algorithms.el.ELDescriptionNode; import org.dllearner.algorithms.el.ELDescriptionTree; import org.dllearner.core.ReasonerComponent; @@ -93,6 +94,9 @@ // utility class private Utility utility; + // comparators + ELDescriptionEdgeComparator edgeComp = new ELDescriptionEdgeComparator(); + public ELDown2(ReasonerComponent rs) { this.rs = rs; subsumptionHierarchy = rs.getClassHierarchy(); @@ -266,10 +270,12 @@ // loop through most general roles for(ObjectProperty op : mgr) { -// logger.trace("pick most general role: " + op); + logger.trace("pick most general role: " + op); // a list of subtrees (stored as edges i.e. role + root node which points to tree) - LinkedList<ELDescriptionEdge> m = new LinkedList<ELDescriptionEdge>(); +// LinkedList<ELDescriptionEdge> m = new LinkedList<ELDescriptionEdge>(); + // we must store m as set, otherwise we get duplicates + TreeSet<ELDescriptionEdge> m = new TreeSet<ELDescriptionEdge>(edgeComp); // create tree corresponding to top node ELDescriptionTree topTree = new ELDescriptionTree(rs, Thing.instance); @@ -281,7 +287,7 @@ while(!m.isEmpty()) { // pick and remove first element ELDescriptionEdge edge = m.pollFirst(); -// logger.trace("picked first element of M: " + edge); + logger.trace("picked first element of M: " + edge); ObjectProperty r = edge.getLabel(); // tp = t' in algorithm description (p stands for prime) ELDescriptionTree tp = edge.getNode().getTree(); @@ -296,20 +302,20 @@ ELDescriptionNode wClone = mergedTree.getNode(wPosition); -// logger.trace("merged to t_{C'}: \n" + mergedTree); + logger.trace("merged to t_{C'}: \n" + mergedTree); // we check equivalence by a minimality test (TODO: can we still do this?) boolean minimal = mergedTree.isMinimal(); MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); if(minimal) { -// logger.trace("Merged tree is minimal, i.e. not equivalent."); + logger.trace("Merged tree is minimal, i.e. not equivalent."); // it is not equivalent, i.e. we found a refinement refinements.add(mergedTree); } else { -// logger.trace("Merged tree is not minimal, i.e. equivalent."); + logger.trace("Merged tree is not minimal, i.e. equivalent."); // perform complex check in merged tree boolean check = asCheck(wClone); -// logger.trace("Result of complex check: " + check); + logger.trace("Result of complex check: " + check); MonitorFactory.add("as.check", "boolean", check ? 1 : 0); if(check) { @@ -318,19 +324,19 @@ m.add(new ELDescriptionEdge(subRole, tp.getRootNode())); } // refine tree using recursive operator call -// logger.trace("Recursive Call"); + logger.trace("Recursive Call"); // do not monitor recursive calls (counts time twice or more) mon.stop(); List<ELDescriptionTree> recRefs = refine(tp); mon.start(); -// logger.trace("Recursive Call Done"); + logger.trace("Recursive Call Done"); for(ELDescriptionTree tpp : recRefs) { m.add(new ELDescriptionEdge(r, tpp.getRootNode())); } } } -// logger.trace("M: " + m); + logger.trace("M: " + m); } } mon.stop(); Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-17 18:27:07 UTC (rev 1578) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-18 16:41:36 UTC (rev 1579) @@ -75,10 +75,11 @@ * @throws ParseException Thrown if concept syntax does not correspond * to current KB syntax. * @throws ComponentInitException + * @throws IOException */ @Test - public void test1() throws ParseException, ComponentInitException { - System.out.println("TEST 1"); + public void test1() throws ParseException, ComponentInitException, IOException { + System.out.println("TEST 1"); ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); // input description @@ -112,6 +113,13 @@ System.out.println("desired: " + tmp.toString(KBParser.internalNamespace, null)); } + Logger logger = Logger.getRootLogger(); + logger.setLevel(Level.TRACE); + SimpleLayout layout = new SimpleLayout(); + FileAppender app = new FileAppender(layout, "log/el/test.txt", false); + logger.removeAllAppenders(); + logger.addAppender(app); + // perform refinement and compare solutions long startTime = System.nanoTime(); Set<Description> refinements = operator.refine(input); @@ -159,13 +167,7 @@ @Test public void test2() throws ParseException, IOException { - System.out.println("TEST 2"); -// Logger logger = Logger.getRootLogger(); -// logger.setLevel(Level.TRACE); -// SimpleLayout layout = new SimpleLayout(); -// FileAppender app = new FileAppender(layout, "log/el/log.txt", false); -// logger.removeAllAppenders(); -// logger.addAppender(app); + System.out.println("TEST 2"); ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE_NO_DR); @@ -180,6 +182,12 @@ desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.cat))"); desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.EXISTS has.TOP))"); desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasChild.TOP))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.human))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.(animal AND EXISTS has.TOP)))"); + desiredString.add("(human AND EXISTS hasPet.(bird AND cat))"); + desiredString.add("(human AND (EXISTS has.(animal AND EXISTS has.TOP) AND EXISTS hasPet.bird))"); + desiredString.add("(human AND (EXISTS has.(bird AND EXISTS has.TOP) AND EXISTS hasPet.bird))"); + desiredString.add("(human AND EXISTS hasPet.(bird AND EXISTS has.TOP))"); ConceptComparator cc = new ConceptComparator(); SortedSet<Description> desired = new TreeSet<Description>(cc); @@ -191,6 +199,13 @@ System.out.println("desired: " + tmp.toString(KBParser.internalNamespace, null)); } + Logger logger = Logger.getRootLogger(); + logger.setLevel(Level.TRACE); + SimpleLayout layout = new SimpleLayout(); + FileAppender app = new FileAppender(layout, "log/el/test_no_dr.txt", false); + logger.removeAllAppenders(); + logger.addAppender(app); + RefinementOperator operator = new ELDown2(rs); Set<Description> refinements = operator.refine(input); @@ -208,6 +223,7 @@ @Test public void test3() throws ParseException, IOException { System.out.println("TEST 3"); + ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE_NO_DISJOINT); // input description @@ -223,7 +239,7 @@ desiredString.add("(human AND (EXISTS hasChild.human AND (EXISTS has.TOP AND EXISTS has.animal)))"); desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS has.(animal AND EXISTS has.TOP)))"); desiredString.add("(human AND (EXISTS hasChild.human AND (EXISTS has.animal AND EXISTS has.EXISTS has.TOP)))"); - + ConceptComparator cc = new ConceptComparator(); SortedSet<Description> desired = new TreeSet<Description>(cc); for(String str : desiredString) { @@ -234,6 +250,13 @@ System.out.println("desired: " + tmp.toString(KBParser.internalNamespace, null)); } + Logger logger = Logger.getRootLogger(); + logger.setLevel(Level.TRACE); + SimpleLayout layout = new SimpleLayout(); + FileAppender app = new FileAppender(layout, "log/el/test_no_disjoint.txt", false); + logger.removeAllAppenders(); + logger.addAppender(app); + RefinementOperator operator = new ELDown2(rs); Set<Description> refinements = operator.refine(input); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-17 18:27:17
|
Revision: 1578 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1578&view=rev Author: jenslehmann Date: 2009-01-17 18:27:07 +0000 (Sat, 17 Jan 2009) Log Message: ----------- added option to configure horizontal expansion penalty (can be used to say whether the search should be more breadth or depth like) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/test/PelletPerformanceProblem.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -215,6 +215,7 @@ options.add(new DoubleConfigOption("negativeWeight", "Used to penalise errors on negative examples different from those of positive examples (lower = less importance for negatives).",1.0)); options.add(new DoubleConfigOption("startNodeBonus", "You can use this to give a heuristic bonus on the start node (= initially broader exploration of search space).",0.0)); options.add(new IntegerConfigOption("negationPenalty", "Penalty on negations (TODO: better explanation).", 0)); + options.add(CommonConfigOptions.getExpansionPenaltyFactor(0.02)); return options; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -98,6 +98,7 @@ this.configurator = configurator; negativeWeight = configurator.getNegativeWeight(); startNodeBonus = configurator.getStartNodeBonus(); + expansionPenaltyFactor = configurator.getExpansionPenaltyFactor(); } // public MultiHeuristic(int nrOfPositiveExamples, int nrOfNegativeExamples, double expansionPenaltyFactor, double gainBonusFactor) { Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -402,6 +402,15 @@ public int getNegationPenalty() { return (Integer) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "negationPenalty") ; } +/** +* expansionPenaltyFactor describes the reduction in heuristic score one is willing to accept for reducing the length of the concept by one. +* mandatory: false| reinit necessary: true +* default value: 0.02 +* @return double +**/ +public double getExpansionPenaltyFactor() { +return (Double) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "expansionPenaltyFactor") ; +} /** * @param writeSearchTree specifies whether to write a search tree. @@ -745,6 +754,15 @@ ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "negationPenalty", negationPenalty); reinitNecessary = true; } +/** +* @param expansionPenaltyFactor describes the reduction in heuristic score one is willing to accept for reducing the length of the concept by one. +* mandatory: false| reinit necessary: true +* default value: 0.02 +**/ +public void setExpansionPenaltyFactor(double expansionPenaltyFactor) { +ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "expansionPenaltyFactor", expansionPenaltyFactor); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -80,6 +80,11 @@ return option; } + public static DoubleConfigOption getExpansionPenaltyFactor(double defaultValue) { + DoubleConfigOption option = new DoubleConfigOption("expansionPenaltyFactor", "describes the reduction in heuristic score one is willing to accept for reducing the length of the concept by one", defaultValue); + return option; + } + public static StringConfigOption getReturnType() { return new StringConfigOption("returnType", "Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type."); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -252,7 +252,7 @@ public boolean hasTypeImpl(Description description, Individual individual) throws ReasoningMethodUnsupportedException { - // System.out.println(description + " " + individual); +// System.out.println(description + " " + individual); if (description instanceof NamedClass) { return classInstancesPos.get((NamedClass) description).contains(individual); @@ -366,7 +366,10 @@ int number = ((ObjectCardinalityRestriction) description).getNumber(); int nrOfFillers = 0; - SortedSet<Individual> roleFillers = opPos.get(op).get(individual); +// SortedSet<Individual> roleFillers = opPos.get(op).get(individual); + SortedSet<Individual> roleFillers = mapping.get(individual); +// System.out.println(roleFillers); + // special case: there are always at least zero fillers if (number == 0) { return true; @@ -384,7 +387,7 @@ if (nrOfFillers == number) { return true; } - // earyl abort: e.g. >= 10 hasStructure.Methyl; + // early abort: e.g. >= 10 hasStructure.Methyl; // if there are 11 fillers and 2 are not Methyl, the result // is false } else { Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -71,7 +71,12 @@ new File(dir).mkdir(); String example = "/home/jl/promotion/ontologien/galen2.owl"; - testOntology(dir, example, 100, 17); + + for(int i=10; i<17; i++) { + rand = new Random(2); + testOntology(dir, example, 100, i); + } + System.exit(0); /* TEST ON ARTIFICIAL ONTOLOGIES @@ -142,7 +147,7 @@ // log file name String name = ontFile.getName(); - String statFileName = name.substring(0, name.lastIndexOf(".")) + ".txt"; + String statFileName = name.substring(0, name.lastIndexOf(".")) + "_" + chainLength + ".txt"; File statFile = new File(statDir + statFileName); String statString = ""; @@ -221,6 +226,9 @@ statString += getMonitorData(MonitorFactory.getMonitor("disjointness reasoning", "ms.")); Files.createFile(statFile, statString); + + reasoner.releaseKB(); + cm.freeAllComponents(); } private static String getMonitorData(Monitor mon) { Added: trunk/src/dl-learner/org/dllearner/test/PelletPerformanceProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/PelletPerformanceProblem.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/PelletPerformanceProblem.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -0,0 +1,63 @@ +/** + * Copyright (C) 2007-2009, 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.test; + +import java.io.File; +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.inference.OWLReasoner; +import org.semanticweb.owl.inference.OWLReasonerException; +import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLOntologyCreationException; +import org.semanticweb.owl.model.OWLOntologyManager; + +/** + * @author Jens Lehmann + * + */ +public class PelletPerformanceProblem { + + public static void main(String[] args) throws OWLOntologyCreationException, OWLReasonerException { + Logger pelletLogger = Logger.getLogger("org.mindswap.pellet"); + pelletLogger.setLevel(Level.WARN); + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + + File f = new File("examples/epc/conf/sap_modell_komplett_2.owl"); + URI physicalURI = f.toURI(); + OWLOntology ontology = manager.loadOntologyFromPhysicalURI(physicalURI); + + Set<OWLOntology> ontologies = new HashSet<OWLOntology>(); + ontologies.add(ontology); + OWLReasoner reasoner = new org.mindswap.pellet.owlapi.Reasoner(manager); + reasoner.loadOntologies(ontologies); + System.out.println("ontology loaded"); + + reasoner.classify(); + System.out.println("ontology classified"); + reasoner.realise(); + System.out.println("ontology realised"); + } + +} Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -38,6 +38,7 @@ import org.dllearner.kb.OWLFile; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; +import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.OWLAPIReasoner; import org.junit.Test; @@ -76,7 +77,7 @@ * Performs an instance checks on all reasoner components to verify that * they all return the correct result. */ - @Test +// @Test public void instanceCheckTest() { try { ComponentManager cm = ComponentManager.getInstance(); @@ -114,7 +115,7 @@ * @throws ComponentInitException * @throws ParseException */ - @Test +// @Test public void fastInstanceCheckTest() throws ComponentInitException, ParseException { String file = "examples/carcinogenesis/carcinogenesis.owl"; ComponentManager cm = ComponentManager.getInstance(); @@ -157,6 +158,28 @@ } } + @Test + public void fastInstanceCheck2() throws ComponentInitException, ParseException { + String file = "examples/epc/conf/sap_modell_komplett_2.owl"; + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + try { + cm.applyConfigEntry(ks, "url", new File(file).toURI().toURL()); + } catch (MalformedURLException e) { + // should never happen + e.printStackTrace(); + } + ks.init(); + ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, ks); + reasoner.init(); + baseURI = reasoner.getBaseURI(); + + Description description = KBParser.parseConcept("(\"http://localhost/aris/sap_model.owl#EPC\" AND EXISTS \"http://localhost/aris/sap_model.owl#hasModelElements\".(\"http://localhost/aris/sap_model.owl#Event\" AND >= 2 \"http://localhost/aris/sap_model.owl#previousObjects\".TOP))"); + Individual ind = new Individual("http://localhost/aris/sap_model.owl#e4j0__6_____u__"); + boolean result = reasoner.hasType(description, ind); + System.out.println(result); + } + private List<Individual> getIndSet(String... inds) { List<Individual> individuals = new LinkedList<Individual>(); for(String ind : inds) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-16 16:24:49
|
Revision: 1577 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1577&view=rev Author: jenslehmann Date: 2009-01-16 16:24:44 +0000 (Fri, 16 Jan 2009) Log Message: ----------- two EL operator unit tests (failing) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-12 18:34:36 UTC (rev 1576) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-16 16:24:44 UTC (rev 1577) @@ -78,6 +78,7 @@ */ @Test public void test1() throws ParseException, ComponentInitException { + System.out.println("TEST 1"); ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); // input description @@ -158,6 +159,7 @@ @Test public void test2() throws ParseException, IOException { + System.out.println("TEST 2"); // Logger logger = Logger.getRootLogger(); // logger.setLevel(Level.TRACE); // SimpleLayout layout = new SimpleLayout(); @@ -165,21 +167,90 @@ // logger.removeAllAppenders(); // logger.addAppender(app); - ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); + ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE_NO_DR); // input description - Description input = KBParser.parseConcept("(human AND (EXISTS has.bird AND EXISTS has.cat))"); + Description input = KBParser.parseConcept("(human AND EXISTS hasPet.bird)"); ConceptTransformation.cleanConcept(input); + Set<String> desiredString = new TreeSet<String>(); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.human))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.cat))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.EXISTS has.TOP))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.cat))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.EXISTS has.TOP))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasChild.TOP))"); + + ConceptComparator cc = new ConceptComparator(); + SortedSet<Description> desired = new TreeSet<Description>(cc); + for(String str : desiredString) { + Description tmp = KBParser.parseConcept(str); + ConceptTransformation.cleanConcept(tmp); + ConceptTransformation.transformToOrderedForm(tmp, cc); + desired.add(tmp); + System.out.println("desired: " + tmp.toString(KBParser.internalNamespace, null)); + } + RefinementOperator operator = new ELDown2(rs); - operator.refine(input); + Set<Description> refinements = operator.refine(input); +// assertTrue(refinements.size() == desired.size()); + System.out.println("\nproduced refinements and their unit test status (true = assertion satisfied):"); + for(Description refinement : refinements) { + ConceptTransformation.transformToOrderedForm(refinement, cc); + boolean ok = desired.contains(refinement); + System.out.println(ok + ": " + refinement.toString(KBParser.internalNamespace, null)); +// assertTrue(desired.contains(refinement)); + } } @Test - public void test3() throws ComponentInitException, ParseException, IOException { + public void test3() throws ParseException, IOException { + System.out.println("TEST 3"); + ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE_NO_DISJOINT); + // input description + Description input = KBParser.parseConcept("(human AND (EXISTS hasChild.human AND EXISTS has.animal))"); + ConceptTransformation.cleanConcept(input); + + Set<String> desiredString = new TreeSet<String>(); + desiredString.add("(human AND (animal AND (EXISTS hasChild.human AND EXISTS has.animal)))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS has.(animal AND human)))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS has.bird))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS has.cat))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS hasPet.animal))"); + desiredString.add("(human AND (EXISTS hasChild.human AND (EXISTS has.TOP AND EXISTS has.animal)))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS has.(animal AND EXISTS has.TOP)))"); + desiredString.add("(human AND (EXISTS hasChild.human AND (EXISTS has.animal AND EXISTS has.EXISTS has.TOP)))"); + + ConceptComparator cc = new ConceptComparator(); + SortedSet<Description> desired = new TreeSet<Description>(cc); + for(String str : desiredString) { + Description tmp = KBParser.parseConcept(str); + ConceptTransformation.cleanConcept(tmp); + ConceptTransformation.transformToOrderedForm(tmp, cc); + desired.add(tmp); + System.out.println("desired: " + tmp.toString(KBParser.internalNamespace, null)); + } + + RefinementOperator operator = new ELDown2(rs); + + Set<Description> refinements = operator.refine(input); + +// assertTrue(refinements.size() == desired.size()); + System.out.println("\nproduced refinements and their unit test status (true = assertion satisfied):"); + for(Description refinement : refinements) { + ConceptTransformation.transformToOrderedForm(refinement, cc); + boolean ok = desired.contains(refinement); + System.out.println(ok + ": " + refinement.toString(KBParser.internalNamespace, null)); +// assertTrue(desired.contains(refinement)); + } + } + +// @Test + public void test4() throws ComponentInitException, ParseException, IOException { + Logger logger = Logger.getRootLogger(); logger.setLevel(Level.TRACE); SimpleLayout layout = new SimpleLayout(); @@ -205,7 +276,7 @@ } - @Test +// @Test public void asTest() throws ComponentInitException, MalformedURLException { ComponentManager cm = ComponentManager.getInstance(); Modified: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-01-12 18:34:36 UTC (rev 1576) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-01-16 16:24:44 UTC (rev 1577) @@ -36,7 +36,7 @@ */ public final class TestOntologies { - public enum TestOntology { EMPTY, SIMPLE, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES }; + public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES }; public static ReasonerComponent getTestOntology(TestOntology ont) { String kbString = ""; @@ -54,6 +54,22 @@ kbString += "bird SUB animal.\n"; kbString += "cat SUB animal.\n"; kbString += "(human AND animal) = BOTTOM.\n"; + } else if(ont.equals(TestOntology.SIMPLE_NO_DR)) { + kbString += "Subrole(hasChild, has).\n"; + kbString += "Subrole(hasPet, has).\n"; + kbString += "bird SUB animal.\n"; + kbString += "cat SUB animal.\n"; + kbString += "(human AND animal) = BOTTOM.\n"; + } else if(ont.equals(TestOntology.SIMPLE_NO_DISJOINT)) { + kbString += "OPDOMAIN(hasChild) = human.\n"; + kbString += "OPRANGE(hasChild) = human.\n"; + kbString += "OPDOMAIN(hasPet) = human.\n"; + kbString += "OPRANGE(hasPet) = animal.\n"; + kbString += "Subrole(hasChild, has).\n"; + kbString += "Subrole(hasPet, has).\n"; + kbString += "bird SUB animal.\n"; + kbString += "cat SUB animal.\n"; + kbString += "human SUB TOP.\n"; } else if(ont.equals(TestOntology.SIMPLE2)) { kbString += "Subrole(r2,r3).\n"; kbString += "a1 SUB TOP.\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-12 18:34:47
|
Revision: 1576 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1576&view=rev Author: jenslehmann Date: 2009-01-12 18:34:36 +0000 (Mon, 12 Jan 2009) Log Message: ----------- fixed display bug in tree display in GUI Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/gui/SearchTree.java trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2009-01-11 19:24:30 UTC (rev 1575) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2009-01-12 18:34:36 UTC (rev 1576) @@ -183,7 +183,7 @@ } public String getShortDescriptionHTML(int nrOfPositiveExamples, int nrOfNegativeExamples, String baseURI) { - String ret = "<html><nobr> " + concept.toString(baseURI,null) + " <i>["; + String ret = "<html><nobr> " + concept.toManchesterSyntaxString(baseURI,null) + " <i>["; if(isTooWeak) ret += "q:tw"; Modified: trunk/src/dl-learner/org/dllearner/gui/SearchTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/SearchTree.java 2009-01-11 19:24:30 UTC (rev 1575) +++ trunk/src/dl-learner/org/dllearner/gui/SearchTree.java 2009-01-12 18:34:36 UTC (rev 1576) @@ -42,6 +42,7 @@ this.nrOfPositiveExamples = nrOfPositiveExamples; this.nrOfNegativeExamples = nrOfNegativeExamples; this.baseURI = baseURI; +// setRowHeight(0); } @Override @@ -53,5 +54,6 @@ boolean hasFocus) { ExampleBasedNode node = (ExampleBasedNode) value; return node.getShortDescriptionHTML(nrOfPositiveExamples, nrOfNegativeExamples, baseURI); +// return node.toString(); } } Modified: trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2009-01-11 19:24:30 UTC (rev 1575) +++ trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2009-01-12 18:34:36 UTC (rev 1576) @@ -86,6 +86,11 @@ int nrOfNegativeExamples = negExamples.size(); tree = new SearchTree(ebNodeModel, nrOfPositiveExamples, nrOfNegativeExamples, baseURI); + // we need to call this, otherwise the width of the elements below the root node + // corresponds to that of the toString() method on ExampleBasedNode, although we + // use a different method to create a string representation of a node + tree.updateUI(); +// ebNodeModel.nodeChanged(rootNode); // tree.addTreeWillExpandListener(this); this.add(new JScrollPane(tree)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-11 19:24:47
|
Revision: 1575 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1575&view=rev Author: jenslehmann Date: 2009-01-11 19:24:30 +0000 (Sun, 11 Jan 2009) Log Message: ----------- made trains example a bit more OWL like Modified Paths: -------------- trunk/examples/trains/trains_owl.conf trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java Added Paths: ----------- trunk/examples/trains/trains2.owl trunk/resources/architecture_large.png Added: trunk/examples/trains/trains2.owl =================================================================== --- trunk/examples/trains/trains2.owl (rev 0) +++ trunk/examples/trains/trains2.owl 2009-01-11 19:24:30 UTC (rev 1575) @@ -0,0 +1,741 @@ +<?xml version="1.0"?> + + +<!DOCTYPE rdf:RDF [ + <!ENTITY foo "http://example.com/foo#" > + <!ENTITY trains "http://example.com/trains#" > + <!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/trains#" + xml:base="http://example.com/trains" + 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:foo="http://example.com/foo#" + xmlns:trains="http://example.com/trains#"> + <owl:Ontology rdf:about=""/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Object Properties + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://example.com/trains#hasCar --> + + <owl:ObjectProperty rdf:about="#hasCar"> + <rdfs:range rdf:resource="#Car"/> + <rdfs:domain rdf:resource="#Train"/> + </owl:ObjectProperty> + + + + <!-- http://example.com/trains#hasShape --> + + <owl:ObjectProperty rdf:about="#hasShape"/> + + + + <!-- http://example.com/trains#load --> + + <owl:ObjectProperty rdf:about="#load"/> + + + + <!-- http://example.com/trains#loadCount --> + + <owl:ObjectProperty rdf:about="#loadCount"/> + + + + <!-- http://example.com/trains#wheels --> + + <owl:ObjectProperty rdf:about="#wheels"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Classes + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://example.com/trains#Car --> + + <owl:Class rdf:about="#Car"/> + + + + <!-- http://example.com/trains#ClosedCar --> + + <owl:Class rdf:about="#ClosedCar"> + <rdfs:subClassOf rdf:resource="#Car"/> + <owl:disjointWith rdf:resource="#OpenCar"/> + </owl:Class> + + + + <!-- http://example.com/trains#DoubleCar --> + + <owl:Class rdf:about="#DoubleCar"> + <rdfs:subClassOf rdf:resource="#Car"/> + </owl:Class> + + + + <!-- http://example.com/trains#JaggedCar --> + + <owl:Class rdf:about="#JaggedCar"> + <rdfs:subClassOf rdf:resource="#Car"/> + </owl:Class> + + + + <!-- http://example.com/trains#LongCar --> + + <owl:Class rdf:about="#LongCar"> + <rdfs:subClassOf rdf:resource="#Car"/> + <owl:disjointWith rdf:resource="#ShortCar"/> + </owl:Class> + + + + <!-- http://example.com/trains#OpenCar --> + + <owl:Class rdf:about="#OpenCar"> + <rdfs:subClassOf rdf:resource="#Car"/> + </owl:Class> + + + + <!-- http://example.com/trains#Shape --> + + <owl:Class rdf:about="#Shape"/> + + + + <!-- http://example.com/trains#ShortCar --> + + <owl:Class rdf:about="#ShortCar"> + <rdfs:subClassOf rdf:resource="#Car"/> + </owl:Class> + + + + <!-- http://example.com/trains#Train --> + + <owl:Class rdf:about="#Train"/> + + + + <!-- http://www.w3.org/2002/07/owl#Thing --> + + <owl:Class rdf:about="&owl;Thing"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Individuals + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://example.com/trains#car_101 --> + + <ShortCar rdf:about="#car_101"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#OpenCar"/> + <loadCount rdf:resource="#one"/> + <load rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + <hasShape rdf:resource="#u_shaped"/> + </ShortCar> + + + + <!-- http://example.com/trains#car_102 --> + + <LongCar rdf:about="#car_102"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#OpenCar"/> + <load rdf:resource="#rectangle"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + <loadCount rdf:resource="#two"/> + </LongCar> + + + + <!-- http://example.com/trains#car_11 --> + + <LongCar rdf:about="#car_11"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#OpenCar"/> + <hasShape rdf:resource="#rectangle"/> + <load rdf:resource="#rectangle"/> + <loadCount rdf:resource="#three"/> + <wheels rdf:resource="#two"/> + </LongCar> + + + + <!-- http://example.com/trains#car_12 --> + + <Car rdf:about="#car_12"> + <rdf:type rdf:resource="#ClosedCar"/> + <rdf:type rdf:resource="#ShortCar"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <load rdf:resource="#triangle"/> + <wheels rdf:resource="#two"/> + </Car> + + + + <!-- http://example.com/trains#car_13 --> + + <Car rdf:about="#car_13"> + <rdf:type rdf:resource="#LongCar"/> + <rdf:type rdf:resource="#OpenCar"/> + <load rdf:resource="#hexagon"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#three"/> + </Car> + + + + <!-- http://example.com/trains#car_14 --> + + <OpenCar rdf:about="#car_14"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ShortCar"/> + <load rdf:resource="#circle"/> + <load rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + </OpenCar> + + + + <!-- http://example.com/trains#car_21 --> + + <Car rdf:about="#car_21"> + <rdf:type rdf:resource="#OpenCar"/> + <rdf:type rdf:resource="#ShortCar"/> + <loadCount rdf:resource="#one"/> + <load rdf:resource="#triangle"/> + <wheels rdf:resource="#two"/> + <hasShape rdf:resource="#u_shaped"/> + </Car> + + + + <!-- http://example.com/trains#car_22 --> + + <ShortCar rdf:about="#car_22"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#OpenCar"/> + <loadCount rdf:resource="#one"/> + <load rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + <hasShape rdf:resource="#u_shaped"/> + </ShortCar> + + + + <!-- http://example.com/trains#car_23 --> + + <Car rdf:about="#car_23"> + <rdf:type rdf:resource="#ClosedCar"/> + <rdf:type rdf:resource="#ShortCar"/> + <load rdf:resource="#circle"/> + <hasShape rdf:resource="#rectangle"/> + <loadCount rdf:resource="#two"/> + <wheels rdf:resource="#two"/> + </Car> + + + + <!-- http://example.com/trains#car_31 --> + + <ShortCar rdf:about="#car_31"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#OpenCar"/> + <load rdf:resource="#circle"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + </ShortCar> + + + + <!-- http://example.com/trains#car_32 --> + + <ShortCar rdf:about="#car_32"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ClosedCar"/> + <hasShape rdf:resource="#hexagon"/> + <loadCount rdf:resource="#one"/> + <load rdf:resource="#triangle"/> + <wheels rdf:resource="#two"/> + </ShortCar> + + + + <!-- http://example.com/trains#car_33 --> + + <ClosedCar rdf:about="#car_33"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#LongCar"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#three"/> + <load rdf:resource="#triangle"/> + </ClosedCar> + + + + <!-- http://example.com/trains#car_41 --> + + <Car rdf:about="#car_41"> + <rdf:type rdf:resource="#OpenCar"/> + <rdf:type rdf:resource="#ShortCar"/> + <loadCount rdf:resource="#one"/> + <load rdf:resource="#triangle"/> + <wheels rdf:resource="#two"/> + <hasShape rdf:resource="#u_shaped"/> + </Car> + + + + <!-- http://example.com/trains#car_42 --> + + <DoubleCar rdf:about="#car_42"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#OpenCar"/> + <rdf:type rdf:resource="#ShortCar"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <load rdf:resource="#triangle"/> + <wheels rdf:resource="#two"/> + </DoubleCar> + + + + <!-- http://example.com/trains#car_43 --> + + <ClosedCar rdf:about="#car_43"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ShortCar"/> + <hasShape rdf:resource="#elipse"/> + <loadCount rdf:resource="#one"/> + <load rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + </ClosedCar> + + + + <!-- http://example.com/trains#car_44 --> + + <Car rdf:about="#car_44"> + <rdf:type rdf:resource="#OpenCar"/> + <rdf:type rdf:resource="#ShortCar"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <load rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + </Car> + + + + <!-- http://example.com/trains#car_51 --> + + <Car rdf:about="#car_51"> + <rdf:type rdf:resource="#DoubleCar"/> + <rdf:type rdf:resource="#OpenCar"/> + <rdf:type rdf:resource="#ShortCar"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <load rdf:resource="#triangle"/> + <wheels rdf:resource="#two"/> + </Car> + + + + <!-- http://example.com/trains#car_52 --> + + <ClosedCar rdf:about="#car_52"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ShortCar"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <load rdf:resource="#rectangle"/> + <wheels rdf:resource="#three"/> + </ClosedCar> + + + + <!-- http://example.com/trains#car_53 --> + + <ShortCar rdf:about="#car_53"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ClosedCar"/> + <load rdf:resource="#circle"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + </ShortCar> + + + + <!-- http://example.com/trains#car_61 --> + + <LongCar rdf:about="#car_61"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ClosedCar"/> + <load rdf:resource="#circle"/> + <hasShape rdf:resource="#rectangle"/> + <loadCount rdf:resource="#three"/> + <wheels rdf:resource="#two"/> + </LongCar> + + + + <!-- http://example.com/trains#car_62 --> + + <Car rdf:about="#car_62"> + <rdf:type rdf:resource="#OpenCar"/> + <rdf:type rdf:resource="#ShortCar"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <load rdf:resource="#triangle"/> + <wheels rdf:resource="#two"/> + </Car> + + + + <!-- http://example.com/trains#car_71 --> + + <ShortCar rdf:about="#car_71"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#DoubleCar"/> + <rdf:type rdf:resource="#OpenCar"/> + <load rdf:resource="#circle"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + </ShortCar> + + + + <!-- http://example.com/trains#car_72 --> + + <OpenCar rdf:about="#car_72"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ShortCar"/> + <loadCount rdf:resource="#one"/> + <load rdf:resource="#triangle"/> + <wheels rdf:resource="#two"/> + <hasShape rdf:resource="#u_shaped"/> + </OpenCar> + + + + <!-- http://example.com/trains#car_73 --> + + <Car rdf:about="#car_73"> + <rdf:type rdf:resource="#JaggedCar"/> + <rdf:type rdf:resource="#LongCar"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + <loadCount rdf:resource="#zero"/> + </Car> + + + + <!-- http://example.com/trains#car_81 --> + + <LongCar rdf:about="#car_81"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ClosedCar"/> + <loadCount rdf:resource="#one"/> + <load rdf:resource="#rectangle"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#three"/> + </LongCar> + + + + <!-- http://example.com/trains#car_82 --> + + <OpenCar rdf:about="#car_82"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ShortCar"/> + <load rdf:resource="#circle"/> + <loadCount rdf:resource="#one"/> + <wheels rdf:resource="#two"/> + <hasShape rdf:resource="#u_shaped"/> + </OpenCar> + + + + <!-- http://example.com/trains#car_91 --> + + <OpenCar rdf:about="#car_91"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#ShortCar"/> + <load rdf:resource="#circle"/> + <loadCount rdf:resource="#one"/> + <wheels rdf:resource="#two"/> + <hasShape rdf:resource="#u_shaped"/> + </OpenCar> + + + + <!-- http://example.com/trains#car_92 --> + + <Car rdf:about="#car_92"> + <rdf:type rdf:resource="#JaggedCar"/> + <rdf:type rdf:resource="#LongCar"/> + <loadCount rdf:resource="#one"/> + <hasShape rdf:resource="#rectangle"/> + <load rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + </Car> + + + + <!-- http://example.com/trains#car_93 --> + + <ShortCar rdf:about="#car_93"> + <rdf:type rdf:resource="#Car"/> + <rdf:type rdf:resource="#OpenCar"/> + <loadCount rdf:resource="#one"/> + <load rdf:resource="#rectangle"/> + <hasShape rdf:resource="#rectangle"/> + <wheels rdf:resource="#two"/> + </ShortCar> + + + + <!-- http://example.com/trains#car_94 --> + + <Car rdf:about="#car_94"> + <rdf:type rdf:resource="#OpenCar"/> + <rdf:type rdf:resource="#ShortCar"/> + <load rdf:resource="#circle"/> + <loadCount rdf:resource="#one"/> + <wheels rdf:resource="#two"/> + <hasShape rdf:resource="#u_shaped"/> + </Car> + + + + <!-- http://example.com/trains#circle --> + + <Shape rdf:about="#circle"/> + + + + <!-- http://example.com/trains#east1 --> + + <Train rdf:about="#east1"> + <hasCar rdf:resource="#car_11"/> + <hasCar rdf:resource="#car_12"/> + <hasCar rdf:resource="#car_13"/> + <hasCar rdf:resource="#car_14"/> + </Train> + + + + <!-- http://example.com/trains#east2 --> + + <Train rdf:about="#east2"> + <hasCar rdf:resource="#car_21"/> + <hasCar rdf:resource="#car_22"/> + <hasCar rdf:resource="#car_23"/> + </Train> + + + + <!-- http://example.com/trains#east3 --> + + <Train rdf:about="#east3"> + <hasCar rdf:resource="#car_31"/> + <hasCar rdf:resource="#car_32"/> + <hasCar rdf:resource="#car_33"/> + </Train> + + + + <!-- http://example.com/trains#east4 --> + + <Train rdf:about="#east4"> + <hasCar rdf:resource="#car_41"/> + <hasCar rdf:resource="#car_42"/> + <hasCar rdf:resource="#car_43"/> + <hasCar rdf:resource="#car_44"/> + </Train> + + + + <!-- http://example.com/trains#east5 --> + + <Train rdf:about="#east5"> + <hasCar rdf:resource="#car_51"/> + <hasCar rdf:resource="#car_52"/> + <hasCar rdf:resource="#car_53"/> + </Train> + + + + <!-- http://example.com/trains#elipse --> + + <Shape rdf:about="#elipse"/> + + + + <!-- http://example.com/trains#hexagon --> + + <Shape rdf:about="#hexagon"/> + + + + <!-- http://example.com/trains#one --> + + <owl:Thing rdf:about="#one"/> + + + + <!-- http://example.com/trains#rectangle --> + + <Shape rdf:about="#rectangle"/> + + + + <!-- http://example.com/trains#three --> + + <owl:Thing rdf:about="#three"/> + + + + <!-- http://example.com/trains#triangle --> + + <Shape rdf:about="#triangle"/> + + + + <!-- http://example.com/trains#two --> + + <owl:Thing rdf:about="#two"/> + + + + <!-- http://example.com/trains#u_shaped --> + + <Shape rdf:about="#u_shaped"/> + + + + <!-- http://example.com/trains#west10 --> + + <Train rdf:about="#west10"> + <hasCar rdf:resource="#car_101"/> + <hasCar rdf:resource="#car_102"/> + </Train> + + + + <!-- http://example.com/trains#west6 --> + + <Train rdf:about="#west6"> + <hasCar rdf:resource="#car_61"/> + <hasCar rdf:resource="#car_62"/> + </Train> + + + + <!-- http://example.com/trains#west7 --> + + <Train rdf:about="#west7"> + <hasCar rdf:resource="#car_71"/> + <hasCar rdf:resource="#car_72"/> + <hasCar rdf:resource="#car_73"/> + </Train> + + + + <!-- http://example.com/trains#west8 --> + + <Train rdf:about="#west8"> + <hasCar rdf:resource="#car_81"/> + <hasCar rdf:resource="#car_82"/> + </Train> + + + + <!-- http://example.com/trains#west9 --> + + <Train rdf:about="#west9"> + <hasCar rdf:resource="#car_91"/> + <hasCar rdf:resource="#car_92"/> + <hasCar rdf:resource="#car_93"/> + <hasCar rdf:resource="#car_94"/> + </Train> + + + + <!-- http://example.com/trains#zero --> + + <owl:Thing rdf:about="#zero"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // General axioms + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + <rdf:Description> + <rdf:type rdf:resource="&owl;AllDisjointClasses"/> + <owl:members rdf:parseType="Collection"> + <rdf:Description rdf:about="#Car"/> + <rdf:Description rdf:about="#Shape"/> + <rdf:Description rdf:about="#Train"/> + </owl:members> + </rdf:Description> +</rdf:RDF> + + + +<!-- Generated by the OWL API (version 2.2.1.962) http://owlapi.sourceforge.net --> + Modified: trunk/examples/trains/trains_owl.conf =================================================================== --- trunk/examples/trains/trains_owl.conf 2009-01-11 11:53:29 UTC (rev 1574) +++ trunk/examples/trains/trains_owl.conf 2009-01-11 19:24:30 UTC (rev 1575) @@ -5,20 +5,20 @@ * Copyright (C) 2007, Jens Lehmann */ -hidePrefix = "http://example.com/foo#"; +hidePrefix = "http://example.com/trains#"; /*Background knowledge*/ -import("trains.owl"); +import("trains2.owl"); /*Examples*/ -+"http://example.com/foo#east1" -+"http://example.com/foo#east2" -+"http://example.com/foo#east3" -+"http://example.com/foo#east4" -+"http://example.com/foo#east5" --"http://example.com/foo#west6" --"http://example.com/foo#west7" --"http://example.com/foo#west8" --"http://example.com/foo#west9" --"http://example.com/foo#west10" ++"http://example.com/trains#east1" ++"http://example.com/trains#east2" ++"http://example.com/trains#east3" ++"http://example.com/trains#east4" ++"http://example.com/trains#east5" +-"http://example.com/trains#west6" +-"http://example.com/trains#west7" +-"http://example.com/trains#west8" +-"http://example.com/trains#west9" +-"http://example.com/trains#west10" Added: trunk/resources/architecture_large.png =================================================================== (Binary files differ) Property changes on: trunk/resources/architecture_large.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2009-01-11 11:53:29 UTC (rev 1574) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2009-01-11 19:24:30 UTC (rev 1575) @@ -183,7 +183,7 @@ } public String getShortDescriptionHTML(int nrOfPositiveExamples, int nrOfNegativeExamples, String baseURI) { - String ret = "<html> " + concept.toString(baseURI,null) + " <i>["; + String ret = "<html><nobr> " + concept.toString(baseURI,null) + " <i>["; if(isTooWeak) ret += "q:tw"; @@ -202,7 +202,7 @@ ret += " ("+qualityEvaluationMethod+"), he:" + horizontalExpansion; ret += " c:" + children.size() + "]"; - return ret + "</i></html>"; + return ret + "</i></nobr></html>"; } //TODO integrate this method with the one above Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-11 11:53:29 UTC (rev 1574) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-11 19:24:30 UTC (rev 1575) @@ -71,7 +71,7 @@ new File(dir).mkdir(); String example = "/home/jl/promotion/ontologien/galen2.owl"; - testOntology(dir, example, 100, 15); + testOntology(dir, example, 100, 17); System.exit(0); /* TEST ON ARTIFICIAL ONTOLOGIES This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-11 12:32:23
|
Revision: 1574 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1574&view=rev Author: jenslehmann Date: 2009-01-11 11:53:29 +0000 (Sun, 11 Jan 2009) Log Message: ----------- several changes to improve EL operator performance Modified Paths: -------------- trunk/doc/checkstyle.xml trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/examples/corpus/Sentence.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java Modified: trunk/doc/checkstyle.xml =================================================================== --- trunk/doc/checkstyle.xml 2009-01-11 07:56:41 UTC (rev 1573) +++ trunk/doc/checkstyle.xml 2009-01-11 11:53:29 UTC (rev 1574) @@ -82,7 +82,7 @@ </module> <module name="UpperEll"/> <module name="Header"> - <property name="header" value="/** * 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/>. * */"/> + <property name="header" value="/** * Copyright (C) 2007-2009, 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/>. * */"/> <property name="ignoreLines" value="20"/> </module> </module> Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-11 07:56:41 UTC (rev 1573) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-11 11:53:29 UTC (rev 1574) @@ -19,6 +19,7 @@ */ package org.dllearner.algorithms.el; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -31,17 +32,15 @@ import org.apache.log4j.Logger; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.UnsupportedLanguageException; -import org.dllearner.refinementoperators.ELDown2; -import org.dllearner.utilities.Helper; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; @@ -56,6 +55,7 @@ */ public class ELDescriptionTree implements Cloneable { + @SuppressWarnings("unused") private static Logger logger = Logger.getLogger(ELDescriptionTree.class); // to simplify equivalence checks and minimisation, we @@ -69,7 +69,7 @@ protected ELDescriptionNode rootNode; // the set of all nodes in the tree - private Set<ELDescriptionNode> nodes = new HashSet<ELDescriptionNode>(); + private Collection<ELDescriptionNode> nodes = new LinkedList<ELDescriptionNode>(); // nodes on a given level of the tree private Map<Integer, Set<ELDescriptionNode>> levelNodeMapping = new HashMap<Integer, Set<ELDescriptionNode>>(); @@ -535,7 +535,7 @@ treeClone.maxLevel = maxLevel; // nodes - treeClone.nodes = new HashSet<ELDescriptionNode>(); + treeClone.nodes = new LinkedList<ELDescriptionNode>(); for(ELDescriptionNode oldNode : nodes) { treeClone.nodes.add(cloneMap.get(oldNode)); } @@ -591,7 +591,7 @@ /** * @return the nodes */ - public Set<ELDescriptionNode> getNodes() { + public Collection<ELDescriptionNode> getNodes() { return nodes; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2009-01-11 07:56:41 UTC (rev 1573) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2009-01-11 11:53:29 UTC (rev 1574) @@ -22,7 +22,6 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; -import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -116,7 +115,7 @@ // pick the best candidate according to the heuristic SearchTreeNode best = candidates.pollLast(); // apply operator - Set<ELDescriptionTree> refinements = operator.refine(best.getDescriptionTree()); + List<ELDescriptionTree> refinements = operator.refine(best.getDescriptionTree()); // add all refinements to search tree, candidates, best descriptions for(ELDescriptionTree refinement : refinements) { addDescriptionTree(refinement, best); Modified: trunk/src/dl-learner/org/dllearner/examples/corpus/Sentence.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/corpus/Sentence.java 2009-01-11 07:56:41 UTC (rev 1573) +++ trunk/src/dl-learner/org/dllearner/examples/corpus/Sentence.java 2009-01-11 11:53:29 UTC (rev 1574) @@ -8,10 +8,8 @@ import org.dllearner.examples.Corpus; import org.dllearner.utilities.URLencodeUTF8; import org.semanticweb.owl.model.OWLClass; -import org.semanticweb.owl.model.OWLClassAssertionAxiom; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLIndividual; -import org.semanticweb.owl.model.OWLObject; import org.semanticweb.owl.model.OWLObjectProperty; public class Sentence { @@ -72,11 +70,11 @@ //%String %% word lemma tag morph edge parent secedge comment String word = st.nextToken(); - String lemma = st.nextToken(); +// String lemma = st.nextToken(); String tag = st.nextToken(); String morph = st.nextToken(); String edge = st.nextToken(); - String parent = st.nextToken(); +// String parent = st.nextToken(); //word if(word.startsWith("#")){ elementURL+="s_"+id+"_"+word.substring(1); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-11 07:56:41 UTC (rev 1573) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-11 11:53:29 UTC (rev 1574) @@ -95,7 +95,6 @@ public ELDown2(ReasonerComponent rs) { this.rs = rs; - utility = new Utility(rs); subsumptionHierarchy = rs.getClassHierarchy(); opHierarchy = rs.getObjectPropertyHierarchy(); @@ -104,7 +103,9 @@ for(ObjectProperty op : rs.getObjectProperties()) { opDomains.put(op, rs.getDomain(op)); opRanges.put(op, rs.getRange(op)); - } + } + + utility = new Utility(rs, opDomains); } /* (non-Javadoc) @@ -114,7 +115,7 @@ public Set<Description> refine(Description concept) { logger.trace("refining " + concept); ELDescriptionTree tree = new ELDescriptionTree(rs, concept); - Set<ELDescriptionTree> refinementTrees = refine(tree); + List<ELDescriptionTree> refinementTrees = refine(tree); Set<Description> refinements = new HashSet<Description>(); for(ELDescriptionTree refinementTree : refinementTrees) { refinements.add(refinementTree.transformToDescription()); @@ -130,15 +131,14 @@ * @param tree Input EL description tree. * @return Set of refined EL description trees. */ - public Set<ELDescriptionTree> refine(ELDescriptionTree tree) { + public List<ELDescriptionTree> refine(ELDescriptionTree tree) { logger.trace("applying \\rho on " + tree.toDescriptionString()); -// System.out.println("tree:" + tree); - Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); + List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // loop over all nodes of the tree and perform one of the // transformations on it (we make a copy of all nodes, because // the transformations can, of course, add new nodes) - Set<ELDescriptionNode> nodes = new HashSet<ELDescriptionNode>(tree.getNodes()); + List<ELDescriptionNode> nodes = new LinkedList<ELDescriptionNode>(tree.getNodes()); for(ELDescriptionNode v : nodes) { logger.trace("picked node v: " + v); @@ -154,20 +154,13 @@ refinements.addAll(attachSubtree(tree, v, position)); } -// for(ELDescriptionTree refinement : refinements) { -// if(refinement.getDepth() > tree.getDepth() + 1) { -// throw new Error("DEPTH WARNING"); -// } -// } - -// return refine(tree, tree.getRootNode(), new Thing(), true); return refinements; } // operation 1: label extension - private Set<ELDescriptionTree> extendLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + private List<ELDescriptionTree> extendLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { Monitor mon = MonitorFactory.start("extend label"); - Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); + List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // the index is the range of role in the edge pointing to the parent of this node Description index; @@ -179,10 +172,8 @@ // call ncc (see paper) Set<NamedClass> candidates = utility.getClassCandidates(index, v.getLabel()); -// System.out.println("label: " + v.getLabel()); for(NamedClass nc : candidates) { -// System.out.println("candidate: " + nc); // clone operation ELDescriptionTree clonedTree = tree.clone(); ELDescriptionNode clonedNode = clonedTree.getNode(position); @@ -198,9 +189,9 @@ } // operation 2: label refinement - private Set<ELDescriptionTree> refineLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + private List<ELDescriptionTree> refineLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { Monitor mon = MonitorFactory.start("refine label"); - Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); + List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // loop through all classes in label for(NamedClass nc : v.getLabel()) { @@ -225,9 +216,9 @@ } // operation 3: refine edge - private Set<ELDescriptionTree> refineEdge(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + private List<ELDescriptionTree> refineEdge(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { Monitor mon = MonitorFactory.start("refine edge"); - Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); + List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); for(int edgeNumber = 0; edgeNumber < v.getEdges().size(); edgeNumber++) { ELDescriptionEdge edge = v.getEdges().get(edgeNumber); @@ -256,9 +247,9 @@ } // operation 4: attach tree - private Set<ELDescriptionTree> attachSubtree(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + private List<ELDescriptionTree> attachSubtree(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { Monitor mon = MonitorFactory.start("attach tree"); - Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); + List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // compute the set of most general roles such that the domain of each role is not disjoint // with the range of the role pointing to this node @@ -268,12 +259,14 @@ } else { index = opRanges.get(v.getParentEdge().getLabel()); } + SortedSet<ObjectProperty> appOPs = utility.computeApplicableObjectProperties(index); + Set<ObjectProperty> mgr = utility.computeMgr(appOPs); // loop through most general roles for(ObjectProperty op : mgr) { - logger.trace("pick most general role: " + op); +// logger.trace("pick most general role: " + op); // a list of subtrees (stored as edges i.e. role + root node which points to tree) LinkedList<ELDescriptionEdge> m = new LinkedList<ELDescriptionEdge>(); @@ -288,7 +281,7 @@ while(!m.isEmpty()) { // pick and remove first element ELDescriptionEdge edge = m.pollFirst(); - logger.trace("picked first element of M: " + edge); +// logger.trace("picked first element of M: " + edge); ObjectProperty r = edge.getLabel(); // tp = t' in algorithm description (p stands for prime) ELDescriptionTree tp = edge.getNode().getTree(); @@ -299,29 +292,24 @@ // the position of w is the position of v + #edges outgoing from v int[] wPosition = new int[position.length+1]; System.arraycopy(position, 0, wPosition, 0, position.length); - wPosition[position.length] = v.getEdges().size(); -// logger.trace("position of v: " + arrayContent(position)); -// logger.trace("position of w: " + arrayContent(wPosition)); + wPosition[position.length] = v.getEdges().size(); - ELDescriptionNode wClone = mergedTree.getNode(wPosition); - logger.trace("merged to t_{C'}: \n" + mergedTree); +// logger.trace("merged to t_{C'}: \n" + mergedTree); -// System.out.println(mergedTree.toSimulationString()); - // we check equivalence by a minimality test (TODO: can we still do this?) boolean minimal = mergedTree.isMinimal(); MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); if(minimal) { - logger.trace("Merged tree is minimal, i.e. not equivalent."); +// logger.trace("Merged tree is minimal, i.e. not equivalent."); // it is not equivalent, i.e. we found a refinement refinements.add(mergedTree); } else { - logger.trace("Merged tree is not minimal, i.e. equivalent."); +// logger.trace("Merged tree is not minimal, i.e. equivalent."); // perform complex check in merged tree boolean check = asCheck(wClone); - logger.trace("Result of complex check: " + check); +// logger.trace("Result of complex check: " + check); MonitorFactory.add("as.check", "boolean", check ? 1 : 0); if(check) { @@ -330,20 +318,19 @@ m.add(new ELDescriptionEdge(subRole, tp.getRootNode())); } // refine tree using recursive operator call - logger.trace("Recursive Call"); +// logger.trace("Recursive Call"); // do not monitor recursive calls (counts time twice or more) mon.stop(); - Set<ELDescriptionTree> recRefs = refine(tp); + List<ELDescriptionTree> recRefs = refine(tp); mon.start(); - logger.trace("Recursive Call Done"); +// logger.trace("Recursive Call Done"); for(ELDescriptionTree tpp : recRefs) { -// System.out.println("aa " + tpp.toDescriptionString()); m.add(new ELDescriptionEdge(r, tpp.getRootNode())); } } } - logger.trace("M: " + m); +// logger.trace("M: " + m); } } mon.stop(); @@ -352,7 +339,7 @@ // create a new tree which is obtained by attaching the new tree at the given node in the tree via role r private ELDescriptionTree mergeTrees(ELDescriptionTree tree, ELDescriptionNode node, int[] position, ObjectProperty r, ELDescriptionTree newTree) { - Monitor mon = MonitorFactory.start("merge trees"); + Monitor mon = MonitorFactory.start("as.merge trees"); // System.out.println("merge start"); // System.out.println(tree); // System.out.println(newTree); @@ -365,15 +352,15 @@ // logger.trace("node position: " + arrayContent(position)); // logger.trace("merge start: " + mergedTree); - // create a list of nodes we still need to process LinkedList<ELDescriptionNode> toProcess = new LinkedList<ELDescriptionNode>(); toProcess.add(newTree.getRootNode()); // map from nodes to cloned nodes Map<ELDescriptionNode,ELDescriptionNode> cloneMap = new HashMap<ELDescriptionNode,ELDescriptionNode>(); -// cloneMap.put(newTree.getRootNode(), nodeNew); +// Monitor mon2 = MonitorFactory.start("as.tmp"); + // loop until the process list is empty while(!toProcess.isEmpty()) { // process a node @@ -397,14 +384,15 @@ } } -// System.out.println(mergedTree); -// System.out.println("merge end"); +// mon2.stop(); + mon.stop(); return mergedTree; } // TODO: variables have been renamed in article public boolean asCheck(ELDescriptionNode v) { + Monitor mon = MonitorFactory.start("as.complex check"); // System.out.println("asCheck: " + v.getTree().toSimulationString()); // find all edges up to the root node @@ -442,6 +430,7 @@ } } + mon.stop(); return true; } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2009-01-11 07:56:41 UTC (rev 1573) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2009-01-11 11:53:29 UTC (rev 1574) @@ -38,6 +38,9 @@ import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptComparator; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; + /** * Utility methods for constructing refinement operators. * @@ -46,8 +49,9 @@ */ public final class Utility { - private ReasonerComponent rs; + private ReasonerComponent reasoner; ClassHierarchy sh; + private Map<ObjectProperty,Description> opDomains; // concept comparator private ConceptComparator conceptComparator = new ConceptComparator(); @@ -59,10 +63,18 @@ // cache for reasoner queries private Map<Description,Map<Description,Boolean>> cachedDisjoints = new TreeMap<Description,Map<Description,Boolean>>(conceptComparator); - + // cache for applicaple object properties + private Map<Description, SortedSet<ObjectProperty>> appOPCache = new TreeMap<Description, SortedSet<ObjectProperty>>(conceptComparator); + public Utility(ReasonerComponent rs) { - this.rs = rs; + throw new Error("not implemented yet"); + } + + public Utility(ReasonerComponent rs, Map<ObjectProperty,Description> opDomains) { + this.reasoner = rs; sh = rs.getClassHierarchy(); + // we cache object property domains + this.opDomains = opDomains; } /** @@ -76,12 +88,18 @@ * */ public SortedSet<ObjectProperty> computeApplicableObjectProperties(Description index) { - Set<ObjectProperty> objectProperties = rs.getObjectProperties(); - SortedSet<ObjectProperty> applicableObjectProperties = new TreeSet<ObjectProperty>(); - for(ObjectProperty op : objectProperties) { - Description domain = rs.getDomain(op); - if(!isDisjoint(index,domain)) - applicableObjectProperties.add(op); + // use a cache, because large ontologies can have many object properties + SortedSet<ObjectProperty> applicableObjectProperties = appOPCache.get(index); + if(applicableObjectProperties == null) { + Set<ObjectProperty> objectProperties = reasoner.getObjectProperties(); + applicableObjectProperties = new TreeSet<ObjectProperty>(); + for(ObjectProperty op : objectProperties) { + Description domain = opDomains.get(op); + if(!isDisjoint(index,domain)) { + applicableObjectProperties.add(op); + } + } + appOPCache.put(index, applicableObjectProperties); } return applicableObjectProperties; } @@ -99,7 +117,7 @@ * @return The most general applicable properties. */ public SortedSet<ObjectProperty> computeMgr(SortedSet<ObjectProperty> applicableObjectProperties) { - return Helper.intersection(rs.getMostGeneralProperties(), applicableObjectProperties); + return Helper.intersection(reasoner.getMostGeneralProperties(), applicableObjectProperties); } public Set<NamedClass> getClassCandidates(Description index, Set<NamedClass> existingClasses) { @@ -190,7 +208,9 @@ result = isDisjointInstanceBased(d1,d2); } else { Description d = new Intersection(d1, d2); - result = rs.isSuperClassOf(new Nothing(), d); + Monitor mon = MonitorFactory.start("disjointness reasoning"); + result = reasoner.isSuperClassOf(new Nothing(), d); + mon.stop(); } // add the result to the cache (we add it twice such that // the order of access does not matter) @@ -213,8 +233,8 @@ } private boolean isDisjointInstanceBased(Description d1, Description d2) { - SortedSet<Individual> d1Instances = rs.getIndividuals(d1); - SortedSet<Individual> d2Instances = rs.getIndividuals(d2); + SortedSet<Individual> d1Instances = reasoner.getIndividuals(d1); + SortedSet<Individual> d2Instances = reasoner.getIndividuals(d2); for(Individual d1Instance : d1Instances) { if(d2Instances.contains(d1Instance)) return false; Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-11 07:56:41 UTC (rev 1573) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-11 11:53:29 UTC (rev 1574) @@ -20,23 +20,13 @@ package org.dllearner.scripts.evaluation; import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; -import java.net.MalformedURLException; import java.text.DecimalFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; import java.util.Date; -import java.util.GregorianCalendar; +import java.util.List; import java.util.Random; -import java.util.Set; -import org.apache.log4j.FileAppender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.SimpleLayout; import org.dllearner.algorithms.el.ELDescriptionTree; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; @@ -171,7 +161,7 @@ System.out.print("current concept: " + currTree.transformToDescription().toString(reasoner.getBaseURI(), reasoner.getPrefixes())); // apply operator on current description long start = System.nanoTime(); - Set<ELDescriptionTree> refinements = operator.refine(currTree); + List<ELDescriptionTree> refinements = operator.refine(currTree); long time = System.nanoTime() - start; runtime.addNumber(time/1000000d); runtimePerRefinement.addNumber(time/1000000d/refinements.size()); @@ -181,6 +171,7 @@ int sizeSum = 0; for(ELDescriptionTree tree : refinements) { +// System.out.println(" " + tree.toDescriptionString()); sizeSum += tree.getSize(); } @@ -191,7 +182,8 @@ // pick a refinement randomly (which is kind of slow for a set, but // this does not matter here) int index = rand.nextInt(refinements.size()); - currTree = new ArrayList<ELDescriptionTree>(refinements).get(index); +// currTree = new ArrayList<ELDescriptionTree>(refinements).get(index); + currTree = refinements.get(index); MonitorFactory.add("picked refinement size", "count", currTree.getSize()); } System.out.println("operator time: " + runtime.prettyPrint("ms")); @@ -218,10 +210,15 @@ statString += getMonitorData(MonitorFactory.getMonitor("refine label", "ms.")); statString += getMonitorData(MonitorFactory.getMonitor("refine edge", "ms.")); statString += getMonitorData(MonitorFactory.getMonitor("attach tree", "ms.")); + statString += getMonitorData(MonitorFactory.getMonitor("as.merge trees", "ms.")); + statString += getMonitorData(MonitorFactory.getMonitor("as.complex check", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("as.tmp", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("el.tmp", "ms.")); statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.minimal", "boolean")); statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.check", "boolean")); statString += getMonitorData(MonitorFactory.getMonitor("tree clone", "ms.")); statString += getMonitorData(MonitorFactory.getMonitor("simulation update", "ms.")); + statString += getMonitorData(MonitorFactory.getMonitor("disjointness reasoning", "ms.")); Files.createFile(statFile, statString); } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-11 07:56:41 UTC (rev 1573) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-11 11:53:29 UTC (rev 1574) @@ -136,12 +136,12 @@ // number of refinements has to be correct and each produced // refinement must be in the set of desired refinements -// assertTrue(refinements.size() == desired.size()); + assertTrue(refinements.size() == desired.size()); System.out.println("\nproduced refinements and their unit test status (true = assertion satisfied):"); for(Description refinement : refinements) { boolean ok = desired.contains(refinement); System.out.println(ok + ": " + refinement.toString(KBParser.internalNamespace, null)); -// assertTrue(desired.contains(refinement)); + assertTrue(desired.contains(refinement)); } File jamonlog = new File("log/jamontest.html"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-11 07:56:48
|
Revision: 1573 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1573&view=rev Author: jenslehmann Date: 2009-01-11 07:56:41 +0000 (Sun, 11 Jan 2009) Log Message: ----------- EL monitoring Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/utilities/Files.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-09 15:55:33 UTC (rev 1572) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-11 07:56:41 UTC (rev 1573) @@ -465,7 +465,7 @@ @Override @SuppressWarnings("unchecked") public ELDescriptionTree clone() { - Monitor mon = MonitorFactory.start("EL tree clone"); + Monitor mon = MonitorFactory.start("tree clone"); // clone "global" tree ELDescriptionTree treeClone = new ELDescriptionTree(rs); @@ -598,4 +598,16 @@ public int getDepth() { return maxLevel; } + + /** + * size of tree = number of nodes + sum of cardinality of node labels + * @return The tree size. + */ + public int getSize() { + int size = nodes.size(); + for(ELDescriptionNode node : nodes) { + size += node.getLabel().size(); + } + return size; + } } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-09 15:55:33 UTC (rev 1572) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-11 07:56:41 UTC (rev 1573) @@ -145,7 +145,7 @@ // the position of the node within the tree (needed for getting // the corresponding node in a cloned tree) int[] position = v.getCurrentPosition(); - logger.trace(" at position " + Helper.arrayContent(position)); +// logger.trace(" at position " + Helper.arrayContent(position)); // perform operations refinements.addAll(extendLabel(tree, v, position)); @@ -311,7 +311,9 @@ // System.out.println(mergedTree.toSimulationString()); // we check equivalence by a minimality test (TODO: can we still do this?) - if(mergedTree.isMinimal()) { + boolean minimal = mergedTree.isMinimal(); + MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); + if(minimal) { logger.trace("Merged tree is minimal, i.e. not equivalent."); // it is not equivalent, i.e. we found a refinement refinements.add(mergedTree); @@ -320,6 +322,7 @@ // perform complex check in merged tree boolean check = asCheck(wClone); logger.trace("Result of complex check: " + check); + MonitorFactory.add("as.check", "boolean", check ? 1 : 0); if(check) { // refine property Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-09 15:55:33 UTC (rev 1572) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-11 07:56:41 UTC (rev 1573) @@ -20,9 +20,16 @@ package org.dllearner.scripts.evaluation; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; import java.util.Random; import java.util.Set; @@ -39,8 +46,12 @@ import org.dllearner.kb.OWLFile; import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.refinementoperators.ELDown2; +import org.dllearner.utilities.Files; import org.dllearner.utilities.statistics.Stat; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; + /** * An evaluation of the EL refinement operator {@link ELDown2}. It creates * a set of artificial ontologies with varying complexity and performs @@ -52,6 +63,7 @@ public class ELOperatorBenchmark { private static Random rand = new Random(1); + private static DecimalFormat df = new DecimalFormat(); public static void main(String[] args) throws ComponentInitException, IOException { @@ -62,8 +74,14 @@ // logger.removeAllAppenders(); // logger.addAppender(app); - String example = "/home/jl/ontologien/galen2.owl"; - testOntology(example); + // create a directory for log files + Date dt = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); + String dir = "log/el/" + df.format(dt) + "/"; + new File(dir).mkdir(); + + String example = "/home/jl/promotion/ontologien/galen2.owl"; + testOntology(dir, example, 100, 15); System.exit(0); /* TEST ON ARTIFICIAL ONTOLOGIES @@ -119,30 +137,36 @@ // ELDown2 operator = new ELDown2(); } - private static void testOntology(String ont) throws MalformedURLException, ComponentInitException { + private static void testOntology(String statDir, String ont, int nrOfChains, int chainLength) throws ComponentInitException, IOException { System.out.print("Reading in " + ont + " ... "); ComponentManager cm = ComponentManager.getInstance(); // reading ontology into a reasoner KnowledgeSource source = cm.knowledgeSource(OWLFile.class); - cm.applyConfigEntry(source, "url", new File(ont).toURI().toURL()); + File ontFile = new File(ont); + cm.applyConfigEntry(source, "url", ontFile.toURI().toURL()); source.init(); ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, source); reasoner.init(); System.out.println("done."); System.out.println(); - int outerLoops = 1000; - for(int loop = 0; loop < outerLoops; loop++) { + // log file name + String name = ontFile.getName(); + String statFileName = name.substring(0, name.lastIndexOf(".")) + ".txt"; + File statFile = new File(statDir + statFileName); + String statString = ""; + MonitorFactory.reset(); + for(int loop = 0; loop < nrOfChains; loop++) { + // application of operator and statistics recording - int nrOfApplications = 15; ELDescriptionTree currTree = new ELDescriptionTree(reasoner, Thing.instance); ELDown2 operator = new ELDown2(reasoner); Stat runtime = new Stat(); Stat runtimePerRefinement = new Stat(); - System.out.println("Testing operator (applying it " + nrOfApplications + " times):"); - for(int i=0; i < nrOfApplications; i++) { + System.out.println("Testing operator (applying it " + chainLength + " times):"); + for(int i=0; i < chainLength; i++) { // System.out.println(currTree.transformToDescription().toKBSyntaxString()); System.out.print("current concept: " + currTree.transformToDescription().toString(reasoner.getBaseURI(), reasoner.getPrefixes())); // apply operator on current description @@ -151,16 +175,66 @@ long time = System.nanoTime() - start; runtime.addNumber(time/1000000d); runtimePerRefinement.addNumber(time/1000000d/refinements.size()); + MonitorFactory.add("operator application time", "ms.", time/1000000d); + MonitorFactory.add("operator application time per refinement", "ms.", time/1000000d/refinements.size()); + MonitorFactory.add("refinement count", "count", refinements.size()); + + int sizeSum = 0; + for(ELDescriptionTree tree : refinements) { + sizeSum += tree.getSize(); + } + + MonitorFactory.add("refinement size", "count", sizeSum/(double)refinements.size()); + MonitorFactory.add("refinement size increase", "count", (sizeSum-refinements.size()*currTree.getSize())/(double)refinements.size()); + System.out.println(" [has " + refinements.size() + " refinements]"); // pick a refinement randomly (which is kind of slow for a set, but // this does not matter here) int index = rand.nextInt(refinements.size()); currTree = new ArrayList<ELDescriptionTree>(refinements).get(index); + MonitorFactory.add("picked refinement size", "count", currTree.getSize()); } System.out.println("operator time: " + runtime.prettyPrint("ms")); System.out.println("operator time per refinement: " + runtimePerRefinement.prettyPrint("ms")); System.out.println(); } + + statString += "file: " + name + "\n"; + statString += "nr of refinement chains: " + nrOfChains + "\n"; + statString += "refinement chain length: " + chainLength + "\n\n"; + + statString += getMonitorData(MonitorFactory.getMonitor("operator application time", "ms.")); + statString += getMonitorData(MonitorFactory.getMonitor("operator application time per refinement", "ms.")); + statString += "\n"; + + statString += getMonitorDataCount(MonitorFactory.getMonitor("refinement count", "count")); + statString += getMonitorDataCount(MonitorFactory.getMonitor("refinement size", "count")); + statString += getMonitorDataCount(MonitorFactory.getMonitor("picked refinement size", "count")); + statString += getMonitorDataCount(MonitorFactory.getMonitor("refinement size increase", "count")); + statString += "\n"; + + statString += getMonitorData(MonitorFactory.getMonitor("extend label", "ms.")); + statString += getMonitorData(MonitorFactory.getMonitor("refine label", "ms.")); + statString += getMonitorData(MonitorFactory.getMonitor("refine edge", "ms.")); + statString += getMonitorData(MonitorFactory.getMonitor("attach tree", "ms.")); + statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.minimal", "boolean")); + statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.check", "boolean")); + statString += getMonitorData(MonitorFactory.getMonitor("tree clone", "ms.")); + statString += getMonitorData(MonitorFactory.getMonitor("simulation update", "ms.")); + + Files.createFile(statFile, statString); } + + private static String getMonitorData(Monitor mon) { + return mon.getLabel() + ": av " + df.format(mon.getAvg()) + "ms (stddev " + df.format(mon.getStdDev()) + "ms, min " + df.format(mon.getMin()) + "ms, max " + df.format(mon.getMax()) + "ms, " + df.format(mon.getTotal()/1000) + "s total, " + (int)mon.getHits() + " hits)\n"; + } + + private static String getMonitorDataCount(Monitor mon) { + return mon.getLabel() + ": av " + df.format(mon.getAvg()) + " (stddev " + df.format(mon.getStdDev()) + ", min " + df.format(mon.getMin()) + ", max " + df.format(mon.getMax()) + ", " + df.format(mon.getTotal()) + " total, " + (int)mon.getHits() + " hits)\n"; + } + + private static String getMonitorDataBoolean(Monitor mon) { + return mon.getLabel() + ": " + df.format(mon.getAvg()*100) + "%\n"; + } } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-09 15:55:33 UTC (rev 1572) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-11 07:56:41 UTC (rev 1573) @@ -196,7 +196,8 @@ reasoner.init(); System.out.println("Galen loaded."); - Description input = KBParser.parseConcept("(\"http://www.co-ode.org/ontologies/galen#15.0\" AND (\"http://www.co-ode.org/ontologies/galen#30.0\" AND (EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#5.0\" AND EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#6.0\")))"); +// Description input = KBParser.parseConcept("(\"http://www.co-ode.org/ontologies/galen#15.0\" AND (\"http://www.co-ode.org/ontologies/galen#30.0\" AND (EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#5.0\" AND EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#6.0\")))"); + Description input = KBParser.parseConcept("(\"http://www.co-ode.org/ontologies/galen#1.0\" AND (\"http://www.co-ode.org/ontologies/galen#10.0\" AND (EXISTS \"http://www.co-ode.org/ontologies/galen#DomainAttribute\".(\"http://www.co-ode.org/ontologies/galen#1.0\" AND (\"http://www.co-ode.org/ontologies/galen#6.0\" AND \"http://www.co-ode.org/ontologies/galen#TopCategory\")) AND EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".(\"http://www.co-ode.org/ontologies/galen#1.0\" AND (\"http://www.co-ode.org/ontologies/galen#TopCategory\" AND EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".TOP)))))"); ConceptTransformation.cleanConcept(input); ELDown2 operator = new ELDown2(reasoner); Modified: trunk/src/dl-learner/org/dllearner/utilities/Files.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Files.java 2009-01-09 15:55:33 UTC (rev 1572) +++ trunk/src/dl-learner/org/dllearner/utilities/Files.java 2009-01-11 07:56:41 UTC (rev 1573) @@ -178,7 +178,7 @@ if(debug){System.exit(0);} } } - + public static void clearFile(File file) { try{ createFile(file, ""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-01-09 15:55:45
|
Revision: 1572 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1572&view=rev Author: lorenz_b Date: 2009-01-09 15:55:33 +0000 (Fri, 09 Jan 2009) Log Message: ----------- added library for entailment explanation with pellet reasoner Added Paths: ----------- trunk/lib/pellet/pellet-explanation.jar Added: trunk/lib/pellet/pellet-explanation.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/pellet/pellet-explanation.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-09 10:31:47
|
Revision: 1571 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1571&view=rev Author: jenslehmann Date: 2009-01-09 10:31:42 +0000 (Fri, 09 Jan 2009) Log Message: ----------- commented out code causing compiler errors Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationTest.java Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationTest.java 2009-01-08 15:27:50 UTC (rev 1570) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationTest.java 2009-01-09 10:31:42 UTC (rev 1571) @@ -15,10 +15,8 @@ import org.semanticweb.owl.model.OWLOntologyCreationException; import org.semanticweb.owl.model.OWLOntologyManager; -import com.clarkparsia.explanation.PelletExplanation; -import com.clarkparsia.explanation.io.manchester.ManchesterSyntaxExplanationRenderer; - +@SuppressWarnings("unused") public class ExplanationTest { // private static final String file = "file:examples/ore/inconsistent.owl"; @@ -29,7 +27,7 @@ * @param args */ public static void main(String[] args) { - + /* try { PelletExplanation.setup(); @@ -96,7 +94,9 @@ // TODO Auto-generated catch block e.printStackTrace(); } + */ } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-08 15:27:57
|
Revision: 1570 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1570&view=rev Author: jenslehmann Date: 2009-01-08 15:27:50 +0000 (Thu, 08 Jan 2009) Log Message: ----------- continued EL operator benchmark Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-07 15:56:02 UTC (rev 1569) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-08 15:27:50 UTC (rev 1570) @@ -401,7 +401,7 @@ } // TODO: variables have been renamed in article - private boolean asCheck(ELDescriptionNode v) { + public boolean asCheck(ELDescriptionNode v) { // System.out.println("asCheck: " + v.getTree().toSimulationString()); // find all edges up to the root node @@ -421,9 +421,9 @@ ObjectProperty rp = piVEdge.getLabel(); ELDescriptionNode w = wp.getParent(); -// System.out.println(w); -// System.out.println(rp); -// System.out.println(wp); +// System.out.println("w: " + w); +// System.out.println("rp: " + rp); +// System.out.println("wp: " + wp); // go through all (w,s,w'') for(ELDescriptionEdge wEdge : w.getEdges()) { @@ -432,7 +432,7 @@ if(wp != wpp && opHierarchy.isSubpropertyOf(rp, rpp)) { // System.out.println("wp: " + wp); // System.out.println("wpp: " + wpp); - if(wp.getOut().contains(wpp)) { + if(wp.getIn().contains(wpp)) { return false; } } Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-07 15:56:02 UTC (rev 1569) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-08 15:27:50 UTC (rev 1570) @@ -62,7 +62,7 @@ // logger.removeAllAppenders(); // logger.addAppender(app); - String example = "/home/jl/promotion/ontologien/galen2.owl"; + String example = "/home/jl/ontologien/galen2.owl"; testOntology(example); System.exit(0); @@ -131,11 +131,11 @@ System.out.println("done."); System.out.println(); - int outerLoops = 100; + int outerLoops = 1000; for(int loop = 0; loop < outerLoops; loop++) { // application of operator and statistics recording - int nrOfApplications = 10; + int nrOfApplications = 15; ELDescriptionTree currTree = new ELDescriptionTree(reasoner, Thing.instance); ELDown2 operator = new ELDown2(reasoner); Stat runtime = new Stat(); Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-07 15:56:02 UTC (rev 1569) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-08 15:27:50 UTC (rev 1570) @@ -32,11 +32,15 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import org.dllearner.algorithms.el.ELDescriptionNode; +import org.dllearner.algorithms.el.ELDescriptionTree; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; import org.dllearner.kb.OWLFile; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; @@ -185,7 +189,7 @@ ComponentManager cm = ComponentManager.getInstance(); KnowledgeSource source = cm.knowledgeSource(OWLFile.class); - String ont = "/home/jl/promotion/ontologien/galen2.owl"; + String ont = "/home/jl/ontologien/galen2.owl"; cm.applyConfigEntry(source, "url", new File(ont).toURI().toURL()); source.init(); ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, source); @@ -195,9 +199,40 @@ Description input = KBParser.parseConcept("(\"http://www.co-ode.org/ontologies/galen#15.0\" AND (\"http://www.co-ode.org/ontologies/galen#30.0\" AND (EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#5.0\" AND EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#6.0\")))"); ConceptTransformation.cleanConcept(input); - RefinementOperator operator = new ELDown2(reasoner); + ELDown2 operator = new ELDown2(reasoner); operator.refine(input); + + } + @Test + public void asTest() throws ComponentInitException, MalformedURLException { + + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource source = cm.knowledgeSource(OWLFile.class); + String ont = "/home/jl/ontologien/galen2.owl"; + cm.applyConfigEntry(source, "url", new File(ont).toURI().toURL()); + source.init(); + ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, source); + reasoner.init(); + System.out.println("Galen loaded."); + + ELDescriptionTree tree = new ELDescriptionTree(reasoner); + NamedClass a1 = new NamedClass("http://www.co-ode.org/ontologies/galen#1.0"); + NamedClass a2 = new NamedClass("http://www.co-ode.org/ontologies/galen#10.0"); + NamedClass a3 = new NamedClass("http://www.co-ode.org/ontologies/galen#6.0"); + NamedClass a4 = new NamedClass("http://www.co-ode.org/ontologies/galen#TopCategory"); + ObjectProperty r1 = new ObjectProperty("http://www.co-ode.org/ontologies/galen#Attribute"); + ObjectProperty r2 = new ObjectProperty("http://www.co-ode.org/ontologies/galen#DomainAttribute"); + ELDescriptionNode v1 = new ELDescriptionNode(tree, a1, a2); + ELDescriptionNode v2 = new ELDescriptionNode(v1, r2, a1, a3, a4); + ELDescriptionNode v3 = new ELDescriptionNode(v1, r1, a1, a4); + new ELDescriptionNode(v3, r1); + + ELDescriptionNode w = new ELDescriptionNode(v2, r1); + + ELDown2 operator = new ELDown2(reasoner); + System.out.println(operator.asCheck(w)); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-07 15:56:10
|
Revision: 1569 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1569&view=rev Author: jenslehmann Date: 2009-01-07 15:56:02 +0000 (Wed, 07 Jan 2009) Log Message: ----------- EL bugfixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/test/junit/SimulationTests.java trunk/src/dl-learner/org/dllearner/utilities/Helper.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2009-01-06 08:04:37 UTC (rev 1568) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2009-01-07 15:56:02 UTC (rev 1569) @@ -301,7 +301,7 @@ int[] position = new int[level-1]; ELDescriptionNode root = this; while(root.parent != null) { - position[root.level-2] = getChildNumber(); + position[root.level-2] = root.getChildNumber(); root = root.parent; } return position; @@ -316,6 +316,7 @@ if(edge.getNode() == this) { return count; } + count++; } throw new RuntimeException("Inconsistent tree. Child tree not reachable from parent."); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-06 08:04:37 UTC (rev 1568) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-07 15:56:02 UTC (rev 1569) @@ -29,6 +29,7 @@ import java.util.TreeSet; import java.util.Map.Entry; +import org.apache.log4j.Logger; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Intersection; @@ -39,6 +40,8 @@ import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.UnsupportedLanguageException; +import org.dllearner.refinementoperators.ELDown2; +import org.dllearner.utilities.Helper; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; @@ -53,6 +56,8 @@ */ public class ELDescriptionTree implements Cloneable { + private static Logger logger = Logger.getLogger(ELDescriptionTree.class); + // to simplify equivalence checks and minimisation, we // attach a simulation relation to the description tree // private Simulation simulation; @@ -225,6 +230,8 @@ * @return The node at the specified position. */ public ELDescriptionNode getNode(int[] position) { +// logger.trace(Helper.arrayContent(position)); +// logger.trace(this); ELDescriptionNode currentNode = rootNode; for (int i = 0; i < position.length; i++) { currentNode = currentNode.getEdges().get(position[i]).getNode(); @@ -587,4 +594,8 @@ public Set<ELDescriptionNode> getNodes() { return nodes; } + + public int getDepth() { + return maxLevel; + } } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-06 08:04:37 UTC (rev 1568) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-07 15:56:02 UTC (rev 1569) @@ -19,6 +19,7 @@ */ package org.dllearner.refinementoperators; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -44,6 +45,7 @@ import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Thing; +import org.dllearner.utilities.Helper; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; @@ -130,6 +132,7 @@ */ public Set<ELDescriptionTree> refine(ELDescriptionTree tree) { logger.trace("applying \\rho on " + tree.toDescriptionString()); +// System.out.println("tree:" + tree); Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); // loop over all nodes of the tree and perform one of the @@ -142,6 +145,7 @@ // the position of the node within the tree (needed for getting // the corresponding node in a cloned tree) int[] position = v.getCurrentPosition(); + logger.trace(" at position " + Helper.arrayContent(position)); // perform operations refinements.addAll(extendLabel(tree, v, position)); @@ -150,6 +154,12 @@ refinements.addAll(attachSubtree(tree, v, position)); } +// for(ELDescriptionTree refinement : refinements) { +// if(refinement.getDepth() > tree.getDepth() + 1) { +// throw new Error("DEPTH WARNING"); +// } +// } + // return refine(tree, tree.getRootNode(), new Thing(), true); return refinements; } @@ -290,7 +300,10 @@ int[] wPosition = new int[position.length+1]; System.arraycopy(position, 0, wPosition, 0, position.length); wPosition[position.length] = v.getEdges().size(); +// logger.trace("position of v: " + arrayContent(position)); +// logger.trace("position of w: " + arrayContent(wPosition)); + ELDescriptionNode wClone = mergedTree.getNode(wPosition); logger.trace("merged to t_{C'}: \n" + mergedTree); @@ -344,8 +357,10 @@ ELDescriptionTree mergedTree = tree.clone(); ELDescriptionNode clonedNode = mergedTree.getNode(position); // ELDescriptionNode nodeNew = new ELDescriptionNode(clonedNode, r); -// System.out.println("node: " + node); -// System.out.println("cloned node: " + clonedNode); +// logger.trace("node: " + node); +// logger.trace("cloned node: " + clonedNode); +// logger.trace("node position: " + arrayContent(position)); +// logger.trace("merge start: " + mergedTree); // create a list of nodes we still need to process Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-06 08:04:37 UTC (rev 1568) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-07 15:56:02 UTC (rev 1569) @@ -20,11 +20,16 @@ package org.dllearner.scripts.evaluation; import java.io.File; +import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Random; import java.util.Set; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; import org.dllearner.algorithms.el.ELDescriptionTree; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; @@ -48,7 +53,15 @@ private static Random rand = new Random(1); - public static void main(String[] args) throws MalformedURLException, ComponentInitException { + public static void main(String[] args) throws ComponentInitException, IOException { + +// Logger logger = Logger.getRootLogger(); +// logger.setLevel(Level.TRACE); +// SimpleLayout layout = new SimpleLayout(); +// FileAppender app = new FileAppender(layout, "log/el/log.txt", false); +// logger.removeAllAppenders(); +// logger.addAppender(app); + String example = "/home/jl/promotion/ontologien/galen2.owl"; testOntology(example); System.exit(0); @@ -118,7 +131,7 @@ System.out.println("done."); System.out.println(); - int outerLoops = 10; + int outerLoops = 100; for(int loop = 0; loop < outerLoops; loop++) { // application of operator and statistics recording @@ -130,6 +143,7 @@ System.out.println("Testing operator (applying it " + nrOfApplications + " times):"); for(int i=0; i < nrOfApplications; i++) { +// System.out.println(currTree.transformToDescription().toKBSyntaxString()); System.out.print("current concept: " + currTree.transformToDescription().toString(reasoner.getBaseURI(), reasoner.getPrefixes())); // apply operator on current description long start = System.nanoTime(); Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-06 08:04:37 UTC (rev 1568) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-07 15:56:02 UTC (rev 1569) @@ -22,16 +22,25 @@ import static org.junit.Assert.assertTrue; import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Description; +import org.dllearner.kb.OWLFile; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; +import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.refinementoperators.ELDown2; import org.dllearner.refinementoperators.RefinementOperator; import org.dllearner.test.junit.TestOntologies.TestOntology; @@ -64,7 +73,7 @@ * @throws ComponentInitException */ @Test - public void refinementTest() throws ParseException, ComponentInitException { + public void test1() throws ParseException, ComponentInitException { ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); // input description @@ -103,7 +112,7 @@ Set<Description> refinements = operator.refine(input); long runTime = System.nanoTime() - startTime; logger.debug("Refinement step took " + Helper.prettyPrintNanoSeconds(runTime, true, true) + "."); - boolean runStats = true; + boolean runStats = false; if(runStats) { Stat stat = new Stat(); int runs = 1000; @@ -123,12 +132,12 @@ // number of refinements has to be correct and each produced // refinement must be in the set of desired refinements - assertTrue(refinements.size() == desired.size()); +// assertTrue(refinements.size() == desired.size()); System.out.println("\nproduced refinements and their unit test status (true = assertion satisfied):"); for(Description refinement : refinements) { boolean ok = desired.contains(refinement); System.out.println(ok + ": " + refinement.toString(KBParser.internalNamespace, null)); - assertTrue(desired.contains(refinement)); +// assertTrue(desired.contains(refinement)); } File jamonlog = new File("log/jamontest.html"); @@ -141,6 +150,54 @@ // edge added, but refinement not recognized as being minimal // (http://localhost/foo#human AND EXISTS http://localhost/foo#has.http://localhost/foo#animal AND EXISTS http://localhost/foo#has.TOP) - } + } + @Test + public void test2() throws ParseException, IOException { +// Logger logger = Logger.getRootLogger(); +// logger.setLevel(Level.TRACE); +// SimpleLayout layout = new SimpleLayout(); +// FileAppender app = new FileAppender(layout, "log/el/log.txt", false); +// logger.removeAllAppenders(); +// logger.addAppender(app); + + ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); + + // input description + Description input = KBParser.parseConcept("(human AND (EXISTS has.bird AND EXISTS has.cat))"); + ConceptTransformation.cleanConcept(input); + + RefinementOperator operator = new ELDown2(rs); + + operator.refine(input); + + } + + @Test + public void test3() throws ComponentInitException, ParseException, IOException { + + Logger logger = Logger.getRootLogger(); + logger.setLevel(Level.TRACE); + SimpleLayout layout = new SimpleLayout(); + FileAppender app = new FileAppender(layout, "log/el/log.txt", false); + logger.removeAllAppenders(); + logger.addAppender(app); + + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource source = cm.knowledgeSource(OWLFile.class); + String ont = "/home/jl/promotion/ontologien/galen2.owl"; + cm.applyConfigEntry(source, "url", new File(ont).toURI().toURL()); + source.init(); + ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, source); + reasoner.init(); + System.out.println("Galen loaded."); + + Description input = KBParser.parseConcept("(\"http://www.co-ode.org/ontologies/galen#15.0\" AND (\"http://www.co-ode.org/ontologies/galen#30.0\" AND (EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#5.0\" AND EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#6.0\")))"); + ConceptTransformation.cleanConcept(input); + + RefinementOperator operator = new ELDown2(reasoner); + operator.refine(input); + + } + } Modified: trunk/src/dl-learner/org/dllearner/test/junit/SimulationTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/SimulationTests.java 2009-01-06 08:04:37 UTC (rev 1568) +++ trunk/src/dl-learner/org/dllearner/test/junit/SimulationTests.java 2009-01-07 15:56:02 UTC (rev 1569) @@ -32,7 +32,6 @@ import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.Thing; import org.dllearner.parser.KBParser; import org.dllearner.test.junit.TestOntologies.TestOntology; import org.junit.Test; Modified: trunk/src/dl-learner/org/dllearner/utilities/Helper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2009-01-06 08:04:37 UTC (rev 1568) +++ trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2009-01-07 15:56:02 UTC (rev 1569) @@ -616,4 +616,12 @@ System.out.println("remaining individuals: " + inds); System.out.println(); } + + public static String arrayContent(int[] ar) { + String str = ""; + for(int i=0; i<ar.length; i++) { + str += ar[i] + ","; + } + return str; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-01-06 08:04:43
|
Revision: 1568 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1568&view=rev Author: lorenz_b Date: 2009-01-06 08:04:37 +0000 (Tue, 06 Jan 2009) Log Message: ----------- solved packet conflicts Removed Paths: ------------- trunk/lib/ore-tool/owlapi-bin.jar trunk/lib/ore-tool/pellet-cli.jar trunk/lib/ore-tool/pellet-explanation.jar trunk/lib/ore-tool/pellet-owlapi.jar Deleted: trunk/lib/ore-tool/owlapi-bin.jar =================================================================== (Binary files differ) Deleted: trunk/lib/ore-tool/pellet-cli.jar =================================================================== (Binary files differ) Deleted: trunk/lib/ore-tool/pellet-explanation.jar =================================================================== (Binary files differ) Deleted: trunk/lib/ore-tool/pellet-owlapi.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-01-05 12:35:32
|
Revision: 1567 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1567&view=rev Author: jenslehmann Date: 2009-01-05 12:35:24 +0000 (Mon, 05 Jan 2009) Log Message: ----------- EL operator benchmark started and a number of smaller changes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/KB.java trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/ContextDescription.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/package-info.java trunk/src/dl-learner/org/dllearner/scripts/package-info.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/scripts/package.html Added: trunk/src/dl-learner/org/dllearner/core/owl/ContextDescription.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ContextDescription.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/ContextDescription.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -0,0 +1,57 @@ +/** + * 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.core.owl; + +/** + * A class description in its context, i.e. including a parent link (if any). + * For instance, there is only one description owl:Thing, but it can occur + * nested within different descriptions like "createdBy SOME owl:Thing". + * Depending on what you want to do, you either need a Description or a + * ContextDescription. + * + * @author Jens Lehmann + * + */ +public class ContextDescription { + + private Description description; + + private Description parent; + + public ContextDescription(Description description, Description parent) { + this.description = description; + this.parent = parent; + } + + /** + * @return the description + */ + public Description getDescription() { + return description; + } + + /** + * @return the parent + */ + public Description getParent() { + return parent; + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/KB.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/KB.java 2008-12-22 13:50:14 UTC (rev 1566) +++ trunk/src/dl-learner/org/dllearner/core/owl/KB.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -1,11 +1,22 @@ package org.dllearner.core.owl; +import java.io.File; +import java.net.URI; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.utilities.owl.OWLAPIAxiomConvertVisitor; +import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLOntologyCreationException; +import org.semanticweb.owl.model.OWLOntologyManager; +import org.semanticweb.owl.model.OWLOntologyStorageException; +import org.semanticweb.owl.model.UnknownOWLOntologyException; +import org.semanticweb.owl.util.SimpleURIMapper; + public class KB implements KBElement { // private Set<Axiom> axioms = new HashSet<Axiom>(); @@ -273,4 +284,24 @@ return axioms; } + public void export(File file, org.dllearner.core.OntologyFormat format){ + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + URI ontologyURI = URI.create("http://example.com"); + URI physicalURI = file.toURI(); + SimpleURIMapper mapper = new SimpleURIMapper(ontologyURI, physicalURI); + manager.addURIMapper(mapper); + OWLOntology ontology; + try { + ontology = manager.createOntology(ontologyURI); + // OWLAPIReasoner.fillOWLAPIOntology(manager,ontology,kb); + OWLAPIAxiomConvertVisitor.fillOWLOntology(manager, ontology, this); + manager.saveOntology(ontology); + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); + } catch (UnknownOWLOntologyException e) { + e.printStackTrace(); + } catch (OWLOntologyStorageException e) { + e.printStackTrace(); + } + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2008-12-22 13:50:14 UTC (rev 1566) +++ trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -22,7 +22,7 @@ import java.util.Map; /** - * Implementation of owl:nothing/BOTTOM. + * Implementation of owl:Nothing/BOTTOM. * * @author Jens Lehmann * Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-12-22 13:50:14 UTC (rev 1566) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -38,14 +38,6 @@ import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGConverter; -import org.dllearner.utilities.owl.OWLAPIAxiomConvertVisitor; -import org.semanticweb.owl.apibinding.OWLManager; -import org.semanticweb.owl.model.OWLOntology; -import org.semanticweb.owl.model.OWLOntologyCreationException; -import org.semanticweb.owl.model.OWLOntologyManager; -import org.semanticweb.owl.model.OWLOntologyStorageException; -import org.semanticweb.owl.model.UnknownOWLOntologyException; -import org.semanticweb.owl.util.SimpleURIMapper; /** * KB files are an internal convenience format used in DL-Learner. Their @@ -158,24 +150,25 @@ @Override public void export(File file, org.dllearner.core.OntologyFormat format){ - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - URI ontologyURI = URI.create("http://example.com"); - URI physicalURI = file.toURI(); - SimpleURIMapper mapper = new SimpleURIMapper(ontologyURI, physicalURI); - manager.addURIMapper(mapper); - OWLOntology ontology; - try { - ontology = manager.createOntology(ontologyURI); - // OWLAPIReasoner.fillOWLAPIOntology(manager,ontology,kb); - OWLAPIAxiomConvertVisitor.fillOWLOntology(manager, ontology, kb); - manager.saveOntology(ontology); - } catch (OWLOntologyCreationException e) { - e.printStackTrace(); - } catch (UnknownOWLOntologyException e) { - e.printStackTrace(); - } catch (OWLOntologyStorageException e) { - e.printStackTrace(); - } + kb.export(file, format); +// OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); +// URI ontologyURI = URI.create("http://example.com"); +// URI physicalURI = file.toURI(); +// SimpleURIMapper mapper = new SimpleURIMapper(ontologyURI, physicalURI); +// manager.addURIMapper(mapper); +// OWLOntology ontology; +// try { +// ontology = manager.createOntology(ontologyURI); +// // OWLAPIReasoner.fillOWLAPIOntology(manager,ontology,kb); +// OWLAPIAxiomConvertVisitor.fillOWLOntology(manager, ontology, kb); +// manager.saveOntology(ontology); +// } catch (OWLOntologyCreationException e) { +// e.printStackTrace(); +// } catch (UnknownOWLOntologyException e) { +// e.printStackTrace(); +// } catch (OWLOntologyStorageException e) { +// e.printStackTrace(); +// } } public URL getURL() { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-12-22 13:50:14 UTC (rev 1566) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -71,7 +71,6 @@ import org.dllearner.parser.ParseException; import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptTransformation; -import org.semanticweb.owl.inference.OWLReasonerException; /** * Reasoner for fast instance checks. It works by completely dematerialising the Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2008-12-22 13:50:14 UTC (rev 1566) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -393,7 +393,6 @@ List<ELDescriptionEdge> piVEdges = new LinkedList<ELDescriptionEdge>(); ELDescriptionNode tmp = v; while(!tmp.isRoot()) { -// System.out.println("blub"); piVEdges.add(tmp.getParentEdge()); tmp = tmp.getParent(); } @@ -446,9 +445,14 @@ i.addChild(opDomains.get(edge.getLabel())); } + int size = i.getChildren().size(); + // size = 0 means we have the top concept + if(size == 0) { + return Thing.instance; + } // if the intersection has just one element, we return // the element itself instead - if(i.getChildren().size() == 1) { + else if(size == 1) { return i.getChild(0); } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2008-12-22 13:50:14 UTC (rev 1566) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -176,6 +176,7 @@ public boolean isDisjoint(Description d1, Description d2) { // System.out.println("d1: " + d1); // System.out.println("d2: " + d2); +// System.out.println("cache: " + cachedDisjoints); // check whether we have cached this query Map<Description,Boolean> tmp = cachedDisjoints.get(d1); Added: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -0,0 +1,152 @@ +/** + * 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.evaluation; + +import java.io.File; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Random; +import java.util.Set; + +import org.dllearner.algorithms.el.ELDescriptionTree; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.owl.Thing; +import org.dllearner.kb.OWLFile; +import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.refinementoperators.ELDown2; +import org.dllearner.utilities.statistics.Stat; + +/** + * An evaluation of the EL refinement operator {@link ELDown2}. It creates + * a set of artificial ontologies with varying complexity and performs + * refinement steps on them. + * + * @author Jens Lehmann + * + */ +public class ELOperatorBenchmark { + + private static Random rand = new Random(1); + + public static void main(String[] args) throws MalformedURLException, ComponentInitException { + String example = "/home/jl/promotion/ontologien/galen2.owl"; + testOntology(example); + System.exit(0); + + /* TEST ON ARTIFICIAL ONTOLOGIES + + + // number of concepts and roles + int[] conceptCounts = new int[] { 5, 10 }; + int[] roleCounts = new int[] { 5, 10}; + + // number of applications of operator + int opApplications = 10; + + // statistics directory + String statDir = "/log/stat/el/"; + String statFile = statDir + "stats.txt"; + String gnuPlotApplicationTimeFile = statDir + "application.gp"; + String gnuPlotRefinementTimeFile = statDir + "refinement.gp"; + boolean writeOntologies = true; + String ontologyDir = "/log/stat/el/ontologies/"; + + + + for(int conceptCount : conceptCounts) { + for(int roleCount : roleCounts) { + // code for ontology creation + KB kb = new KB(); + + // create class hierarchy (concept 0 is owl:Thing) + for(int i=1; i<=conceptCount; i++) { + // create class + NamedClass nc = new NamedClass("a" + i); + // pick an existing class as super class + int j = (i == 0) ? 0 : rand.nextInt(i); + Description superClass; + if(j==0) { + superClass = Thing.instance; + } else { + superClass = new NamedClass("a" + j); + } + kb.addAxiom(new SubClassAxiom(nc, superClass)); + // disjointness with siblings + } + + + // save ontology + File f = new File(ontologyDir + "c" + conceptCount + "r" + roleCount + ".owl"); + kb.export(f, OntologyFormat.RDF_XML); + + + } + } + */ +// ELDown2 operator = new ELDown2(); + } + + private static void testOntology(String ont) throws MalformedURLException, ComponentInitException { + System.out.print("Reading in " + ont + " ... "); + ComponentManager cm = ComponentManager.getInstance(); + // reading ontology into a reasoner + KnowledgeSource source = cm.knowledgeSource(OWLFile.class); + cm.applyConfigEntry(source, "url", new File(ont).toURI().toURL()); + source.init(); + ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, source); + reasoner.init(); + System.out.println("done."); + System.out.println(); + + int outerLoops = 10; + for(int loop = 0; loop < outerLoops; loop++) { + + // application of operator and statistics recording + int nrOfApplications = 10; + ELDescriptionTree currTree = new ELDescriptionTree(reasoner, Thing.instance); + ELDown2 operator = new ELDown2(reasoner); + Stat runtime = new Stat(); + Stat runtimePerRefinement = new Stat(); + + System.out.println("Testing operator (applying it " + nrOfApplications + " times):"); + for(int i=0; i < nrOfApplications; i++) { + System.out.print("current concept: " + currTree.transformToDescription().toString(reasoner.getBaseURI(), reasoner.getPrefixes())); + // apply operator on current description + long start = System.nanoTime(); + Set<ELDescriptionTree> refinements = operator.refine(currTree); + long time = System.nanoTime() - start; + runtime.addNumber(time/1000000d); + runtimePerRefinement.addNumber(time/1000000d/refinements.size()); + System.out.println(" [has " + refinements.size() + " refinements]"); + // pick a refinement randomly (which is kind of slow for a set, but + // this does not matter here) + int index = rand.nextInt(refinements.size()); + currTree = new ArrayList<ELDescriptionTree>(refinements).get(index); + } + System.out.println("operator time: " + runtime.prettyPrint("ms")); + System.out.println("operator time per refinement: " + runtimePerRefinement.prettyPrint("ms")); + System.out.println(); + + } + } +} Added: trunk/src/dl-learner/org/dllearner/scripts/evaluation/package-info.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/package-info.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/package-info.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -0,0 +1,6 @@ +/** + * All scripts, which serve evaluation purposes, i.e. evaluation of + * learning algorithms, refinement operators, components etc. These + * are usually benchmarks testing accuracy, performance etc. of algorithms. + */ +package org.dllearner.scripts.evaluation; \ No newline at end of file Copied: trunk/src/dl-learner/org/dllearner/scripts/package-info.java (from rev 1566, trunk/src/dl-learner/org/dllearner/scripts/package.html) =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/package-info.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/package-info.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -0,0 +1,4 @@ +/** + * Runnable scripts, each for a different task or experiment. + */ +package org.dllearner.scripts; \ No newline at end of file Property changes on: trunk/src/dl-learner/org/dllearner/scripts/package-info.java ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/src/dl-learner/org/dllearner/scripts/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/package.html 2008-12-22 13:50:14 UTC (rev 1566) +++ trunk/src/dl-learner/org/dllearner/scripts/package.html 2009-01-05 12:35:24 UTC (rev 1567) @@ -1,7 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head></head> -<body bgcolor="white"> -<p>Runnable scripts, each for a different task or experiment.</p> -</body> -</html> Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-12-22 13:50:14 UTC (rev 1566) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -19,7 +19,7 @@ */ package org.dllearner.test.junit; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; import java.io.File; import java.util.Set; @@ -30,7 +30,6 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Description; -import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.refinementoperators.ELDown2; @@ -38,7 +37,6 @@ import org.dllearner.test.junit.TestOntologies.TestOntology; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.JamonMonitorLogger; import org.dllearner.utilities.owl.ConceptComparator; import org.dllearner.utilities.owl.ConceptTransformation; import org.dllearner.utilities.statistics.Stat; Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java 2008-12-22 13:50:14 UTC (rev 1566) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java 2009-01-05 12:35:24 UTC (rev 1567) @@ -24,7 +24,7 @@ /** * Utility class for calculating the mean and standard deviation of a given set - * of numbers. + * of numbers. The class also contains convenience methods for printing values. * * @author Jens Lehmann * @@ -144,4 +144,20 @@ return str; } + /** + * Pretty prints the results under the assumption that the input + * values are time spans measured in nano seconds. + * + * @see System#nanoTime() + * @return A string summarising statistical values. + */ +// public String prettyPrintNanoSeconds() { +// DecimalFormat df = new DecimalFormat(); +// String str = "av. " + df.format(getMean()) + unit; +// str += " (deviation " + df.format(getStandardDeviation()) + unit + "; "; +// str += "min " + df.format(getMin()) + unit + "; "; +// str += "max " + df.format(getMax()) + unit + ")"; +// return str; +// } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-12-22 13:50:20
|
Revision: 1566 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1566&view=rev Author: heeroyuy Date: 2008-12-22 13:50:14 +0000 (Mon, 22 Dec 2008) Log Message: ----------- -changed error message when ontology is inconsistent Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-12-22 13:30:05 UTC (rev 1565) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-12-22 13:50:14 UTC (rev 1566) @@ -455,7 +455,7 @@ } else { hint.setForeground(Color.RED); run.setEnabled(false); - hint.setText("Can't reason with inconsistent ontology"); + hint.setText("The ontology is inconsistent and suggestions for class descriptions can only \nbe computed on consistent ontologies. Please repair the ontology first"); } hint.setVisible(true); advanced.setIcon(icon); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-12-22 13:30:11
|
Revision: 1565 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1565&view=rev Author: heeroyuy Date: 2008-12-22 13:30:05 +0000 (Mon, 22 Dec 2008) Log Message: ----------- -shows learning panel with warning when ontology is inconsistent -shows warning when suggested class descriptions leads to inconsistency Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-12-22 13:18:39 UTC (rev 1564) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-12-22 13:30:05 UTC (rev 1565) @@ -397,6 +397,7 @@ } else { dm.add(i, new SuggestListItem(colorRed, eval.getDescription().toManchesterSyntaxString(ontology, null),eval.getAccuracy()*100)); i++; + view.setIsInconsistent(true); break; } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-12-22 13:18:39 UTC (rev 1564) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-12-22 13:30:05 UTC (rev 1565) @@ -49,6 +49,7 @@ import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; import org.jdesktop.swingx.JXTaskPane; +import org.mindswap.pellet.exceptions.InconsistentOntologyException; import org.protege.editor.owl.OWLEditorKit; import org.protege.editor.owl.ui.frame.OWLFrame; import org.semanticweb.owl.apibinding.OWLManager; @@ -189,6 +190,7 @@ private NamedClass currentConcept; private Vector<IndividualObject> individualVector; private Set<String> ontologieURI; + private boolean ontologyConsistent; // This is a List of evaluated descriptions to get more information of the // suggested concept @@ -213,6 +215,7 @@ current = h; this.id = id; this.view = view; + ontologyConsistent = true; owlDescription = new HashSet<OWLDescription>(); posListModel = new DefaultListModel(); negListModel = new DefaultListModel(); @@ -301,14 +304,18 @@ */ public void setReasoner() { this.reasoner = cm.reasoner(FastInstanceChecker.class, sources); - try { reasoner.init(); + reasoner.isSatisfiable(); + view.setIsInconsistent(false); } catch (ComponentInitException e) { // TODO Auto-generated catch block - System.out.println("fehler!!!!!!!!!"); + System.out.println("fehler!!!!!!!!!"); e.printStackTrace(); + } catch (InconsistentOntologyException incon) { + view.setIsInconsistent(true); } + // rs = cm.reasoningService(reasoner); } @@ -814,6 +821,13 @@ public Set<String> getOntologyURIString() { return ontologieURI; } + /** + * This method reutrns a bollean if an ontology is inconsistent. + * @return ontologyInconsistent + */ + public boolean getOntologyConsistent() { + return ontologyConsistent; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-12-22 13:18:39 UTC (rev 1564) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-12-22 13:30:05 UTC (rev 1565) @@ -356,6 +356,7 @@ private JLabel wikiPane; private ImageIcon toggledIcon; private JTextArea hint; + private boolean isInconsistent; // This is the Panel for more details of the suggested concept private MoreDetailForSuggestedConceptsPanel detail; private OWLFrame<OWLClass> frame; @@ -434,22 +435,30 @@ public void makeView() { model.clearVector(); + hint.setText("To get suggestions for class descriptions, please click the button above."); + isInconsistent = false; model.unsetListModel(); model.initReasoner(); - model.checkURI(); - model.setPosVector(); - hint.setVisible(true); - if (model.hasIndividuals()) { - run.setEnabled(true); + if(!isInconsistent) { + + model.checkURI(); + model.setPosVector(); + if (model.hasIndividuals()) { + run.setEnabled(true); + } else { + run.setEnabled(false); + hint.setVisible(false); + String message ="There are no Instances for "+ frame.getRootObject()+" available. Please insert some Instances."; + renderErrorMessage(message); + } + posPanel.setExampleList(model.getPosListModel(), model.getNegListModel()); } else { + hint.setForeground(Color.RED); run.setEnabled(false); - hint.setVisible(false); - String message ="There are no Instances for "+ frame.getRootObject()+" available. Please insert some Instances."; - renderErrorMessage(message); - } + hint.setText("Can't reason with inconsistent ontology"); + } + hint.setVisible(true); advanced.setIcon(icon); - - posPanel.setExampleList(model.getPosListModel(), model.getNegListModel()); accept.setEnabled(false); action.resetToggled(); addButtonPanel.add("North", accept); @@ -468,8 +477,8 @@ posPanel.getAddToPosPanelButton().setEnabled(false); posPanel.setBounds(10, 230, 490, 250); accept.setBounds(510, 40, 80, 110); - hint.setBounds(10, 150, 490, 20); - errorMessage.setBounds(10, 170, 490, 20); + hint.setBounds(10, 150, 490, 35); + errorMessage.setBounds(10, 180, 490, 20); learner.add(run); learner.add(wikiPane); learner.add(adv); @@ -481,6 +490,7 @@ learner.add(posPanel); detail = new MoreDetailForSuggestedConceptsPanel(model); add(learner); + } /** * This method sets the right icon for the advanced Panel. @@ -593,7 +603,10 @@ public JButton getRunButton() { return run; } - + + public void setIsInconsistent(boolean isIncon) { + this.isInconsistent = isIncon; + } /** * Destroys the view after the plugin is closed. */ @@ -634,7 +647,12 @@ */ public void algorithmTerminated() { String error = "learning succesful"; - String message = "To view details about why a class description was suggested, please doubleclick on it."; + String message = ""; + if(isInconsistent) { + message = "Class descriptions marked red will lead to an inconsistent ontology. \nPlease double click on them to view detail information."; + } else { + message = "To view details about why a class description was suggested, please doubleclick on it."; + } run.setEnabled(true); // start the algorithm and print the best concept found renderErrorMessage(error); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-12-22 13:18:43
|
Revision: 1564 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1564&view=rev Author: jenslehmann Date: 2008-12-22 13:18:39 +0000 (Mon, 22 Dec 2008) Log Message: ----------- - added performance monitoring to EL operator Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2008-12-22 11:08:04 UTC (rev 1563) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2008-12-22 13:18:39 UTC (rev 1564) @@ -37,6 +37,9 @@ import org.dllearner.core.owl.Thing; import org.dllearner.utilities.Helper; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; + /** * Represents an EL description tree, which corresponds to a * description in the EL description logic. Note that an EL description tree @@ -133,6 +136,7 @@ tree.addNodeToLevel(this, level); // simulation update + Monitor mon = MonitorFactory.start("simulation update"); // the nodes, which need to be updated Set<ELDescriptionNode> update = new HashSet<ELDescriptionNode>(); @@ -182,7 +186,8 @@ // System.out.println(update); // apply updates recursively top-down - tree.updateSimulation(update); + tree.updateSimulation(update); + mon.stop(); // add all classes in label for(NamedClass nc : label) { @@ -338,6 +343,7 @@ // simulation update when extending or refining label // (same in both cases) private void labelSimulationUpdate() { + Monitor mon = MonitorFactory.start("simulation update"); // compute the nodes, which need to be updated Set<ELDescriptionNode> update = new HashSet<ELDescriptionNode>(); @@ -397,12 +403,14 @@ */ // apply updates recursively top-down - tree.updateSimulation(update); + tree.updateSimulation(update); + mon.stop(); } public void refineEdge(int edgeNumber, ObjectProperty op) { edges.get(edgeNumber).setLabel(op); + Monitor mon = MonitorFactory.start("simulation update"); // compute the nodes, which need to be updated Set<ELDescriptionNode> update = new HashSet<ELDescriptionNode>(); update.add(this); @@ -435,7 +443,8 @@ // update.add(this.parent); // apply updates recursively top-down - tree.updateSimulation(update); + tree.updateSimulation(update); + mon.stop(); } /** Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-12-22 11:08:04 UTC (rev 1563) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-12-22 13:18:39 UTC (rev 1564) @@ -40,6 +40,9 @@ import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.UnsupportedLanguageException; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; + /** * Represents an EL description tree. Unlike {@link ELDescriptionNode}, this is * a tree-wide structure, i.e. it does not implement the tree structure itself, @@ -455,6 +458,7 @@ @Override @SuppressWarnings("unchecked") public ELDescriptionTree clone() { + Monitor mon = MonitorFactory.start("EL tree clone"); // clone "global" tree ELDescriptionTree treeClone = new ELDescriptionTree(rs); @@ -539,6 +543,7 @@ treeClone.levelNodeMapping.put(i, newNodes); } + mon.stop(); return treeClone; } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-12-22 11:08:04 UTC (rev 1563) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-12-22 13:18:39 UTC (rev 1564) @@ -71,6 +71,7 @@ import org.dllearner.parser.ParseException; import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptTransformation; +import org.semanticweb.owl.inference.OWLReasonerException; /** * Reasoner for fast instance checks. It works by completely dematerialising the @@ -726,6 +727,11 @@ } @Override + public boolean isSatisfiableImpl() { + return rc.isSatisfiable(); + } + + @Override public Set<Constant> getLabelImpl(Entity entity) throws ReasoningMethodUnsupportedException { return rc.getLabel(entity); } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2008-12-22 11:08:04 UTC (rev 1563) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2008-12-22 13:18:39 UTC (rev 1564) @@ -45,6 +45,9 @@ import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Thing; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; + /** * EL downward refinement operator constructed by Jens Lehmann * and Christoph Haase. It takes an EL description tree as input @@ -153,6 +156,7 @@ // operation 1: label extension private Set<ELDescriptionTree> extendLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + Monitor mon = MonitorFactory.start("extend label"); Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); // the index is the range of role in the edge pointing to the parent of this node @@ -179,11 +183,13 @@ } } + mon.stop(); return refinements; } // operation 2: label refinement private Set<ELDescriptionTree> refineLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + Monitor mon = MonitorFactory.start("refine label"); Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); // loop through all classes in label @@ -204,12 +210,13 @@ } } } - + mon.stop(); return refinements; } // operation 3: refine edge private Set<ELDescriptionTree> refineEdge(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + Monitor mon = MonitorFactory.start("refine edge"); Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); for(int edgeNumber = 0; edgeNumber < v.getEdges().size(); edgeNumber++) { @@ -234,12 +241,13 @@ } } } - + mon.stop(); return refinements; } // operation 4: attach tree private Set<ELDescriptionTree> attachSubtree(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { + Monitor mon = MonitorFactory.start("attach tree"); Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); // compute the set of most general roles such that the domain of each role is not disjoint @@ -307,7 +315,10 @@ } // refine tree using recursive operator call logger.trace("Recursive Call"); + // do not monitor recursive calls (counts time twice or more) + mon.stop(); Set<ELDescriptionTree> recRefs = refine(tp); + mon.start(); logger.trace("Recursive Call Done"); for(ELDescriptionTree tpp : recRefs) { // System.out.println("aa " + tpp.toDescriptionString()); @@ -319,12 +330,13 @@ logger.trace("M: " + m); } } - + mon.stop(); return refinements; } // create a new tree which is obtained by attaching the new tree at the given node in the tree via role r private ELDescriptionTree mergeTrees(ELDescriptionTree tree, ELDescriptionNode node, int[] position, ObjectProperty r, ELDescriptionTree newTree) { + Monitor mon = MonitorFactory.start("merge trees"); // System.out.println("merge start"); // System.out.println(tree); // System.out.println(newTree); @@ -369,6 +381,7 @@ // System.out.println(mergedTree); // System.out.println("merge end"); + mon.stop(); return mergedTree; } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-12-22 11:08:04 UTC (rev 1563) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-12-22 13:18:39 UTC (rev 1564) @@ -21,6 +21,7 @@ import static org.junit.Assert.*; +import java.io.File; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -29,17 +30,23 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Description; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.refinementoperators.ELDown2; import org.dllearner.refinementoperators.RefinementOperator; import org.dllearner.test.junit.TestOntologies.TestOntology; +import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; +import org.dllearner.utilities.JamonMonitorLogger; import org.dllearner.utilities.owl.ConceptComparator; import org.dllearner.utilities.owl.ConceptTransformation; import org.dllearner.utilities.statistics.Stat; import org.junit.Test; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; + /** * Tests related to the EL downward refinement operator. * @@ -98,14 +105,17 @@ Set<Description> refinements = operator.refine(input); long runTime = System.nanoTime() - startTime; logger.debug("Refinement step took " + Helper.prettyPrintNanoSeconds(runTime, true, true) + "."); - boolean runStats = false; + boolean runStats = true; if(runStats) { Stat stat = new Stat(); - int runs = 100; + int runs = 1000; for(int run=0; run<runs; run++) { + Monitor refinementTime = MonitorFactory.start("extraction time"); startTime = System.nanoTime(); refinements = operator.refine(input); runTime = System.nanoTime() - startTime; + refinementTime.stop(); + stat.addNumber(runTime/1000000); } // System.out.println("Identical 2nd refinement step took " + Helper.prettyPrintNanoSeconds(runTime, true, true) + "."); @@ -123,6 +133,8 @@ assertTrue(desired.contains(refinement)); } + File jamonlog = new File("log/jamontest.html"); + Files.createFile(jamonlog, MonitorFactory.getReport()); // generated by operator (and currently corresponding to its definition): // false (http://localhost/foo#human AND EXISTS http://localhost/foo#has.(http://localhost/foo#animal AND http://localhost/foo#human This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-12-22 11:08:09
|
Revision: 1563 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1563&view=rev Author: jenslehmann Date: 2008-12-22 11:08:04 +0000 (Mon, 22 Dec 2008) Log Message: ----------- small change in README Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/README Modified: trunk/src/dl-learner/org/dllearner/tools/protege/README =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/README 2008-12-21 12:54:15 UTC (rev 1562) +++ trunk/src/dl-learner/org/dllearner/tools/protege/README 2008-12-22 11:08:04 UTC (rev 1563) @@ -1,7 +1,7 @@ README ====== The Protégé DL-Learner plugin allows to learn equivalence and super class axioms based on -the instance data in the ontologies loaded in Protégé. It integrated seamlessly in Protégé. +the instance data in the ontologies loaded in Protégé. It integrates seamlessly in Protégé. Homepage: http://dl-learner.org/wiki/ProtegePlugin Sourceforge.net Project Page: http://sourceforge.net/projects/dl-learner/ @@ -12,6 +12,6 @@ The Protégé Plugin is Open Source and licenced under the GNU General Public License. -Documentation for the Protégé Plugin can be found -at http://dl-learner.org/wiki/ProtegePlugin. +More information and a screencast can be found at: +http://dl-learner.org/wiki/ProtegePlugin. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-12-21 12:54:17
|
Revision: 1562 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1562&view=rev Author: heeroyuy Date: 2008-12-21 12:54:15 +0000 (Sun, 21 Dec 2008) Log Message: ----------- -round accuracy on suggest panel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2008-12-21 12:47:11 UTC (rev 1561) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2008-12-21 12:54:15 UTC (rev 1562) @@ -55,7 +55,7 @@ int arg2, boolean iss, boolean arg4) { // Set the text and // background color for rendering - setText(((SuggestListItem) value).getValue() + " " + "Accuracy: " + ((SuggestListItem) value).getAccuracy()+"%"); + setText(((SuggestListItem) value).getValue() + " " + "Accuracy: " + Math.round(((SuggestListItem) value).getAccuracy())+"%"); setBackground(Color.WHITE); setForeground(((SuggestListItem) value).getColor()); // Set a border if the list This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-12-21 12:47:23
|
Revision: 1561 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1561&view=rev Author: jenslehmann Date: 2008-12-21 12:47:11 +0000 (Sun, 21 Dec 2008) Log Message: ----------- - Protege plugin: disallow negation in superclass axioms Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-12-21 12:30:08 UTC (rev 1560) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-12-21 12:47:11 UTC (rev 1561) @@ -364,6 +364,7 @@ currentClass = ignoredClass; } } + cm.applyConfigEntry(la, "useNegation", false); } cm.applyConfigEntry(la, "ignoredConcepts", ignore); cm.applyConfigEntry(la, "noisePercentage", 5.0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-12-21 12:30:16
|
Revision: 1560 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1560&view=rev Author: jenslehmann Date: 2008-12-21 12:30:08 +0000 (Sun, 21 Dec 2008) Log Message: ----------- - FastInstanceChecker: negation by failure added - ConceptTransformation: transformation of cardinality restrictions added Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-12-19 16:04:45 UTC (rev 1559) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-12-21 12:30:08 UTC (rev 1560) @@ -261,9 +261,14 @@ if (child instanceof NamedClass) { return classInstancesNeg.get((NamedClass) child).contains(individual); } else { - logger.debug("Converting description to negation normal form in fast instance check (should be avoided if possible)."); - Description nnf = ConceptTransformation.transformToNegationNormalForm(child); - return hasTypeImpl(nnf, individual); + // default negation + if(configurator.getDefaultNegation()) { + return !hasTypeImpl(child, individual); + } else { + logger.debug("Converting description to negation normal form in fast instance check (should be avoided if possible)."); + Description nnf = ConceptTransformation.transformToNegationNormalForm(child); + return hasTypeImpl(nnf, individual); + } // throw new ReasoningMethodUnsupportedException("Instance check for description " // + description // + " unsupported. Description needs to be in negation normal form."); Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2008-12-19 16:04:45 UTC (rev 1559) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2008-12-21 12:30:08 UTC (rev 1560) @@ -33,6 +33,9 @@ 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.ObjectProperty; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.Intersection; @@ -161,6 +164,21 @@ // All else return new ObjectSomeRestriction(r,transformToNegationNormalForm(c)); + } else if(child instanceof ObjectCardinalityRestriction) { + ObjectCardinalityRestriction card = (ObjectCardinalityRestriction)child; + ObjectPropertyExpression r = card.getRole(); + int number = card.getCardinality(); + // Negation nach innen + Description c = new Negation(child.getChild(0)); + // <= n is transformed to >= n+1 + if(child instanceof ObjectMaxCardinalityRestriction) + return new ObjectMinCardinalityRestriction(number+1,r,transformToNegationNormalForm(c)); + // >= n is transformed to <= n-1 + else if(child instanceof ObjectMinCardinalityRestriction) + return new ObjectMinCardinalityRestriction(number+1,r,transformToNegationNormalForm(c)); + // >= n is transformed to <= n-1 + else + throw new RuntimeException("Conversion to negation normal form not supported for " + concept); } else if(child instanceof Intersection) { // wg. Negation wird Konjunktion zu Disjunktion Union md = new Union(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-12-19 16:04:57
|
Revision: 1559 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1559&view=rev Author: jenslehmann Date: 2008-12-19 16:04:45 +0000 (Fri, 19 Dec 2008) Log Message: ----------- continued EL refinement operator - it now passes unit test 1 ! Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.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/refinementoperators/Utility.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-12-17 15:20:27 UTC (rev 1558) +++ trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-12-19 16:04:45 UTC (rev 1559) @@ -188,7 +188,7 @@ Description conceptModForCache = ConceptTransformation.applyEquivalenceRules(conceptMod); - ConceptTransformation.transformToOrderedNegationNormalForm(conceptModForCache, conceptComparator); + ConceptTransformation.transformToOrderedForm(conceptModForCache, conceptComparator); Score score = program.getScore(); // Eval-Cache füllen @@ -207,7 +207,7 @@ /////////// TESTCODE: umwandeln des erhaltenen Konzepts // someTimeStart = System.nanoTime(); Description newConceptMod = ConceptTransformation.applyEquivalenceRules(newConcept); - ConceptTransformation.transformToOrderedNegationNormalForm(newConceptMod, conceptComparator); + ConceptTransformation.transformToOrderedForm(newConceptMod, conceptComparator); // someTime += System.nanoTime() - someTimeStart; /////////// Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2008-12-17 15:20:27 UTC (rev 1558) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2008-12-19 16:04:45 UTC (rev 1559) @@ -107,7 +107,7 @@ */ @Override public Set<Description> refine(Description concept) { - System.out.println("refining " + concept); + logger.trace("refining " + concept); ELDescriptionTree tree = new ELDescriptionTree(rs, concept); Set<ELDescriptionTree> refinementTrees = refine(tree); Set<Description> refinements = new HashSet<Description>(); @@ -126,7 +126,7 @@ * @return Set of refined EL description trees. */ public Set<ELDescriptionTree> refine(ELDescriptionTree tree) { - System.out.println("applying \\rho on " + tree.toDescriptionString()); + logger.trace("applying \\rho on " + tree.toDescriptionString()); Set<ELDescriptionTree> refinements = new HashSet<ELDescriptionTree>(); // loop over all nodes of the tree and perform one of the @@ -134,7 +134,7 @@ // the transformations can, of course, add new nodes) Set<ELDescriptionNode> nodes = new HashSet<ELDescriptionNode>(tree.getNodes()); for(ELDescriptionNode v : nodes) { - System.out.println("picked node v: " + v); + logger.trace("picked node v: " + v); // the position of the node within the tree (needed for getting // the corresponding node in a cloned tree) @@ -142,8 +142,8 @@ // perform operations refinements.addAll(extendLabel(tree, v, position)); -// refinements.addAll(refineLabel(tree, v, position)); -// refinements.addAll(refineEdge(tree, v, position)); + refinements.addAll(refineLabel(tree, v, position)); + refinements.addAll(refineEdge(tree, v, position)); refinements.addAll(attachSubtree(tree, v, position)); } @@ -255,7 +255,7 @@ // loop through most general roles for(ObjectProperty op : mgr) { - System.out.println("pick most general role: " + op); + logger.trace("pick most general role: " + op); // a list of subtrees (stored as edges i.e. role + root node which points to tree) LinkedList<ELDescriptionEdge> m = new LinkedList<ELDescriptionEdge>(); @@ -270,29 +270,35 @@ while(!m.isEmpty()) { // pick and remove first element ELDescriptionEdge edge = m.pollFirst(); - System.out.println("picked first element of M: " + edge); + logger.trace("picked first element of M: " + edge); ObjectProperty r = edge.getLabel(); // tp = t' in algorithm description (p stands for prime) ELDescriptionTree tp = edge.getNode().getTree(); // merge tree into main tree ELDescriptionTree mergedTree = mergeTrees(tree, v, position, r, tp); - ELDescriptionNode vClone = mergedTree.getNode(position); - System.out.println("merged to t_{C'}: \n" + mergedTree); + // the position of w is the position of v + #edges outgoing from v + int[] wPosition = new int[position.length+1]; + System.arraycopy(position, 0, wPosition, 0, position.length); + wPosition[position.length] = v.getEdges().size(); + ELDescriptionNode wClone = mergedTree.getNode(wPosition); + + logger.trace("merged to t_{C'}: \n" + mergedTree); + // System.out.println(mergedTree.toSimulationString()); // we check equivalence by a minimality test (TODO: can we still do this?) if(mergedTree.isMinimal()) { - System.out.println("Merged tree is minimal, i.e. not equivalent."); + logger.trace("Merged tree is minimal, i.e. not equivalent."); // it is not equivalent, i.e. we found a refinement refinements.add(mergedTree); } else { - System.out.println("Merged tree is not minimal, i.e. equivalent."); + logger.trace("Merged tree is not minimal, i.e. equivalent."); // perform complex check in merged tree - boolean check = asCheck(vClone); - System.out.println("Result of complex check: " + check); + boolean check = asCheck(wClone); + logger.trace("Result of complex check: " + check); if(check) { // refine property @@ -300,9 +306,9 @@ m.add(new ELDescriptionEdge(subRole, tp.getRootNode())); } // refine tree using recursive operator call - System.out.println("Recursive Call"); + logger.trace("Recursive Call"); Set<ELDescriptionTree> recRefs = refine(tp); - System.out.println("Recursive Call Done"); + logger.trace("Recursive Call Done"); for(ELDescriptionTree tpp : recRefs) { // System.out.println("aa " + tpp.toDescriptionString()); m.add(new ELDescriptionEdge(r, tpp.getRootNode())); @@ -310,7 +316,7 @@ } } - System.out.println("M: " + m); + logger.trace("M: " + m); } } @@ -366,15 +372,21 @@ return mergedTree; } + // TODO: variables have been renamed in article private boolean asCheck(ELDescriptionNode v) { +// System.out.println("asCheck: " + v.getTree().toSimulationString()); + // find all edges up to the root node List<ELDescriptionEdge> piVEdges = new LinkedList<ELDescriptionEdge>(); ELDescriptionNode tmp = v; while(!tmp.isRoot()) { +// System.out.println("blub"); piVEdges.add(tmp.getParentEdge()); tmp = tmp.getParent(); } +// System.out.println(piVEdges); + // go through all edges for(ELDescriptionEdge piVEdge : piVEdges) { // collect (w,r',w') @@ -382,12 +394,18 @@ ObjectProperty rp = piVEdge.getLabel(); ELDescriptionNode w = wp.getParent(); - // go through all (w,s,w'') - TODO: s or a new s' ? +// System.out.println(w); +// System.out.println(rp); +// System.out.println(wp); + + // go through all (w,s,w'') for(ELDescriptionEdge wEdge : w.getEdges()) { ObjectProperty rpp = wEdge.getLabel(); ELDescriptionNode wpp = wEdge.getNode(); if(wp != wpp && opHierarchy.isSubpropertyOf(rp, rpp)) { - if(wp.getIn().contains(wpp)) { +// System.out.println("wp: " + wp); +// System.out.println("wpp: " + wpp); + if(wp.getOut().contains(wpp)) { return false; } } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-12-17 15:20:27 UTC (rev 1558) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-12-19 16:04:45 UTC (rev 1559) @@ -779,7 +779,7 @@ // convert all concepts in ordered negation normal form for(Description concept : baseSet) { - ConceptTransformation.transformToOrderedNegationNormalForm(concept, conceptComparator); + ConceptTransformation.transformToOrderedForm(concept, conceptComparator); } // apply the exists filter (throwing out all refinements with Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java 2008-12-17 15:20:27 UTC (rev 1558) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java 2008-12-19 16:04:45 UTC (rev 1559) @@ -460,7 +460,7 @@ // Umwandlung aller Konzepte in Negationsnormalform for(Description concept : baseSet) { - ConceptTransformation.transformToOrderedNegationNormalForm(concept, conceptComparator); + ConceptTransformation.transformToOrderedForm(concept, conceptComparator); } if(applyExistsFilter) { Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2008-12-17 15:20:27 UTC (rev 1558) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2008-12-19 16:04:45 UTC (rev 1559) @@ -123,7 +123,8 @@ // not satisfied // check1: disjointness with index // check3: no superclass exists already - if(!isDisjoint(candidate,index) && checkSubClasses(existingClasses,candidate)) { + // check5: disjointness + if(!isDisjoint(candidate,index) && checkSubClasses(existingClasses,candidate) && checkDisjoints(existingClasses,candidate)) { // check whether the class is meaningful, i.e. adds something to the index // to do this, we need to make sure that the class is not a superclass of the // index (otherwise we get nothing new) @@ -162,6 +163,16 @@ return true; } + // returns false if any of the classes is disjoint with the new one; true otherwise + private boolean checkDisjoints(Set<NamedClass> existingClasses, NamedClass candidate) { + for(NamedClass nc : existingClasses) { + if(isDisjoint(nc, candidate)) + return false; + } + return true; + } + + public boolean isDisjoint(Description d1, Description d2) { // System.out.println("d1: " + d1); // System.out.println("d2: " + d2); Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-12-17 15:20:27 UTC (rev 1558) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-12-19 16:04:45 UTC (rev 1559) @@ -19,20 +19,25 @@ */ package org.dllearner.test.junit; +import static org.junit.Assert.*; + import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Description; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.refinementoperators.ELDown2; +import org.dllearner.refinementoperators.RefinementOperator; import org.dllearner.test.junit.TestOntologies.TestOntology; import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptComparator; import org.dllearner.utilities.owl.ConceptTransformation; +import org.dllearner.utilities.statistics.Stat; import org.junit.Test; /** @@ -43,6 +48,8 @@ */ public class ELDownTests { + private static Logger logger = Logger.getLogger(ELDownTests.class); + /** * Implementation of test case created by Christoph Haase for * new operator. @@ -57,11 +64,11 @@ // input description Description input = KBParser.parseConcept("(human AND EXISTS has.animal)"); - System.out.println("refining: " + input); + System.out.println("refining: " + input.toString(KBParser.internalNamespace, null)); // TODO For this test, we need to turn instance based disjoints // off! (We do not have any instances here.) - ELDown2 operator = new ELDown2(rs); + RefinementOperator operator = new ELDown2(rs); // desired refinements as strings Set<String> desiredString = new TreeSet<String>(); @@ -71,7 +78,7 @@ desiredString.add("((human AND EXISTS hasPet.TOP) AND EXISTS has.animal)"); desiredString.add("((human AND EXISTS hasChild.TOP) AND EXISTS has.animal)"); desiredString.add("((human AND EXISTS hasPet.TOP) AND EXISTS has.animal)"); - desiredString.add("((human AND EXISTS has.person) AND EXISTS has.animal)"); + desiredString.add("((human AND EXISTS has.human) AND EXISTS has.animal)"); desiredString.add("((human AND EXISTS has.EXISTS has.TOP) AND EXISTS has.animal)"); desiredString.add("(human AND EXISTS has.(animal AND EXISTS has.TOP))"); @@ -81,29 +88,42 @@ Description tmp = KBParser.parseConcept(str); // eliminate conjunctions nested in other conjunctions ConceptTransformation.cleanConcept(tmp); + ConceptTransformation.transformToOrderedForm(tmp, cc); desired.add(tmp); - System.out.println("desired: " + tmp); + System.out.println("desired: " + tmp.toString(KBParser.internalNamespace, null)); } // perform refinement and compare solutions long startTime = System.nanoTime(); Set<Description> refinements = operator.refine(input); long runTime = System.nanoTime() - startTime; - System.out.println("Refinement step took " + Helper.prettyPrintNanoSeconds(runTime, true, true) + "."); - startTime = System.nanoTime(); - refinements = operator.refine(input); - runTime = System.nanoTime() - startTime; - System.out.println("Identical 2nd refinement step took " + Helper.prettyPrintNanoSeconds(runTime, true, true) + "."); - + logger.debug("Refinement step took " + Helper.prettyPrintNanoSeconds(runTime, true, true) + "."); + boolean runStats = false; + if(runStats) { + Stat stat = new Stat(); + int runs = 100; + for(int run=0; run<runs; run++) { + startTime = System.nanoTime(); + refinements = operator.refine(input); + runTime = System.nanoTime() - startTime; + stat.addNumber(runTime/1000000); + } +// System.out.println("Identical 2nd refinement step took " + Helper.prettyPrintNanoSeconds(runTime, true, true) + "."); + System.out.println("average over " + runs + " runs:"); + System.out.println(stat.prettyPrint("ms")); + } + // number of refinements has to be correct and each produced // refinement must be in the set of desired refinements -// assertTrue(refinements.size() == desired.size()); + assertTrue(refinements.size() == desired.size()); + System.out.println("\nproduced refinements and their unit test status (true = assertion satisfied):"); for(Description refinement : refinements) { boolean ok = desired.contains(refinement); - System.out.println(ok + ": " + refinement); -// assertTrue(desired.contains(refinement)); + System.out.println(ok + ": " + refinement.toString(KBParser.internalNamespace, null)); + assertTrue(desired.contains(refinement)); } + // generated by operator (and currently corresponding to its definition): // false (http://localhost/foo#human AND EXISTS http://localhost/foo#has.(http://localhost/foo#animal AND http://localhost/foo#human // false (http://localhost/foo#animal AND http://localhost/foo#human AND EXISTS http://localhost/foo#has.http://localhost/foo#animal Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2008-12-17 15:20:27 UTC (rev 1558) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2008-12-19 16:04:45 UTC (rev 1559) @@ -286,11 +286,11 @@ // 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) { + public static void transformToOrderedForm(Description concept, Comparator<Description> conceptComparator) { // alle Kinderkonzepte in geordnete Negationsnormalform bringen for(Description child : concept.getChildren()) { - transformToOrderedNegationNormalForm(child, conceptComparator); + transformToOrderedForm(child, conceptComparator); } onnfTimeNsStart = System.nanoTime(); Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java 2008-12-17 15:20:27 UTC (rev 1558) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java 2008-12-19 16:04:45 UTC (rev 1559) @@ -127,4 +127,21 @@ return max; } + public String prettyPrint(String unit) { + DecimalFormat df = new DecimalFormat(); + String str = "av. " + df.format(getMean()) + unit; + str += " (deviation " + df.format(getStandardDeviation()) + unit + "; "; + str += "min " + df.format(getMin()) + unit + "; "; + str += "max " + df.format(getMax()) + unit + ")"; + return str; + } + + public String prettyPrint(String unit, DecimalFormat df) { + String str = "av. " + df.format(getMean()) + unit; + str += " (deviation " + df.format(getStandardDeviation()) + unit + "; "; + str += "min " + df.format(getMin()) + unit + "; "; + str += "max " + df.format(getMax()) + unit + ")"; + return str; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |