From: <jen...@us...> - 2008-02-26 10:47:11
|
Revision: 640 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=640&view=rev Author: jenslehmann Date: 2008-02-26 02:47:09 -0800 (Tue, 26 Feb 2008) Log Message: ----------- added ability to query which datatype properties have one of a specified set of datatypes (double, boolean, int) as ranges in an OWL 1.1 ontology Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-26 10:47:09 UTC (rev 640) @@ -94,6 +94,12 @@ // object properties (of course one could implement it but it is not easy) public Set<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException; + public Set<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException; + + public Set<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException; + + public Set<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException; + public SortedSet<Individual> getIndividuals(); } Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-26 10:47:09 UTC (rev 640) @@ -124,5 +124,17 @@ public Set<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } + + public Set<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Set<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Set<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-26 10:47:09 UTC (rev 640) @@ -30,7 +30,7 @@ DOUBLE ("http://www.w3.org/2001/XMLSchema#double"), INT ("http://www.w3.org/2001/XMLSchema#int"), - BOOLEAN ("http://www.w3.org/2001/XMLSchema#Boolean"); + BOOLEAN ("http://www.w3.org/2001/XMLSchema#boolean"); private URI uri; Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-26 10:47:09 UTC (rev 640) @@ -166,6 +166,8 @@ // define properties including domain and range String kbString = "DPDOMAIN(" + getURI2("charge") + ") = " + getURI2("Atom") + ".\n"; kbString += "DPRANGE(" + getURI2("charge") + ") = DOUBLE.\n"; + kbString += "DPDOMAIN(" + getURI2("amesTestPositive") + ") = " + getURI2("Compound") + ".\n"; + kbString += "DPRANGE(" + getURI2("amesTestPositive") + ") = BOOLEAN.\n"; kbString += "OPDOMAIN(" + getURI2("hasAtom") + ") = " + getURI2("Compound") + ".\n"; kbString += "OPRANGE(" + getURI2("hasAtom") + ") = " + getURI2("Atom") + ".\n"; kbString += "OPDOMAIN(" + getURI2("hasBond") + ") = " + getURI2("Compound") + ".\n"; Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-26 10:47:09 UTC (rev 640) @@ -25,6 +25,7 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeMap; +import java.util.TreeSet; import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; @@ -76,6 +77,9 @@ private Set<NamedClass> atomicConcepts; private Set<ObjectProperty> atomicRoles; private Set<DatatypeProperty> datatypeProperties; + private Set<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); + private Set<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); + private Set<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); private SortedSet<Individual> individuals; private ReasoningService rs; @@ -112,10 +116,18 @@ rc = new OWLAPIReasoner(sources); rc.init(); - atomicConcepts = rc.getAtomicConcepts(); - datatypeProperties = rc.getDatatypeProperties(); - atomicRoles = rc.getAtomicRoles(); - individuals = rc.getIndividuals(); + try { + atomicConcepts = rc.getAtomicConcepts(); + datatypeProperties = rc.getDatatypeProperties(); + booleanDatatypeProperties = rc.getBooleanDatatypeProperties(); + doubleDatatypeProperties = rc.getDoubleDatatypeProperties(); + intDatatypeProperties = rc.getIntDatatypeProperties(); + atomicRoles = rc.getAtomicRoles(); + individuals = rc.getIndividuals(); + } catch (ReasoningMethodUnsupportedException e) { + throw new ComponentInitException("Underlying reasoner does not support all necessary reasoning methods.", e); + } + rs = new ReasoningService(rc); // TODO: some code taken from Helper.createFlatABox, but pasted here because additional things need to @@ -232,6 +244,21 @@ return datatypeProperties; } + @Override + public Set<DatatypeProperty> getBooleanDatatypeProperties() { + return booleanDatatypeProperties; + } + + @Override + public Set<DatatypeProperty> getDoubleDatatypeProperties() { + return doubleDatatypeProperties; + } + + @Override + public Set<DatatypeProperty> getIntDatatypeProperties() { + return intDatatypeProperties; + } + /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getIndividuals() */ Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-26 10:47:09 UTC (rev 640) @@ -43,6 +43,7 @@ import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.owl.AssertionalAxiom; import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.EquivalentClassesAxiom; @@ -79,6 +80,8 @@ import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLDataFactory; import org.semanticweb.owl.model.OWLDataProperty; +import org.semanticweb.owl.model.OWLDataRange; +import org.semanticweb.owl.model.OWLDataType; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLIndividual; import org.semanticweb.owl.model.OWLNamedObject; @@ -124,7 +127,9 @@ Set<NamedClass> atomicConcepts = new TreeSet<NamedClass>(conceptComparator); Set<ObjectProperty> atomicRoles = new TreeSet<ObjectProperty>(roleComparator); Set<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); -// Set<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); + Set<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); + Set<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); + Set<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); SortedSet<Individual> individuals = new TreeSet<Individual>(); public OWLAPIReasoner(Set<KnowledgeSource> sources) { @@ -275,12 +280,19 @@ for(OWLObjectProperty owlProperty : owlObjectProperties) atomicRoles.add(new ObjectProperty(owlProperty.getURI().toString())); for(OWLDataProperty owlProperty : owlDatatypeProperties) { - // empty ranges are returned for ames test positive -// Set<OWLDataRange> ranges = owlProperty.getRanges(allImports); -// System.out.println(owlProperty); -// System.out.println(ranges); - datatypeProperties.add(new DatatypeProperty(owlProperty.getURI().toString())); - System.exit(0); + DatatypeProperty dtp = new DatatypeProperty(owlProperty.getURI().toString()); + Set<OWLDataRange> ranges = owlProperty.getRanges(allImports); + OWLDataRange range = ranges.iterator().next(); + if(range.isDataType()) { + URI uri = ((OWLDataType)range).getURI(); + if(uri.equals(Datatype.BOOLEAN.getURI())) + booleanDatatypeProperties.add(dtp); + else if(uri.equals(Datatype.DOUBLE.getURI())) + doubleDatatypeProperties.add(dtp); + else if(uri.equals(Datatype.INT.getURI())) + intDatatypeProperties.add(dtp); + } + datatypeProperties.add(dtp); } for(OWLIndividual owlIndividual : owlIndividuals) individuals.add(new Individual(owlIndividual.getURI().toString())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |