From: <jen...@us...> - 2008-02-24 17:48:02
|
Revision: 635 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=635&view=rev Author: jenslehmann Date: 2008-02-24 09:47:44 -0800 (Sun, 24 Feb 2008) Log Message: ----------- - boolean hasValue restrictions - Datatype now implemented as enum (easier programmatic access) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java trunk/src/dl-learner/org/dllearner/parser/kb.jj Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-24 17:47:44 UTC (rev 635) @@ -42,6 +42,7 @@ import org.dllearner.core.owl.ObjectPropertyExpression; import org.dllearner.core.owl.ObjectQuantorRestriction; import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.ValueRestriction; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; @@ -143,7 +144,8 @@ } else if (concept instanceof Nothing) { // return new HashSet<Concept>(); -// } else if (concept instanceof ) + } else if (concept instanceof ValueRestriction) { + // value restrictions cannot be further refined } else if (concept instanceof NamedClass) { // Erkenntnisse aus Benchmarks: dieser Teil wird sehr häufig aufgerufen, // allerdings lässt er sich kaum weiter verbessern (selbst ohne klonen Modified: trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java 2008-02-24 17:47:44 UTC (rev 635) @@ -28,7 +28,7 @@ * @author Jens Lehmann * */ -public class BooleanDataRange extends DataRange { +public class BooleanDataRange implements DataRange { private boolean isTrue; Added: trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java 2008-02-24 17:47:44 UTC (rev 635) @@ -0,0 +1,47 @@ +/** + * 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; + +/** + * Convenience class for boolean value restrictions. + * + * @author Jens Lehmann + * + */ +public class BooleanValueRestriction extends DatatypeValueRestriction { + + /** + * TODO: Internally a typed constant with datatype boolean and + * strings "true" or "false" is created. This is a clean way to + * implement boolean value restrictions. However, if they are + * created millions of times during the run of an algorithm, + * this may cause unnecessary delays. + * Possible Solution: It may be good to create a BooleanConstant + * class, which just holds the boolean value and only performs + * operations when requested. + * + * @param restrictedPropertyExpression + * @param value + */ + public BooleanValueRestriction(DatatypeProperty restrictedPropertyExpression, Boolean value) { + super(restrictedPropertyExpression, new TypedConstant(value.toString(), Datatype.BOOLEAN)); + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java 2008-02-24 17:47:44 UTC (rev 635) @@ -23,6 +23,6 @@ * @author Jens Lehmann * */ -public abstract class DataRange implements PropertyRange { +public interface DataRange extends PropertyRange { } Deleted: trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-24 17:47:44 UTC (rev 635) @@ -1,82 +0,0 @@ -/** - * 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.net.URI; -import java.util.Map; - -/** - * Enumeration of possible types wrapped in a class such that - * it is a valid data range. - * - * @author Jens Lehmann - * - */ -public class Datatype extends DataRange { - - public enum Type { DOUBLE, INT, BOOLEAN }; - - private Type type; - - private static final String xsd = "http://www.w3.org/2001/XMLSchema#"; - - public Datatype(Type type) { - this.type = type; - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.KBElement#accept(org.dllearner.core.owl.KBElementVisitor) - */ - public void accept(KBElementVisitor visitor) { - visitor.visit(this); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.KBElement#getLength() - */ - public int getLength() { - return 1; - } - - /* (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; - } - - public URI getURI() { - switch(type) { - case DOUBLE: return URI.create(xsd + "double"); - case INT: return URI.create(xsd + "int"); - case BOOLEAN: return URI.create(xsd + "Boolean"); - default: throw new Error("Unknown tpye " + type + "."); - } - } - - /** - * @return the type - */ - public Type getType() { - return type; - } - -} Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-24 17:47:44 UTC (rev 635) @@ -67,6 +67,10 @@ return restrictedPropertyExpression.toString(baseURI, prefixes) + " = " + value.toString(baseURI, prefixes); } + public DatatypeProperty getRestrictedPropertyExpresssion() { + return (DatatypeProperty) restrictedPropertyExpression; + } + @Override public Constant getValue() { return (Constant) value; Modified: trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java 2008-02-24 17:47:44 UTC (rev 635) @@ -25,6 +25,6 @@ * @author Jens Lehmann * */ -public abstract class DoubleDataRange extends DataRange { +public interface DoubleDataRange extends DataRange { } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java 2008-02-24 17:47:44 UTC (rev 635) @@ -28,7 +28,7 @@ * @author Jens Lehmann * */ -public class DoubleMaxValue extends DoubleDataRange { +public class DoubleMaxValue implements DoubleDataRange { private double value; Modified: trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java 2008-02-24 17:47:44 UTC (rev 635) @@ -28,7 +28,7 @@ * @author Jens Lehmann * */ -public class DoubleMinValue extends DoubleDataRange { +public class DoubleMinValue implements DoubleDataRange { private double value; Modified: trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java 2008-02-24 17:47:44 UTC (rev 635) @@ -47,7 +47,7 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return literal + datatype.toString(baseURI, prefixes); + return literal + "^^" + datatype; } /** Modified: trunk/src/dl-learner/org/dllearner/parser/kb.jj =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-24 17:47:44 UTC (rev 635) @@ -227,9 +227,9 @@ DatatypePropertyRangeAxiom DatatypePropertyRangeAxiom() : {DatatypeProperty op; DataRange range; } { ( "DPRANGE" | "DATATYPEPROPERTYRANGE") "(" op=DatatypeProperty() ")" "=" - ( "DOUBLE" { range = new Datatype(Datatype.Type.DOUBLE); } - | "BOOLEAN" { range = new Datatype(Datatype.Type.BOOLEAN); } - | "INTEGER" { range = new Datatype(Datatype.Type.INT); } ) + ( "DOUBLE" { range = Datatype.DOUBLE; } + | "BOOLEAN" { range = Datatype.BOOLEAN; } + | "INTEGER" { range = Datatype.INT; } ) <COMMAND_END> { return new DatatypePropertyRangeAxiom(op, range); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |