From: <jen...@us...> - 2010-02-08 19:02:13
|
Revision: 1994 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1994&view=rev Author: jenslehmann Date: 2010-02-08 19:02:07 +0000 (Mon, 08 Feb 2010) Log Message: ----------- some bug fixes for data hasValue support Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLComponent2.java trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/owl/Constant.java trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java trunk/src/dl-learner/org/dllearner/core/owl/UntypedConstant.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptComparator.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -152,6 +152,7 @@ options.add(CommonConfigOptions.useAllConstructor()); options.add(CommonConfigOptions.useExistsConstructor()); options.add(CommonConfigOptions.useHasValueConstructor()); + options.add(CommonConfigOptions.useDataHasValueConstructor()); options.add(CommonConfigOptions.valueFreqencyThreshold()); options.add(CommonConfigOptions.useCardinalityRestrictions()); options.add(CommonConfigOptions.cardinalityLimit()); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLComponent2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLComponent2.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLComponent2.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -193,6 +193,7 @@ options.add(CommonConfigOptions.useAllConstructor()); options.add(CommonConfigOptions.useExistsConstructor()); options.add(CommonConfigOptions.useHasValueConstructor()); + options.add(CommonConfigOptions.useDataHasValueConstructor()); options.add(CommonConfigOptions.valueFreqencyThreshold()); options.add(CommonConfigOptions.useCardinalityRestrictions()); options.add(CommonConfigOptions.cardinalityLimit()); Modified: trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -85,6 +85,15 @@ return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useHasValueConstructor") ; } /** +* useDataHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm in combination with data properties. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getUseDataHasValueConstructor() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useDataHasValueConstructor") ; +} +/** * valueFrequencyThreshold specifies how often an object must occur as value in order to be considered for hasValue restrictions. * mandatory: false| reinit necessary: true * default value: 3 @@ -221,6 +230,15 @@ reinitNecessary = true; } /** +* @param useDataHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm in combination with data properties. +* mandatory: false| reinit necessary: true +* default value: false +**/ +public void setUseDataHasValueConstructor(boolean useDataHasValueConstructor) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "useDataHasValueConstructor", useDataHasValueConstructor); +reinitNecessary = true; +} +/** * @param valueFrequencyThreshold specifies how often an object must occur as value in order to be considered for hasValue restrictions. * mandatory: false| reinit necessary: true * default value: 3 Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -225,6 +225,15 @@ return (Boolean) ComponentManager.getInstance().getConfigOptionValue(rOLComponent2, "useHasValueConstructor") ; } /** +* useDataHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm in combination with data properties. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getUseDataHasValueConstructor() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(rOLComponent2, "useDataHasValueConstructor") ; +} +/** * valueFrequencyThreshold specifies how often an object must occur as value in order to be considered for hasValue restrictions. * mandatory: false| reinit necessary: true * default value: 3 @@ -586,6 +595,15 @@ reinitNecessary = true; } /** +* @param useDataHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm in combination with data properties. +* mandatory: false| reinit necessary: true +* default value: false +**/ +public void setUseDataHasValueConstructor(boolean useDataHasValueConstructor) { +ComponentManager.getInstance().applyConfigEntry(rOLComponent2, "useDataHasValueConstructor", useDataHasValueConstructor); +reinitNecessary = true; +} +/** * @param valueFrequencyThreshold specifies how often an object must occur as value in order to be considered for hasValue restrictions. * mandatory: false| reinit necessary: true * default value: 3 Modified: trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -45,6 +45,10 @@ return false; } + public boolean getUseDataHasValueConstructor() { + return false; + } + public int getValueFrequencyThreshold() { return 3; } Modified: trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -43,6 +43,7 @@ public static boolean useAllConstructorDefault = true; public static boolean useExistsConstructorDefault = true; public static boolean useHasValueConstructorDefault = false; + public static boolean useDataHasValueConstructorDefault = false; public static int valueFrequencyThresholdDefault = 3; public static boolean useCardinalityRestrictionsDefault = true; public static int cardinalityLimitDefault = 5; @@ -133,6 +134,10 @@ return new BooleanConfigOption("useHasValueConstructor", "specifies whether the hasValue constructor is used in the learning algorithm",useHasValueConstructorDefault); } + public static BooleanConfigOption useDataHasValueConstructor() { + return new BooleanConfigOption("useDataHasValueConstructor", "specifies whether the hasValue constructor is used in the learning algorithm in combination with data properties",useDataHasValueConstructorDefault); + } + public static IntegerConfigOption valueFreqencyThreshold() { return new IntegerConfigOption("valueFrequencyThreshold", "specifies how often an object must occur as value in order to be considered for hasValue restrictions",valueFrequencyThresholdDefault); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Constant.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Constant.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/core/owl/Constant.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -25,7 +25,7 @@ * @author Jens Lehmann * */ -public abstract class Constant implements KBElement { +public abstract class Constant implements KBElement, Comparable<Constant> { /** * @@ -43,4 +43,5 @@ public String getLiteral() { return literal; } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -27,7 +27,7 @@ * @author Jens Lehmann * */ -public class TypedConstant extends Constant implements Comparable<TypedConstant> { +public class TypedConstant extends Constant { /** * @@ -100,6 +100,14 @@ return literal + "^^" + datatype; } + @Override + public int compareTo(Constant o) { + if(o instanceof UntypedConstant) { + return 1; + } + String str = literal + datatype; + String str2 = o.literal + ((TypedConstant)o).datatype; + return str.compareTo(str2); + } - } Modified: trunk/src/dl-learner/org/dllearner/core/owl/UntypedConstant.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/UntypedConstant.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/core/owl/UntypedConstant.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -113,6 +113,15 @@ return literal; } } + + @Override + public int compareTo(Constant o) { + if(o instanceof TypedConstant) { + return -1; + } + String str = literal + lang; + String str2 = ((UntypedConstant)o).literal + ((UntypedConstant)o).lang; + return str.compareTo(str2); + } - } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -998,6 +998,12 @@ } @Override + public Map<Individual, SortedSet<Constant>> getDatatypeMembersImpl( + DatatypeProperty datatypeProperty) { + return rc.getDatatypeMembersImpl(datatypeProperty); + } + + @Override public Set<Individual> getRelatedIndividualsImpl(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { return rc.getRelatedIndividuals(individual, objectProperty); } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -205,6 +205,7 @@ useAllConstructor = configurator.getUseAllConstructor(); useExistsConstructor = configurator.getUseExistsConstructor(); useHasValueConstructor = configurator.getUseHasValueConstructor(); + useDataHasValueConstructor = configurator.getUseDataHasValueConstructor(); frequencyThreshold = configurator.getValueFrequencyThreshold(); useCardinalityRestrictions = configurator.getUseCardinalityRestrictions(); cardinalityLimit = configurator.getCardinalityLimit(); @@ -231,6 +232,7 @@ this.frequencyThreshold = valueFrequencyThreshold; this.useCardinalityRestrictions = useCardinalityRestrictions; cardinalityLimit = configurator.getCardinalityLimit(); + this.useDataHasValueConstructor = configurator.getUseDataHasValueConstructor(); this.useNegation = useNegation; this.useBooleanDatatypes = useBooleanDatatypes; this.useDoubleDatatypes = useDoubleDatatypes; Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptComparator.java 2010-02-08 10:08:43 UTC (rev 1993) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptComparator.java 2010-02-08 19:02:07 UTC (rev 1994) @@ -23,8 +23,10 @@ import java.util.Set; import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypeSomeRestriction; +import org.dllearner.core.owl.DatatypeValueRestriction; import org.dllearner.core.owl.DoubleMaxValue; import org.dllearner.core.owl.DoubleMinValue; import org.dllearner.core.owl.Individual; @@ -204,8 +206,23 @@ } } else return -1; + } else if(concept1 instanceof DatatypeValueRestriction) { + if(concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction || concept2 instanceof DatatypeSomeRestriction || concept2 instanceof ObjectValueRestriction) { + return 1; + } else if(concept2 instanceof DatatypeValueRestriction) { + int roleCompare = rc.compare(((DatatypeValueRestriction)concept1).getRestrictedPropertyExpression(), ((DatatypeValueRestriction)concept2).getRestrictedPropertyExpression()); + + if(roleCompare == 0) { + Constant value1 = ((DatatypeValueRestriction)concept1).getValue(); + Constant value2 = ((DatatypeValueRestriction)concept2).getValue(); + return value1.compareTo(value2); + } else { + return roleCompare; + } + } else + return -1; } else if(concept1 instanceof Thing) { - if(concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction || concept2 instanceof DatatypeSomeRestriction || concept2 instanceof ObjectValueRestriction) + if(concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction || concept2 instanceof DatatypeSomeRestriction || concept2 instanceof ObjectValueRestriction || concept2 instanceof DatatypeValueRestriction) return 1; else if(concept2 instanceof Thing) return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |