From: <jen...@us...> - 2008-02-12 09:20:08
|
Revision: 545 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=545&view=rev Author: jenslehmann Date: 2008-02-12 01:20:06 -0800 (Tue, 12 Feb 2008) Log Message: ----------- - added more OWL structures, in particular datatype some-restrictions and data ranges - continued visitor pattern - implemented DL-Learner to OWL API converter using visitors Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Description.java trunk/src/dl-learner/org/dllearner/core/owl/DescriptionVisitor.java trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java trunk/src/dl-learner/org/dllearner/core/owl/Negation.java trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Thing.java trunk/src/dl-learner/org/dllearner/core/owl/Union.java trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/package.html trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Added Paths: ----------- 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/DatatypeQuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.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/PropertyExpression.java trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIConverterVisitor.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2008-02-12 09:20:06 UTC (rev 545) @@ -3,6 +3,7 @@ import java.util.Map; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.DescriptionVisitor; public class ADC extends Description { @@ -29,4 +30,13 @@ public int getArity() { return 0; } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } + } Added: trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,28 @@ +/** + * 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; + +/** + * @author Jens Lehmann + * + */ +public class BooleanDataRange extends DataRange { + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -23,6 +23,6 @@ * @author Jens Lehmann * */ -public abstract class CardinalityRestriction extends Description { +public abstract class CardinalityRestriction extends Restriction { } Added: trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,28 @@ +/** + * 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; + +/** + * @author Jens Lehmann + * + */ +public abstract class DataRange { + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -51,5 +51,13 @@ // TODO Auto-generated method stub return null; } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -52,4 +52,11 @@ return null; } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -52,4 +52,11 @@ return null; } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2008-02-12 09:20:06 UTC (rev 545) @@ -27,7 +27,7 @@ * @author Jens Lehmann * */ -public class DatatypeProperty implements Property { +public class DatatypeProperty extends PropertyExpression implements Property { protected String name; Added: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,28 @@ +/** + * 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; + +/** + * @author Jens Lehmann + * + */ +public abstract class DatatypeQuantorRestriction extends QuantorRestriction { + +} Added: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,70 @@ +/** + * 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.Map; + +/** + * This class represents restrictions on datatypes, such as + * Man AND EXISTS hasAge >= 18. + * + * TODO: connect this with a data range and a datatype property + * + * @author Jens Lehmann + * + */ +public class DatatypeSomeRestriction extends DatatypeQuantorRestriction { + + + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#getArity() + */ + @Override + public int getArity() { + // TODO Auto-generated method stub + return 0; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#getLength() + */ + public int getLength() { + // TODO Auto-generated method stub + return 0; + } + + /* (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; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -25,4 +25,11 @@ */ public class DatatypeValueRestriction extends ValueRestriction { + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Description.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Description.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/Description.java 2008-02-12 09:20:06 UTC (rev 545) @@ -274,5 +274,6 @@ public String toString() { return toString(null, null); } - + + public abstract void accept(DescriptionVisitor visitor); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DescriptionVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DescriptionVisitor.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/DescriptionVisitor.java 2008-02-12 09:20:06 UTC (rev 545) @@ -19,6 +19,8 @@ */ package org.dllearner.core.owl; +import org.dllearner.algorithms.gp.ADC; + /** * Visitor for elements in complex class descriptions (it supports * the currently relevant ones - needs to be extended when further @@ -28,13 +30,19 @@ * */ public interface DescriptionVisitor { - + + public void visit(NamedClass description); + + public void visit(ADC description); + public void visit(Negation description); public void visit(ObjectAllRestriction description); public void visit(ObjectSomeRestriction description); + public void visit(DatatypeSomeRestriction description); + public void visit(Nothing description); public void visit(Thing description); @@ -51,5 +59,12 @@ public void visit(ObjectValueRestriction description); + public void visit(DatatypeMinCardinalityRestriction description); + + public void visit(DatatypeExactCardinalityRestriction description); + + public void visit(DatatypeMaxCardinalityRestriction description); + public void visit(DatatypeValueRestriction description); + } Added: trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,30 @@ +/** + * 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; + +/** + * Ranges of type double for use in datatye restrictions. + * + * @author Jens Lehmann + * + */ +public abstract class DoubleDataRange extends DataRange { + +} Added: trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,44 @@ +/** + * 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; + +/** + * Double data range restricted by a maximum value, e.g. + * hasAge <= 65. + * + * @author Jens Lehmann + * + */ +public class DoubleMaxValue extends DoubleDataRange { + + private double value; + + public DoubleMaxValue(double value) { + this.value = value; + } + + /** + * @return The maximum value. + */ + public double getValue() { + return value; + } + +} Added: trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,44 @@ +/** + * 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; + +/** + * Double data range restricted by a maximum value, e.g. + * hasAge >= 18. + * + * @author Jens Lehmann + * + */ +public class DoubleMinValue extends DoubleDataRange { + + private double value; + + public DoubleMinValue(double value) { + this.value = value; + } + + /** + * @return The maximum value. + */ + public double getValue() { + return value; + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java 2008-02-12 09:20:06 UTC (rev 545) @@ -55,4 +55,11 @@ return ret; } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-02-12 09:20:06 UTC (rev 545) @@ -60,4 +60,11 @@ return Helper.getAbbreviatedString(name, baseURI, prefixes); } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Negation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Negation.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/Negation.java 2008-02-12 09:20:06 UTC (rev 545) @@ -31,4 +31,11 @@ return 1; } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2008-02-12 09:20:06 UTC (rev 545) @@ -26,4 +26,12 @@ public int getArity() { return 0; } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -96,4 +96,11 @@ } */ + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -1,6 +1,6 @@ package org.dllearner.core.owl; -public abstract class ObjectCardinalityRestriction extends Description { +public abstract class ObjectCardinalityRestriction extends CardinalityRestriction { protected ObjectPropertyExpression role; protected int number; Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -40,4 +40,11 @@ return "= " + number + " " + role.toString(baseURI, prefixes) + " " + getChild(0).toString(baseURI, prefixes); } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -16,4 +16,12 @@ public String toString(String baseURI, Map<String,String> prefixes) { return "<= " + number + " " + role.toString(baseURI, prefixes) + " " + getChild(0).toString(baseURI, prefixes); } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -16,4 +16,12 @@ public String toString(String baseURI, Map<String,String> prefixes) { return ">= " + number + " " + role.toString(baseURI, prefixes) + " " + getChild(0).toString(baseURI, prefixes); } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java 2008-02-12 09:20:06 UTC (rev 545) @@ -27,7 +27,7 @@ * @author Jens Lehmann * */ -public abstract class ObjectPropertyExpression implements KBElement { +public abstract class ObjectPropertyExpression extends PropertyExpression implements KBElement { protected String name; Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -1,6 +1,6 @@ package org.dllearner.core.owl; -public abstract class ObjectQuantorRestriction extends Description { +public abstract class ObjectQuantorRestriction extends QuantorRestriction { ObjectPropertyExpression role; Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -95,5 +95,13 @@ public int getLength() { return 2; } - */ + */ + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -25,4 +25,12 @@ */ public class ObjectValueRestriction extends ValueRestriction { + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } + } Added: trunk/src/dl-learner/org/dllearner/core/owl/PropertyExpression.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/PropertyExpression.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/PropertyExpression.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,28 @@ +/** + * 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; + +/** + * @author Jens Lehmann + * + */ +public abstract class PropertyExpression implements KBElement { + +} Added: trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,28 @@ +/** + * 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; + +/** + * @author Jens Lehmann + * + */ +public abstract class QuantorRestriction extends Restriction { + +} Added: trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,29 @@ +/** + * 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; + +/** + * @author Jens Lehmann + * + */ +public abstract class Restriction extends Description { + + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/Thing.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Thing.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/Thing.java 2008-02-12 09:20:06 UTC (rev 545) @@ -23,5 +23,13 @@ @Override public int getArity() { return 0; - } + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Union.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Union.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/Union.java 2008-02-12 09:20:06 UTC (rev 545) @@ -57,4 +57,12 @@ return ret; } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + */ + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-02-12 09:20:06 UTC (rev 545) @@ -25,7 +25,7 @@ * @author Jens Lehmann * */ -public class ValueRestriction extends Description { +public abstract class ValueRestriction extends Description { /* (non-Javadoc) * @see org.dllearner.core.owl.Concept#getArity() Modified: trunk/src/dl-learner/org/dllearner/core/owl/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/package.html 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/core/owl/package.html 2008-02-12 09:20:06 UTC (rev 545) @@ -2,6 +2,6 @@ <html> <head></head> <body bgcolor="white"> -<p>Classes for representing Description Logic constructs.</p> +<p>Classes for representing OWL constructs.</p> </body> </html> \ No newline at end of file Copied: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java (from rev 543, trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIConverterVisitor.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,209 @@ +/** + * 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.reasoning; + +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +import org.dllearner.core.owl.AxiomVisitor; +import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.DoubleDatatypePropertyAssertion; +import org.dllearner.core.owl.EquivalentClassesAxiom; +import org.dllearner.core.owl.FunctionalObjectPropertyAxiom; +import org.dllearner.core.owl.InverseObjectPropertyAxiom; +import org.dllearner.core.owl.KB; +import org.dllearner.core.owl.ObjectPropertyAssertion; +import org.dllearner.core.owl.SubClassAxiom; +import org.dllearner.core.owl.SymmetricObjectPropertyAxiom; +import org.dllearner.core.owl.TransitiveObjectPropertyAxiom; +import org.semanticweb.owl.model.AddAxiom; +import org.semanticweb.owl.model.OWLAxiom; +import org.semanticweb.owl.model.OWLDataFactory; +import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.OWLIndividual; +import org.semanticweb.owl.model.OWLObjectProperty; +import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLOntologyChangeException; +import org.semanticweb.owl.model.OWLOntologyManager; + +// static import for easy access to the description converter +import static org.dllearner.reasoning.OWLAPIDescriptionConvertVisitor.getOWLDescription; + +/** + * A converter from DL-Learner axioms to OWL API axioms based on the visitor + * pattern. + * + * TODO: Investigate whether OWLOntologyManager and OWLOntology should be + * removed as parameters. It would be natural to have a DL-Learner KB as input + * and an OWL API OWLOntology as output. + * + * @author Jens Lehmann + * + */ +public class OWLAPIAxiomConvertVisitor implements AxiomVisitor { + + OWLDataFactory factory; + private OWLOntology ontology; + private OWLOntologyManager manager; + + public OWLAPIAxiomConvertVisitor(OWLOntologyManager manager, OWLOntology ontology, KB kb) { + this.manager = manager; + this.ontology = ontology; + factory = manager.getOWLDataFactory(); + } + + public static void fillOWLOntology(OWLOntologyManager manager, OWLOntology ontology, KB kb) { + // OWLAPIAxiomConvertVisitor converter = new OWLAPIAxiomConvertVisitor(manager, ontology, kb); + // for(Axiom axiom : kb.getTbox()) + // axiom.accept(this); + // return converter.getOWLDescription(); + } + + // convencience function for adding an axiom to the ontology + private void addAxiom(OWLAxiom axiom) { + AddAxiom addAxiom = new AddAxiom(ontology, axiom); + try { + manager.applyChange(addAxiom); + } catch (OWLOntologyChangeException e) { + e.printStackTrace(); + } + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.dl.AxiomVisitor#visit(org.dllearner.core.dl.ObjectPropertyAssertion) + */ + public void visit(ObjectPropertyAssertion axiom) { + OWLObjectProperty role = factory.getOWLObjectProperty(URI + .create(((ObjectPropertyAssertion) axiom).getRole().getName())); + OWLIndividual i1 = factory.getOWLIndividual(URI.create(((ObjectPropertyAssertion) axiom) + .getIndividual1().getName())); + OWLIndividual i2 = factory.getOWLIndividual(URI.create(((ObjectPropertyAssertion) axiom) + .getIndividual2().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLObjectPropertyAssertionAxiom(i1, role, i2); + addAxiom(axiomOWLAPI); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.ClassAssertionAxiom) + */ + public void visit(ClassAssertionAxiom axiom) { + OWLDescription d = getOWLDescription(axiom.getConcept()); + OWLIndividual i = factory.getOWLIndividual(URI.create(((ClassAssertionAxiom) axiom) + .getIndividual().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLClassAssertionAxiom(i, d); + addAxiom(axiomOWLAPI); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.DoubleDatatypePropertyAssertion) + */ + public void visit(DoubleDatatypePropertyAssertion axiom) { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.FunctionalObjectPropertyAxiom) + */ + public void visit(FunctionalObjectPropertyAxiom axiom) { + OWLObjectProperty role = factory.getOWLObjectProperty( + URI.create(((FunctionalObjectPropertyAxiom) axiom).getRole().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLFunctionalObjectPropertyAxiom(role); + addAxiom(axiomOWLAPI); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.InverseObjectPropertyAxiom) + */ + public void visit(InverseObjectPropertyAxiom axiom) { + OWLObjectProperty role = factory.getOWLObjectProperty( + URI.create(((InverseObjectPropertyAxiom) axiom).getRole().getName())); + OWLObjectProperty inverseRole = factory.getOWLObjectProperty( + URI.create(((InverseObjectPropertyAxiom) axiom).getInverseRole().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLInverseObjectPropertiesAxiom(role, inverseRole); + addAxiom(axiomOWLAPI); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.SymmetricObjectPropertyAxiom) + */ + public void visit(SymmetricObjectPropertyAxiom axiom) { + OWLObjectProperty role = factory.getOWLObjectProperty( + URI.create(((SymmetricObjectPropertyAxiom) axiom).getRole().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLSymmetricObjectPropertyAxiom(role); + addAxiom(axiomOWLAPI); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.TransitiveObjectPropertyAxiom) + */ + public void visit(TransitiveObjectPropertyAxiom axiom) { + OWLObjectProperty role = factory.getOWLObjectProperty( + URI.create(axiom.getRole().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLTransitiveObjectPropertyAxiom(role); + addAxiom(axiomOWLAPI); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.owl.TerminologicalAxiomVisitor#visit(org.dllearner.core.owl.EquivalentClassesAxiom) + */ + public void visit(EquivalentClassesAxiom axiom) { + OWLDescription d1 = getOWLDescription(axiom.getConcept1()); + OWLDescription d2 = getOWLDescription(axiom.getConcept2()); + Set<OWLDescription> ds = new HashSet<OWLDescription>(); + ds.add(d1); + ds.add(d2); + OWLAxiom axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); + addAxiom(axiomOWLAPI); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.owl.TerminologicalAxiomVisitor#visit(org.dllearner.core.owl.SubClassAxiom) + */ + public void visit(SubClassAxiom axiom) { + OWLDescription d1 = getOWLDescription(axiom.getSubConcept()); + OWLDescription d2 = getOWLDescription(axiom.getSuperConcept()); + Set<OWLDescription> ds = new HashSet<OWLDescription>(); + ds.add(d1); + ds.add(d2); + OWLAxiom axiomOWLAPI = factory.getOWLSubClassAxiom(d1,d2); + addAxiom(axiomOWLAPI); + } + +} Deleted: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIConverterVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIConverterVisitor.java 2008-02-12 09:15:20 UTC (rev 544) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIConverterVisitor.java 2008-02-12 09:20:06 UTC (rev 545) @@ -1,284 +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.reasoning; - -import java.net.URI; - -import org.dllearner.core.owl.ClassAssertionAxiom; -import org.dllearner.core.owl.DatatypeProperty; -import org.dllearner.core.owl.DatatypeValueRestriction; -import org.dllearner.core.owl.DoubleDatatypePropertyAssertion; -import org.dllearner.core.owl.EquivalentClassesAxiom; -import org.dllearner.core.owl.FunctionalObjectPropertyAxiom; -import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.InverseObjectPropertyAxiom; -import org.dllearner.core.owl.KB; -import org.dllearner.core.owl.KBElementVisitor; -import org.dllearner.core.owl.Negation; -import org.dllearner.core.owl.Nothing; -import org.dllearner.core.owl.ObjectAllRestriction; -import org.dllearner.core.owl.ObjectExactCardinalityRestriction; -import org.dllearner.core.owl.ObjectMaxCardinalityRestriction; -import org.dllearner.core.owl.ObjectMinCardinalityRestriction; -import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectPropertyAssertion; -import org.dllearner.core.owl.ObjectPropertyInverse; -import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.ObjectValueRestriction; -import org.dllearner.core.owl.SubClassAxiom; -import org.dllearner.core.owl.SymmetricObjectPropertyAxiom; -import org.dllearner.core.owl.Thing; -import org.dllearner.core.owl.TransitiveObjectPropertyAxiom; -import org.dllearner.core.owl.Union; -import org.semanticweb.owl.model.AddAxiom; -import org.semanticweb.owl.model.OWLAxiom; -import org.semanticweb.owl.model.OWLDataFactory; -import org.semanticweb.owl.model.OWLIndividual; -import org.semanticweb.owl.model.OWLObjectProperty; -import org.semanticweb.owl.model.OWLOntology; -import org.semanticweb.owl.model.OWLOntologyChangeException; -import org.semanticweb.owl.model.OWLOntologyManager; - -/** - * A converter from DL-Learner format to OWL API format. - * - * @author Jens Lehmann - * - */ -public class OWLAPIConverterVisitor implements KBElementVisitor { - - OWLDataFactory factory; - private OWLOntology ontology; - private OWLOntologyManager manager; - - public OWLAPIConverterVisitor(OWLOntologyManager manager, OWLOntology ontology, KB kb) { - this.manager = manager; - this.ontology = ontology; - factory = manager.getOWLDataFactory(); - } - - private void addAxiom(OWLAxiom axiom) { - AddAxiom addAxiom = new AddAxiom(ontology, axiom); - try { - manager.applyChange(addAxiom); - } catch (OWLOntologyChangeException e) { - e.printStackTrace(); - } - } - - /* (non-Javadoc) - * @see org.dllearner.core.dl.AxiomVisitor#visit(org.dllearner.core.dl.ObjectPropertyAssertion) - */ - public void visit(ObjectPropertyAssertion axiom) { - OWLObjectProperty role = factory.getOWLObjectProperty( - URI.create(((ObjectPropertyAssertion) axiom).getRole().getName())); - OWLIndividual i1 = factory.getOWLIndividual( - URI.create(((ObjectPropertyAssertion) axiom).getIndividual1().getName())); - OWLIndividual i2 = factory.getOWLIndividual( - URI.create(((ObjectPropertyAssertion) axiom).getIndividual2().getName())); - OWLAxiom axiomOWLAPI = factory.getOWLObjectPropertyAssertionAxiom(i1, role, i2); - addAxiom(axiomOWLAPI); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.ClassAssertionAxiom) - */ - public void visit(ClassAssertionAxiom axiom) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.DoubleDatatypePropertyAssertion) - */ - public void visit(DoubleDatatypePropertyAssertion axiom) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.FunctionalObjectPropertyAxiom) - */ - public void visit(FunctionalObjectPropertyAxiom axiom) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.InverseObjectPropertyAxiom) - */ - public void visit(InverseObjectPropertyAxiom axiom) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.SymmetricObjectPropertyAxiom) - */ - public void visit(SymmetricObjectPropertyAxiom axiom) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.TransitiveObjectPropertyAxiom) - */ - public void visit(TransitiveObjectPropertyAxiom axiom) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.TerminologicalAxiomVisitor#visit(org.dllearner.core.owl.EquivalentClassesAxiom) - */ - public void visit(EquivalentClassesAxiom axiom) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.TerminologicalAxiomVisitor#visit(org.dllearner.core.owl.SubClassAxiom) - */ - public void visit(SubClassAxiom axiom) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Negation) - */ - public void visit(Negation description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectAllRestriction) - */ - public void visit(ObjectAllRestriction description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectSomeRestriction) - */ - public void visit(ObjectSomeRestriction description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Nothing) - */ - public void visit(Nothing description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Thing) - */ - public void visit(Thing description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Intersection) - */ - public void visit(Intersection description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Union) - */ - public void visit(Union description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectMinCardinalityRestriction) - */ - public void visit(ObjectMinCardinalityRestriction description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectExactCardinalityRestriction) - */ - public void visit(ObjectExactCardinalityRestriction description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectMaxCardinalityRestriction) - */ - public void visit(ObjectMaxCardinalityRestriction description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectValueRestriction) - */ - public void visit(ObjectValueRestriction description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.DatatypeValueRestriction) - */ - public void visit(DatatypeValueRestriction description) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyExpressionVisitor#visit(org.dllearner.core.owl.ObjectProperty) - */ - public void visit(ObjectProperty property) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyExpressionVisitor#visit(org.dllearner.core.owl.ObjectPropertyInverse) - */ - public void visit(ObjectPropertyInverse property) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.PropertyExpressionVisitor#visit(org.dllearner.core.owl.DatatypeProperty) - */ - public void visit(DatatypeProperty property) { - // TODO Auto-generated method stub - - } - -} Added: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java 2008-02-12 09:20:06 UTC (rev 545) @@ -0,0 +1,256 @@ +/** + * 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.reasoning; + +import java.net.URI; +import java.util.HashSet; +import java.util.Set; +import java.util.Stack; + +import org.dllearner.algorithms.gp.ADC; +import org.dllearner.core.owl.DatatypeExactCardinalityRestriction; +import org.dllearner.core.owl.DatatypeMaxCardinalityRestriction; +import org.dllearner.core.owl.DatatypeMinCardinalityRestriction; +import org.dllearner.core.owl.DatatypeSomeRestriction; +import org.dllearner.core.owl.DatatypeValueRestriction; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.DescriptionVisitor; +import org.dllearner.core.owl.Intersection; +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.ObjectExactCardinalityRestriction; +import org.dllearner.core.owl.ObjectMaxCardinalityRestriction; +import org.dllearner.core.owl.ObjectMinCardinalityRestriction; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.ObjectValueRestriction; +import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.Union; +import org.dllearner.parser.KBParser; +import org.dllearner.parser.ParseException; +import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.model.OWLDataFactory; +import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.OWLObjectProperty; + +/** + * Converter from DL-Learner descriptions to OWL API descriptions based + * on the visitor pattern. + * + * @author Jens Lehmann + * + */ +public class OWLAPIDescriptionConvertVisitor implements DescriptionVisitor { + + // private OWLDescription description; + private Stack<OWLDescription> stack = new Stack<OWLDescription>(); + + private OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory(); + + public OWLDescription getOWLDescription() { + return stack.pop(); + } + + /** + * Converts a DL-Learner description into an OWL API decription. + * @param description DL-Learner description. + * @return Corresponding OWL API description. + */ + public static OWLDescription getOWLDescription(Description description) { + OWLAPIDescriptionConvertVisitor converter = new OWLAPIDescriptionConvertVisitor(); + description.accept(converter); + return converter.getOWLDescription(); + } + + /** + * Used for testing the OWL API converter. + * + * @param args + */ + public static void main(String[] args) { + try { + Description d = KBParser.parseConcept("(male AND (rich OR NOT stupid))"); + OWLDescription od = OWLAPIDescriptionConvertVisitor.getOWLDescription(d); + System.out.println(d); + System.out.println(od); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Negation) + */ + public void visit(Negation description) { + description.getChild(0).accept(this); + OWLDescription d = stack.pop(); + stack.push(factory.getOWLObjectComplementOf(d)); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectAllRestriction) + */ + public void visit(ObjectAllRestriction description) { + OWLObjectProperty role = factory.getOWLObjectProperty( + URI.create(description.getRole().getName())); + description.getChild(0).accept(this); + OWLDescription d = stack.pop(); + stack.push(factory.getOWLObjectAllRestriction(role, d)); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectSomeRestriction) + */ + public void visit(ObjectSomeRestriction description) { + OWLObjectProperty role = factory.getOWLObjectProperty( + URI.create(description.getRole().getName())); + description.getChild(0).accept(this); + OWLDescription d = stack.pop(); + stack.push(factory.getOWLObjectSomeRestriction(role, d)); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Nothing) + */ + public void visit(Nothing description) { + stack.push(factory.getOWLNothing()); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Thing) + */ + public void visit(Thing description) { + stack.push(factory.getOWLThing()); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Intersection) + */ + public void visit(Intersection description) { + Set<OWLDescription> descriptions = new HashSet<OWLDescription>(); + for(Description child : description.getChildren()) { + child.accept(this); + descriptions.add(stack.pop()); + } + stack.push(factory.getOWLObjectIntersectionOf(descriptions)); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.Union) + */ + public void visit(Union description) { + Set<OWLDescription> descriptions = new HashSet<OWLDescription>(); + for(Description child : description.getChildren()) { + child.accept(this); + descriptions.add(stack.pop()); + } + stack.push(factory.getOWLObjectUnionOf(descriptions)); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectMinCardinalityRestriction) + */ + public void visit(ObjectMinCardinalityRestriction description) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectExactCardinalityRestriction) + */ + public void visit(ObjectExactCardinalityRestriction description) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectMaxCardinalityRestriction) + */ + public void visit(ObjectMaxCardinalityRestriction description) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectValueRestriction) + */ + public void visit(ObjectValueRestriction description) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.DatatypeValueRe... [truncated message content] |