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...> - 2008-03-03 19:40:24
|
Revision: 677 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=677&view=rev Author: jenslehmann Date: 2008-03-03 11:38:48 -0800 (Mon, 03 Mar 2008) Log Message: ----------- several bugfixes and first succesful run of new refinement operator on arch example Modified Paths: -------------- trunk/examples/arch/arch.conf trunk/examples/arch/arch.kb trunk/examples/arch/arch.owl trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Modified: trunk/examples/arch/arch.conf =================================================================== --- trunk/examples/arch/arch.conf 2008-03-03 15:49:03 UTC (rev 676) +++ trunk/examples/arch/arch.conf 2008-03-03 19:38:48 UTC (rev 677) @@ -16,13 +16,12 @@ * Copyright (C) 2007, Sebastian Hellmann */ +algorithm = refexamples; +reasoner = fastInstanceChecker; -//export("arch.owl"); - -/** background knowledge **/ +// export("arch.owl"); import("arch.kb"); - /** examples **/ +c1 +c4 Modified: trunk/examples/arch/arch.kb =================================================================== --- trunk/examples/arch/arch.kb 2008-03-03 15:49:03 UTC (rev 676) +++ trunk/examples/arch/arch.kb 2008-03-03 19:38:48 UTC (rev 677) @@ -1,6 +1,11 @@ parallelpipe = (brick OR wedge). -freeStandingPillar = (pillar AND NOT EXISTS touches.TOP ) . +freeStandingPillar = (pillar AND NOT EXISTS touches.TOP ). +// disjoint classes +(parallelpipe AND pillar) = BOTTOM. +(construction AND pillar) = BOTTOM. +(parallelpipe AND construction) = BOTTOM. + construction(c1). construction(c2). construction(c3). @@ -24,6 +29,8 @@ wedge(d). wedge(e). +OPDOMAIN(hasPillar) = construction. +OPRANGE(hasPillar) = pillar. hasPillar(c1,p1). hasPillar(c1,p2). hasPillar(c2,p3). @@ -34,12 +41,16 @@ hasPillar(c4,p8). hasPillar(c5,p9). +OPDOMAIN(hasParallelpipe) = construction. +OPRANGE(hasParallelpipe) = parallelpipe. hasParallelpipe(c1,a). hasParallelpipe(c2,b). hasParallelpipe(c3,c). hasParallelpipe(c4,d). hasParallelpipe(c5,e). +OPDOMAIN(supports) = pillar. +OPRANGE(supports) = parallelpipe. supports(p1,a). supports(p2,a). supports(p5,c). @@ -48,11 +59,15 @@ supports(p8,d). supports(p9,e). +OPDOMAIN(leftof) = pillar. +OPRANGE(leftof) = pillar. leftof(p1,p2). leftof(p3,p4). leftof(p5,p6). leftof(p7,p8). +OPDOMAIN(touches) = pillar. +OPRANGE(touches) = pillar. touches(p5,p6). freeStandingPillar(p1). Modified: trunk/examples/arch/arch.owl =================================================================== --- trunk/examples/arch/arch.owl 2008-03-03 15:49:03 UTC (rev 676) +++ trunk/examples/arch/arch.owl 2008-03-03 19:38:48 UTC (rev 677) @@ -1,115 +1,362 @@ -<?xml version="1.0"?> -<!DOCTYPE rdf:RDF [ - <!ENTITY owl 'http://www.w3.org/2002/07/owl#'> -]> -<rdf:RDF xml:base="http://localhost/foo" -xmlns:a="http://localhost/foo#" -xmlns:owl="http://www.w3.org/2002/07/owl#" -xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" -xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" -xmlns:prefix1="http://localhost/foo#"> - <owl:Ontology rdf:about=""/> - <owl:Class rdf:ID="freeStandingPillar"> - <owl:equivalentClass> - <owl:Class> - <owl:intersectionOf rdf:parseType="Collection"> - <owl:Class rdf:about="#pillar"/> - <owl:Class> - <owl:complementOf> - <owl:Restriction> - <owl:onProperty rdf:resource="#touches"/> - <owl:someValuesFrom rdf:resource="&owl;Thing"/> - </owl:Restriction> - </owl:complementOf> - </owl:Class> - </owl:intersectionOf> - </owl:Class> - </owl:equivalentClass> - </owl:Class> - <owl:Class rdf:ID="parallelpipe"> - <owl:equivalentClass> - <owl:Class> - <owl:unionOf rdf:parseType="Collection"> - <owl:Class rdf:about="#brick"/> - <owl:Class rdf:about="#wedge"/> - </owl:unionOf> - </owl:Class> - </owl:equivalentClass> - </owl:Class> - <prefix1:brick rdf:ID="a"/> - <prefix1:brick rdf:ID="b"/> - <prefix1:brick rdf:ID="c"/> - <prefix1:construction rdf:ID="c1"> - <prefix1:hasParallelpipe rdf:resource="#a"/> - <prefix1:hasPillar rdf:resource="#p1"/> - <prefix1:hasPillar rdf:resource="#p2"/> - </prefix1:construction> - <prefix1:construction rdf:ID="c2"> - <prefix1:hasParallelpipe rdf:resource="#b"/> - <prefix1:hasPillar rdf:resource="#p3"/> - <prefix1:hasPillar rdf:resource="#p4"/> - </prefix1:construction> - <prefix1:construction rdf:ID="c3"> - <prefix1:hasParallelpipe rdf:resource="#c"/> - <prefix1:hasPillar rdf:resource="#p5"/> - <prefix1:hasPillar rdf:resource="#p6"/> - </prefix1:construction> - <prefix1:construction rdf:ID="c4"> - <prefix1:hasParallelpipe rdf:resource="#d"/> - <prefix1:hasPillar rdf:resource="#p7"/> - <prefix1:hasPillar rdf:resource="#p8"/> - </prefix1:construction> - <prefix1:construction rdf:ID="c5"> - <prefix1:hasParallelpipe rdf:resource="#e"/> - <prefix1:hasPillar rdf:resource="#p9"/> - </prefix1:construction> - <prefix1:wedge rdf:ID="d"/> - <prefix1:wedge rdf:ID="e"/> - <prefix1:freeStandingPillar rdf:ID="p1"> - <rdf:type rdf:resource="#pillar"/> - <prefix1:leftof rdf:resource="#p2"/> - <prefix1:supports rdf:resource="#a"/> - </prefix1:freeStandingPillar> - <prefix1:freeStandingPillar rdf:ID="p2"> - <rdf:type rdf:resource="#pillar"/> - <prefix1:supports rdf:resource="#a"/> - </prefix1:freeStandingPillar> - <prefix1:freeStandingPillar rdf:ID="p3"> - <rdf:type rdf:resource="#pillar"/> - <prefix1:leftof rdf:resource="#p4"/> - </prefix1:freeStandingPillar> - <prefix1:freeStandingPillar rdf:ID="p4"> - <rdf:type rdf:resource="#pillar"/> - </prefix1:freeStandingPillar> - <prefix1:pillar rdf:ID="p5"> - <prefix1:leftof rdf:resource="#p6"/> - <prefix1:supports rdf:resource="#c"/> - <prefix1:touches rdf:resource="#p6"/> - </prefix1:pillar> - <prefix1:pillar rdf:ID="p6"> - <prefix1:supports rdf:resource="#c"/> - </prefix1:pillar> - <prefix1:freeStandingPillar rdf:ID="p7"> - <rdf:type rdf:resource="#pillar"/> - <prefix1:leftof rdf:resource="#p8"/> - <prefix1:supports rdf:resource="#d"/> - </prefix1:freeStandingPillar> - <prefix1:freeStandingPillar rdf:ID="p8"> - <rdf:type rdf:resource="#pillar"/> - <prefix1:supports rdf:resource="#d"/> - </prefix1:freeStandingPillar> - <prefix1:freeStandingPillar rdf:ID="p9"> - <rdf:type rdf:resource="#pillar"/> - <prefix1:supports rdf:resource="#e"/> - </prefix1:freeStandingPillar> - <owl:Class rdf:ID="brick"/> - <owl:Class rdf:ID="construction"/> - <owl:Class rdf:ID="pillar"/> - <owl:Class rdf:ID="wedge"/> - <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> - <owl:ObjectProperty rdf:ID="hasParallelpipe"/> - <owl:ObjectProperty rdf:ID="hasPillar"/> - <owl:ObjectProperty rdf:ID="leftof"/> - <owl:ObjectProperty rdf:ID="supports"/> - <owl:ObjectProperty rdf:ID="touches"/> -</rdf:RDF> +<?xml version="1.0"?> + + +<!DOCTYPE rdf:RDF [ + <!ENTITY foo "http://localhost/foo#" > + <!ENTITY owl "http://www.w3.org/2002/07/owl#" > + <!ENTITY owl11 "http://www.w3.org/2006/12/owl11#" > + <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > + <!ENTITY owl11xml "http://www.w3.org/2006/12/owl11-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#" + xml:base="http://example.com" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl11="http://www.w3.org/2006/12/owl11#" + xmlns:owl11xml="http://www.w3.org/2006/12/owl11-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://localhost/foo#"> + <owl:Ontology rdf:about=""/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Object Properties + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://localhost/foo#hasParallelpipe --> + + <owl:ObjectProperty rdf:about="&foo;hasParallelpipe"> + <rdfs:range rdf:resource="&foo;parallelpipe"/> + <rdfs:domain rdf:resource="&foo;construction"/> + </owl:ObjectProperty> + + + + <!-- http://localhost/foo#hasPillar --> + + <owl:ObjectProperty rdf:about="&foo;hasPillar"> + <rdfs:domain rdf:resource="&foo;construction"/> + <rdfs:range rdf:resource="&foo;pillar"/> + </owl:ObjectProperty> + + + + <!-- http://localhost/foo#leftof --> + + <owl:ObjectProperty rdf:about="&foo;leftof"> + <rdfs:domain rdf:resource="&foo;pillar"/> + <rdfs:range rdf:resource="&foo;pillar"/> + </owl:ObjectProperty> + + + + <!-- http://localhost/foo#supports --> + + <owl:ObjectProperty rdf:about="&foo;supports"> + <rdfs:range rdf:resource="&foo;parallelpipe"/> + <rdfs:domain rdf:resource="&foo;pillar"/> + </owl:ObjectProperty> + + + + <!-- http://localhost/foo#touches --> + + <owl:ObjectProperty rdf:about="&foo;touches"> + <rdfs:domain rdf:resource="&foo;pillar"/> + <rdfs:range rdf:resource="&foo;pillar"/> + </owl:ObjectProperty> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Classes + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://localhost/foo#brick --> + + <owl:Class rdf:about="&foo;brick"/> + + + + <!-- http://localhost/foo#construction --> + + <owl:Class rdf:about="&foo;construction"/> + + + + <!-- http://localhost/foo#freeStandingPillar --> + + <owl:Class rdf:about="&foo;freeStandingPillar"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="&foo;pillar"/> + <owl:Class> + <owl:complementOf> + <owl:Restriction> + <owl:onProperty rdf:resource="&foo;touches"/> + <owl:someValuesFrom rdf:resource="&owl;Thing"/> + </owl:Restriction> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + + + + <!-- http://localhost/foo#parallelpipe --> + + <owl:Class rdf:about="&foo;parallelpipe"> + <owl:equivalentClass> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="&foo;wedge"/> + <rdf:Description rdf:about="&foo;brick"/> + </owl:unionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + + + + <!-- http://localhost/foo#pillar --> + + <owl:Class rdf:about="&foo;pillar"/> + + + + <!-- http://localhost/foo#wedge --> + + <owl:Class rdf:about="&foo;wedge"/> + + + + <!-- http://www.w3.org/2002/07/owl#Nothing --> + + <owl:Class rdf:about="&owl;Nothing"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="&foo;pillar"/> + <rdf:Description rdf:about="&foo;parallelpipe"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="&foo;construction"/> + <rdf:Description rdf:about="&foo;parallelpipe"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="&foo;construction"/> + <rdf:Description rdf:about="&foo;pillar"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + + + + <!-- http://www.w3.org/2002/07/owl#Thing --> + + <owl:Class rdf:about="&owl;Thing"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Individuals + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://localhost/foo#a --> + + <foo:brick rdf:about="&foo;a"/> + + + + <!-- http://localhost/foo#b --> + + <foo:brick rdf:about="&foo;b"/> + + + + <!-- http://localhost/foo#c --> + + <foo:brick rdf:about="&foo;c"/> + + + + <!-- http://localhost/foo#c1 --> + + <foo:construction rdf:about="&foo;c1"> + <foo:hasParallelpipe rdf:resource="&foo;a"/> + <foo:hasPillar rdf:resource="&foo;p2"/> + <foo:hasPillar rdf:resource="&foo;p1"/> + </foo:construction> + + + + <!-- http://localhost/foo#c2 --> + + <foo:construction rdf:about="&foo;c2"> + <foo:hasPillar rdf:resource="&foo;p3"/> + <foo:hasParallelpipe rdf:resource="&foo;b"/> + <foo:hasPillar rdf:resource="&foo;p4"/> + </foo:construction> + + + + <!-- http://localhost/foo#c3 --> + + <foo:construction rdf:about="&foo;c3"> + <foo:hasPillar rdf:resource="&foo;p5"/> + <foo:hasParallelpipe rdf:resource="&foo;c"/> + <foo:hasPillar rdf:resource="&foo;p6"/> + </foo:construction> + + + + <!-- http://localhost/foo#c4 --> + + <foo:construction rdf:about="&foo;c4"> + <foo:hasParallelpipe rdf:resource="&foo;d"/> + <foo:hasPillar rdf:resource="&foo;p8"/> + <foo:hasPillar rdf:resource="&foo;p7"/> + </foo:construction> + + + + <!-- http://localhost/foo#c5 --> + + <foo:construction rdf:about="&foo;c5"> + <foo:hasPillar rdf:resource="&foo;p9"/> + <foo:hasParallelpipe rdf:resource="&foo;e"/> + </foo:construction> + + + + <!-- http://localhost/foo#d --> + + <foo:wedge rdf:about="&foo;d"/> + + + + <!-- http://localhost/foo#e --> + + <foo:wedge rdf:about="&foo;e"/> + + + + <!-- http://localhost/foo#p1 --> + + <foo:pillar rdf:about="&foo;p1"> + <rdf:type rdf:resource="&foo;freeStandingPillar"/> + <foo:supports rdf:resource="&foo;a"/> + <foo:leftof rdf:resource="&foo;p2"/> + </foo:pillar> + + + + <!-- http://localhost/foo#p2 --> + + <foo:pillar rdf:about="&foo;p2"> + <rdf:type rdf:resource="&foo;freeStandingPillar"/> + <foo:supports rdf:resource="&foo;a"/> + </foo:pillar> + + + + <!-- http://localhost/foo#p3 --> + + <foo:freeStandingPillar rdf:about="&foo;p3"> + <rdf:type rdf:resource="&foo;pillar"/> + <foo:leftof rdf:resource="&foo;p4"/> + </foo:freeStandingPillar> + + + + <!-- http://localhost/foo#p4 --> + + <foo:freeStandingPillar rdf:about="&foo;p4"> + <rdf:type rdf:resource="&foo;pillar"/> + </foo:freeStandingPillar> + + + + <!-- http://localhost/foo#p5 --> + + <foo:pillar rdf:about="&foo;p5"> + <foo:supports rdf:resource="&foo;c"/> + <foo:touches rdf:resource="&foo;p6"/> + <foo:leftof rdf:resource="&foo;p6"/> + </foo:pillar> + + + + <!-- http://localhost/foo#p6 --> + + <foo:pillar rdf:about="&foo;p6"> + <foo:supports rdf:resource="&foo;c"/> + </foo:pillar> + + + + <!-- http://localhost/foo#p7 --> + + <foo:freeStandingPillar rdf:about="&foo;p7"> + <rdf:type rdf:resource="&foo;pillar"/> + <foo:leftof rdf:resource="&foo;p8"/> + <foo:supports rdf:resource="&foo;d"/> + </foo:freeStandingPillar> + + + + <!-- http://localhost/foo#p8 --> + + <foo:freeStandingPillar rdf:about="&foo;p8"> + <rdf:type rdf:resource="&foo;pillar"/> + <foo:supports rdf:resource="&foo;d"/> + </foo:freeStandingPillar> + + + + <!-- http://localhost/foo#p9 --> + + <foo:freeStandingPillar rdf:about="&foo;p9"> + <rdf:type rdf:resource="&foo;pillar"/> + <foo:supports rdf:resource="&foo;e"/> + </foo:freeStandingPillar> +</rdf:RDF> Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-03 15:49:03 UTC (rev 676) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-03 19:38:48 UTC (rev 677) @@ -43,7 +43,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.refinementoperators.RhoDown; +import org.dllearner.refinementoperators.RhoDRDown; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; @@ -54,8 +54,6 @@ * passes them to the actual refinement operator, heuristic, and * learning algorithm implementations. * - * Note: The component is not working yet. - * * Note: The options supported by the ROLearner component and this * one are not equal. Options that have been dropped for now: * - horizontal expansion factor: The goal of the algorithm will @@ -106,6 +104,7 @@ private boolean useNegation = true; private boolean useBooleanDatatypes = true; private double noisePercentage = 0.0; + private NamedClass startClass = null; // Variablen zur Einstellung der Protokollierung // boolean quiet = false; @@ -167,6 +166,7 @@ noisePercentage.setLowerLimit(0); noisePercentage.setUpperLimit(100); options.add(noisePercentage); + options.add(new StringConfigOption("startClass", "the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class)")); return options; } @@ -219,8 +219,9 @@ noisePercentage = (Double) entry.getValue(); } else if(name.equals("useBooleanDatatypes")) { useBooleanDatatypes = (Boolean) entry.getValue(); + } else if(name.equals("startClass")) { + startClass = new NamedClass((String)entry.getValue()); } - } /* (non-Javadoc) @@ -276,19 +277,21 @@ if(improveSubsumptionHierarchy) rs.getSubsumptionHierarchy().improveSubsumptionHierarchy(); rs.prepareRoleHierarchy(usedRoles); + rs.prepareDatatypePropertyHierarchy(); // create a refinement operator and pass all configuration // variables to it - RhoDown operator = new RhoDown( - rs, - applyAllFilter, - applyExistsFilter, - useAllConstructor, - useExistsConstructor, - useNegation, - useBooleanDatatypes - ); - + RhoDRDown operator = new RhoDRDown( + rs, + applyAllFilter, + applyExistsFilter, + useAllConstructor, + useExistsConstructor, + useNegation, + useBooleanDatatypes, + startClass + ); + // create an algorithm object and pass all configuration // options to it algorithm = new ExampleBasedROLearner( Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-03 15:49:03 UTC (rev 676) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-03 19:38:48 UTC (rev 677) @@ -42,7 +42,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.refinementoperators.RhoDown; +import org.dllearner.refinementoperators.RhoDRDown; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; @@ -107,7 +107,8 @@ private List<Description> solutions = new LinkedList<Description>(); // used refinement operator and heuristic (exchangeable) - private RhoDown operator; + private RhoDRDown operator; +// private RefinementOperator operator; // private ExampleBasedHeuristic heuristic; // specifies whether to compute and log benchmark information @@ -195,7 +196,7 @@ } nrOfExamples = nrOfPositiveExamples + nrOfNegativeExamples; this.rs = rs; - this.operator = (RhoDown) operator; + this.operator = (RhoDRDown) operator; // initialise candidate set with heuristic as ordering candidates = new TreeSet<ExampleBasedNode>(heuristic); this.noise = noise; @@ -568,7 +569,7 @@ tooWeakList.add(refinement); } else { // Lösung gefunden - if(quality >= 0 && quality<allowedMisclassifications) { + if(quality >= 0 && quality<=allowedMisclassifications) { solutionFound = true; solutions.add(refinement); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-03 15:49:03 UTC (rev 676) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-03 19:38:48 UTC (rev 677) @@ -279,6 +279,11 @@ + description + " unsupported."); } + @Override + public SortedSet<Individual> retrieval(Description concept) { + return rs.retrieval(concept); + } + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-03 15:49:03 UTC (rev 676) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-03 19:38:48 UTC (rev 677) @@ -97,8 +97,8 @@ private Map<Integer, List<List<Integer>>> combos = new HashMap<Integer, List<List<Integer>>>(); // refinements of the top concept ordered by length - private Map<Integer, SortedSet<? extends Description>> topRefinements = new TreeMap<Integer, SortedSet<? extends Description>>(); - private Map<NamedClass,Map<Integer, SortedSet<? extends Description>>> topARefinements = new TreeMap<NamedClass,Map<Integer, SortedSet<? extends Description>>>(); + private Map<Integer, SortedSet<Description>> topRefinements = new TreeMap<Integer, SortedSet<Description>>(); + private Map<NamedClass,Map<Integer, SortedSet<Description>>> topARefinements = new TreeMap<NamedClass,Map<Integer, SortedSet<Description>>>(); // cumulated refinements of top (all from length one to the specified length) private Map<Integer, TreeSet<Description>> topRefinementsCumulative = new HashMap<Integer, TreeSet<Description>>(); @@ -119,8 +119,8 @@ private ConceptComparator conceptComparator = new ConceptComparator(); // Statistik - private long mComputationTimeNs = 0; - private long topComputationTimeNs = 0; + public long mComputationTimeNs = 0; + public long topComputationTimeNs = 0; private boolean applyAllFilter = true; private boolean applyExistsFilter = true; @@ -129,12 +129,20 @@ private boolean useNegation = true; private boolean useBooleanDatatypes = true; - public RhoDRDown(ReasoningService rs) { - this(rs, null); + public RhoDRDown(ReasoningService reasoningService) { + this(reasoningService, true, true, true, true, true, true, null); } - public RhoDRDown(ReasoningService rs, NamedClass startClass) { - this.rs = rs; + public RhoDRDown(ReasoningService reasoningService, boolean applyAllFilter, boolean applyExistsFilter, boolean useAllConstructor, + boolean useExistsConstructor, boolean useNegation, boolean useBooleanDatatypes, NamedClass startClass) { + this.rs = reasoningService; + this.applyAllFilter = applyAllFilter; + this.applyExistsFilter = applyExistsFilter; + this.useAllConstructor = useAllConstructor; + this.useExistsConstructor = useExistsConstructor; + this.useNegation = useNegation; + this.useBooleanDatatypes = useBooleanDatatypes; + subHierarchy = rs.getSubsumptionHierarchy(); // query reasoner for domains and ranges @@ -169,6 +177,14 @@ @SuppressWarnings({"unchecked"}) public Set<Description> refine(Description description, int maxLength, List<Description> knownRefinements, Description currDomain) { + +// System.out.println(description + " " + currDomain); + + // actions needing to be performed if this is the first time the + // current domain is used + if(!(currDomain instanceof Thing) && !topARefinementsLength.containsKey(currDomain)) + topARefinementsLength.put((NamedClass)currDomain, 0); + // TODO: check whether using list or set makes more sense // here; and whether HashSet or TreeSet should be used Set<Description> refinements = new TreeSet<Description>(conceptComparator); @@ -184,8 +200,8 @@ refinements = (TreeSet<Description>) topRefinementsCumulative.get(maxLength).clone(); } else { if(maxLength>topARefinementsLength.get(currDomain)) - computeTopRefinements(maxLength); - refinements = (TreeSet<Description>) topRefinementsCumulative.get(maxLength).clone(); + computeTopRefinements(maxLength, (NamedClass) currDomain); + refinements = (TreeSet<Description>) topARefinementsCumulative.get(currDomain).get(maxLength).clone(); } // refinements.addAll(subHierarchy.getMoreSpecialConcepts(description)); @@ -303,9 +319,10 @@ int topRefLength = maxLength - description.getLength() - 1; // maybe we have to compute new top refinements here - if(currDomain instanceof Thing && topRefLength > topRefinementsLength) - computeTopRefinements(topRefLength); - else if(topRefLength > topARefinementsLength.get(currDomain)) + if(currDomain instanceof Thing) { + if(topRefLength > topRefinementsLength) + computeTopRefinements(topRefLength); + } else if(topRefLength > topARefinementsLength.get(currDomain)) computeTopRefinements(topRefLength,(NamedClass)currDomain); if(topRefLength>0) { @@ -366,24 +383,48 @@ if(domain != null && !mA.containsKey(domain)) computeM(domain); + int refinementsLength; + + if(domain == null) { + refinementsLength = topRefinementsLength; + } else { + if(!topARefinementsLength.containsKey(domain)) + topARefinementsLength.put(domain,0); + + refinementsLength = topARefinementsLength.get(domain); + } + // compute all possible combinations of the disjunction - int refinementsLength = (domain == null) ? topRefinementsLength : topARefinementsLength.get(domain); for(int i = refinementsLength+1; i <= maxLength; i++) { combos.put(i,MathOperations.getCombos(i, mMaxLength)); + // initialise the refinements with empty sets + if(domain == null) { + topRefinements.put(i, new TreeSet<Description>(conceptComparator)); + } else { + if(!topARefinements.containsKey(domain)) + topARefinements.put(domain, new TreeMap<Integer,SortedSet<Description>>()); + topARefinements.get(domain).put(i, new TreeSet<Description>(conceptComparator)); + } + for(List<Integer> combo : combos.get(i)) { // combination is a single number => try to use M if(combo.size()==1) { + // note we cannot use "put" instead of "addAll" because there + // can be several combos for one length if(domain == null) - topRefinements.put(i,m.get(i)); + topRefinements.get(i).addAll(m.get(i)); else - topARefinements.get(domain).put(i,mA.get(domain).get(i)); + topARefinements.get(domain).get(i).addAll(mA.get(domain).get(i)); // combinations has several numbers => generate disjunct } else { SortedSet<Union> baseSet = new TreeSet<Union>(conceptComparator); for(Integer j : combo) { - baseSet = MathOperations.incCrossProduct(baseSet, m.get(j)); + if(domain == null) + baseSet = MathOperations.incCrossProduct(baseSet, m.get(j)); + else + baseSet = MathOperations.incCrossProduct(baseSet, mA.get(domain).get(j)); } // convert all concepts in ordered negation normal form @@ -405,9 +446,9 @@ // add computed refinements if(domain == null) - topRefinements.put(new Integer(i), baseSet); + topRefinements.get(i).addAll(baseSet); else - topARefinements.get(domain).put(new Integer(i), baseSet); + topARefinements.get(domain).get(i).addAll(baseSet); } } @@ -415,15 +456,20 @@ // be accessed easily TreeSet<Description> cumulativeRefinements = new TreeSet<Description>(conceptComparator); for(int j=1; j<=i; j++) { - if(domain == null) + if(domain == null) { cumulativeRefinements.addAll(topRefinements.get(j)); - else + } else { cumulativeRefinements.addAll(topARefinements.get(domain).get(j)); + } } - if(domain == null) + + if(domain == null) { topRefinementsCumulative.put(i, cumulativeRefinements); - else + } else { + if(!topARefinementsCumulative.containsKey(domain)) + topARefinementsCumulative.put(domain, new TreeMap<Integer, TreeSet<Description>>()); topARefinementsCumulative.get(domain).put(i, cumulativeRefinements); + } } // register new top refinements length @@ -495,12 +541,12 @@ mA.put(nc, new TreeMap<Integer,SortedSet<Description>>()); // initialise all possible lengths (1 to 3) - for(int i=1; i<=3; i++) { + for(int i=1; i<=mMaxLength; i++) { mA.get(nc).put(i, new TreeSet<Description>(conceptComparator)); } SortedSet<Description> m1 = rs.getMoreSpecialConcepts(nc); - m.put(1,m1); + mA.get(nc).put(1,m1); if(useNegation) { // the definition in the paper is more complex, but acutally @@ -516,11 +562,11 @@ m2.add(c); else { NamedClass a = (NamedClass) c; - if(!isNotADisjoint(a, nc) && !isNotAMeaningFul(a, nc)) + if(!isNotADisjoint(a, nc) && isNotAMeaningFul(a, nc)) m2.add(new Negation(a)); } } - m.put(2,m2); + mA.get(nc).put(2,m2); } // compute applicable properties @@ -551,7 +597,7 @@ } } - m.put(3,m3); + mA.get(nc).put(3,m3); mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; } @@ -560,6 +606,12 @@ // compute the applicable properties if this has not been done yet if(appOP.get(domain) == null) computeApp(domain); + + // initialise mgr, mgbd, mgdd + mgr.put(domain, new TreeSet<ObjectProperty>()); + mgbd.put(domain, new TreeSet<DatatypeProperty>()); + mgdd.put(domain, new TreeSet<DatatypeProperty>()); + SortedSet<ObjectProperty> mostGeneral = rs.getMostGeneralRoles(); computeMgrRecursive(domain, mostGeneral, mgr.get(domain)); SortedSet<DatatypeProperty> mostGeneralDP = rs.getMostGeneralDatatypeProperties(); @@ -606,8 +658,8 @@ for(ObjectProperty role : mostGeneral) { // TODO: currently we just rely on named classes as roles, // instead of computing dom(r) and ran(r) - NamedClass nc = (NamedClass) rs.getDomain(role); - if(!isDisjoint(domain,nc)) + Description d = rs.getDomain(role); + if(!isDisjoint(domain,d)) applicableRoles.add(role); } appOP.put(domain, applicableRoles); @@ -616,8 +668,8 @@ Set<DatatypeProperty> mostGeneralBDPs = rs.getBooleanDatatypeProperties(); Set<DatatypeProperty> applicableBDPs = new TreeSet<DatatypeProperty>(); for(DatatypeProperty role : mostGeneralBDPs) { - NamedClass nc = (NamedClass) rs.getDomain(role); - if(!isDisjoint(domain,nc)) + Description d = (NamedClass) rs.getDomain(role); + if(!isDisjoint(domain,d)) applicableBDPs.add(role); } appBD.put(domain, applicableBDPs); @@ -626,8 +678,8 @@ Set<DatatypeProperty> mostGeneralDDPs = rs.getBooleanDatatypeProperties(); Set<DatatypeProperty> applicableDDPs = new TreeSet<DatatypeProperty>(); for(DatatypeProperty role : mostGeneralDDPs) { - NamedClass nc = (NamedClass) rs.getDomain(role); - if(!isDisjoint(domain,nc)) + Description d = (NamedClass) rs.getDomain(role); + if(!isDisjoint(domain,d)) applicableDDPs.add(role); } appDD.put(domain, applicableDDPs); @@ -637,10 +689,10 @@ // by the reasoner only ones and otherwise taken from a matrix // => this has low importance in the long run, because M is cached anyway, // but avoids many duplicate queries when computing M - private boolean isDisjoint(NamedClass a, NamedClass b) { + private boolean isDisjoint(NamedClass a, Description d) { // we need to test whether A AND B is equivalent to BOTTOM - Description d = new Intersection(a, b); - return rs.subsumes(new Nothing(), d); + Description d2 = new Intersection(a, d); + return rs.subsumes(new Nothing(), d2); } // we need to test whether NOT A AND B is equivalent to BOTTOM @@ -656,7 +708,8 @@ private boolean isNotAMeaningFul(NamedClass a, NamedClass b) { Description notA = new Negation(a); Description d = new Intersection(notA, b); - return !rs.subsumes(b, d); + // check b subClassOf b AND NOT A (if yes then it is not meaningful) + return !rs.subsumes(d, b); } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-03 15:49:07
|
Revision: 676 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=676&view=rev Author: jenslehmann Date: 2008-03-03 07:49:03 -0800 (Mon, 03 Mar 2008) Log Message: ----------- refinement operator implementation continued Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java 2008-03-03 12:46:23 UTC (rev 675) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java 2008-03-03 15:49:03 UTC (rev 676) @@ -19,7 +19,6 @@ */ package org.dllearner.refinementoperators; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-03 12:46:23 UTC (rev 675) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-03 15:49:03 UTC (rev 676) @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -40,6 +41,8 @@ import org.dllearner.core.owl.Nothing; import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectPropertyExpression; +import org.dllearner.core.owl.ObjectQuantorRestriction; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.core.owl.Thing; @@ -119,7 +122,7 @@ private long mComputationTimeNs = 0; private long topComputationTimeNs = 0; -// private boolean applyAllFilter = true; + private boolean applyAllFilter = true; private boolean applyExistsFilter = true; private boolean useAllConstructor = true; private boolean useExistsConstructor = true; @@ -168,12 +171,10 @@ List<Description> knownRefinements, Description currDomain) { // TODO: check whether using list or set makes more sense // here; and whether HashSet or TreeSet should be used - Set<Description> refinements = new HashSet<Description>(); + Set<Description> refinements = new TreeSet<Description>(conceptComparator); - // .. do most general rules here ... - // (easier because it may be possible to add return - // statements instead of going through the complete - // function) + // used as temporary variable + Set<Description> tmp = new HashSet<Description>(); if(description instanceof Thing) { // extends top refinements if necessary @@ -192,8 +193,163 @@ // cannot be further refined } else if(description instanceof NamedClass) { refinements.addAll(subHierarchy.getMoreSpecialConcepts(description)); + refinements.remove(new Nothing()); + } else if (description instanceof Negation && description.getChild(0) instanceof NamedClass) { + + tmp = rs.getMoreGeneralConcepts(description.getChild(0)); + + for(Description c : tmp) { + if(!(c instanceof Thing)) + refinements.add(new Negation(c)); + } + + } else if (description instanceof Intersection) { + + // refine one of the elements + for(Description child : description.getChildren()) { + + // refine the child; the new max length is the current max length minus + // the currently considered concept plus the length of the child + // TODO: add better explanation + tmp = refine(child, maxLength - description.getLength()+child.getLength(),null,currDomain); + + // create new intersection + for(Description c : tmp) { + List<Description> newChildren = (List<Description>)((LinkedList)description.getChildren()).clone(); + newChildren.add(c); + newChildren.remove(child); + Intersection mc = new Intersection(newChildren); + + // clean concept and transform it to ordered negation normal form + // (non-recursive variant because only depth 1 was modified) + ConceptTransformation.cleanConceptNonRecursive(mc); + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); + + refinements.add(mc); + } + + } + + } else if (description instanceof Union) { + // refine one of the elements + for(Description child : description.getChildren()) { + + // refine child + tmp = refine(child, maxLength - description.getLength()+child.getLength(),null,currDomain); + + // construct intersection (see above) + for(Description c : tmp) { + List<Description> newChildren = new LinkedList<Description>(description.getChildren()); + newChildren.remove(child); + newChildren.add(c); + Union md = new Union(newChildren); + + // transform to ordered negation normal form + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(md, conceptComparator); + // note that we do not have to call clean here because a disjunction will + // never be nested in another disjunction in this operator + + refinements.add(md); + } + + } + + } else if (description instanceof ObjectSomeRestriction) { + ObjectPropertyExpression role = ((ObjectQuantorRestriction)description).getRole(); + Description range = opRanges.get(role); + + // rule 1: EXISTS r.D => EXISTS r.E + tmp = refine(description.getChild(0), maxLength-2, null, range); + + for(Description c : tmp) + refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)description).getRole(),c)); + + // rule 2: EXISTS r.D => EXISTS s.D or EXISTS r^-1.D => EXISTS s^-1.D + // currently inverse roles are not supported + ObjectProperty ar = (ObjectProperty) role; + Set<ObjectProperty> moreSpecialRoles = rs.getMoreSpecialRoles(ar); + for(ObjectProperty moreSpecialRole : moreSpecialRoles) + refinements.add(new ObjectSomeRestriction(moreSpecialRole, description.getChild(0))); + + } else if (description instanceof ObjectAllRestriction) { + ObjectPropertyExpression role = ((ObjectQuantorRestriction)description).getRole(); + Description range = opRanges.get(role); + + // rule 1: ALL r.D => ALL r.E + tmp = refine(description.getChild(0), maxLength-2, null, range); + + for(Description c : tmp) { + refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)description).getRole(),c)); + } + + // rule 2: ALL r.D => ALL r.BOTTOM if D is a most specific atomic concept + if(description.getChild(0) instanceof NamedClass && tmp.size()==0) { + refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)description).getRole(),new Nothing())); + } + + // rule 3: ALL r.D => ALL s.D or ALL r^-1.D => ALL s^-1.D + // currently inverse roles are not supported + ObjectProperty ar = (ObjectProperty) role; + Set<ObjectProperty> moreSpecialRoles = rs.getMoreSpecialRoles(ar); + for(ObjectProperty moreSpecialRole : moreSpecialRoles) { + refinements.add(new ObjectAllRestriction(moreSpecialRole, description.getChild(0))); + } + } + // if a refinement is neither Bottom nor Top a refinement of top can be appended + if(!(description instanceof Thing) && !(description instanceof Nothing)) { + // -1 because of the AND symbol which is appended + int topRefLength = maxLength - description.getLength() - 1; + + // maybe we have to compute new top refinements here + if(currDomain instanceof Thing && topRefLength > topRefinementsLength) + computeTopRefinements(topRefLength); + else if(topRefLength > topARefinementsLength.get(currDomain)) + computeTopRefinements(topRefLength,(NamedClass)currDomain); + + if(topRefLength>0) { + Set<Description> topRefs; + if(currDomain instanceof Thing) + topRefs = topRefinementsCumulative.get(topRefLength); + else + topRefs = topARefinementsCumulative.get(currDomain).get(topRefLength); + + for(Description c : topRefs) { + // true if refinement should be skipped due to filters, + // false otherwise + boolean skip = false; + + // if a refinement of of the form ALL r, we check whether ALL r + // does not occur already + if(applyAllFilter) { + if(c instanceof ObjectAllRestriction) { + for(Description child : description.getChildren()) { + if(child instanceof ObjectAllRestriction) { + ObjectPropertyExpression r1 = ((ObjectAllRestriction)c).getRole(); + ObjectPropertyExpression r2 = ((ObjectAllRestriction)child).getRole(); + if(r1.toString().equals(r2.toString())) + skip = true; + } + } + } + } + + if(!skip) { + Intersection mc = new Intersection(); + mc.addChild(description); + mc.addChild(c); + + // clean and transform to ordered negation normal form + ConceptTransformation.cleanConceptNonRecursive(mc); + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); + + refinements.add(mc); + } + } + } + } + return refinements; } @@ -214,8 +370,7 @@ int refinementsLength = (domain == null) ? topRefinementsLength : topARefinementsLength.get(domain); for(int i = refinementsLength+1; i <= maxLength; i++) { combos.put(i,MathOperations.getCombos(i, mMaxLength)); -// topRefinements.put(i, new TreeSet<Description>(conceptComparator)); - + for(List<Integer> combo : combos.get(i)) { // combination is a single number => try to use M This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-03 12:46:25
|
Revision: 675 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=675&view=rev Author: jenslehmann Date: 2008-03-03 04:46:23 -0800 (Mon, 03 Mar 2008) Log Message: ----------- continued refinement operator implementation Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-03-03 07:45:57 UTC (rev 674) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-03-03 12:46:23 UTC (rev 675) @@ -112,13 +112,13 @@ // currently, we do not require that datatype properties can be returned; // the main reason is that DIG does not distinguish between datatype and // object properties (of course one could implement it but it is not easy) - public Set<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException; + public SortedSet<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException; - public Set<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException; + public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException; - public Set<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException; + public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException; - public Set<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException; + public SortedSet<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException; public SortedSet<Individual> getIndividuals(); Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-03-03 07:45:57 UTC (rev 674) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-03-03 12:46:23 UTC (rev 675) @@ -219,19 +219,19 @@ throw new ReasoningMethodUnsupportedException(); } - public Set<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException { + public SortedSet<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } - public Set<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException { + public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } - public Set<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException { + public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } - public Set<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException { + public SortedSet<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-03-03 07:45:57 UTC (rev 674) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-03-03 12:46:23 UTC (rev 675) @@ -467,7 +467,7 @@ return reasoner.getAtomicRoles(); } - public Set<DatatypeProperty> getDatatypeProperties() { + public SortedSet<DatatypeProperty> getDatatypeProperties() { try { return reasoner.getDatatypeProperties(); } catch (ReasoningMethodUnsupportedException e) { @@ -476,7 +476,7 @@ } } - public Set<DatatypeProperty> getBooleanDatatypeProperties() { + public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() { try { return reasoner.getBooleanDatatypeProperties(); } catch (ReasoningMethodUnsupportedException e) { @@ -485,7 +485,7 @@ } } - public Set<DatatypeProperty> getIntDatatypeProperties() { + public SortedSet<DatatypeProperty> getIntDatatypeProperties() { try { return reasoner.getIntDatatypeProperties(); } catch (ReasoningMethodUnsupportedException e) { @@ -494,7 +494,7 @@ } } - public Set<DatatypeProperty> getDoubleDatatypeProperties() { + public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() { try { return reasoner.getDoubleDatatypeProperties(); } catch (ReasoningMethodUnsupportedException e) { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-03 07:45:57 UTC (rev 674) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-03 12:46:23 UTC (rev 675) @@ -78,10 +78,10 @@ private Set<NamedClass> atomicConcepts; private Set<ObjectProperty> atomicRoles; - private Set<DatatypeProperty> datatypeProperties; - private Set<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); - private Set<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); - private Set<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); + private SortedSet<DatatypeProperty> datatypeProperties; + private SortedSet<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); + private SortedSet<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); + private SortedSet<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); private SortedSet<Individual> individuals; private ReasoningService rs; @@ -298,22 +298,22 @@ } @Override - public Set<DatatypeProperty> getDatatypeProperties() { + public SortedSet<DatatypeProperty> getDatatypeProperties() { return datatypeProperties; } @Override - public Set<DatatypeProperty> getBooleanDatatypeProperties() { + public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() { return booleanDatatypeProperties; } @Override - public Set<DatatypeProperty> getDoubleDatatypeProperties() { + public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() { return doubleDatatypeProperties; } @Override - public Set<DatatypeProperty> getIntDatatypeProperties() { + public SortedSet<DatatypeProperty> getIntDatatypeProperties() { return intDatatypeProperties; } Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-03 07:45:57 UTC (rev 674) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-03 12:46:23 UTC (rev 675) @@ -136,10 +136,10 @@ // primitives Set<NamedClass> atomicConcepts = new TreeSet<NamedClass>(conceptComparator); Set<ObjectProperty> atomicRoles = new TreeSet<ObjectProperty>(roleComparator); - Set<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); - Set<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); - Set<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); - Set<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); + SortedSet<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); + SortedSet<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); + SortedSet<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); + SortedSet<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); SortedSet<Individual> individuals = new TreeSet<Individual>(); // namespaces @@ -334,7 +334,7 @@ } @Override - public Set<DatatypeProperty> getDatatypeProperties() { + public SortedSet<DatatypeProperty> getDatatypeProperties() { return datatypeProperties; } @@ -960,7 +960,7 @@ * @return the booleanDatatypeProperties */ @Override - public Set<DatatypeProperty> getBooleanDatatypeProperties() { + public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() { return booleanDatatypeProperties; } @@ -968,7 +968,7 @@ * @return the doubleDatatypeProperties */ @Override - public Set<DatatypeProperty> getDoubleDatatypeProperties() { + public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() { return doubleDatatypeProperties; } @@ -976,7 +976,7 @@ * @return the intDatatypeProperties */ @Override - public Set<DatatypeProperty> getIntDatatypeProperties() { + public SortedSet<DatatypeProperty> getIntDatatypeProperties() { return intDatatypeProperties; } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java 2008-03-03 07:45:57 UTC (rev 674) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java 2008-03-03 12:46:23 UTC (rev 675) @@ -23,9 +23,13 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.Union; +import org.dllearner.utilities.ConceptComparator; /** * Math operations related to refinement operators. @@ -114,20 +118,44 @@ return combosTmp; } + /** + * @see #getCombos(int) + * @param length Length of construct. + * @param maxValue Maximum value which can occur in sum. + * @return + */ + public static List<List<Integer>> getCombos(int length, int maxValue) { + LinkedList<List<Integer>> combosTmp = new LinkedList<List<Integer>>(); + decompose(length, maxValue, new LinkedList<Integer>(), combosTmp); + return combosTmp; + } + @SuppressWarnings("unchecked") private static LinkedList<Integer> cloneList(LinkedList<Integer> list) { return (LinkedList<Integer>) list.clone(); - } - - public static void main(String args[]) { - System.out.println(getCombos(7)); } - // neue Implementierung, die nicht mehr zur incompleteness führen soll, - // da die Konzepte in einer MultiDisjunction als Liste gespeichert werden - public static Set<Union> incCrossProduct(Set<Union> baseSet, Set<Description> newSet) { - Set<Union> retSet = new HashSet<Union>(); - + /** + * Implements a cross product in the sense that each union description in the + * base set is extended by each description in the new set. + * + * Example: + * baseSet = {A1 OR A2, A1 or A3} + * newSet = {A1, EXISTS r.A3} + * + * Returns: + * {A1 OR A2 OR A1, A1 OR A2 OR EXISTS r.A3, A1 OR A3 OR A1, A1 OR A3 OR EXISTS r.A3} + * + * If the base set is empty, then the return value are union class descriptions + * for each value in newSet (a union with only one concept). + * + * @param baseSet A set of union class descriptions. + * @param newSet The descriptions to add to each union class descriptions. + * @return The "cross product" of baseSet and newSet. + */ + public static SortedSet<Union> incCrossProduct(Set<Union> baseSet, Set<Description> newSet) { + SortedSet<Union> retSet = new TreeSet<Union>(new ConceptComparator()); + if(baseSet.isEmpty()) { for(Description c : newSet) { Union md = new Union(); @@ -148,4 +176,26 @@ return retSet; } + /** + * Returns true if the same property is used twice in an object some + * restriction, e.g. (EXISTS r.A1 AND A2 AND EXISTS r.A3) returns true, + * while (A1 OR A2) and (EXISTS r.A1 AND A2 AND EXISTS s.A3) return false. + * Note that the method does not work recursively, e.g. it return false + * for EXISTS r.(EXISTS r.A1 AND A2 AND EXISTS r.A3). + * + * @param d Description to test. + * @return See description. + */ + public static boolean containsDoubleObjectSomeRestriction(Description d) { + Set<String> roles = new TreeSet<String>(); + for(Description c : d.getChildren()) { + if(c instanceof ObjectSomeRestriction) { + String role = ((ObjectSomeRestriction)c).getRole().getName(); + boolean roleExists = !roles.add(role); + if(roleExists) + return true; + } + } + return false; + } } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-03 07:45:57 UTC (rev 674) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-03 12:46:23 UTC (rev 675) @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; @@ -45,6 +46,7 @@ import org.dllearner.core.owl.Union; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; +import org.dllearner.utilities.Helper; /** * A downward refinement operator, which makes use of domains @@ -81,17 +83,19 @@ // for refinements of \rho_\top(\top), the second one for \rho_A(\top) private int topRefinementsLength = 0; private Map<NamedClass, Integer> topARefinementsLength = new TreeMap<NamedClass, Integer>(); + // M is finite and this value is the maximum length of any value in M + private static int mMaxLength = 3; // the sets M_\top and M_A - private Map<Integer,Set<Description>> m = new TreeMap<Integer,Set<Description>>(); - private Map<NamedClass,Map<Integer,Set<Description>>> mA = new TreeMap<NamedClass,Map<Integer,Set<Description>>>(); + private Map<Integer,SortedSet<Description>> m = new TreeMap<Integer,SortedSet<Description>>(); + private Map<NamedClass,Map<Integer,SortedSet<Description>>> mA = new TreeMap<NamedClass,Map<Integer,SortedSet<Description>>>(); // @see MathOperations.getCombos private Map<Integer, List<List<Integer>>> combos = new HashMap<Integer, List<List<Integer>>>(); // refinements of the top concept ordered by length - private Map<Integer, TreeSet<Description>> topRefinements = new TreeMap<Integer, TreeSet<Description>>(); - private Map<NamedClass,Map<Integer, TreeSet<Description>>> topARefinements = new TreeMap<NamedClass,Map<Integer, TreeSet<Description>>>(); + private Map<Integer, SortedSet<? extends Description>> topRefinements = new TreeMap<Integer, SortedSet<? extends Description>>(); + private Map<NamedClass,Map<Integer, SortedSet<? extends Description>>> topARefinements = new TreeMap<NamedClass,Map<Integer, SortedSet<? extends Description>>>(); // cumulated refinements of top (all from length one to the specified length) private Map<Integer, TreeSet<Description>> topRefinementsCumulative = new HashMap<Integer, TreeSet<Description>>(); @@ -105,6 +109,8 @@ // most general applicable properties private Map<NamedClass,Set<ObjectProperty>> mgr = new TreeMap<NamedClass,Set<ObjectProperty>>(); + private Map<NamedClass,Set<DatatypeProperty>> mgbd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); + private Map<NamedClass,Set<DatatypeProperty>> mgdd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); // comparator für Konzepte private ConceptComparator conceptComparator = new ConceptComparator(); @@ -154,7 +160,7 @@ */ public Set<Description> refine(Description description, int maxLength, List<Description> knownRefinements) { - return refine(description, maxLength, knownRefinements, new Thing()); + return refine(description, maxLength, knownRefinements, startClass); } @SuppressWarnings({"unchecked"}) @@ -198,89 +204,84 @@ private void computeTopRefinements(int maxLength, NamedClass domain) { long topComputationTimeStartNs = System.nanoTime(); - // M erweiteren - computeM(maxLength); + if(domain == null && m.size() == 0) + computeM(); - // berechnen aller möglichen Kombinationen für Disjunktion, - for(int i = topRefinementsLength+1; i <= maxLength; i++) { - combos.put(i,MathOperations.getCombos(i)); - topRefinements.put(i, new TreeSet<Description>(conceptComparator)); - // topRefinements.put(i, new HashSet<Concept>()); + if(domain != null && !mA.containsKey(domain)) + computeM(domain); + + // compute all possible combinations of the disjunction + int refinementsLength = (domain == null) ? topRefinementsLength : topARefinementsLength.get(domain); + for(int i = refinementsLength+1; i <= maxLength; i++) { + combos.put(i,MathOperations.getCombos(i, mMaxLength)); +// topRefinements.put(i, new TreeSet<Description>(conceptComparator)); for(List<Integer> combo : combos.get(i)) { - // Kombination besteht aus nur einer Zahl => einfach M benutzen - // if(combo.getNumbers().size()==1) { + // combination is a single number => try to use M if(combo.size()==1) { - topRefinements.get(i).addAll(m.get(i)); - // Kombination besteht aus mehreren Zahlen => Disjunktion erzeugen + if(domain == null) + topRefinements.put(i,m.get(i)); + else + topARefinements.get(domain).put(i,mA.get(domain).get(i)); + // combinations has several numbers => generate disjunct } else { - Set<Union> baseSet = new HashSet<Union>(); - for(Integer j : combo) { // combo.getNumbers()) { + SortedSet<Union> baseSet = new TreeSet<Union>(conceptComparator); + for(Integer j : combo) { baseSet = MathOperations.incCrossProduct(baseSet, m.get(j)); } - // Umwandlung aller Konzepte in Negationsnormalform + // convert all concepts in ordered negation normal form for(Description concept : baseSet) { ConceptTransformation.transformToOrderedNegationNormalForm(concept, conceptComparator); } + // apply the exists filter (throwing out all refinements with + // double \exists r for any r) + // TODO: similar filtering can be done for boolean datatype + // properties if(applyExistsFilter) { - Iterator<Union> it = baseSet.iterator(); - while(it.hasNext()) { - Union md = it.next(); - boolean remove = false; - // falls Exists r für gleiche Rolle zweimal vorkommt, - // dann rausschmeißen - // Map<AtomicRole,Boolean> roleOccured = new HashMap<AtomicRole,Boolean>(); - Set<String> roles = new TreeSet<String>(); - for(Description c : md.getChildren()) { - if(c instanceof ObjectSomeRestriction) { - String role = ((ObjectSomeRestriction)c).getRole().getName(); - boolean roleExists = !roles.add(role); - // falls Rolle schon vorkommt, dann kann ganzes - // Refinement ignoriert werden (man könnte dann auch - // gleich abbrechen, aber das hat nur minimalste - // Auswirkungen auf Effizienz) - if(roleExists) - remove = true; - } + Iterator<Union> it = baseSet.iterator(); + while(it.hasNext()) { + if(MathOperations.containsDoubleObjectSomeRestriction(it.next())) + it.remove(); } - if(remove) - it.remove(); + } - } - } - - topRefinements.get(i).addAll(baseSet); + // add computed refinements + if(domain == null) + topRefinements.put(new Integer(i), baseSet); + else + topARefinements.get(domain).put(new Integer(i), baseSet); } } - // neu berechnete Refinements kumulieren, damit sie schneller abgefragt werden können - // computeCumulativeTopRefinements(i); + // create cumulative versions of refinements such that they can + // be accessed easily TreeSet<Description> cumulativeRefinements = new TreeSet<Description>(conceptComparator); - // Set<Concept> cumulativeRefinements = new HashSet<Concept>(); for(int j=1; j<=i; j++) { - cumulativeRefinements.addAll(topRefinements.get(j)); + if(domain == null) + cumulativeRefinements.addAll(topRefinements.get(j)); + else + cumulativeRefinements.addAll(topARefinements.get(domain).get(j)); } - topRefinementsCumulative.put(i, cumulativeRefinements); + if(domain == null) + topRefinementsCumulative.put(i, cumulativeRefinements); + else + topARefinementsCumulative.get(domain).put(i, cumulativeRefinements); } - // neue Maximallänge eintragen - topRefinementsLength = maxLength; + // register new top refinements length + if(domain == null) + topRefinementsLength = maxLength; + else + topARefinementsLength.put(domain,maxLength); topComputationTimeNs += System.nanoTime() - topComputationTimeStartNs; } // compute M_\top - private void computeM(int maxLength) { - computeM(maxLength, null); - } - - // computation of the set M_A - // a major difference compared to the ILP 2007 \rho operator is that - // M is finite and contains elements of length (currently) at most 3 - private void computeM(int maxLength, NamedClass domain) { + private void computeM() { long mComputationTimeStartNs = System.nanoTime(); // initialise all possible lengths (1 to 3) @@ -288,19 +289,19 @@ m.put(i, new TreeSet<Description>(conceptComparator)); } - Set<Description> m1 = rs.getMoreSpecialConcepts(new Thing()); + SortedSet<Description> m1 = rs.getMoreSpecialConcepts(new Thing()); m.put(1,m1); if(useNegation) { Set<Description> m2tmp = rs.getMoreGeneralConcepts(new Nothing()); - Set<Description> m2 = new TreeSet<Description>(conceptComparator); + SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); for(Description c : m2tmp) { m2.add(new Negation(c)); } m.put(2,m2); } - Set<Description> m3 = new TreeSet<Description>(conceptComparator); + SortedSet<Description> m3 = new TreeSet<Description>(conceptComparator); if(useExistsConstructor) { // only uses most general roles for(ObjectProperty r : rs.getMostGeneralRoles()) { @@ -330,13 +331,89 @@ mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; } + + // computation of the set M_A + // a major difference compared to the ILP 2007 \rho operator is that + // M is finite and contains elements of length (currently) at most 3 + private void computeM(NamedClass nc) { + long mComputationTimeStartNs = System.nanoTime(); + + mA.put(nc, new TreeMap<Integer,SortedSet<Description>>()); + // initialise all possible lengths (1 to 3) + for(int i=1; i<=3; i++) { + mA.get(nc).put(i, new TreeSet<Description>(conceptComparator)); + } - private void computeMgr(NamedClass domain) { + SortedSet<Description> m1 = rs.getMoreSpecialConcepts(nc); + m.put(1,m1); + + if(useNegation) { + // the definition in the paper is more complex, but acutally + // we only have to insert the most specific concepts satisfying + // the mentioned restrictions; there is no need to implement a + // recursive method because for A subClassOf A' we have not A' + // subClassOf A and thus: if A and B are disjoint then also A' + // and B; if not A AND B = B then also not A' AND B = B + SortedSet<Description> m2tmp = rs.getMoreGeneralConcepts(new Nothing()); + SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); + for(Description c : m2tmp) { + if(c instanceof Thing) + m2.add(c); + else { + NamedClass a = (NamedClass) c; + if(!isNotADisjoint(a, nc) && !isNotAMeaningFul(a, nc)) + m2.add(new Negation(a)); + } + } + m.put(2,m2); + } + + // compute applicable properties + computeMg(nc); + + SortedSet<Description> m3 = new TreeSet<Description>(conceptComparator); + if(useExistsConstructor) { + for(ObjectProperty r : mgr.get(nc)) { + m3.add(new ObjectSomeRestriction(r, new Thing())); + } + } + + if(useAllConstructor) { + // we allow \forall r.\top here because otherwise the operator + // becomes too difficult to manage due to dependencies between + // M_A and M_A' where A'=ran(r) + for(ObjectProperty r : mgr.get(nc)) { + m3.add(new ObjectAllRestriction(r, new Thing())); + } + } + + // boolean datatypes, e.g. testPositive = true + if(useBooleanDatatypes) { + Set<DatatypeProperty> booleanDPs = mgbd.get(nc); + for(DatatypeProperty dp : booleanDPs) { + m3.add(new BooleanValueRestriction(dp,true)); + m3.add(new BooleanValueRestriction(dp,false)); + } + } + + m.put(3,m3); + + mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; + } + + private void computeMg(NamedClass domain) { // compute the applicable properties if this has not been done yet if(appOP.get(domain) == null) - computeApp(domain); - Set<ObjectProperty> mostGeneral = rs.getMostGeneralRoles(); + computeApp(domain); + SortedSet<ObjectProperty> mostGeneral = rs.getMostGeneralRoles(); computeMgrRecursive(domain, mostGeneral, mgr.get(domain)); + SortedSet<DatatypeProperty> mostGeneralDP = rs.getMostGeneralDatatypeProperties(); + // we make the (reasonable) assumption here that all sub and super + // datatype properties have the same type (e.g. boolean, integer, double) + Set<DatatypeProperty> mostGeneralBDP = Helper.intersection(mostGeneralDP, rs.getBooleanDatatypeProperties()); + Set<DatatypeProperty> mostGeneralDDP = Helper.intersection(mostGeneralDP, rs.getDoubleDatatypeProperties()); + computeMgbdRecursive(domain, mostGeneralBDP, mgbd.get(domain)); + computeMgddRecursive(domain, mostGeneralDDP, mgdd.get(domain)); } private void computeMgrRecursive(NamedClass domain, Set<ObjectProperty> currProperties, Set<ObjectProperty> mgrTmp) { @@ -348,9 +425,27 @@ } } + private void computeMgbdRecursive(NamedClass domain, Set<DatatypeProperty> currProperties, Set<DatatypeProperty> mgbdTmp) { + for(DatatypeProperty prop : currProperties) { + if(appBD.get(domain).contains(prop)) + mgbdTmp.add(prop); + else + computeMgbdRecursive(domain, rs.getMoreSpecialDatatypeProperties(prop), mgbdTmp); + } + } + + private void computeMgddRecursive(NamedClass domain, Set<DatatypeProperty> currProperties, Set<DatatypeProperty> mgddTmp) { + for(DatatypeProperty prop : currProperties) { + if(appDD.get(domain).contains(prop)) + mgddTmp.add(prop); + else + computeMgddRecursive(domain, rs.getMoreSpecialDatatypeProperties(prop), mgddTmp); + } + } + // computes the set of applicable properties for a given class private void computeApp(NamedClass domain) { - // TODO: also implement this for boolean/double datatype properties + // object properties Set<ObjectProperty> mostGeneral = rs.getAtomicRoles(); Set<ObjectProperty> applicableRoles = new TreeSet<ObjectProperty>(); for(ObjectProperty role : mostGeneral) { @@ -361,14 +456,52 @@ applicableRoles.add(role); } appOP.put(domain, applicableRoles); + + // boolean datatype properties + Set<DatatypeProperty> mostGeneralBDPs = rs.getBooleanDatatypeProperties(); + Set<DatatypeProperty> applicableBDPs = new TreeSet<DatatypeProperty>(); + for(DatatypeProperty role : mostGeneralBDPs) { + NamedClass nc = (NamedClass) rs.getDomain(role); + if(!isDisjoint(domain,nc)) + applicableBDPs.add(role); + } + appBD.put(domain, applicableBDPs); + + // double datatype properties + Set<DatatypeProperty> mostGeneralDDPs = rs.getBooleanDatatypeProperties(); + Set<DatatypeProperty> applicableDDPs = new TreeSet<DatatypeProperty>(); + for(DatatypeProperty role : mostGeneralDDPs) { + NamedClass nc = (NamedClass) rs.getDomain(role); + if(!isDisjoint(domain,nc)) + applicableDDPs.add(role); + } + appDD.put(domain, applicableDDPs); } // computes whether two classes are disjoint; this should be computed // by the reasoner only ones and otherwise taken from a matrix - private boolean isDisjoint(NamedClass class1, NamedClass class2) { + // => this has low importance in the long run, because M is cached anyway, + // but avoids many duplicate queries when computing M + private boolean isDisjoint(NamedClass a, NamedClass b) { // we need to test whether A AND B is equivalent to BOTTOM - Description d = new Intersection(class1, class2); + Description d = new Intersection(a, b); return rs.subsumes(new Nothing(), d); } + // we need to test whether NOT A AND B is equivalent to BOTTOM + private boolean isNotADisjoint(NamedClass a, NamedClass b) { + Description notA = new Negation(a); + Description d = new Intersection(notA, b); + return rs.subsumes(new Nothing(), d); + } + + // we need to test whether NOT A AND B = B + // (if not then NOT A is not meaningful in the sense that it does + // not semantically add anything to B) + private boolean isNotAMeaningFul(NamedClass a, NamedClass b) { + Description notA = new Negation(a); + Description d = new Intersection(notA, b); + return !rs.subsumes(b, d); + } + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-03 07:47:55
|
Revision: 674 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=674&view=rev Author: jenslehmann Date: 2008-03-02 23:45:57 -0800 (Sun, 02 Mar 2008) Log Message: ----------- - improved datatype support - continued refinement operator implementation Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-03-02 19:23:08 UTC (rev 673) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-03-03 07:45:57 UTC (rev 674) @@ -27,6 +27,7 @@ import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypePropertyHierarchy; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -52,6 +53,7 @@ // (siehe einfacher Traversal in Diplomarbeit) public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts); public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) throws ReasoningMethodUnsupportedException; + public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedDatatypeProperties) throws ReasoningMethodUnsupportedException; public boolean subsumes(Description superConcept, Description subConcept) throws ReasoningMethodUnsupportedException; @@ -69,6 +71,8 @@ public ObjectPropertyHierarchy getRoleHierarchy() throws ReasoningMethodUnsupportedException; + public DatatypePropertyHierarchy getDatatypePropertyHierarchy() throws ReasoningMethodUnsupportedException; + public SortedSet<Individual> retrieval(Description concept) throws ReasoningMethodUnsupportedException; public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) throws ReasoningMethodUnsupportedException; Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-03-02 19:23:08 UTC (rev 673) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-03-03 07:45:57 UTC (rev 674) @@ -30,6 +30,7 @@ import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypePropertyHierarchy; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -186,10 +187,18 @@ throw new ReasoningMethodUnsupportedException(); } + public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedDatatypeProperties) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + public ObjectPropertyHierarchy getRoleHierarchy() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } + public DatatypePropertyHierarchy getDatatypePropertyHierarchy() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + public Set<NamedClass> getConcepts(Individual i) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-03-02 19:23:08 UTC (rev 673) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-03-03 07:45:57 UTC (rev 674) @@ -29,6 +29,7 @@ import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypePropertyHierarchy; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -328,6 +329,44 @@ return getRoleHierarchy().getMostSpecialRoles(); } + /** + * Returns more general concepts in the subsumption hierarchy. + * + * @see ObjectPropertyHierarchy#getMoreGeneralRoles(ObjectProperty) + * @param role Atomic concept, top, or bottom. + * @return A set of more general concepts. + */ + public SortedSet<DatatypeProperty> getMoreGeneralDatatypeProperties(DatatypeProperty role) { + return getDatatypePropertyHierarchy().getMoreGeneralRoles(role); + } + + /** + * Returns more special concepts in the subsumption hierarchy. + * + * @see ObjectPropertyHierarchy#getMoreSpecialRoles(ObjectProperty) + * @param role Atomic concept, top, or bottom. + * @return A set of more special concepts. + */ + public SortedSet<DatatypeProperty> getMoreSpecialDatatypeProperties(DatatypeProperty role) { + return getDatatypePropertyHierarchy().getMoreSpecialRoles(role); + } + + /** + * @see ObjectPropertyHierarchy#getMostGeneralRoles() + * @return The most general roles. + */ + public TreeSet<DatatypeProperty> getMostGeneralDatatypeProperties() { + return getDatatypePropertyHierarchy().getMostGeneralRoles(); + } + + /** + * @see ObjectPropertyHierarchy#getMostSpecialRoles() + * @return The most special roles. + */ + public TreeSet<DatatypeProperty> getMostSpecialDatatypeProperties() { + return getDatatypePropertyHierarchy().getMostSpecialRoles(); + } + public void prepareSubsumptionHierarchy() { reasoner.prepareSubsumptionHierarchy(getAtomicConcepts()); } @@ -367,6 +406,27 @@ } } + public void prepareDatatypePropertyHierarchy() { + prepareDatatypePropertyHierarchy(getDatatypeProperties()); + } + + public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedRoles) { + try { + reasoner.prepareDatatypePropertyHierarchy(allowedRoles); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + } + } + + public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { + try { + return reasoner.getDatatypePropertyHierarchy(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + public boolean isSatisfiable() { reasoningStartTimeTmp = System.nanoTime(); boolean result; Added: trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java 2008-03-03 07:45:57 UTC (rev 674) @@ -0,0 +1,110 @@ +/** + * 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; + +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.dllearner.utilities.RoleComparator; + +/** + * Represents a hierarchy of datatype properties. + * + * @todo. Currently, the role hierarchy pruning algorithm (analogous to the + * subsumption hierarchy) is not implemented. + * + * @author Jens Lehmann + * + */ +public class DatatypePropertyHierarchy { + + RoleComparator rc = new RoleComparator(); + TreeMap<DatatypeProperty,TreeSet<DatatypeProperty>> roleHierarchyUp; + TreeMap<DatatypeProperty,TreeSet<DatatypeProperty>> roleHierarchyDown; + TreeSet<DatatypeProperty> mostGeneralRoles = new TreeSet<DatatypeProperty>(rc); + TreeSet<DatatypeProperty> mostSpecialRoles = new TreeSet<DatatypeProperty>(rc); + + public DatatypePropertyHierarchy(Set<DatatypeProperty> atomicRoles, TreeMap<DatatypeProperty,TreeSet<DatatypeProperty>> roleHierarchyUp , TreeMap<DatatypeProperty,TreeSet<DatatypeProperty>> roleHierarchyDown) { + this.roleHierarchyUp = roleHierarchyUp; + this.roleHierarchyDown = roleHierarchyDown; + + // find most general and most special roles + for(DatatypeProperty role : atomicRoles) { + if(getMoreGeneralRoles(role).size()==0) + mostGeneralRoles.add(role); + if(getMoreSpecialRoles(role).size()==0) + mostSpecialRoles.add(role); + } + } + + @SuppressWarnings("unchecked") + public SortedSet<DatatypeProperty> getMoreGeneralRoles(DatatypeProperty role) { + // we clone all concepts before returning them such that they cannot be + // modified externally + return (TreeSet<DatatypeProperty>) roleHierarchyUp.get(role).clone(); + } + + @SuppressWarnings("unchecked") + public SortedSet<DatatypeProperty> getMoreSpecialRoles(DatatypeProperty role) { + return (TreeSet<DatatypeProperty>) roleHierarchyDown.get(role).clone(); + } + + + + @Override + public String toString() { + String str = ""; + for(DatatypeProperty role : mostGeneralRoles) { + str += toString(roleHierarchyDown, role, 0); + } + return str; + } + + private String toString(TreeMap<DatatypeProperty,TreeSet<DatatypeProperty>> hierarchy, DatatypeProperty role, int depth) { + String str = ""; + for(int i=0; i<depth; i++) + str += " "; + str += role.toString() + "\n"; + Set<DatatypeProperty> tmp = hierarchy.get(role); + if(tmp!=null) { + for(DatatypeProperty c : tmp) + str += toString(hierarchy, c, depth+1); + } + return str; + } + + /** + * @return The most general roles. + */ + public TreeSet<DatatypeProperty> getMostGeneralRoles() { + return mostGeneralRoles; + } + + /** + * @return The most special roles. + */ + public TreeSet<DatatypeProperty> getMostSpecialRoles() { + return mostSpecialRoles; + } + + +} Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-02 19:23:08 UTC (rev 673) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-03 07:45:57 UTC (rev 674) @@ -38,6 +38,7 @@ import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.owl.BooleanValueRestriction; import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypePropertyHierarchy; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; @@ -359,6 +360,16 @@ } @Override + public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedRoles) { + rs.prepareDatatypePropertyHierarchy(allowedRoles); + } + + @Override + public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { + return rs.getDatatypePropertyHierarchy(); + } + + @Override public boolean subsumes(Description superConcept, Description subConcept) { // Negation neg = new Negation(subConcept); // Intersection c = new Intersection(neg,superConcept); Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-02 19:23:08 UTC (rev 673) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-03 07:45:57 UTC (rev 674) @@ -46,6 +46,7 @@ import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypePropertyHierarchy; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.EquivalentClassesAxiom; import org.dllearner.core.owl.FunctionalObjectPropertyAxiom; @@ -129,6 +130,7 @@ private RoleComparator roleComparator = new RoleComparator(); private SubsumptionHierarchy subsumptionHierarchy; private ObjectPropertyHierarchy roleHierarchy; + private DatatypePropertyHierarchy datatypePropertyHierarchy; private Set<Description> allowedConceptsInSubsumptionHierarchy; // primitives @@ -430,6 +432,30 @@ } @Override + public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedRoles) { + // code copied from DIG reasoner + + TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>> datatypePropertyHierarchyUp = new TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>>( + roleComparator); + TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>> datatypePropertyHierarchyDown = new TreeMap<DatatypeProperty, TreeSet<DatatypeProperty>>( + roleComparator); + + // refinement of atomic concepts + for (DatatypeProperty role : datatypeProperties) { + datatypePropertyHierarchyDown.put(role, getMoreSpecialDatatypeProperties(role)); + datatypePropertyHierarchyUp.put(role, getMoreGeneralDatatypeProperties(role)); + } + + datatypePropertyHierarchy = new DatatypePropertyHierarchy(allowedRoles, datatypePropertyHierarchyUp, + datatypePropertyHierarchyDown); + } + + @Override + public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { + return datatypePropertyHierarchy; + } + + @Override public boolean subsumes(Description superConcept, Description subConcept) { try { return reasoner.isSubClassOf(OWLAPIDescriptionConvertVisitor.getOWLDescription(subConcept), OWLAPIDescriptionConvertVisitor.getOWLDescription(superConcept)); @@ -469,7 +495,7 @@ e.printStackTrace(); throw new Error("OWL API classification error."); } - return getFirstProperties(properties); + return getFirstObjectProperties(properties); } private TreeSet<ObjectProperty> getMoreSpecialRoles(ObjectProperty role) { @@ -480,9 +506,31 @@ e.printStackTrace(); throw new Error("OWL API classification error."); } - return getFirstProperties(properties); + return getFirstObjectProperties(properties); } + private TreeSet<DatatypeProperty> getMoreGeneralDatatypeProperties(DatatypeProperty role) { + Set<Set<OWLDataProperty>> properties; + try { + properties = reasoner.getSuperProperties(getOWLAPIDescription(role)); + } catch (OWLReasonerException e) { + e.printStackTrace(); + throw new Error("OWL API classification error."); + } + return getFirstDatatypeProperties(properties); + } + + private TreeSet<DatatypeProperty> getMoreSpecialDatatypeProperties(DatatypeProperty role) { + Set<Set<OWLDataProperty>> properties; + try { + properties = reasoner.getSubProperties(getOWLAPIDescription(role)); + } catch (OWLReasonerException e) { + e.printStackTrace(); + throw new Error("OWL API classification error."); + } + return getFirstDatatypeProperties(properties); + } + @Override public boolean instanceCheck(Description concept, Individual individual) { OWLDescription d = getOWLAPIDescription(concept); @@ -681,7 +729,7 @@ return concepts; } - private TreeSet<ObjectProperty> getFirstProperties(Set<Set<OWLObjectProperty>> setOfSets) { + private TreeSet<ObjectProperty> getFirstObjectProperties(Set<Set<OWLObjectProperty>> setOfSets) { TreeSet<ObjectProperty> roles = new TreeSet<ObjectProperty>(roleComparator); for(Set<OWLObjectProperty> innerSet : setOfSets) { // take one element from the set and ignore the rest @@ -692,6 +740,15 @@ return roles; } + private TreeSet<DatatypeProperty> getFirstDatatypeProperties(Set<Set<OWLDataProperty>> setOfSets) { + TreeSet<DatatypeProperty> roles = new TreeSet<DatatypeProperty>(roleComparator); + for(Set<OWLDataProperty> innerSet : setOfSets) { + OWLDataProperty property = innerSet.iterator().next(); + roles.add(new DatatypeProperty(property.getURI().toString())); + } + return roles; + } + @SuppressWarnings({"unused"}) private Set<Description> owlClassesToAtomicConcepts(Set<OWLClass> owlClasses) { Set<Description> concepts = new HashSet<Description>(); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-02 19:23:08 UTC (rev 673) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-03 07:45:57 UTC (rev 674) @@ -103,6 +103,9 @@ private Map<NamedClass, Set<DatatypeProperty>> appBD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); private Map<NamedClass, Set<DatatypeProperty>> appDD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); + // most general applicable properties + private Map<NamedClass,Set<ObjectProperty>> mgr = new TreeMap<NamedClass,Set<ObjectProperty>>(); + // comparator für Konzepte private ConceptComparator conceptComparator = new ConceptComparator(); @@ -328,6 +331,23 @@ mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; } + private void computeMgr(NamedClass domain) { + // compute the applicable properties if this has not been done yet + if(appOP.get(domain) == null) + computeApp(domain); + Set<ObjectProperty> mostGeneral = rs.getMostGeneralRoles(); + computeMgrRecursive(domain, mostGeneral, mgr.get(domain)); + } + + private void computeMgrRecursive(NamedClass domain, Set<ObjectProperty> currProperties, Set<ObjectProperty> mgrTmp) { + for(ObjectProperty prop : currProperties) { + if(appOP.get(domain).contains(prop)) + mgrTmp.add(prop); + else + computeMgrRecursive(domain, rs.getMoreSpecialRoles(prop), mgrTmp); + } + } + // computes the set of applicable properties for a given class private void computeApp(NamedClass domain) { // TODO: also implement this for boolean/double datatype properties This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-02 19:24:07
|
Revision: 673 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=673&view=rev Author: tonytacker Date: 2008-03-02 11:23:08 -0800 (Sun, 02 Mar 2008) Log Message: ----------- could it be a bug in method makeTime()? Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-02 19:04:28 UTC (rev 672) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-02 19:23:08 UTC (rev 673) @@ -25,7 +25,7 @@ import java.awt.event.ActionListener; import javax.swing.*; -import java.lang.Long; +import org.dllearner.utilities.Helper; /** * RunPanel let algorithm start and stop and show informations about. @@ -105,8 +105,8 @@ infoArea.setText(config.getLearningAlgorithm().getSolutionScore().toString()); } // ReasonerStats - if (e.getSource() == getReasonerStatsButton && runBoolean) { - infoArea.setText(""); + if (e.getSource() == getReasonerStatsButton /* && runBoolean*/) { +/* infoArea.setText(""); infoArea.append("Algorithm Runtime: " + makeTime(config.getAlgorithmRunTime()) + "\n"); infoArea.append("OverallReasoningTime: " @@ -128,6 +128,9 @@ infoArea.append("Subsumption (" + config.getReasoningService().getNrOfSubsumptionChecks() + "): " + makeTime(config.getReasoningService().getTimePerSubsumptionCheckNs()) + "\n"); + +*/ infoArea.setText(makeTime(9927255727L)); + } } @@ -138,23 +141,48 @@ * is type of Long and represent a time interval in ns * @return a string like this: 3h 12min 46s 753ms */ - public String makeTime(Long nanoSeconds) { + public String makeTime(long nanoSeconds) { String time = ""; - Integer hours = 0, minutes = 0, seconds = 0, miliSeconds = 0; - nanoSeconds /= 1000000; // miliSeconds - hours = Math.round(nanoSeconds / 1000 / 60 / 60); - minutes = Math.round(nanoSeconds / 1000 / 60); - seconds = Math.round(nanoSeconds / 1000); - miliSeconds = Math.round(nanoSeconds - (hours * 1000 * 60 * 60) - (minutes * 1000 * 60) - - (seconds * 1000)); + long hours, minutes, seconds, millis, mikros, nanos; + + // it cuts last decimals + nanos = nanoSeconds; + mikros = nanos / 1000; + millis = mikros / 1000; + seconds = millis / 1000; + minutes = seconds / 60; + hours = minutes / 60; + + // and calculate back + minutes -= hours * 60; + seconds -= minutes * 60; + millis -= seconds * 1000; + mikros -= millis * 1000; + nanos -= mikros * 1000; + + System.out.println("TEST: " + hours + "h " + minutes + "min " + seconds + "s " + millis + "ms " + mikros + "mikro " + nanos + "nano "); + + + + + + System.out.println(Helper.prettyPrintNanoSeconds(nanoSeconds, true, true)); + + + if (hours > 0) time += hours + "h "; if (minutes > 0) time += minutes + "min "; if (seconds > 0) time += seconds + "s "; - if (miliSeconds > 0) - time += miliSeconds + "ms "; + if (millis > 0) + time += millis + "ms "; + if (mikros > 0) + time += mikros + "ms "; + if (nanos > 0) + time += nanos + "ms "; + // System.out.println("time: " + time); return time; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-02 19:06:18
|
Revision: 672 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=672&view=rev Author: jenslehmann Date: 2008-03-02 11:04:28 -0800 (Sun, 02 Mar 2008) Log Message: ----------- started implementation of new refinement operator Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryThreaded.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-03-02 15:40:29 UTC (rev 671) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-03-02 19:04:28 UTC (rev 672) @@ -32,8 +32,6 @@ import org.apache.log4j.Logger; -import com.hp.hpl.jena.query.ResultSet; - /** * SPARQL query cache to avoid possibly expensive multiple queries. The queries * and their results are written to files. A cache has an associated cache Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-03-02 15:40:29 UTC (rev 671) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-03-02 19:04:28 UTC (rev 672) @@ -22,8 +22,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.Charset; -import java.util.Iterator; -import java.util.List; import org.apache.log4j.Logger; import org.dllearner.kb.sparql.configuration.SparqlEndpoint; @@ -31,7 +29,6 @@ import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFactory; import com.hp.hpl.jena.query.ResultSetFormatter; -import com.hp.hpl.jena.sparql.core.ResultBinding; import com.hp.hpl.jena.sparql.engine.http.HttpQuery; import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryThreaded.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryThreaded.java 2008-03-02 15:40:29 UTC (rev 671) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryThreaded.java 2008-03-02 19:04:28 UTC (rev 672) @@ -1,7 +1,5 @@ package org.dllearner.kb.sparql; -import com.hp.hpl.jena.query.ResultSet; - /** * The class is used for threaded querying of a Sparql Endpoint. * @author Sebastian Knappe Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-02 15:40:29 UTC (rev 671) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-02 19:04:28 UTC (rev 672) @@ -33,6 +33,7 @@ import org.dllearner.core.owl.BooleanValueRestriction; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.Nothing; @@ -51,7 +52,8 @@ * development. Its aim is to span a much "cleaner" and smaller search * tree compared to RhoDown by omitting many class descriptions, * which are obviously too weak, because they violate - * domain/range restrictions. + * domain/range restrictions. Furthermore, it makes use of disjoint + * classes in the knowledge base. * * @author Jens Lehmann * @@ -68,23 +70,39 @@ private Map<DatatypeProperty,Description> dpDomains = new TreeMap<DatatypeProperty,Description>(); private Map<ObjectProperty,Description> opRanges = new TreeMap<ObjectProperty,Description>(); - // gibt die Gr��e an bis zu der die Refinements des Top-Konzepts - // bereits berechnet worden => entspricht der max. L�nge der Menge M + // start concept (can be used to start from an arbitrary concept, needs + // to be Thing or NamedClass), note that when you use e.g. Compound as + // start class, then the algorithm should start the search with class + // Compound (and not with Thing), because otherwise concepts like + // NOT Carbon-87 will be returned which itself is not a subclass of Compound + private Description startClass = new Thing(); + + // the length of concepts of top refinements, the first values is + // for refinements of \rho_\top(\top), the second one for \rho_A(\top) private int topRefinementsLength = 0; + private Map<NamedClass, Integer> topARefinementsLength = new TreeMap<NamedClass, Integer>(); - // die Menge M im Refinement-Operator indiziert nach ihrer L�nge - private Map<Integer,Set<Description>> m = new HashMap<Integer,Set<Description>>(); + // the sets M_\top and M_A + private Map<Integer,Set<Description>> m = new TreeMap<Integer,Set<Description>>(); + private Map<NamedClass,Map<Integer,Set<Description>>> mA = new TreeMap<NamedClass,Map<Integer,Set<Description>>>(); - // Zerlegungen der Zahl n in Mengen - // Map<Integer,Set<IntegerCombo>> combos = new HashMap<Integer,Set<IntegerCombo>>(); + // @see MathOperations.getCombos private Map<Integer, List<List<Integer>>> combos = new HashMap<Integer, List<List<Integer>>>(); - // abspeichern von Kombinationen während diese rekursiv berechnet werden - // private List<List<Integer>> combosTmp; + + // refinements of the top concept ordered by length + private Map<Integer, TreeSet<Description>> topRefinements = new TreeMap<Integer, TreeSet<Description>>(); + private Map<NamedClass,Map<Integer, TreeSet<Description>>> topARefinements = new TreeMap<NamedClass,Map<Integer, TreeSet<Description>>>(); - // Refinements des Top-Konzept indiziert nach Länge - private Map<Integer, TreeSet<Description>> topRefinements = new HashMap<Integer, TreeSet<Description>>(); + // cumulated refinements of top (all from length one to the specified length) private Map<Integer, TreeSet<Description>> topRefinementsCumulative = new HashMap<Integer, TreeSet<Description>>(); + private Map<NamedClass,Map<Integer, TreeSet<Description>>> topARefinementsCumulative = new TreeMap<NamedClass,Map<Integer, TreeSet<Description>>>(); + // app_A set of applicable properties for a given class (separte for + // object properties, boolean datatypes, and double data types) + private Map<NamedClass, Set<ObjectProperty>> appOP = new TreeMap<NamedClass, Set<ObjectProperty>>(); + private Map<NamedClass, Set<DatatypeProperty>> appBD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); + private Map<NamedClass, Set<DatatypeProperty>> appDD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); + // comparator für Konzepte private ConceptComparator conceptComparator = new ConceptComparator(); @@ -100,6 +118,10 @@ private boolean useBooleanDatatypes = true; public RhoDRDown(ReasoningService rs) { + this(rs, null); + } + + public RhoDRDown(ReasoningService rs, NamedClass startClass) { this.rs = rs; subHierarchy = rs.getSubsumptionHierarchy(); @@ -111,7 +133,10 @@ } for(DatatypeProperty dp : rs.getDatatypeProperties()) { dpDomains.put(dp, rs.getDomain(dp)); - } + } + + if(startClass != null) + this.startClass = startClass; } /* (non-Javadoc) @@ -129,6 +154,7 @@ return refine(description, maxLength, knownRefinements, new Thing()); } + @SuppressWarnings({"unchecked"}) public Set<Description> refine(Description description, int maxLength, List<Description> knownRefinements, Description currDomain) { // TODO: check whether using list or set makes more sense @@ -141,7 +167,18 @@ // function) if(description instanceof Thing) { - refinements.addAll(subHierarchy.getMoreSpecialConcepts(description)); + // extends top refinements if necessary + if(currDomain instanceof Thing) { + if(maxLength>topRefinementsLength) + computeTopRefinements(maxLength); + refinements = (TreeSet<Description>) topRefinementsCumulative.get(maxLength).clone(); + } else { + if(maxLength>topARefinementsLength.get(currDomain)) + computeTopRefinements(maxLength); + refinements = (TreeSet<Description>) topRefinementsCumulative.get(maxLength).clone(); + } + +// refinements.addAll(subHierarchy.getMoreSpecialConcepts(description)); } else if(description instanceof Nothing) { // cannot be further refined } else if(description instanceof NamedClass) { @@ -151,8 +188,11 @@ return refinements; } - // TODO: später private - public void computeTopRefinements(int maxLength) { + private void computeTopRefinements(int maxLength) { + computeTopRefinements(maxLength, null); + } + + private void computeTopRefinements(int maxLength, NamedClass domain) { long topComputationTimeStartNs = System.nanoTime(); // M erweiteren @@ -229,98 +269,86 @@ topComputationTimeNs += System.nanoTime() - topComputationTimeStartNs; } - // computation of the set M + // compute M_\top private void computeM(int maxLength) { + computeM(maxLength, null); + } + + // computation of the set M_A + // a major difference compared to the ILP 2007 \rho operator is that + // M is finite and contains elements of length (currently) at most 3 + private void computeM(int maxLength, NamedClass domain) { long mComputationTimeStartNs = System.nanoTime(); - // System.out.println("compute M from " + (topRefinementsLength+1) + " up to " + maxLength); - - // initialise all not yet initialised lengths - // (avoids null pointers in some cases) - for(int i=topRefinementsLength+1; i<=maxLength; i++) { + + // initialise all possible lengths (1 to 3) + for(int i=1; i<=3; i++) { m.put(i, new TreeSet<Description>(conceptComparator)); } - // Berechnung der Basiskonzepte in M - // TODO: Spezialfälle, dass zwischen Top und Bottom nichts liegt behandeln - if(topRefinementsLength==0 && maxLength>0) { - // Konzepte der Länge 1 = alle Konzepte, die in der Subsumptionhierarchie unter Top liegen - Set<Description> m1 = rs.getMoreSpecialConcepts(new Thing()); - m.put(1,m1); - } + Set<Description> m1 = rs.getMoreSpecialConcepts(new Thing()); + m.put(1,m1); - if(topRefinementsLength<2 && maxLength>1) { - // Konzepte der Länge 2 = Negation aller Konzepte, die über Bottom liegen - if(useNegation) { - Set<Description> m2tmp = rs.getMoreGeneralConcepts(new Nothing()); - Set<Description> m2 = new TreeSet<Description>(conceptComparator); - for(Description c : m2tmp) { - m2.add(new Negation(c)); - } - m.put(2,m2); + if(useNegation) { + Set<Description> m2tmp = rs.getMoreGeneralConcepts(new Nothing()); + Set<Description> m2 = new TreeSet<Description>(conceptComparator); + for(Description c : m2tmp) { + m2.add(new Negation(c)); } + m.put(2,m2); } - if(topRefinementsLength<3 && maxLength>2) { - // Konzepte der Länge 3: EXISTS r.TOP - Set<Description> m3 = new TreeSet<Description>(conceptComparator); - if(useExistsConstructor) { - // previous operator: uses all roles - // for(AtomicRole r : Config.Refinement.allowedRoles) { - // m3.add(new Exists(r, new Top())); - //} - // new operator: only uses most general roles - for(ObjectProperty r : rs.getMostGeneralRoles()) { - m3.add(new ObjectSomeRestriction(r, new Thing())); - } - - } - - // boolean datatypes, e.g. testPositive = true - if(useBooleanDatatypes) { - Set<DatatypeProperty> booleanDPs = rs.getBooleanDatatypeProperties(); - for(DatatypeProperty dp : booleanDPs) { - m3.add(new BooleanValueRestriction(dp,true)); - m3.add(new BooleanValueRestriction(dp,false)); - } - } - - m.put(3,m3); + Set<Description> m3 = new TreeSet<Description>(conceptComparator); + if(useExistsConstructor) { + // only uses most general roles + for(ObjectProperty r : rs.getMostGeneralRoles()) { + m3.add(new ObjectSomeRestriction(r, new Thing())); + } } - if(maxLength>2) { - if(useAllConstructor) { - // Konzepte, die mit ALL r starten - // alle existierenden Konzepte durchgehen, die maximal 2 k�rzer als - // die maximale L�nge sind - // topRefinementsLength - 1, damit Konzepte der Länge mindestens - // topRefinementsLength + 1 erzeugt werden (ALL r) - for(int i=topRefinementsLength-1; i<=maxLength-2; i++) { - // i muss natürlich mindestens 1 sein - if(i>=1) { - - // alle Konzepte durchgehen - for(Description c : m.get(i)) { - // Fall wird jetzt weiter oben schon abgehandelt - // if(!m.containsKey(i+2)) - // m.put(i+2, new TreeSet<Concept>(conceptComparator)); - - // previous operator: uses all roles - // for(AtomicRole r : Config.Refinement.allowedRoles) { - // Mehrfacheinf�gen ist bei einer Menge kein Problem - // m.get(i+2).add(new All(r,c)); - // } - - for(ObjectProperty r : rs.getMostGeneralRoles()) { - m.get(i+2).add(new ObjectAllRestriction(r,c)); - } - } - } - } + if(useAllConstructor) { + // we allow \forall r.\top here because otherwise the operator + // becomes too difficult to manage due to dependencies between + // M_A and M_A' where A'=ran(r) + for(ObjectProperty r : rs.getMostGeneralRoles()) { + m3.add(new ObjectAllRestriction(r, new Thing())); + } + } + + // boolean datatypes, e.g. testPositive = true + if(useBooleanDatatypes) { + Set<DatatypeProperty> booleanDPs = rs.getBooleanDatatypeProperties(); + for(DatatypeProperty dp : booleanDPs) { + m3.add(new BooleanValueRestriction(dp,true)); + m3.add(new BooleanValueRestriction(dp,false)); } } + m.put(3,m3); + mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; } + // computes the set of applicable properties for a given class + private void computeApp(NamedClass domain) { + // TODO: also implement this for boolean/double datatype properties + Set<ObjectProperty> mostGeneral = rs.getAtomicRoles(); + Set<ObjectProperty> applicableRoles = new TreeSet<ObjectProperty>(); + for(ObjectProperty role : mostGeneral) { + // TODO: currently we just rely on named classes as roles, + // instead of computing dom(r) and ran(r) + NamedClass nc = (NamedClass) rs.getDomain(role); + if(!isDisjoint(domain,nc)) + applicableRoles.add(role); + } + appOP.put(domain, applicableRoles); + } -} + // computes whether two classes are disjoint; this should be computed + // by the reasoner only ones and otherwise taken from a matrix + private boolean isDisjoint(NamedClass class1, NamedClass class2) { + // we need to test whether A AND B is equivalent to BOTTOM + Description d = new Intersection(class1, class2); + return rs.subsumes(new Nothing(), d); + } + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-02 15:41:07
|
Revision: 671 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=671&view=rev Author: tonytacker Date: 2008-03-02 07:40:29 -0800 (Sun, 02 Mar 2008) Log Message: ----------- some statistics for algorithm Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-03-02 15:40:29 UTC (rev 671) @@ -48,6 +48,9 @@ private LearningAlgorithm la; private LearningAlgorithm oldLearningAlgorithm; private boolean[] isInit = new boolean[4]; + private Boolean threadIsRunning = false; + private Long algorithmRunStartTime = null; + private Long algorithmRunStopTime = null; /** * Get ComponentManager. @@ -274,4 +277,38 @@ isInit[3] = is; } + /** + * Set true if you start the algorithm. + * + * @param isThreadRunning + */ + public void setThreadIsRunning(Boolean isThreadRunning) { + if (isThreadRunning) + algorithmRunStartTime = System.nanoTime(); + else if (algorithmRunStartTime != null) + if (algorithmRunStartTime < System.nanoTime()) + algorithmRunStopTime = System.nanoTime(); + this.threadIsRunning = isThreadRunning; + } + + /** + * Get true if algorithm has started, false if not. + * + * @return true if algorithm is running, false if not. + */ + public Boolean getThreadIsRunning() { + return this.threadIsRunning; + } + + /** + * Get time in ns for run of algorithm. + * + * @return time in ns + */ + public Long getAlgorithmRunTime() { + if (algorithmRunStartTime != null && algorithmRunStopTime != null) + if (algorithmRunStartTime < algorithmRunStopTime) + return algorithmRunStopTime - algorithmRunStartTime; + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-03-02 15:40:29 UTC (rev 671) @@ -34,7 +34,7 @@ import java.io.PrintWriter; /** - * Open a config file. + * Save a config file. * * @author Tilo Hielscher */ Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-02 15:40:29 UTC (rev 671) @@ -25,6 +25,7 @@ import java.awt.event.ActionListener; import javax.swing.*; +import java.lang.Long; /** * RunPanel let algorithm start and stop and show informations about. @@ -36,7 +37,8 @@ private static final long serialVersionUID = 1643304576470046636L; - private JButton runButton, stopButton, getBestSolutionButton, getSolutionScoreButton; + private JButton runButton, stopButton, getBestSolutionButton, getSolutionScoreButton, + getReasonerStatsButton; private JTextArea infoArea; private Config config; @@ -63,6 +65,9 @@ getSolutionScoreButton = new JButton("GetSolutionScore"); getSolutionScoreButton.addActionListener(this); + getReasonerStatsButton = new JButton("GetReasonerStats"); + getReasonerStatsButton.addActionListener(this); + infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); @@ -73,6 +78,7 @@ solutionPanel.add(getBestSolutionButton); solutionPanel.add(getSolutionScoreButton); + solutionPanel.add(getReasonerStatsButton); add(showPanel, BorderLayout.PAGE_START); add(infoPanel, BorderLayout.CENTER); @@ -98,6 +104,58 @@ if (e.getSource() == getSolutionScoreButton && runBoolean) { infoArea.setText(config.getLearningAlgorithm().getSolutionScore().toString()); } + // ReasonerStats + if (e.getSource() == getReasonerStatsButton && runBoolean) { + infoArea.setText(""); + infoArea.append("Algorithm Runtime: " + + makeTime(config.getAlgorithmRunTime()) + "\n"); + infoArea.append("OverallReasoningTime: " + + makeTime(config.getReasoningService().getOverallReasoningTimeNs()) + "\n"); + infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() + + "): "); + if (config.getReasoningService().getNrOfInstanceChecks() > 0) + infoArea.append(makeTime(config.getReasoningService().getTimePerInstanceCheckNs()) + + "\n"); + else + infoArea.append(" - \n"); + infoArea.append("Retrieval (" + config.getReasoningService().getNrOfRetrievals() + + "): "); + if (config.getReasoningService().getNrOfRetrievals() > 0) + infoArea.append(makeTime(config.getReasoningService().getTimePerRetrievalNs()) + + "\n"); + else + infoArea.append(" - \n"); + infoArea.append("Subsumption (" + + config.getReasoningService().getNrOfSubsumptionChecks() + "): " + + makeTime(config.getReasoningService().getTimePerSubsumptionCheckNs()) + "\n"); + } } + /** + * Build a String form nanoSeconds. + * + * @param nanoSeconds + * is type of Long and represent a time interval in ns + * @return a string like this: 3h 12min 46s 753ms + */ + public String makeTime(Long nanoSeconds) { + String time = ""; + Integer hours = 0, minutes = 0, seconds = 0, miliSeconds = 0; + nanoSeconds /= 1000000; // miliSeconds + hours = Math.round(nanoSeconds / 1000 / 60 / 60); + minutes = Math.round(nanoSeconds / 1000 / 60); + seconds = Math.round(nanoSeconds / 1000); + miliSeconds = Math.round(nanoSeconds - (hours * 1000 * 60 * 60) - (minutes * 1000 * 60) + - (seconds * 1000)); + if (hours > 0) + time += hours + "h "; + if (minutes > 0) + time += minutes + "min "; + if (seconds > 0) + time += seconds + "s "; + if (miliSeconds > 0) + time += miliSeconds + "ms "; + // System.out.println("time: " + time); + return time; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-03-02 15:40:29 UTC (rev 671) @@ -38,8 +38,11 @@ */ @Override public void run() { - if (config.getLearningAlgorithm() != null) + if (config.getLearningAlgorithm() != null) { + config.setThreadIsRunning(true); config.getLearningAlgorithm().start(); + config.setThreadIsRunning(false); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-29 10:56:34
|
Revision: 670 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=670&view=rev Author: sknappe Date: 2008-02-29 02:56:30 -0800 (Fri, 29 Feb 2008) Log Message: ----------- searchbox not shown Modified Paths: -------------- trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-02-29 09:17:28 UTC (rev 669) +++ trunk/src/dbpedia-navigator/index.php 2008-02-29 10:56:30 UTC (rev 670) @@ -52,7 +52,7 @@ }; hideLoading = function() { xajax.$('Loading').style.display = 'none'; - xajax.$('SearchResultBox').style.display = 'block'; + //xajax.$('SearchResultBox').style.display = 'block'; xajax.$('LastArticlesBox').style.display = 'block'; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-29 09:17:34
|
Revision: 669 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=669&view=rev Author: sknappe Date: 2008-02-29 01:17:28 -0800 (Fri, 29 Feb 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-29 05:41:38 UTC (rev 668) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-29 09:17:28 UTC (rev 669) @@ -34,6 +34,7 @@ $objResponse = new xajaxResponse(); $objResponse->assign("articlecontent", "innerHTML", $content); + $objResponse->assign("ArticleTitle","innerHTML","Searchresult for ".$label); return $objResponse; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-29 05:41:41
|
Revision: 668 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=668&view=rev Author: tonytacker Date: 2008-02-28 21:41:38 -0800 (Thu, 28 Feb 2008) Log Message: ----------- save file works Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-02-29 00:06:36 UTC (rev 667) +++ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-02-29 05:41:38 UTC (rev 668) @@ -62,9 +62,9 @@ public String getValueFormatting(Boolean value, Integer special) { if (value != null) { if (value) - return "true"; + return "true;"; else - return "false"; + return "false;"; } else return null; } Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2008-02-29 00:06:36 UTC (rev 667) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2008-02-29 05:41:38 UTC (rev 668) @@ -57,12 +57,12 @@ * @return a formatted string */ public String toConfString(String componentName) { - if (option.getName() == "positiveExamples") { + if (option.getName().equalsIgnoreCase("positiveExamples")) { return option.getValueFormatting(value, 1); - } else if (option.getName() == "negativeExamples") { + } else if (option.getName().equalsIgnoreCase("negativeExamples")) { return option.getValueFormatting(value, 2); - } else - return componentName.toString() + "." + option.getName() + " = " + } + return componentName.toString() + "." + option.getName() + " = " + option.getValueFormatting(value, 0); } } Modified: trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-02-29 00:06:36 UTC (rev 667) +++ trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-02-29 05:41:38 UTC (rev 668) @@ -110,7 +110,7 @@ @Override public String getValueFormatting(Double value, Integer special) { if (value != null) - return value.toString(); + return value.toString() + ";"; else return null; } Modified: trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-02-29 00:06:36 UTC (rev 667) +++ trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-02-29 05:41:38 UTC (rev 668) @@ -110,7 +110,7 @@ @Override public String getValueFormatting(Integer value, Integer special) { if (value != null) - return value.toString(); + return value.toString() + ";"; else return null; } Modified: trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-02-29 00:06:36 UTC (rev 667) +++ trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-02-29 05:41:38 UTC (rev 668) @@ -92,7 +92,7 @@ @Override public String getValueFormatting(String value, Integer special) { if (value != null) - return value.toString(); + return value.toString() + ";"; else return null; } Modified: trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-02-29 00:06:36 UTC (rev 667) +++ trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-02-29 05:41:38 UTC (rev 668) @@ -91,8 +91,13 @@ } // negative examples if (value != null && special == 2) { + Integer count = 0; for (String i : value) { - back += "\n-\"" + i + "\""; + count++; + if (count == 1) + back += "-\"" + i + "\""; + else + back += "\n-\"" + i + "\""; } return back + "\n"; } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-29 00:06:36 UTC (rev 667) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-29 05:41:38 UTC (rev 668) @@ -93,6 +93,7 @@ config.setKnowledgeSource(config.getKnowledgeSource()); Start.configureComponent(config.getComponentManager(), config.getKnowledgeSource(), componentPrefixMapping, parser); + startGUI.updateTabColors(); // init if (config.getKnowledgeSource() != null && config.isSetURL()) { try { Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-02-29 00:06:36 UTC (rev 667) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-02-29 05:41:38 UTC (rev 668) @@ -31,6 +31,7 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.cli.*; +import java.io.PrintWriter; /** * Open a config file. @@ -57,9 +58,12 @@ /** * parse to file + * + * @param out + * is a PrintWriter to a file */ @SuppressWarnings("unchecked") - public void startParser() { + public void startParser(PrintWriter out) { // KNOWLEDGE SOURCE (sparql or nothing) if (config.getKnowledgeSource() != null) { // KBFile or OWLFile @@ -69,14 +73,19 @@ String url = (String) config.getComponentManager().getConfigOptionValue( config.getKnowledgeSource(), "url"); if (url != null) { - System.out.println("import(\"" + url + "\");"); + if (url.startsWith("file")) + url = url.substring(url.lastIndexOf("/") + 1); + // System.out.println("import(\"" + url + "\");"); + out.println("import(\"" + url + "\");"); } // filename (only for KBFile) if (config.getKnowledgeSource().getClass().toString().endsWith("KBFile")) { String filename = (String) config.getComponentManager().getConfigOptionValue( config.getKnowledgeSource(), "filename"); if (filename != null) { - System.out.println("import(\"" + filename + "\");"); + filename = filename.substring(filename.lastIndexOf("/") + 1); + // System.out.println("import(\"" + filename + "\");"); + out.println("import(\"" + filename + "\");"); } } } @@ -85,21 +94,22 @@ String url = (String) config.getComponentManager().getConfigOptionValue( config.getKnowledgeSource(), "url"); if (url != null) { - setFileEntry(config.getKnowledgeSource()); + out.println("import(\"" + url + "\",\"SPARQL\");"); + setFileEntry(config.getKnowledgeSource(), out); } } } // REASONER if (config.getReasoner() != null) { - setFileEntry(config.getReasoner()); + setFileEntry(config.getReasoner(), out); } // LEARNING PROBLEM if (config.getLearningProblem() != null) { - setFileEntry(config.getLearningProblem()); + setFileEntry(config.getLearningProblem(), out); } // LEARNING ALGORITHM if (config.getLearningAlgorithm() != null) { - setFileEntry(config.getLearningAlgorithm()); + setFileEntry(config.getLearningAlgorithm(), out); } } @@ -111,7 +121,7 @@ * i.e. config.getKnowledgeSource(), config.getResaoner(), ... */ @SuppressWarnings("unchecked") - public void setFileEntry(Component component) { + public void setFileEntry(Component component, PrintWriter out) { // get prefix map Map<Class<? extends Component>, String> componentPrefixMapping = Start .createComponentPrefixMapping(); @@ -125,7 +135,7 @@ Object dflt = optionList.get(i).getDefaultValue(); Object value = config.getComponentManager().getConfigOptionValue(component, optionList.get(i).getName()); - // System.out.println("default: " + dflt); + // not for url or filename if (optionList.get(i).getName() != "url" && optionList.get(i).getName() != "filename" && value != null) { if (value != null) @@ -133,7 +143,7 @@ ConfigOption specialOption = config.getComponentManager() .getConfigOption(componentOption, optionList.get(i).getName()); ConfigEntry entry = new ConfigEntry(specialOption, value); - System.out.println(entry.toConfString(prefix)); + out.println(entry.toConfString(prefix)); } } } catch (InvalidConfigOptionValueException e) { Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-29 00:06:36 UTC (rev 667) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-29 05:41:38 UTC (rev 668) @@ -33,6 +33,8 @@ import org.apache.log4j.SimpleLayout; import java.io.File; +import java.io.PrintWriter; +import java.io.FileWriter; import javax.swing.filechooser.FileFilter; /** @@ -59,7 +61,7 @@ private JMenuBar menuBar = new JMenuBar(); private JMenu menuFile = new JMenu("File"); private JMenuItem openItem = new JMenuItem("Open Config"); - private JMenuItem saveItem = new JMenuItem("Save Config"); + private JMenuItem saveItem = new JMenuItem("Save As Config"); public StartGUI() { this.setTitle("DL-Learner"); @@ -140,10 +142,37 @@ configLoad.startParser(); } } - // save config file + // save as config file if (e.getSource() == saveItem) { - System.out.println("saveItem was pressed"); - configSave.startParser(); + JFileChooser fc = new JFileChooser(new File("examples/")); + // FileFilter only *.conf + fc.addChoosableFileFilter(new FileFilter() { + @Override + public boolean accept(File f) { + if (f.isDirectory()) + return true; + return f.getName().toLowerCase().endsWith(".conf"); + } + + @Override + public String getDescription() { + return "*.conf"; // name for filter + } + }); + if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { + // System.out.println("FILE: " + fc.getSelectedFile()); + File file = fc.getSelectedFile(); + try { + PrintWriter out = new PrintWriter(new FileWriter(file)); + // out.println("test"); + configSave.startParser(out); + out.flush(); + out.close(); + } catch (Exception ex2) { + System.out.println(ex2); + } + } + System.out.println("config file saved"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-29 00:06:42
|
Revision: 667 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=667&view=rev Author: sknappe Date: 2008-02-28 16:06:36 -0800 (Thu, 28 Feb 2008) Log Message: ----------- tagcloud, a bit slow at the moment Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-28 23:55:17 UTC (rev 666) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-29 00:06:36 UTC (rev 667) @@ -174,26 +174,55 @@ { $offset=1; $ret=array(); + $labels=preg_split("[\040]",$label,-1,PREG_SPLIT_NO_EMPTY); + //TODO if instances are checked the offset no longer works do{ if (isset($checkedInstances[0])){ - $query="SELECT DISTINCT ?subject\n". + $query="SELECT DISTINCT ?subject ?cat ?label\n". "WHERE {?subject a <".$checkedInstances[0].">.{SELECT ?zw as ?subject\n". - "WHERE { ?zw <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains \"".$label."\"@en}\n". - "LIMIT 1000 OFFSET ".$offset."}}"; + "WHERE { ?zw <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '"; + $i=0; + foreach ($labels as $l){ + if ($i==0) $query.="\"".$l."\""; + else $query.=" and \"".$l."\""; + $i=1; + } + $query.="'@en.?subject a ?cat.?cat <http://www.w3.org/2000/01/rdf-schema#label> ?label}\n". + "LIMIT 100 OFFSET ".$offset."}}"; }else { - $query="SELECT DISTINCT ?subject\n". - "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains \"".$label."\"@en}". - "LIMIT 1000 OFFSET ".$offset; + $query="SELECT DISTINCT ?subject ?cat ?label\n". + "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '"; + $i=0; + foreach ($labels as $l){ + if ($i==0) $query.="\"".$l."\""; + else $query.=" and \"".$l."\""; + $i=1; + } + $query.="'@en.?subject a ?cat.?cat <http://www.w3.org/2000/01/rdf-schema#label> ?label}". + "LIMIT 100 OFFSET ".$offset; } $result=json_decode($this->getSparqlResultThreaded($query),true); $count=count($result['results']['bindings']); if (($count==0)&&($offset==1)) throw new Exception("Your query brought no result."); foreach ($result['results']['bindings'] as $results){ - $ret[]=$results['subject']['value']; + $ret[$results['subject']['value']]=$results['subject']['value']; + //tagcloud + if (!isset($tagcloud[$results['cat']['value']])){ + $tagcloud[$results['cat']['value']]=1; + $tagcloudLabel[$results['cat']['value']]=$results['label']['value']; + } + else $tagcloud[$results['cat']['value']]++; + } - $offset+=1000; - } while($count==1000); - return $ret; + $offset+=100; + } while($count==100); + //have to do this, because distinct doesn't work, and i use the key to eliminate doubles + unset($tagcloud['http://www.w3.org/2004/02/skos/core#Concept']); + foreach ($ret as $r) + $return['subjects'][]=$r; + $return['tagcloud']=$tagcloud; + $return['tagcloudlabel']=$tagcloudLabel; + return $return; } function getSubjectsFromConcept($concept) @@ -303,6 +332,6 @@ $sc=new DLLearnerConnection(); $ids=$sc->getIDs(); $sc=new DLLearnerConnection($ids[0],$ids[1]); -$triples=$sc->getSubjects("Paris"); +$triples=$sc->getSubjects("Leipzig"); var_dump($triples);*/ ?> Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-28 23:55:17 UTC (rev 666) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-29 00:06:36 UTC (rev 667) @@ -26,7 +26,8 @@ $subjects=$sc->getSubjects($label,$checkedInstances); - $content.=getResultsTable($subjects); + $content.=getTagCloud($subjects['tagcloud'],$subjects['tagcloudlabel']); + $content.=getResultsTable($subjects['subjects']); } catch (Exception $e){ $content=$e->getMessage(); } @@ -451,6 +452,27 @@ // Helper Functions. // /////////////////////// +function getTagCloud($tags,$label) +{ + $max=max($tags); + $min=min($tags); + $diff=$max-$min; + $distribution=$diff/3; + + $ret="<p>"; + foreach ($tags as $tag=>$count){ + if ($count==$min) $style="font-size:xx-small;"; + else if ($count==$max) $style="font-size:xx-large;"; + else if ($count>($min+2*$distribution)) $style="font-size:large;"; + else if ($count>($min+$distribution)) $style="font-size:medium;"; + else $style="font-size:small;"; + + $ret.="<a style='".$style."' href='".$tag."'>".$label[$tag]."</a> "; + } + $ret.="</p>"; + return $ret; +} + function getResultsTable($results) { $ret="<p>Your search brought ".count($results)." results.</p><br/>"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-28 23:55:26
|
Revision: 666 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=666&view=rev Author: tonytacker Date: 2008-02-28 15:55:17 -0800 (Thu, 28 Feb 2008) Log Message: ----------- small fix Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2008-02-28 23:17:17 UTC (rev 665) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2008-02-28 23:55:17 UTC (rev 666) @@ -57,7 +57,7 @@ * @return a formatted string */ public String toConfString(String componentName) { - if (option.getName().equalsIgnoreCase("positiveExamples")) { + if (option.getName() == "positiveExamples") { return option.getValueFormatting(value, 1); } else if (option.getName() == "negativeExamples") { return option.getValueFormatting(value, 2); Modified: trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-02-28 23:17:17 UTC (rev 665) +++ trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-02-28 23:55:17 UTC (rev 666) @@ -85,14 +85,14 @@ // positive examples if (value != null && special == 1) { for (String i : value) { - back += "\n+" + i; + back += "\n+\"" + i + "\""; } return back + "\n"; } // negative examples if (value != null && special == 2) { for (String i : value) { - back += "\n-" + i; + back += "\n-\"" + i + "\""; } return back + "\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-28 23:17:46
|
Revision: 665 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=665&view=rev Author: tonytacker Date: 2008-02-28 15:17:17 -0800 (Thu, 28 Feb 2008) Log Message: ----------- save config (only system.out.println) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java Modified: trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-02-28 23:17:17 UTC (rev 665) @@ -19,10 +19,9 @@ */ package org.dllearner.core.config; - /** * @author Jens Lehmann - * + * */ public class BooleanConfigOption extends ConfigOption<Boolean> { @@ -33,8 +32,10 @@ public BooleanConfigOption(String name, String description, boolean defaultValue) { super(name, description, defaultValue); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) */ @Override @@ -42,7 +43,9 @@ return (object instanceof Boolean); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) */ @Override @@ -50,12 +53,20 @@ return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) */ @Override - public String getValueFormatting(Boolean value) { - return value.toString(); + public String getValueFormatting(Boolean value, Integer special) { + if (value != null) { + if (value) + return "true"; + else + return "false"; + } else + return null; } } Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2008-02-28 23:17:17 UTC (rev 665) @@ -19,45 +19,50 @@ */ package org.dllearner.core.config; - /** * A config entry is a configuration option and a value for the option. * * @author Jens Lehmann - * + * */ public class ConfigEntry<T> { private ConfigOption<T> option; private T value; - + public ConfigEntry(ConfigOption<T> option, T value) throws InvalidConfigOptionValueException { - if(!option.isValidValue(value)) { + if (!option.isValidValue(value)) { throw new InvalidConfigOptionValueException(option, value); } else { this.option = option; this.value = value; } } - + public ConfigOption<T> getOption() { return option; } - + public String getOptionName() { return option.getName(); } - + public T getValue() { return value; } - + /** * Get a string to save into a configuration file. * * @return a formatted string */ public String toConfString(String componentName) { - return componentName.toString() + "." + option.getName() + " = " + option.getValueFormatting(value); + if (option.getName().equalsIgnoreCase("positiveExamples")) { + return option.getValueFormatting(value, 1); + } else if (option.getName() == "negativeExamples") { + return option.getValueFormatting(value, 2); + } else + return componentName.toString() + "." + option.getName() + " = " + + option.getValueFormatting(value, 0); } } Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-02-28 23:17:17 UTC (rev 665) @@ -23,68 +23,81 @@ * This class represents a configuration option (without a value for the * option). * - * Note: Currently, handling the type of a configuration option is not - * straightforward to implement, because Java Generics information is - * erased at runtime. This will be fixed in Java 7, in particular JSR 308, - * which is due at approx. the end of 2008. + * Note: Currently, handling the type of a configuration option is not + * straightforward to implement, because Java Generics information is erased at + * runtime. This will be fixed in Java 7, in particular JSR 308, which is due at + * approx. the end of 2008. * * @author Jens Lehmann - * + * */ public abstract class ConfigOption<T> { protected String name; - + protected String description; - + protected T defaultValue; - + public ConfigOption(String name, String description) { this(name, description, null); } - + public ConfigOption(String name, String description, T defaultValue) { this.name = name; this.description = description; this.defaultValue = defaultValue; } - + public String getName() { return name; } - + public String getDescription() { return description; - } - + } + /** * @return the defaultValue */ public T getDefaultValue() { return defaultValue; - } - + } + /** - * Checks whether the object has the correct type to be used as - * a value for this option (this method is necessary, because - * generic information is erased at runtime in Java). - * - * @param object The object to check. + * Checks whether the object has the correct type to be used as a value for + * this option (this method is necessary, because generic information is + * erased at runtime in Java). + * + * @param object + * The object to check. * @return */ public abstract boolean checkType(Object object); - + public abstract boolean isValidValue(T value); - + public String getAllowedValuesDescription() { return getClass().toString(); } - + @Override public String toString() { - return "option name: " + name + "\ndescription: " + description + "\nvalues: " + getAllowedValuesDescription() + "\ndefault value: " + defaultValue + "\n"; + return "option name: " + name + "\ndescription: " + description + "\nvalues: " + + getAllowedValuesDescription() + "\ndefault value: " + defaultValue + "\n"; } - - public abstract String getValueFormatting(T value); + /** + * Get a formatted value to put into configuration file. + * + * @param value + * @param special + * 0 for normal output. + * 1 for positiveExamples. + * 2 for negativeExamples. + * + * @return a string to put into a file + */ + public abstract String getValueFormatting(T value, Integer special); + } Modified: trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-02-28 23:17:17 UTC (rev 665) @@ -19,38 +19,39 @@ */ package org.dllearner.core.config; - /** - * Represents a configuration option with values of type value. Similar - * to the integer option a minimum and a maximum value can specified. + * Represents a configuration option with values of type value. Similar to the + * integer option a minimum and a maximum value can specified. * * @author Jens Lehmann - * + * */ public class DoubleConfigOption extends ConfigOption<Double> { private double lowerLimit = Double.MIN_VALUE; private double upperLimit = Double.MAX_VALUE; - + public DoubleConfigOption(String name, String description) { super(name, description); } - + public DoubleConfigOption(String name, String description, double defaultValue) { super(name, description, defaultValue); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) */ @Override public boolean isValidValue(Double value) { - if(value >= lowerLimit && value <= upperLimit) + if (value >= lowerLimit && value <= upperLimit) return true; else - return false; + return false; } - + /** * @return the The lowest possible value for this configuration option. */ @@ -59,7 +60,8 @@ } /** - * @param lowerLimit The lowest possible value for this configuration option. + * @param lowerLimit + * The lowest possible value for this configuration option. */ public void setLowerLimit(double lowerLimit) { this.lowerLimit = lowerLimit; @@ -73,26 +75,29 @@ } /** - * @param upperLimit The highest possible value for this configuration option. + * @param upperLimit + * The highest possible value for this configuration option. */ public void setUpperLimit(double upperLimit) { this.upperLimit = upperLimit; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) */ @Override public boolean checkType(Object object) { return (object instanceof Double); } - + @Override public String getAllowedValuesDescription() { String str = getClass().toString(); - if(lowerLimit != Double.MIN_VALUE) + if (lowerLimit != Double.MIN_VALUE) str += " min " + lowerLimit; - if(upperLimit != Double.MAX_VALUE) + if (upperLimit != Double.MAX_VALUE) str += " max " + upperLimit; return str; } @@ -103,8 +108,11 @@ * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) */ @Override - public String getValueFormatting(Double value) { - return value.toString(); + public String getValueFormatting(Double value, Integer special) { + if (value != null) + return value.toString(); + else + return null; } } Modified: trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-02-28 23:17:17 UTC (rev 665) @@ -108,7 +108,10 @@ * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) */ @Override - public String getValueFormatting(Integer value) { - return value.toString(); + public String getValueFormatting(Integer value, Integer special) { + if (value != null) + return value.toString(); + else + return null; } } Modified: trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-02-28 23:17:17 UTC (rev 665) @@ -90,8 +90,11 @@ * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) */ @Override - public String getValueFormatting(String value) { - return value.toString(); + public String getValueFormatting(String value, Integer special) { + if (value != null) + return value.toString(); + else + return null; } } Modified: trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-02-28 23:17:17 UTC (rev 665) @@ -68,8 +68,34 @@ * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) */ @Override - public String getValueFormatting(Set<String> value) { - return value.toString(); + public String getValueFormatting(Set<String> value, Integer special) { + String back = ""; + if (value != null && special == 0) { + Integer count = 0; + back = "{"; + for (String i : value) { + if (count > 0) + back += ","; + back += "\n\"" + i + "\""; + count++; + } + back += "};"; + return back; + } + // positive examples + if (value != null && special == 1) { + for (String i : value) { + back += "\n+" + i; + } + return back + "\n"; + } + // negative examples + if (value != null && special == 2) { + for (String i : value) { + back += "\n-" + i; + } + return back + "\n"; + } + return null; } - } Modified: trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java 2008-02-28 23:17:17 UTC (rev 665) @@ -75,8 +75,20 @@ * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) */ @Override - public String getValueFormatting(List<StringTuple> value) { - return value.toString(); + public String getValueFormatting(List<StringTuple> value, Integer special) { + Integer count = 0; + if (value != null) { + String back = "["; + for (StringTuple i : value) { + if (count > 0) + back += ","; + back += "\n(\"" + i.a + "\",\"" + i.b + "\")"; + count++; + } + back += "];"; + return back; + } else + return null; } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-02-28 23:17:17 UTC (rev 665) @@ -23,19 +23,15 @@ //import java.io.File; //import java.net.URL; import java.util.List; //import java.util.Map; -//import java.util.SortedSet; -//import org.dllearner.core.ComponentInitException; +import java.util.Map; + import org.dllearner.core.ComponentManager; //import org.dllearner.core.KnowledgeSource; -//import org.dllearner.core.LearningProblemUnsupportedException; -//import org.dllearner.learningproblems.PosOnlyDefinitionLP; -//import org.dllearner.parser.ConfParser; import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.cli.*; -//import org.dllearner.cli.ConfFileOption; -//import org.dllearner.cli.Start; -//import org.dllearner.core.config.*; - /** * Open a config file. * @@ -62,11 +58,10 @@ /** * parse to file */ + @SuppressWarnings("unchecked") public void startParser() { - // KNOWLEDGE SOURCE + // KNOWLEDGE SOURCE (sparql or nothing) if (config.getKnowledgeSource() != null) { - // System.out.println("knowledge_source: " + - // config.getKnowledgeSource().getClass()); // KBFile or OWLFile if (config.getKnowledgeSource().getClass().toString().endsWith("KBFile") || config.getKnowledgeSource().getClass().toString().endsWith("OWLFile")) { @@ -76,11 +71,13 @@ if (url != null) { System.out.println("import(\"" + url + "\");"); } - // filename - String filename = (String) config.getComponentManager().getConfigOptionValue( - config.getKnowledgeSource(), "filename"); - if (filename != null) { - System.out.println("import(\"" + filename + "\");"); + // filename (only for KBFile) + if (config.getKnowledgeSource().getClass().toString().endsWith("KBFile")) { + String filename = (String) config.getComponentManager().getConfigOptionValue( + config.getKnowledgeSource(), "filename"); + if (filename != null) { + System.out.println("import(\"" + filename + "\");"); + } } } // sparql @@ -88,36 +85,59 @@ String url = (String) config.getComponentManager().getConfigOptionValue( config.getKnowledgeSource(), "url"); if (url != null) { - System.out.println("import(\"" + url + "\",\"SPARQL\");"); - // widgets - String prefix = "sparql"; - Component component = config.getKnowledgeSource(); + setFileEntry(config.getKnowledgeSource()); + } + } + } + // REASONER + if (config.getReasoner() != null) { + setFileEntry(config.getReasoner()); + } + // LEARNING PROBLEM + if (config.getLearningProblem() != null) { + setFileEntry(config.getLearningProblem()); + } + // LEARNING ALGORITHM + if (config.getLearningAlgorithm() != null) { + setFileEntry(config.getLearningAlgorithm()); + } - Class<? extends Component> componentOption = component.getClass(); // config.getKnowledgeSource().getClass(); - List<ConfigOption<?>> optionList; - optionList = ComponentManager.getConfigOptions(componentOption); - // System.out.println(optionList); - // System.out.println(config.getComponentManager().getConfigOptionValue(component, - // optionName)); - for (int i = 0; i < optionList.size(); i++) { - // if - // (optionList.get(i).getClass().toString().contains("IntegerConfigOption")) - // { - // widgetPanel = new WidgetPanelInteger(config, - // component, oldComponent, componentOption, - // optionList.get(i)); - // System.out.println(optionList.get(i)); - System.out.println(prefix - + "." - + optionList.get(i).getName() - + " = " - + config.getComponentManager().getConfigOptionValue(component, - optionList.get(i).getName())); - System.out.println(config.getComponentManager().getKnowledgeSources() - .get(0)); - // } - } + } + + /** + * Set all entrys to file. + * + * @param component + * i.e. config.getKnowledgeSource(), config.getResaoner(), ... + */ + @SuppressWarnings("unchecked") + public void setFileEntry(Component component) { + // get prefix map + Map<Class<? extends Component>, String> componentPrefixMapping = Start + .createComponentPrefixMapping(); + String prefix = componentPrefixMapping.get(component.getClass()); + if (prefix == null) + return; + Class<? extends Component> componentOption = component.getClass(); + List<ConfigOption<?>> optionList = ComponentManager.getConfigOptions(componentOption); + for (int i = 0; i < optionList.size(); i++) { + try { + Object dflt = optionList.get(i).getDefaultValue(); + Object value = config.getComponentManager().getConfigOptionValue(component, + optionList.get(i).getName()); + // System.out.println("default: " + dflt); + if (optionList.get(i).getName() != "url" + && optionList.get(i).getName() != "filename" && value != null) { + if (value != null) + if (!value.equals(dflt)) { + ConfigOption specialOption = config.getComponentManager() + .getConfigOption(componentOption, optionList.get(i).getName()); + ConfigEntry entry = new ConfigEntry(specialOption, value); + System.out.println(entry.toConfString(prefix)); + } } + } catch (InvalidConfigOptionValueException e) { + e.printStackTrace(); } } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-28 20:25:39 UTC (rev 664) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-28 23:17:17 UTC (rev 665) @@ -69,7 +69,10 @@ } public void actionPerformed(ActionEvent e) { - + if (cb.getSelectedIndex() == 0) + value = false; + else + value = true; setEntry(); } @@ -100,14 +103,14 @@ else setEntry(); // set cb-index - if (value == false) + if (!value) cb.setSelectedIndex(0); else cb.setSelectedIndex(1); } } // default value - if (value != null && configOption.getDefaultValue() != null) { + else if (value != null && configOption.getDefaultValue() != null) { value = (Boolean) configOption.getDefaultValue(); } // value == null? @@ -115,12 +118,11 @@ value = false; } // set cb-index - if (value == false) + if (!value) cb.setSelectedIndex(0); else cb.setSelectedIndex(1); cb.addActionListener(this); - widgetPanel.add(cb); } // UNKNOWN @@ -139,10 +141,6 @@ @Override public void setEntry() { BooleanConfigOption specialOption; - if (cb.getSelectedIndex() == 0) - value = false; - else - value = true; specialOption = (BooleanConfigOption) config.getComponentManager().getConfigOption( componentOption, configOption.getName()); if (specialOption.isValidValue(value)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-28 20:25:43
|
Revision: 664 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=664&view=rev Author: sknappe Date: 2008-02-28 12:25:39 -0800 (Thu, 28 Feb 2008) Log Message: ----------- bugfixes Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/Settings.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-28 20:25:13 UTC (rev 663) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-28 20:25:39 UTC (rev 664) @@ -120,7 +120,7 @@ { $query="SELECT ?pred ?obj ". "WHERE {{<http://dbpedia.org/resource/".str_replace(' ','_',$label)."> ?pred ?obj}UNION{<http://dbpedia.org/resource/".str_replace(' ','_',$label)."> <http://dbpedia.org/property/redirect> ?Conc.?Conc ?pred ?obj}}"; - $result=json_decode($this->getSparqlResult($query),true); + $result=json_decode($this->getSparqlResultThreaded($query),true); if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result. The Label-Search is started."); $ret=array(); foreach ($result['results']['bindings'] as $results){ @@ -131,16 +131,16 @@ return $ret; } - function getSparqlResult($query) + function getSparqlResultThreaded($query) { $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "defaultGraphURIs", array("http://dbpedia.org")); $queryID=$this->client->sparqlQueryThreaded($this->id,$this->ksID,$query); $running=true; $i = 1; - $sleeptime = 0.5; + $sleeptime = 500000; do { // sleep a while - sleep($sleeptime); + usleep($sleeptime); $running=$this->client->isSparqlQueryRunning($this->id,$queryID); @@ -162,29 +162,37 @@ } while($seconds<$this->ttl); $this->client->stopSparqlThread($this->id,$queryID); } + + function getSparqlResult($query) + { + $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "defaultGraphURIs", array("http://dbpedia.org")); + $result=$this->client->sparqlQuery($this->id,$this->ksID,$query); + return $result; + } function getSubjects($label,$checkedInstances) { $offset=1; $ret=array(); do{ - if (strlen($checkedInstances[0])>0){ + if (isset($checkedInstances[0])){ $query="SELECT DISTINCT ?subject\n". "WHERE {?subject a <".$checkedInstances[0].">.{SELECT ?zw as ?subject\n". - "WHERE { ?zw <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}\n". + "WHERE { ?zw <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains \"".$label."\"@en}\n". "LIMIT 1000 OFFSET ".$offset."}}"; }else { $query="SELECT DISTINCT ?subject\n". - "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}". + "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains \"".$label."\"@en}". "LIMIT 1000 OFFSET ".$offset; } - $result=json_decode($this->getSparqlResult($query),true); - if ((count($result['results']['bindings'])==0)&&($offset==1)) throw new Exception("Your query brought no result."); + $result=json_decode($this->getSparqlResultThreaded($query),true); + $count=count($result['results']['bindings']); + if (($count==0)&&($offset==1)) throw new Exception("Your query brought no result."); foreach ($result['results']['bindings'] as $results){ $ret[]=$results['subject']['value']; } $offset+=1000; - } while(count($result['results']['bindings'])==1000); + } while($count==1000); return $ret; } @@ -192,7 +200,7 @@ { $query="SELECT DISTINCT ?subject\n". "WHERE { ?subject a <".$concept.">}\n"; - $result=json_decode($this->getSparqlResult($query),true); + $result=json_decode($this->getSparqlResultThreaded($query),true); if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result."); $ret=array(); foreach ($result['results']['bindings'] as $results){ @@ -291,6 +299,7 @@ } } /* +ini_set('default_socket_timeout',200); $sc=new DLLearnerConnection(); $ids=$sc->getIDs(); $sc=new DLLearnerConnection($ids[0],$ids[1]); Modified: trunk/src/dbpedia-navigator/Settings.php =================================================================== --- trunk/src/dbpedia-navigator/Settings.php 2008-02-28 20:25:13 UTC (rev 663) +++ trunk/src/dbpedia-navigator/Settings.php 2008-02-28 20:25:39 UTC (rev 664) @@ -36,7 +36,7 @@ // public DBpedia mirror // public $dbpediauri='http://dbpedia2.openlinksw.com:8890/isparql'; - public $sparqlttl=60; + public $sparqlttl=60000000; public $language="en"; Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-28 20:25:13 UTC (rev 663) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-28 20:25:39 UTC (rev 664) @@ -153,11 +153,6 @@ // display the remaining properties as list which can be used for further navigation $content .= '<br/><br/><br/>'.get_triple_table($triples); - //BUILD SEARCHRESULT - if ($fromCache==-1) - $searchResult.="<a href=\"\" onclick=\"var list=tree.getAllChecked();xajax_getsubjects('".$subject."',list);return false;\">Show more Results</a>"; - - //Restart the Session session_start(); @@ -222,7 +217,6 @@ $objResponse->assign("articlecontent", "innerHTML", $content); $objResponse->assign("ArticleTitle","innerHTML",$artTitle); $objResponse->assign("lastarticles","innerHTML",$lastArticles); - if ($searchResult!="") $objResponse->assign("searchcontent", "innerHTML", $searchResult); $objResponse->assign('Positives','innerHTML',$posInterests); $objResponse->assign('Negatives','innerHTML',$negInterests); return $objResponse; @@ -468,7 +462,7 @@ for ($j=0;($j<30)&&(($i*30+$j)<count($results));$j++) { $result=$results[$i*30+$j]; - $ret.=" <a href=\"\" onclick=\"xajax_getarticle('".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."</a><br/>"; + $ret.=" <a href=\"\" onclick=\"xajax_getarticle('".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."',-1);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."</a><br/>"; } $ret.="</div>"; $i++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-28 20:25:24
|
Revision: 663 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=663&view=rev Author: sknappe Date: 2008-02-28 12:25:13 -0800 (Thu, 28 Feb 2008) Log Message: ----------- bugfixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryThreaded.java trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQueryClasses.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-02-28 14:18:15 UTC (rev 662) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-02-28 20:25:13 UTC (rev 663) @@ -33,7 +33,6 @@ import org.apache.log4j.Logger; import com.hp.hpl.jena.query.ResultSet; -import com.hp.hpl.jena.query.ResultSetFormatter; /** * SPARQL query cache to avoid possibly expensive multiple queries. The queries @@ -213,19 +212,18 @@ * The SPARQL query. * @return Jena result set. */ - public ResultSet executeSparqlQuery(SparqlQuery query) { + public String executeSparqlQuery(SparqlQuery query) { String result = getCacheEntry(query.getQueryString()); if (result != null) { - return SparqlQuery.JSONtoResultSet(result); + return result; } else { query.send(); - ResultSet rs = query.getResultSet(); - if (rs!=null){ - String json = SparqlQuery.getAsJSON(rs); + String json = query.getResult(); + if (json!=null){ addToCache(query.getQueryString(), json); - return SparqlQuery.JSONtoResultSet(json); } - return rs; + else json=""; + return json; } } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-02-28 14:18:15 UTC (rev 662) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-02-28 20:25:13 UTC (rev 663) @@ -50,7 +50,7 @@ private String queryString; private QueryEngineHTTP queryExecution; private SparqlEndpoint endpoint; - private ResultSet rs = null; + private String json = null; private SparqlQueryException sendException=null; /** @@ -69,6 +69,7 @@ */ public ResultSet send() { isRunning = true; + ResultSet rs=null; logger.info(queryString); String service = endpoint.getURL().toString(); @@ -86,6 +87,7 @@ //TODO after overnext Jena release HttpQuery.urlLimit = 3*1024 ; rs = queryExecution.execSelect(); + json=SparqlQuery.getAsJSON(rs); logger.info(rs.getResultVars().toString()); } catch (Exception e){ sendException=new SparqlQueryException(e.getMessage()); @@ -104,8 +106,8 @@ return queryString; } - public ResultSet getResultSet() { - return rs; + public String getResult() { + return json; } public boolean isRunning() { @@ -121,37 +123,10 @@ } public boolean hasCompleted() { - return (rs != null); + return (json != null); } /** - * TODO define the format - * - * @return - */ - @Deprecated - @SuppressWarnings( { "unchecked" }) - public static String[][] getAsStringArray(ResultSet rs) { - List<ResultBinding> l = ResultSetFormatter.toList(rs); - List<String> resultVars = rs.getResultVars(); - String[][] array = new String[l.size()][resultVars.size()]; - Iterator<String> iter = resultVars.iterator(); - int i = 0, j = 0; - - for (ResultBinding resultBinding : l) { - while (iter.hasNext()) { - String varName = (String) iter.next(); - array[i][j] = resultBinding.get(varName).toString(); - j++; - } - iter = resultVars.iterator(); - i++; - j = 0; - } - return array; - } - - /** * sends a query and returns XML * * @return String xml Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryThreaded.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryThreaded.java 2008-02-28 14:18:15 UTC (rev 662) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryThreaded.java 2008-02-28 20:25:13 UTC (rev 663) @@ -8,38 +8,36 @@ * */ public class SparqlQueryThreaded { - private boolean isRunning=false; private Cache cache; private SparqlQuery query; - private ResultSet result; + private String result; public SparqlQueryThreaded(Cache cache, SparqlQuery query) { this.cache=cache; this.query=query; + this.result=null; } public void stop() { query.getExecution().abort(); - isRunning = false; + result=null; } public boolean isRunning() { - return isRunning; + return result==null; } public void send() { - isRunning=true; result=cache.executeSparqlQuery(query); - isRunning=false; } public SparqlQuery getSparqlQuery(){ return query; } - public ResultSet getResult(){ + public String getResult(){ return result; } } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java 2008-02-28 14:18:15 UTC (rev 662) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java 2008-02-28 20:25:13 UTC (rev 663) @@ -87,7 +87,7 @@ // .getSparqlEndpoint(), cache, uri.toString(), sparqlQueryString); SparqlQuery query = new SparqlQuery(sparqlQueryString, configuration.getSparqlEndpoint()); - ResultSet rs = cache.executeSparqlQuery(query); + ResultSet rs = SparqlQuery.JSONtoResultSet(cache.executeSparqlQuery(query)); List<ResultBinding> l = ResultSetFormatter.toList(rs); p(l.toString()); Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQueryClasses.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQueryClasses.java 2008-02-28 14:18:15 UTC (rev 662) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQueryClasses.java 2008-02-28 20:25:13 UTC (rev 663) @@ -64,7 +64,7 @@ + "}"; SparqlQuery query = new SparqlQuery(sparqlQueryString, configuration.getSparqlEndpoint()); - ResultSet rs = cache.executeSparqlQuery(query); + ResultSet rs = SparqlQuery.JSONtoResultSet(cache.executeSparqlQuery(query)); List<ResultBinding> l = ResultSetFormatter.toList(rs); for (ResultBinding resultBinding : l) { Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-02-28 14:18:15 UTC (rev 662) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-02-28 20:25:13 UTC (rev 663) @@ -57,6 +57,7 @@ import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.kb.sparql.SparqlQueryException; +import org.dllearner.kb.sparql.SparqlQueryThreaded; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; @@ -501,29 +502,21 @@ // SPARQL component methods // //////////////////////////////////////// + @WebMethod - public String[][] getAsStringArray(int sessionID, int queryID) throws ClientNotKnownException, SparqlQueryException - { - ClientState state = getState(sessionID); - SparqlQueryException exception=null; - if ((exception=state.getQuery(queryID).getSparqlQuery().getException())!=null) throw exception; - return SparqlQuery.getAsStringArray(state.getQuery(queryID).getResult()); - } - - @WebMethod public String getAsJSON(int sessionID, int queryID) throws ClientNotKnownException, SparqlQueryException { ClientState state = getState(sessionID); SparqlQueryException exception=null; if ((exception=state.getQuery(queryID).getSparqlQuery().getException())!=null) throw exception; - return SparqlQuery.getAsJSON(state.getQuery(queryID).getResult()); + return state.getQuery(queryID).getResult(); } @WebMethod public String getAsXMLString(int sessionID, int queryID) throws ClientNotKnownException { ClientState state = getState(sessionID); - ResultSet resultSet=state.getQuery(queryID).getResult(); + ResultSet resultSet=SparqlQuery.JSONtoResultSet(state.getQuery(queryID).getResult()); return SparqlQuery.getAsXMLString(resultSet); } @@ -544,6 +537,16 @@ } @WebMethod + public String sparqlQuery(int sessionID, int componentID, String query) throws ClientNotKnownException + { + ClientState state = getState(sessionID); + Component component = state.getComponent(componentID); + SparqlQueryThreaded sparql=((SparqlKnowledgeSource)component).sparqlQueryThreaded(query); + sparql.send(); + return sparql.getResult(); + } + + @WebMethod public boolean isSparqlQueryRunning(int sessionID, int queryID) throws ClientNotKnownException { ClientState state = getState(sessionID); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-28 14:18:24
|
Revision: 662 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=662&view=rev Author: sknappe Date: 2008-02-28 06:18:15 -0800 (Thu, 28 Feb 2008) Log Message: ----------- search with categories should now work Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-28 13:57:59 UTC (rev 661) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-28 14:18:15 UTC (rev 662) @@ -169,9 +169,10 @@ $ret=array(); do{ if (strlen($checkedInstances[0])>0){ - $query="SELECT ?zw\n". - "WHERE {?zw a <".$checkedInstances[0].">.{SELECT ?subject as ?zw\n". - "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}\nLimit 100}}"; + $query="SELECT DISTINCT ?subject\n". + "WHERE {?subject a <".$checkedInstances[0].">.{SELECT ?zw as ?subject\n". + "WHERE { ?zw <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}\n". + "LIMIT 1000 OFFSET ".$offset."}}"; }else { $query="SELECT DISTINCT ?subject\n". "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}". This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-28 13:58:04
|
Revision: 661 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=661&view=rev Author: sknappe Date: 2008-02-28 05:57:59 -0800 (Thu, 28 Feb 2008) Log Message: ----------- changed the search Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-28 13:56:42 UTC (rev 660) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-28 13:57:59 UTC (rev 661) @@ -156,24 +156,34 @@ $run=fgets($file); fclose($file); if ($run=="false"){ - $this->client->stopSparqlQuery($this->id,$queryID); + $this->client->stopSparqlThread($this->id,$queryID); throw new Exception("Query stopped"); } } while($seconds<$this->ttl); $this->client->stopSparqlThread($this->id,$queryID); } - function getSubjects($label) + function getSubjects($label,$checkedInstances) { - $query="SELECT DISTINCT ?subject\n". - "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}\n". - "LIMIT 10"; - $result=json_decode($this->getSparqlResult($query),true); - if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result."); + $offset=1; $ret=array(); - foreach ($result['results']['bindings'] as $results){ - $ret[]=$results['subject']['value']; - } + do{ + if (strlen($checkedInstances[0])>0){ + $query="SELECT ?zw\n". + "WHERE {?zw a <".$checkedInstances[0].">.{SELECT ?subject as ?zw\n". + "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}\nLimit 100}}"; + }else { + $query="SELECT DISTINCT ?subject\n". + "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}". + "LIMIT 1000 OFFSET ".$offset; + } + $result=json_decode($this->getSparqlResult($query),true); + if ((count($result['results']['bindings'])==0)&&($offset==1)) throw new Exception("Your query brought no result."); + foreach ($result['results']['bindings'] as $results){ + $ret[]=$results['subject']['value']; + } + $offset+=1000; + } while(count($result['results']['bindings'])==1000); return $ret; } @@ -283,6 +293,6 @@ $sc=new DLLearnerConnection(); $ids=$sc->getIDs(); $sc=new DLLearnerConnection($ids[0],$ids[1]); -$triples=$sc->getSubjects("Leipzig"); +$triples=$sc->getSubjects("Paris"); var_dump($triples);*/ ?> Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-28 13:56:42 UTC (rev 660) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-28 13:57:59 UTC (rev 661) @@ -16,7 +16,7 @@ setRunning($id,"true"); //get parts of the list - $checkedInstances=preg_split("[,]",$list); + $checkedInstances=preg_split("[,]",$list,-1,PREG_SPLIT_NO_EMPTY); //initialise content $content=""; @@ -24,18 +24,15 @@ require_once("DLLearnerConnection.php"); $sc=new DLLearnerConnection($id,$ksID); - $subjects=$sc->getSubjects($label); + $subjects=$sc->getSubjects($label,$checkedInstances); - foreach ($subjects as $subject) - { - $content.="<a href=\"\" onclick=\"xajax_getarticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; - } + $content.=getResultsTable($subjects); } catch (Exception $e){ $content=$e->getMessage(); } $objResponse = new xajaxResponse(); - $objResponse->assign("searchcontent", "innerHTML", $content); + $objResponse->assign("articlecontent", "innerHTML", $content); return $objResponse; } Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-02-28 13:56:42 UTC (rev 660) +++ trunk/src/dbpedia-navigator/index.php 2008-02-28 13:57:59 UTC (rev 661) @@ -103,7 +103,7 @@ <!-- Search:<br/> --> <form onSubmit="xajax_getarticle(document.getElementById('label').value,-1);return false;"> <input type="text" name="label" id="label" /><br/> - <input type="button" value="Search" class="button" onclick="xajax_getarticle(document.getElementById('label').value,-1);return false;" /> + <input type="button" value="Article" class="button" onclick="xajax_getarticle(document.getElementById('label').value,-1);return false;" /> <input type="button" value="Search" class="button" onclick="var list=tree.getAllChecked();xajax_getsubjects(document.getElementById('label').value,list);return false;" /> <!-- <input type="button" value="Fulltext" class="button" onclick=""/> --> </form> </div> <!-- boxcontent --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-28 13:56:47
|
Revision: 660 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=660&view=rev Author: sknappe Date: 2008-02-28 05:56:42 -0800 (Thu, 28 Feb 2008) Log Message: ----------- fixed some bugs Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-02-27 19:03:22 UTC (rev 659) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-02-28 13:56:42 UTC (rev 660) @@ -33,6 +33,7 @@ import org.apache.log4j.Logger; import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.ResultSetFormatter; /** * SPARQL query cache to avoid possibly expensive multiple queries. The queries @@ -217,13 +218,14 @@ if (result != null) { return SparqlQuery.JSONtoResultSet(result); } else { - ResultSet rs = query.send(); + query.send(); + ResultSet rs = query.getResultSet(); if (rs!=null){ String json = SparqlQuery.getAsJSON(rs); addToCache(query.getQueryString(), json); return SparqlQuery.JSONtoResultSet(json); } - else return rs; + return rs; } } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-02-27 19:03:22 UTC (rev 659) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-02-28 13:56:42 UTC (rev 660) @@ -175,7 +175,7 @@ ResultSetFormatter.outputAsJSON(baos, resultSet); // possible Jena bug: Jena modifies the result set during // JSON transformation, so we need to get it back - //resultSet = JSONtoResultSet(baos.toString()); + resultSet = JSONtoResultSet(baos.toString()); try{ return baos.toString("UTF-8"); }catch (Exception e){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-27 19:04:38
|
Revision: 659 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=659&view=rev Author: jenslehmann Date: 2008-02-27 11:03:22 -0800 (Wed, 27 Feb 2008) Log Message: ----------- extracted math operations in downward refinement operator to separate class such that they can be used by all operators Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java Added: trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java 2008-02-27 19:03:22 UTC (rev 659) @@ -0,0 +1,151 @@ +/** + * 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.refinementoperators; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Union; + +/** + * Math operations related to refinement operators. + * + * @author Jens Lehmann + * + */ +public class MathOperations { + + /** + * This function implements the getCombos method. Through the + * use of the upper limit, it is guaranteed that it + * will never return doublettes, so no special handling for + * them is necessary. + * + * @see #getCombos(int) + * @param number Number to decompose. + * @param upperLimit Maximum number allowed in sum. + * @param bisher Numbers created so far. + * @param combosTmp Temporary list of combinations (filled during run). + */ + private static void decompose(int number, int upperLimit, LinkedList<Integer> bisher, List<List<Integer>> combosTmp) { + + for (int i = Math.min(number, upperLimit); i >= 1; i--) + { + + LinkedList<Integer> newBisher = null; + // für i==0 wird aus Effizienzgründen die bisherige Liste genommen + if(i==0) { + newBisher = bisher; + newBisher.add(i); + // für zahl - i == 1 muss gar keine Liste erstellt werden, da dann keine + // Zerlegung mehr möglich ist + } else if(number - i != 1) { + newBisher = cloneList(bisher); + newBisher.add(i); + } + + + if (number - i > 1) + { + // i wird hinzugefügt, d.h. + // - es muss nur noch zahl - i - 1 zerlegt werden (-1 wegen OR-Symbol) + // - es darf keine größere Zahl als i mehr vorkommen + // (dadurch gehen keine Kombinationen verloren) + decompose(number - i - 1, i, newBisher,combosTmp); + } + // Fall zahl == i, d.h. es muss nicht weiter zerlegt werden + else if(number - i == 0){ + combosTmp.add(newBisher); + } + + + } + + // numbers.add(bisher); + } + + /** + * Given <code>number</code>, the functions returns all + * combinations of natural numbers plus the number count + * (which can be thought of as the number of interconnecting + * symbols between those numbers) adds up to <code>number</code>. + * + * It uses an efficient algorithm to achieve this, which can + * handle number=50 in less than a second and number=30 in + * about 10 milliseconds on an average PC. + * + * For illustrating the function, the return values of the first numbers + * are given: + * number = 1: [[1]] + * number = 2: [[2]] + * number = 3: [[3], [1, 1]] + * number = 4: [[4], [2, 1]] + * number = 5: [[5], [3, 1], [2, 2], [1, 1, 1]] + * number = 6: [[6], [4, 1], [3, 2], [2, 1, 1]] + * number = 7: [[7], [5, 1], [4, 2], [3, 3], [3, 1, 1], [2, 2, 1], [1, 1, 1, 1]] + * + * @param length + * @return + */ + public static List<List<Integer>> getCombos(int length) { + // on Notebook: length 70 in 17 seconds, length 50 in 800ms, length 30 in 15ms + LinkedList<List<Integer>> combosTmp = new LinkedList<List<Integer>>(); + decompose(length, length, new LinkedList<Integer>(), combosTmp); + return combosTmp; + } + + @SuppressWarnings("unchecked") + private static LinkedList<Integer> cloneList(LinkedList<Integer> list) { + return (LinkedList<Integer>) list.clone(); + } + + public static void main(String args[]) { + System.out.println(getCombos(7)); + } + + // neue Implementierung, die nicht mehr zur incompleteness führen soll, + // da die Konzepte in einer MultiDisjunction als Liste gespeichert werden + public static Set<Union> incCrossProduct(Set<Union> baseSet, Set<Description> newSet) { + Set<Union> retSet = new HashSet<Union>(); + + if(baseSet.isEmpty()) { + for(Description c : newSet) { + Union md = new Union(); + md.addChild(c); + retSet.add(md); + } + return retSet; + } + + for(Union md : baseSet) { + for(Description c : newSet) { + Union mdNew = new Union(md.getChildren()); + mdNew.addChild(c); + retSet.add(mdNew); + } + } + + return retSet; + } + +} Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-02-27 15:59:18 UTC (rev 658) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-02-27 19:03:22 UTC (rev 659) @@ -19,21 +19,31 @@ */ package org.dllearner.refinementoperators; +import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; +import java.util.TreeSet; import org.dllearner.algorithms.refinement.RefinementOperator; import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.BooleanValueRestriction; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.Nothing; +import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.Union; +import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.ConceptTransformation; /** * A downward refinement operator, which makes use of domains @@ -58,6 +68,37 @@ private Map<DatatypeProperty,Description> dpDomains = new TreeMap<DatatypeProperty,Description>(); private Map<ObjectProperty,Description> opRanges = new TreeMap<ObjectProperty,Description>(); + // gibt die Gr��e an bis zu der die Refinements des Top-Konzepts + // bereits berechnet worden => entspricht der max. L�nge der Menge M + private int topRefinementsLength = 0; + + // die Menge M im Refinement-Operator indiziert nach ihrer L�nge + private Map<Integer,Set<Description>> m = new HashMap<Integer,Set<Description>>(); + + // Zerlegungen der Zahl n in Mengen + // Map<Integer,Set<IntegerCombo>> combos = new HashMap<Integer,Set<IntegerCombo>>(); + private Map<Integer, List<List<Integer>>> combos = new HashMap<Integer, List<List<Integer>>>(); + // abspeichern von Kombinationen während diese rekursiv berechnet werden + // private List<List<Integer>> combosTmp; + + // Refinements des Top-Konzept indiziert nach Länge + private Map<Integer, TreeSet<Description>> topRefinements = new HashMap<Integer, TreeSet<Description>>(); + private Map<Integer, TreeSet<Description>> topRefinementsCumulative = new HashMap<Integer, TreeSet<Description>>(); + + // comparator für Konzepte + private ConceptComparator conceptComparator = new ConceptComparator(); + + // Statistik + private long mComputationTimeNs = 0; + private long topComputationTimeNs = 0; + +// private boolean applyAllFilter = true; + private boolean applyExistsFilter = true; + private boolean useAllConstructor = true; + private boolean useExistsConstructor = true; + private boolean useNegation = true; + private boolean useBooleanDatatypes = true; + public RhoDRDown(ReasoningService rs) { this.rs = rs; subHierarchy = rs.getSubsumptionHierarchy(); @@ -110,4 +151,176 @@ return refinements; } + // TODO: später private + public void computeTopRefinements(int maxLength) { + long topComputationTimeStartNs = System.nanoTime(); + + // M erweiteren + computeM(maxLength); + + // berechnen aller möglichen Kombinationen für Disjunktion, + for(int i = topRefinementsLength+1; i <= maxLength; i++) { + combos.put(i,MathOperations.getCombos(i)); + topRefinements.put(i, new TreeSet<Description>(conceptComparator)); + // topRefinements.put(i, new HashSet<Concept>()); + + for(List<Integer> combo : combos.get(i)) { + + // Kombination besteht aus nur einer Zahl => einfach M benutzen + // if(combo.getNumbers().size()==1) { + if(combo.size()==1) { + topRefinements.get(i).addAll(m.get(i)); + // Kombination besteht aus mehreren Zahlen => Disjunktion erzeugen + } else { + Set<Union> baseSet = new HashSet<Union>(); + for(Integer j : combo) { // combo.getNumbers()) { + baseSet = MathOperations.incCrossProduct(baseSet, m.get(j)); + } + + // Umwandlung aller Konzepte in Negationsnormalform + for(Description concept : baseSet) { + ConceptTransformation.transformToOrderedNegationNormalForm(concept, conceptComparator); + } + + if(applyExistsFilter) { + Iterator<Union> it = baseSet.iterator(); + while(it.hasNext()) { + Union md = it.next(); + boolean remove = false; + // falls Exists r für gleiche Rolle zweimal vorkommt, + // dann rausschmeißen + // Map<AtomicRole,Boolean> roleOccured = new HashMap<AtomicRole,Boolean>(); + Set<String> roles = new TreeSet<String>(); + for(Description c : md.getChildren()) { + if(c instanceof ObjectSomeRestriction) { + String role = ((ObjectSomeRestriction)c).getRole().getName(); + boolean roleExists = !roles.add(role); + // falls Rolle schon vorkommt, dann kann ganzes + // Refinement ignoriert werden (man könnte dann auch + // gleich abbrechen, aber das hat nur minimalste + // Auswirkungen auf Effizienz) + if(roleExists) + remove = true; + } + } + if(remove) + it.remove(); + + } + } + + topRefinements.get(i).addAll(baseSet); + } + } + + // neu berechnete Refinements kumulieren, damit sie schneller abgefragt werden können + // computeCumulativeTopRefinements(i); + TreeSet<Description> cumulativeRefinements = new TreeSet<Description>(conceptComparator); + // Set<Concept> cumulativeRefinements = new HashSet<Concept>(); + for(int j=1; j<=i; j++) { + cumulativeRefinements.addAll(topRefinements.get(j)); + } + topRefinementsCumulative.put(i, cumulativeRefinements); + } + + // neue Maximallänge eintragen + topRefinementsLength = maxLength; + + topComputationTimeNs += System.nanoTime() - topComputationTimeStartNs; + } + + // computation of the set M + private void computeM(int maxLength) { + long mComputationTimeStartNs = System.nanoTime(); + // System.out.println("compute M from " + (topRefinementsLength+1) + " up to " + maxLength); + + // initialise all not yet initialised lengths + // (avoids null pointers in some cases) + for(int i=topRefinementsLength+1; i<=maxLength; i++) { + m.put(i, new TreeSet<Description>(conceptComparator)); + } + + // Berechnung der Basiskonzepte in M + // TODO: Spezialfälle, dass zwischen Top und Bottom nichts liegt behandeln + if(topRefinementsLength==0 && maxLength>0) { + // Konzepte der Länge 1 = alle Konzepte, die in der Subsumptionhierarchie unter Top liegen + Set<Description> m1 = rs.getMoreSpecialConcepts(new Thing()); + m.put(1,m1); + } + + if(topRefinementsLength<2 && maxLength>1) { + // Konzepte der Länge 2 = Negation aller Konzepte, die über Bottom liegen + if(useNegation) { + Set<Description> m2tmp = rs.getMoreGeneralConcepts(new Nothing()); + Set<Description> m2 = new TreeSet<Description>(conceptComparator); + for(Description c : m2tmp) { + m2.add(new Negation(c)); + } + m.put(2,m2); + } + } + + if(topRefinementsLength<3 && maxLength>2) { + // Konzepte der Länge 3: EXISTS r.TOP + Set<Description> m3 = new TreeSet<Description>(conceptComparator); + if(useExistsConstructor) { + // previous operator: uses all roles + // for(AtomicRole r : Config.Refinement.allowedRoles) { + // m3.add(new Exists(r, new Top())); + //} + // new operator: only uses most general roles + for(ObjectProperty r : rs.getMostGeneralRoles()) { + m3.add(new ObjectSomeRestriction(r, new Thing())); + } + + } + + // boolean datatypes, e.g. testPositive = true + if(useBooleanDatatypes) { + Set<DatatypeProperty> booleanDPs = rs.getBooleanDatatypeProperties(); + for(DatatypeProperty dp : booleanDPs) { + m3.add(new BooleanValueRestriction(dp,true)); + m3.add(new BooleanValueRestriction(dp,false)); + } + } + + m.put(3,m3); + } + + if(maxLength>2) { + if(useAllConstructor) { + // Konzepte, die mit ALL r starten + // alle existierenden Konzepte durchgehen, die maximal 2 k�rzer als + // die maximale L�nge sind + // topRefinementsLength - 1, damit Konzepte der Länge mindestens + // topRefinementsLength + 1 erzeugt werden (ALL r) + for(int i=topRefinementsLength-1; i<=maxLength-2; i++) { + // i muss natürlich mindestens 1 sein + if(i>=1) { + + // alle Konzepte durchgehen + for(Description c : m.get(i)) { + // Fall wird jetzt weiter oben schon abgehandelt + // if(!m.containsKey(i+2)) + // m.put(i+2, new TreeSet<Concept>(conceptComparator)); + + // previous operator: uses all roles + // for(AtomicRole r : Config.Refinement.allowedRoles) { + // Mehrfacheinf�gen ist bei einer Menge kein Problem + // m.get(i+2).add(new All(r,c)); + // } + + for(ObjectProperty r : rs.getMostGeneralRoles()) { + m.get(i+2).add(new ObjectAllRestriction(r,c)); + } + } + } + } + } + } + + mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; + } + + } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java 2008-02-27 15:59:18 UTC (rev 658) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java 2008-02-27 19:03:22 UTC (rev 659) @@ -414,7 +414,7 @@ // berechnen aller möglichen Kombinationen für Disjunktion, for(int i = topRefinementsLength+1; i <= maxLength; i++) { - combos.put(i,getCombos(i)); + combos.put(i,MathOperations.getCombos(i)); topRefinements.put(i, new TreeSet<Description>(conceptComparator)); // topRefinements.put(i, new HashSet<Concept>()); @@ -454,7 +454,7 @@ } else { Set<Union> baseSet = new HashSet<Union>(); for(Integer j : combo) { // combo.getNumbers()) { - baseSet = incCrossProduct2(baseSet, m.get(j)); + baseSet = MathOperations.incCrossProduct(baseSet, m.get(j)); } // Umwandlung aller Konzepte in Negationsnormalform @@ -603,6 +603,7 @@ } + // wird nicht mehr verwendet public static void summen(int zahl, int max, String bisher, int recDepth) { for(int j=0; j<recDepth; j++) @@ -635,99 +636,14 @@ } } - @SuppressWarnings("unchecked") - private LinkedList<Integer> cloneList(LinkedList<Integer> list) { - return (LinkedList<Integer>) list.clone(); - } + - /** - * - * Dadurch das max das Maximum der vorkommenden Zahl regelt, kommen - * keine doppelten Kombinationen vor. - * - * TODO: Implementierung mit Speicherung in Datenstruktur statt - * direkter Ausgabe; IntegerCombo wird hier gar nicht benötigt, da - * alle Elemente bereits in richtiger Reihenfolge vorliegen und - * es keine doppelten Nennungen gibt - * - * @param zahl Zu zerlegende Zahl. - * @param max Maximal in Summenzerlegung vorkommende Zahl. - * @param bisher - */ - private void zerlege(int zahl, int max, LinkedList<Integer> bisher, List<List<Integer>> combosTmp) { - - for (int i = Math.min(zahl, max); i >= 1; i--) - { - - LinkedList<Integer> newBisher = null; - // für i==0 wird aus Effizienzgründen die bisherige Liste genommen - if(i==0) { - newBisher = bisher; - newBisher.add(i); - // für zahl - i == 1 muss gar keine Liste erstellt werden, da dann keine - // Zerlegung mehr möglich ist - } else if(zahl - i != 1) { - newBisher = cloneList(bisher); - newBisher.add(i); - } - - - if (zahl - i > 1) - { - // i wird hinzugefügt, d.h. - // - es muss nur noch zahl - i - 1 zerlegt werden (-1 wegen OR-Symbol) - // - es darf keine größere Zahl als i mehr vorkommen - // (dadurch gehen keine Kombinationen verloren) - zerlege(zahl - i - 1, i, newBisher,combosTmp); - } - // Fall zahl == i, d.h. es muss nicht weiter zerlegt werden - else if(zahl - i == 0){ - combosTmp.add(newBisher); - } - - } - - // numbers.add(bisher); - } - // auf Notebook: Länge 70 in 17 Sekunden, Länge 50 in 800ms, Länge 30 in 15ms - // http://88.198.173.90/tud/forum/messages?topic=304392 - public List<List<Integer>> getCombos(int length) { - LinkedList<List<Integer>> combosTmp = new LinkedList<List<Integer>>(); - zerlege(length, length, new LinkedList<Integer>(), combosTmp); - return combosTmp; - } - - // neue Implementierung, die nicht mehr zur incompleteness führen soll, - // da die Konzepte in einer MultiDisjunction als Liste gespeichert werden - private Set<Union> incCrossProduct2(Set<Union> baseSet, Set<Description> newSet) { - Set<Union> retSet = new HashSet<Union>(); - - if(baseSet.isEmpty()) { - for(Description c : newSet) { - Union md = new Union(); - md.addChild(c); - retSet.add(md); - } - return retSet; - } - - for(Union md : baseSet) { - for(Description c : newSet) { - Union mdNew = new Union(md.getChildren()); - mdNew.addChild(c); - retSet.add(mdNew); - } - } - - return retSet; - } - // incremental cross product // es müssen Listen statt Sets verwendet werden @SuppressWarnings({"unused"}) - private Set<Set<Description>> incCrossProduct(Set<Set<Description>> baseSet, Set<Description> newSet) { + private Set<Set<Description>> incCrossProductOld(Set<Set<Description>> baseSet, Set<Description> newSet) { Set<Set<Description>> retSet = new HashSet<Set<Description>>(); // falls erste Menge leer ist, dann wird Menge mit jeweils Singletons aus der Modified: trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java 2008-02-27 15:59:18 UTC (rev 658) +++ trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java 2008-02-27 19:03:22 UTC (rev 659) @@ -63,11 +63,11 @@ // class cast exception Set<Set<OWLDescription>> test = reasoner.getDomains(p); - OWLClass oc = (OWLClass) test.iterator().next(); - System.out.println(oc); -// for(Set<OWLDescription> test2 : test) { -// System.out.println(test2); -// } +// OWLClass oc = (OWLClass) test.iterator().next(); +// System.out.println(oc); + for(Set<OWLDescription> test2 : test) { + System.out.println(test2); + } // save ontology manager.saveOntology(ontology); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-27 15:59:24
|
Revision: 658 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=658&view=rev Author: sknappe Date: 2008-02-27 07:59:18 -0800 (Wed, 27 Feb 2008) Log Message: ----------- get content of the checkboxes of the menu Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 15:30:42 UTC (rev 657) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 15:59:18 UTC (rev 658) @@ -283,6 +283,6 @@ $sc=new DLLearnerConnection(); $ids=$sc->getIDs(); $sc=new DLLearnerConnection($ids[0],$ids[1]); -$triples=$sc->getYagoSubCategories("http://dbpedia.org/class/yago/Eliminator109272468"); +$triples=$sc->getSubjects("Leipzig"); var_dump($triples);*/ ?> Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-27 15:30:42 UTC (rev 657) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-27 15:59:18 UTC (rev 658) @@ -4,7 +4,7 @@ require("ajax.php"); $xajax->processRequest(); -function getsubjects($label) +function getsubjects($label,$list) { $sid = $_GET['sid']; session_id($sid); @@ -15,6 +15,9 @@ setRunning($id,"true"); + //get parts of the list + $checkedInstances=preg_split("[,]",$list); + //initialise content $content=""; try{ @@ -155,7 +158,7 @@ //BUILD SEARCHRESULT if ($fromCache==-1) - $searchResult.="<a href=\"\" onclick=\"xajax_getsubjects('".$subject."');return false;\">Show more Results</a>"; + $searchResult.="<a href=\"\" onclick=\"var list=tree.getAllChecked();xajax_getsubjects('".$subject."',list);return false;\">Show more Results</a>"; //Restart the Session This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-27 15:30:55
|
Revision: 657 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=657&view=rev Author: sknappe Date: 2008-02-27 07:30:42 -0800 (Wed, 27 Feb 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/processTreeMenu.php Modified: trunk/src/dbpedia-navigator/processTreeMenu.php =================================================================== --- trunk/src/dbpedia-navigator/processTreeMenu.php 2008-02-27 15:24:38 UTC (rev 656) +++ trunk/src/dbpedia-navigator/processTreeMenu.php 2008-02-27 15:30:42 UTC (rev 657) @@ -17,7 +17,7 @@ foreach ($categories as $category){ if ($category['subclasses']=="0") $child=0; else $child=1; - print("<item child=\"".$child."\" id=\"".$category['value']."\" text=\"".$category['label']."\"><userdata name=\"myurl\">".$category."</userdata></item>"); + print("<item child=\"".$child."\" id=\"".$category['value']."\" text=\"".$category['label']."\"><userdata name=\"myurl\">".$category['value']."</userdata></item>"); } } print("</tree>"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-27 15:24:55
|
Revision: 656 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=656&view=rev Author: sknappe Date: 2008-02-27 07:24:38 -0800 (Wed, 27 Feb 2008) Log Message: ----------- bugfixes Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/processTreeMenu.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 15:08:19 UTC (rev 655) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 15:24:38 UTC (rev 656) @@ -192,8 +192,8 @@ function getYagoSubCategories($category) { - $query="SELECT ?subject ?label\n". - "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#subClassOf> <".$category.">.?subject <http://www.w3.org/2000/01/rdf-schema#label> ?label}\n"; + $query="SELECT ?subject ?label count(?subclass) as ?numberOfSubclasses\n". + "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#subClassOf> <".$category.">.?subject <http://www.w3.org/2000/01/rdf-schema#label> ?label.OPTIONAL {?subclass <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?subject} }"; $result=json_decode($this->getSparqlResult($query),true); if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result."); $ret=array(); @@ -201,6 +201,7 @@ $res=array(); $res['value']=$results['subject']['value']; $res['label']=$results['label']['value']; + $res['subclasses']=$results['numberOfSubclasses']['value']; if (strlen($res['label'])>0) $ret[]=$res; } return $ret; @@ -282,6 +283,6 @@ $sc=new DLLearnerConnection(); $ids=$sc->getIDs(); $sc=new DLLearnerConnection($ids[0],$ids[1]); -$triples=$sc->getSubjects("Angela Merkel"); +$triples=$sc->getYagoSubCategories("http://dbpedia.org/class/yago/Eliminator109272468"); var_dump($triples);*/ ?> Modified: trunk/src/dbpedia-navigator/processTreeMenu.php =================================================================== --- trunk/src/dbpedia-navigator/processTreeMenu.php 2008-02-27 15:08:19 UTC (rev 655) +++ trunk/src/dbpedia-navigator/processTreeMenu.php 2008-02-27 15:24:38 UTC (rev 656) @@ -14,8 +14,11 @@ $ids=$sc->getIDs(); $sc=new DLLearnerConnection($ids[0],$ids[1]); $categories=$sc->getYagoSubCategories($url_var); - foreach ($categories as $category) - print("<item child=\"1\" id=\"".$category['value']."\" text=\"".$category['label']."\"><userdata name=\"myurl\">".$category."</userdata></item>"); + foreach ($categories as $category){ + if ($category['subclasses']=="0") $child=0; + else $child=1; + print("<item child=\"".$child."\" id=\"".$category['value']."\" text=\"".$category['label']."\"><userdata name=\"myurl\">".$category."</userdata></item>"); + } } print("</tree>"); ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-27 15:08:28
|
Revision: 655 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=655&view=rev Author: jenslehmann Date: 2008-02-27 07:08:19 -0800 (Wed, 27 Feb 2008) Log Message: ----------- - preliminary datatype domain/range reasoning (bug in OWL API detected) - new refinement operator (and unit tests for it) started Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-02-27 14:10:02 UTC (rev 654) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-02-27 15:08:19 UTC (rev 655) @@ -27,6 +27,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; @@ -446,6 +447,42 @@ return reasoner.getIndividuals(); } + public Description getDomain(ObjectProperty objectProperty) { + try { + return reasoner.getDomain(objectProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Description getDomain(DatatypeProperty datatypeProperty) { + try { + return reasoner.getDomain(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Description getRange(ObjectProperty objectProperty) { + try { + return reasoner.getRange(objectProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public DataRange getRange(DatatypeProperty datatypeProperty) { + try { + return reasoner.getRange(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + public ReasonerType getReasonerType() { return reasoner.getReasonerType(); } Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-27 14:10:02 UTC (rev 654) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-27 15:08:19 UTC (rev 655) @@ -173,7 +173,9 @@ kbString += "OPDOMAIN(" + getURI2("hasBond") + ") = " + getURI2("Compound") + ".\n"; kbString += "OPRANGE(" + getURI2("hasBond") + ") = " + getURI2("Bond") + ".\n"; kbString += "OPDOMAIN(" + getURI2("inBond") + ") = " + getURI2("Bond") + ".\n"; - kbString += "OPRANGE(" + getURI2("inBond") + ") = " + getURI2("Atom") + ".\n"; + kbString += "OPRANGE(" + getURI2("inBond") + ") = " + getURI2("Atom") + ".\n"; + kbString += "OPDOMAIN(" + getURI2("hasStructure") + ") = " + getURI2("Compound") + ".\n"; + kbString += "OPRANGE(" + getURI2("hasStructure") + ") = " + getURI2("Structure") + ".\n"; KB kb2 = KBParser.parseKBFile(kbString); kb.addKB(kb2); Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-27 14:10:02 UTC (rev 654) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-27 15:08:19 UTC (rev 655) @@ -408,4 +408,19 @@ return rc.getPrefixes(); } + @Override + public Description getDomain(ObjectProperty objectProperty) { + return rc.getDomain(objectProperty); + } + + @Override + public Description getDomain(DatatypeProperty datatypeProperty) { + return rc.getDomain(datatypeProperty); + } + + @Override + public Description getRange(ObjectProperty objectProperty) { + return rc.getRange(objectProperty); + } + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-27 14:10:02 UTC (rev 654) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-27 15:08:19 UTC (rev 655) @@ -209,8 +209,8 @@ OWLOntologyFormat format = manager.getOntologyFormat(ontology); if(format instanceof NamespaceOWLOntologyFormat) { prefixes = ((NamespaceOWLOntologyFormat)format).getNamespacesByPrefixMap(); - prefixes.remove(""); baseURI = prefixes.get(""); + prefixes.remove(""); } } catch (OWLOntologyCreationException e) { @@ -541,16 +541,51 @@ // instead of only one description (probably there can be several // domain axiom for one property and the inner set is a conjunction // of descriptions (?)) - OWLDescription d = reasoner.getDomains(prop).iterator().next().iterator().next(); -// OWLAPIDescriptionConvertVisitor.getOWLDescription(d); + // Answer: this function is just horribly broken in OWL API + Set<Set<OWLDescription>> set = reasoner.getDomains(prop); + if(set.size()==0) + return new Thing(); + OWLClass oc = (OWLClass) set.iterator().next(); + return new NamedClass(oc.getURI().toString()); } catch (OWLReasonerException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + throw new Error(e); } - return null; } @Override + public Description getDomain(DatatypeProperty datatypeProperty) { + OWLDataProperty prop = getOWLAPIDescription(datatypeProperty); + try { + // TODO: look up why OWL API return a two dimensional set here + // instead of only one description (probably there can be several + // domain axiom for one property and the inner set is a conjunction + // of descriptions (?)) + // Answer: this function is just horribly broken in OWL API + Set<Set<OWLDescription>> set = reasoner.getDomains(prop); + if(set.size()==0) + return new Thing(); + OWLClass oc = (OWLClass) set.iterator().next(); + return new NamedClass(oc.getURI().toString()); + } catch (OWLReasonerException e) { + throw new Error(e); + } + } + + @Override + public Description getRange(ObjectProperty objectProperty) { + OWLObjectProperty prop = getOWLAPIDescription(objectProperty); + try { + Set<OWLDescription> set = reasoner.getRanges(prop); + if(set.size()==0) + return new Thing(); + OWLClass oc = (OWLClass) set.iterator().next(); + return new NamedClass(oc.getURI().toString()); + } catch (OWLReasonerException e) { + throw new Error(e); + } + } + + @Override public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) { OWLObjectProperty prop = getOWLAPIDescription(atomicRole); Map<Individual, SortedSet<Individual>> map = new TreeMap<Individual, SortedSet<Individual>>(); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-02-27 14:10:02 UTC (rev 654) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-02-27 15:08:19 UTC (rev 655) @@ -19,11 +19,21 @@ */ package org.dllearner.refinementoperators; +import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.TreeMap; import org.dllearner.algorithms.refinement.RefinementOperator; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Nothing; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.SubsumptionHierarchy; +import org.dllearner.core.owl.Thing; /** * A downward refinement operator, which makes use of domains @@ -38,6 +48,31 @@ */ public class RhoDRDown implements RefinementOperator { + private ReasoningService rs; + + // hierarchies + private SubsumptionHierarchy subHierarchy; + + // domains and ranges + private Map<ObjectProperty,Description> opDomains = new TreeMap<ObjectProperty,Description>(); + private Map<DatatypeProperty,Description> dpDomains = new TreeMap<DatatypeProperty,Description>(); + private Map<ObjectProperty,Description> opRanges = new TreeMap<ObjectProperty,Description>(); + + public RhoDRDown(ReasoningService rs) { + this.rs = rs; + subHierarchy = rs.getSubsumptionHierarchy(); + + // query reasoner for domains and ranges + // (because they are used often in the operator) + for(ObjectProperty op : rs.getAtomicRoles()) { + opDomains.put(op, rs.getDomain(op)); + opRanges.put(op, rs.getRange(op)); + } + for(DatatypeProperty dp : rs.getDatatypeProperties()) { + dpDomains.put(dp, rs.getDomain(dp)); + } + } + /* (non-Javadoc) * @see org.dllearner.algorithms.refinement.RefinementOperator#refine(org.dllearner.core.owl.Description) */ @@ -48,10 +83,31 @@ /* (non-Javadoc) * @see org.dllearner.algorithms.refinement.RefinementOperator#refine(org.dllearner.core.owl.Description, int, java.util.List) */ - public Set<Description> refine(Description concept, int maxLength, + public Set<Description> refine(Description description, int maxLength, List<Description> knownRefinements) { + return refine(description, maxLength, knownRefinements, new Thing()); + } + + public Set<Description> refine(Description description, int maxLength, + List<Description> knownRefinements, Description currDomain) { + // TODO: check whether using list or set makes more sense + // here; and whether HashSet or TreeSet should be used + Set<Description> refinements = new HashSet<Description>(); - return null; + // .. do most general rules here ... + // (easier because it may be possible to add return + // statements instead of going through the complete + // function) + + if(description instanceof Thing) { + refinements.addAll(subHierarchy.getMoreSpecialConcepts(description)); + } else if(description instanceof Nothing) { + // cannot be further refined + } else if(description instanceof NamedClass) { + refinements.addAll(subHierarchy.getMoreSpecialConcepts(description)); + } + + return refinements; } - + } Modified: trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java 2008-02-27 14:10:02 UTC (rev 654) +++ trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java 2008-02-27 15:08:19 UTC (rev 655) @@ -1,6 +1,7 @@ package org.dllearner.test; import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.inference.OWLReasoner; import org.semanticweb.owl.model.*; import org.semanticweb.owl.util.SimpleURIMapper; @@ -48,6 +49,26 @@ AddAxiom addAxiom2 = new AddAxiom(ontology, axiom2); manager.applyChange(addAxiom2); + // add property p with domain c + OWLObjectProperty p = factory.getOWLObjectProperty(URI.create(ontologyURI + "#p")); + OWLAxiom axiom3 = factory.getOWLObjectPropertyDomainAxiom(p, c); + AddAxiom addAxiom3 = new AddAxiom(ontology, axiom3); + manager.applyChange(addAxiom3); + + Set<OWLOntology> ontologies = new HashSet<OWLOntology>(); + ontologies.add(ontology); + + OWLReasoner reasoner = new org.mindswap.pellet.owlapi.Reasoner(manager); + reasoner.loadOntologies(ontologies); + + // class cast exception + Set<Set<OWLDescription>> test = reasoner.getDomains(p); + OWLClass oc = (OWLClass) test.iterator().next(); + System.out.println(oc); +// for(Set<OWLDescription> test2 : test) { +// System.out.println(test2); +// } + // save ontology manager.saveOntology(ontology); } Modified: trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java 2008-02-27 14:10:02 UTC (rev 654) +++ trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java 2008-02-27 15:08:19 UTC (rev 655) @@ -47,7 +47,8 @@ logger.setLevel(Level.INFO); JUnitCore.main("org.dllearner.test.junit.ComponentTests", - "org.dllearner.test.junit.ReasonerTests"); + "org.dllearner.test.junit.ReasonerTests", + "org.dllearner.test.junit.RefinementOperatorTests"); } } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2008-02-27 14:10:02 UTC (rev 654) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2008-02-27 15:08:19 UTC (rev 655) @@ -48,7 +48,7 @@ private static Logger logger = Logger.getLogger(ReasonerTests.class); - private KB getSimpleKnowledgeBase() { + public KB getSimpleKnowledgeBase() { String kb = "person SUB TOP."; kb += "man SUB person."; kb += "man SUB male."; Added: trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2008-02-27 15:08:19 UTC (rev 655) @@ -0,0 +1,77 @@ +/** + * 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.test.junit; + +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.Set; + +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; +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.RhoDRDown; +import org.junit.Test; + +/** + * A suite of JUnit tests related to refinement operators. + * + * @author Jens Lehmann + * + */ +public class RefinementOperatorTests { + + private String baseURI; + + @Test + public void rhoDRDownTest() { + try { + String file = "examples/carcinogenesis/pte.owl"; + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + cm.applyConfigEntry(ks, "url", new File(file).toURI().toString()); + ks.init(); + ReasonerComponent rc = cm.reasoner(OWLAPIReasoner.class, ks); + rc.init(); + baseURI = rc.getBaseURI(); + ReasoningService rs = cm.reasoningService(rc); + RhoDRDown op = new RhoDRDown(rs); + Description concept = KBParser.parseConcept(uri("Compound")); + Set<Description> results = op.refine(concept, 4, null); + System.out.println(results); + assertTrue(results.size()==4); + } catch(ComponentInitException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } + } + + private String uri(String name) { + return "\""+baseURI+name+"\""; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-27 14:10:22
|
Revision: 654 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=654&view=rev Author: sknappe Date: 2008-02-27 06:10:02 -0800 (Wed, 27 Feb 2008) Log Message: ----------- label in menu working Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/processTreeMenu.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 13:26:57 UTC (rev 653) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 14:10:02 UTC (rev 654) @@ -192,13 +192,16 @@ function getYagoSubCategories($category) { - $query="SELECT DISTINCT ?subject\n". - "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#subClassOf> <".$category.">}\n"; + $query="SELECT ?subject ?label\n". + "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#subClassOf> <".$category.">.?subject <http://www.w3.org/2000/01/rdf-schema#label> ?label}\n"; $result=json_decode($this->getSparqlResult($query),true); if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result."); $ret=array(); foreach ($result['results']['bindings'] as $results){ - $ret[]=$results['subject']['value']; + $res=array(); + $res['value']=$results['subject']['value']; + $res['label']=$results['label']['value']; + if (strlen($res['label'])>0) $ret[]=$res; } return $ret; } Modified: trunk/src/dbpedia-navigator/processTreeMenu.php =================================================================== --- trunk/src/dbpedia-navigator/processTreeMenu.php 2008-02-27 13:26:57 UTC (rev 653) +++ trunk/src/dbpedia-navigator/processTreeMenu.php 2008-02-27 14:10:02 UTC (rev 654) @@ -15,7 +15,7 @@ $sc=new DLLearnerConnection($ids[0],$ids[1]); $categories=$sc->getYagoSubCategories($url_var); foreach ($categories as $category) - print("<item child=\"1\" id=\"".$category."\" text=\"".substr (strrchr ($category, "/"), 1)."\"><userdata name=\"myurl\">".$category."</userdata></item>"); + print("<item child=\"1\" id=\"".$category['value']."\" text=\"".$category['label']."\"><userdata name=\"myurl\">".$category."</userdata></item>"); } print("</tree>"); ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-27 13:27:01
|
Revision: 653 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=653&view=rev Author: sknappe Date: 2008-02-27 05:26:57 -0800 (Wed, 27 Feb 2008) Log Message: ----------- some bugfixes and menu changed a bit Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/index.php trunk/src/dbpedia-navigator/processTreeMenu.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 12:32:58 UTC (rev 652) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 13:26:57 UTC (rev 653) @@ -156,11 +156,11 @@ $run=fgets($file); fclose($file); if ($run=="false"){ - $this->client->stopSparqlQuery($id,$queryID); + $this->client->stopSparqlQuery($this->id,$queryID); throw new Exception("Query stopped"); } } while($seconds<$this->ttl); - $this->client->stopSparqlThread($id,$queryID); + $this->client->stopSparqlThread($this->id,$queryID); } function getSubjects($label) Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-02-27 12:32:58 UTC (rev 652) +++ trunk/src/dbpedia-navigator/index.php 2008-02-27 13:26:57 UTC (rev 653) @@ -127,6 +127,11 @@ tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); tree.setImagePath("<?php print $path;?>images/csh_bluebooks/"); tree.enableCheckBoxes(1); + tree.setOnClickHandler(doOnClick); + function doOnClick(nodeId){ + var myUrl = tree.getUserData(nodeId,"myurl"); + xajax_getSubjectsFromConcept(myUrl); + } tree.setXMLAutoLoading("processTreeMenu.php"); tree.loadXML("processTreeMenu.php?id=0"); </script> Modified: trunk/src/dbpedia-navigator/processTreeMenu.php =================================================================== --- trunk/src/dbpedia-navigator/processTreeMenu.php 2008-02-27 12:32:58 UTC (rev 652) +++ trunk/src/dbpedia-navigator/processTreeMenu.php 2008-02-27 13:26:57 UTC (rev 653) @@ -15,7 +15,7 @@ $sc=new DLLearnerConnection($ids[0],$ids[1]); $categories=$sc->getYagoSubCategories($url_var); foreach ($categories as $category) - print("<item child=\"1\" id=\"".$category."\" text=\"".substr (strrchr ($category, "/"), 1)."\"><userdata name='ud_block'>ud_data</userdata></item>"); + print("<item child=\"1\" id=\"".$category."\" text=\"".substr (strrchr ($category, "/"), 1)."\"><userdata name=\"myurl\">".$category."</userdata></item>"); } print("</tree>"); ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |