From: <jen...@us...> - 2008-09-27 07:48:22
|
Revision: 1283 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1283&view=rev Author: jenslehmann Date: 2008-09-27 07:48:14 +0000 (Sat, 27 Sep 2008) Log Message: ----------- - working hasValue support (frequency threshold currently at 3) - use refexamples.useHasValueConstructor = true to turn on hasValue support (turned off by default) - provided examples in semantic_bible folder Modified Paths: -------------- trunk/examples/semantic_bible/hasvalue_example.conf trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Added Paths: ----------- trunk/examples/semantic_bible/hasvalue_simple.conf trunk/examples/semantic_bible/hasvalue_simple.kb Modified: trunk/examples/semantic_bible/hasvalue_example.conf =================================================================== --- trunk/examples/semantic_bible/hasvalue_example.conf 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/examples/semantic_bible/hasvalue_example.conf 2008-09-27 07:48:14 UTC (rev 1283) @@ -1,11 +1,10 @@ /** - * It should learn ethnicity hasValue Jewish, but does not work for some reason. + * Learns ethnicity hasValue Jewish (+ potentially something more e.g. Man AND ethnicity hasValue Jewish). */ -import("../NTNcombined.owl"); +import("NTNcombined.owl"); -// reasoner = owlAPIReasoner; -owlAPIReasoner.reasonerType = pellet; +refexamples.useHasValueConstructor = true; +"http://semanticbible.org/ns/2006/NTNames#Hezron" +"http://semanticbible.org/ns/2006/NTNames#Jehoshaphat" Added: trunk/examples/semantic_bible/hasvalue_simple.conf =================================================================== --- trunk/examples/semantic_bible/hasvalue_simple.conf (rev 0) +++ trunk/examples/semantic_bible/hasvalue_simple.conf 2008-09-27 07:48:14 UTC (rev 1283) @@ -0,0 +1,11 @@ +import("hasvalue_simple.kb"); + +reasoner = owlAPIReasoner; +refexamples.useHasValueConstructor = true; + ++a ++b ++c +-e +-f + Added: trunk/examples/semantic_bible/hasvalue_simple.kb =================================================================== --- trunk/examples/semantic_bible/hasvalue_simple.kb (rev 0) +++ trunk/examples/semantic_bible/hasvalue_simple.kb 2008-09-27 07:48:14 UTC (rev 1283) @@ -0,0 +1,9 @@ +knows(a,d). +knows(b,d). +knows(c,d). +knows(e,a). +knows(f,b). + +// TODO bug: apparently there are problems if no class is present in the background ontology, +// so we need to add one +person(a). Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -115,6 +115,7 @@ private boolean improveSubsumptionHierarchy = true; private boolean useAllConstructor = CommonConfigOptions.useAllConstructorDefault; private boolean useExistsConstructor = CommonConfigOptions.useExistsConstructorDefault; + private boolean useHasValueConstructor = CommonConfigOptions.useHasValueConstructorDefault; private boolean useCardinalityRestrictions = CommonConfigOptions.useCardinalityRestrictionsDefault; private boolean useNegation = CommonConfigOptions.useNegationDefault; private boolean useBooleanDatatypes = CommonConfigOptions.useBooleanDatatypesDefault; @@ -190,6 +191,7 @@ options.add(CommonConfigOptions.ignoredRoles()); options.add(CommonConfigOptions.useAllConstructor()); options.add(CommonConfigOptions.useExistsConstructor()); + options.add(CommonConfigOptions.useHasValueConstructor()); options.add(CommonConfigOptions.useCardinalityRestrictions()); options.add(CommonConfigOptions.useNegation()); options.add(CommonConfigOptions.useBooleanDatatypes()); @@ -254,6 +256,8 @@ useAllConstructor = (Boolean) entry.getValue(); } else if(name.equals("useExistsConstructor")) { useExistsConstructor = (Boolean) entry.getValue(); + } else if(name.equals("useHasValueConstructor")) { + useHasValueConstructor = (Boolean) entry.getValue(); } else if(name.equals("useCardinalityRestrictions")) { useCardinalityRestrictions = (Boolean) entry.getValue(); } else if(name.equals("useNegation")) { @@ -365,6 +369,7 @@ applyExistsFilter, useAllConstructor, useExistsConstructor, + useHasValueConstructor, useCardinalityRestrictions, useNegation, useBooleanDatatypes, Modified: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -40,6 +40,7 @@ //public static boolean improveSubsumptionHierarchyDefault = true; public static boolean useAllConstructorDefault = true; public static boolean useExistsConstructorDefault = true; + public static boolean useHasValueConstructorDefault = true; public static boolean useCardinalityRestrictionsDefault = true; public static boolean useNegationDefault = true; public static boolean useBooleanDatatypesDefault = true; @@ -101,6 +102,10 @@ return new BooleanConfigOption("useExistsConstructor", "specifies whether the existential concept constructor is used in the learning algorithm",useExistsConstructorDefault); } + public static BooleanConfigOption useHasValueConstructor() { + return new BooleanConfigOption("useHasValueConstructor", "specifies whether the hasValue constructor is used in the learning algorithm",useHasValueConstructorDefault); + } + public static BooleanConfigOption useCardinalityRestrictions() { return new BooleanConfigOption("useCardinalityRestrictions", "specifies whether CardinalityRestrictions is used in the learning algorithm",useCardinalityRestrictionsDefault); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -23,7 +23,7 @@ /** * Restricts the value of an object property to a single individual - * (corresponds to owl:hasValue). + * (corresponds to owl:hasValue) * * @author Jens Lehmann * @@ -42,8 +42,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; + return restrictedPropertyExpression.toString(baseURI, prefixes) + " value " + value.toString(baseURI, prefixes); } /* (non-Javadoc) @@ -51,7 +50,6 @@ */ @Override public int getArity() { - // TODO Auto-generated method stub return 0; } @@ -59,21 +57,18 @@ * @see org.dllearner.core.owl.KBElement#getLength() */ public int getLength() { - // TODO Auto-generated method stub - return 0; + return 3; } /* (non-Javadoc) * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; + return restrictedPropertyExpression.toString(baseURI, prefixes) + " hasValue " + value.toString(baseURI, prefixes); } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; + return restrictedPropertyExpression.toKBSyntaxString(baseURI, prefixes) + " hasValue " + value.toKBSyntaxString(baseURI, prefixes); } public Individual getIndividual() { Modified: trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -27,7 +27,7 @@ */ public abstract class Restriction extends Description { - PropertyExpression restrictedPropertyExpression; + protected PropertyExpression restrictedPropertyExpression; public Restriction(PropertyExpression restrictedPropertyExpression) { this.restrictedPropertyExpression = restrictedPropertyExpression; Modified: trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -27,7 +27,7 @@ */ public abstract class ValueRestriction extends Restriction { - KBElement value; + protected KBElement value; public ValueRestriction(PropertyExpression propertyExpression, KBElement value) { super(propertyExpression); Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -253,7 +253,7 @@ Logger rootLogger = Logger.getRootLogger(); rootLogger.removeAllAppenders(); rootLogger.addAppender(consoleAppender); - rootLogger.setLevel(Level.TRACE); + rootLogger.setLevel(Level.DEBUG); File file = null; if (args.length > 0) Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -150,8 +150,6 @@ private Map<DatatypeProperty,List<Double>> splits = new TreeMap<DatatypeProperty,List<Double>>(); private int maxNrOfSplits = 10; - // experimental support for hasValue - private boolean useHasValue = false; // data structure for a simple frequent pattern matching preprocessing phase private int frequencyThreshold = 3; private Map<ObjectProperty, Map<Individual, Integer>> valueFrequency = new HashMap<ObjectProperty, Map<Individual, Integer>>(); @@ -166,6 +164,7 @@ private boolean applyExistsFilter = true; private boolean useAllConstructor = true; private boolean useExistsConstructor = true; + private boolean useHasValueConstructor = false; private boolean useCardinalityRestrictions = true; private boolean useNegation = true; private boolean useBooleanDatatypes = true; @@ -181,16 +180,17 @@ // private Map<NamedClass,Map<NamedClass,Boolean>> notABMeaningful = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); public RhoDRDown(ReasoningService reasoningService) { - this(reasoningService, true, true, true, true, true, true, true, true, null); + this(reasoningService, true, true, true, true, true, true, true, true, true, null); } public RhoDRDown(ReasoningService reasoningService, boolean applyAllFilter, boolean applyExistsFilter, boolean useAllConstructor, - boolean useExistsConstructor,boolean useCardinalityRestrictions,boolean useNegation, boolean useBooleanDatatypes, boolean useDoubleDatatypes, NamedClass startClass) { + boolean useExistsConstructor, boolean useHasValueConstructor, boolean useCardinalityRestrictions,boolean useNegation, boolean useBooleanDatatypes, boolean useDoubleDatatypes, NamedClass startClass) { this.rs = reasoningService; this.applyAllFilter = applyAllFilter; this.applyExistsFilter = applyExistsFilter; this.useAllConstructor = useAllConstructor; this.useExistsConstructor = useExistsConstructor; + this.useHasValueConstructor = useHasValueConstructor; this.useCardinalityRestrictions = useCardinalityRestrictions; this.useNegation = useNegation; this.useBooleanDatatypes = useBooleanDatatypes; @@ -204,7 +204,7 @@ opDomains.put(op, rs.getDomain(op)); opRanges.put(op, rs.getRange(op)); - if(useHasValue) { + if(useHasValueConstructor) { // init Map<Individual, Integer> opMap = new TreeMap<Individual, Integer>(); valueFrequency.put(op, opMap); @@ -229,7 +229,7 @@ // after threshold is reached) Set<Individual> frequentInds = new TreeSet<Individual>(); for(Individual i : opMap.keySet()) { - if(opMap.get(i) > frequencyThreshold) { + if(opMap.get(i) >= frequencyThreshold) { frequentInds.add(i); } } @@ -455,12 +455,12 @@ } // rule 4: EXISTS r.TOP => EXISTS r.{value} - if(useHasValue && description.getChild(0) instanceof Thing) { + if(useHasValueConstructor && description.getChild(0) instanceof Thing) { // watch out for frequent patterns Set<Individual> frequentInds = frequentValues.get(role); if(frequentInds != null) { for(Individual ind : frequentInds) { - ObjectValueRestriction ovr = new ObjectValueRestriction(ar, ind); + ObjectValueRestriction ovr = new ObjectValueRestriction((ObjectProperty)role, ind); refinements.add(ovr); } } @@ -661,8 +661,11 @@ boolean maxDoubleOccurence = false; // rule 2: min restrictions at most once boolean minDoubleOccurence = false; - // rule 3: no double boolean datatypes + // rule 3: no double occurences of boolean datatypes TreeSet<DatatypeProperty> occuredDP = new TreeSet<DatatypeProperty>(); + // rule 4: no double occurences of hasValue restrictions + TreeSet<ObjectProperty> occuredVR = new TreeSet<ObjectProperty>(); + for(Description child : intersection.getChildren()) { if(child instanceof DatatypeSomeRestriction) { DataRange dr = ((DatatypeSomeRestriction)child).getDataRange(); @@ -683,6 +686,10 @@ // return false if the boolean property exists already if(!occuredDP.add(dp)) return false; + } else if(child instanceof ObjectValueRestriction) { + ObjectProperty op = (ObjectProperty) ((ObjectValueRestriction)child).getRestrictedPropertyExpression(); + if(!occuredVR.add(op)) + return false; } // System.out.println(child.getClass()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |