From: <jen...@us...> - 2008-02-22 21:58:49
|
Revision: 630 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=630&view=rev Author: jenslehmann Date: 2008-02-22 13:58:43 -0800 (Fri, 22 Feb 2008) Log Message: ----------- added support for boolean datatype restrictions Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/BooleanDatatypePropertyAssertion.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java 2008-02-22 17:05:52 UTC (rev 629) +++ trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java 2008-02-22 21:58:43 UTC (rev 630) @@ -33,4 +33,6 @@ public void visit(DoubleDatatypePropertyAssertion axiom); + public void visit(BooleanDatatypePropertyAssertion axiom); + } Added: trunk/src/dl-learner/org/dllearner/core/owl/BooleanDatatypePropertyAssertion.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanDatatypePropertyAssertion.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanDatatypePropertyAssertion.java 2008-02-22 21:58:43 UTC (rev 630) @@ -0,0 +1,54 @@ +/** + * 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; + +/** + * @author Jens Lehmann + * + */ +public class BooleanDatatypePropertyAssertion extends DatatypePropertyAssertion { + + private boolean value; + + public BooleanDatatypePropertyAssertion(DatatypeProperty datatypeProperty, Individual individual, boolean value) { + super(datatypeProperty, individual); + this.value = value; + } + + public String toString(String baseURI, Map<String, String> prefixes) { + return datatypeProperty.toString(baseURI, prefixes) + "(" + individual.toString(baseURI, prefixes) + "," + value +")"; + } + + public boolean getValue() { + return value; + } + + @Override + public void accept(AxiomVisitor visitor) { + visitor.visit(this); + } + + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } + +} Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-22 17:05:52 UTC (rev 629) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-22 21:58:43 UTC (rev 630) @@ -31,6 +31,7 @@ import java.util.Set; import java.util.TreeSet; +import org.dllearner.core.owl.BooleanDatatypePropertyAssertion; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.ClassAssertionAxiom; @@ -88,7 +89,7 @@ // we need a counter for bonds, because they are instances in OWL // but not in Prolog private static int bondNr = 0; - + /** * @param args * No arguments supported. @@ -216,13 +217,27 @@ // Body body = clause.getBody(); // ArrayList<Literal> literals = body.getLiterals(); // handle: atm(compound,atom,element,atomtype,charge) - if (headName.equals("atm")) { - + + // Ames-Test: http://en.wikipedia.org/wiki/Ames_test + // problem: the file apparently mentions only positive + // tests (why is it different from the other tests e.g. in + // gentoxprops.pl?) => we need to add negative axioms for the + // remaining stuff or use closed world assumption in the + // TBox dematerialisation later on + if(headName.equals("ames")) { String compoundName = head.getArgument(0).toPLString(); + BooleanDatatypePropertyAssertion ames = getBooleanDatatypePropertyAssertion(compoundName, "amesTestPositive", true); + axioms.add(ames); + + } else if (headName.equals("atm")) { + String compoundName = head.getArgument(0).toPLString(); String atomName = head.getArgument(1).toPLString(); String elementName = head.getArgument(2).toPLString(); String type = head.getArgument(3).toPLString(); double charge = Double.parseDouble(head.getArgument(4).toPLString()); + // make the compound an instance of the Compound class + ClassAssertionAxiom cmpAxiom = getConceptAssertion("Compound", compoundName); + axioms.add(cmpAxiom); // relate compound and atom ObjectPropertyAssertion ra = getRoleAssertion("hasAtom", compoundName, atomName); axioms.add(ra); @@ -272,6 +287,7 @@ System.out.println("unsupported clause"); System.out.println(clause.toPLString()); System.out.println(clause); +// System.exit(0); } return axioms; } @@ -323,6 +339,13 @@ return new ObjectPropertyAssertion(ar, ind1, ind2); } + private static BooleanDatatypePropertyAssertion getBooleanDatatypePropertyAssertion( + String individual, String datatypeProperty, boolean value) { + Individual ind = getIndividual(individual); + DatatypeProperty dp = getDatatypeProperty(datatypeProperty); + return new BooleanDatatypePropertyAssertion(dp, ind, value); + } + private static DoubleDatatypePropertyAssertion getDoubleDatatypePropertyAssertion( String individual, String datatypeProperty, double value) { Individual ind = getIndividual(individual); Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-22 17:05:52 UTC (rev 629) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-22 21:58:43 UTC (rev 630) @@ -25,6 +25,7 @@ import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.AxiomVisitor; +import org.dllearner.core.owl.BooleanDatatypePropertyAssertion; import org.dllearner.core.owl.ClassAssertionAxiom; import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.Datatype; @@ -146,6 +147,19 @@ addAxiom(axiomOWLAPI); } + /* (non-Javadoc) + * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.BooleanDatatypePropertyAssertion) + */ + public void visit(BooleanDatatypePropertyAssertion axiom) { + OWLIndividual i = factory.getOWLIndividual(URI.create(axiom.getIndividual().getName())); + OWLDataProperty dp = factory.getOWLDataProperty(URI.create(axiom.getDatatypeProperty().getName())); + Boolean value = axiom.getValue(); + OWLDataType booleanType = factory.getOWLDataType(XSDVocabulary.BOOLEAN.getURI()); + OWLTypedConstant valueConstant = factory.getOWLTypedConstant(value.toString(), booleanType); + OWLAxiom axiomOWLAPI = factory.getOWLDataPropertyAssertionAxiom(i, dp, valueConstant); + addAxiom(axiomOWLAPI); + } + /* * (non-Javadoc) * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |