From: <jen...@us...> - 2009-04-08 14:18:11
|
Revision: 1689 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1689&view=rev Author: jenslehmann Date: 2009-04-08 14:18:01 +0000 (Wed, 08 Apr 2009) Log Message: ----------- moved domain to description conversion to separate method Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-04-08 14:00:46 UTC (rev 1688) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-04-08 14:18:01 UTC (rev 1689) @@ -48,7 +48,6 @@ import org.dllearner.core.options.InvalidConfigOptionValueException; import org.dllearner.core.options.StringConfigOption; import org.dllearner.core.owl.Axiom; -import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypeProperty; @@ -102,8 +101,6 @@ import org.semanticweb.owl.util.SimpleURIMapper; import org.semanticweb.owl.vocab.NamespaceOWLOntologyFormat; -import uk.ac.manchester.cs.owl.OWLPropertyAxiomImpl; - /** * Mapping to OWL API reasoner interface. The OWL API currently * supports two reasoners: FaCT++ and Pellet. FaCT++ is connected @@ -632,45 +629,10 @@ public Description getDomainImpl(ObjectProperty objectProperty) { OWLObjectProperty prop = OWLAPIConverter.getOWLAPIObjectProperty(objectProperty); try { - // TODO: look up why OWL API return a two dimensional set here - // instead of only one description (probably there can be several - // domain axiom for one property and the inner set is a conjunction - // of descriptions (?)) - // Answer: this function is just horribly broken in OWL API + // Pellet returns a set of sets of named class, which are more + // general than the actual domain/range Set<Set<OWLDescription>> set = reasoner.getDomains(prop); - - - if(set.size()==0) - return new Thing(); - - Set<OWLDescription> union = new HashSet<OWLDescription>(); - Set<OWLDescription> domains = new HashSet<OWLDescription>(); - - for(Set<OWLDescription> descs : set){ - for(OWLDescription desc : descs){ - union.add(desc); - } - } - for(OWLDescription desc : union){ - boolean isSuperClass = false; - for(Description d : getClassHierarchy().getSubClasses(OWLAPIConverter.convertClass(desc.asOWLClass()))){ - if(union.contains(OWLAPIConverter.getOWLAPIDescription(d))){ - isSuperClass = true; - break; - } - } - if(!isSuperClass){ - domains.add(desc); - } - } - - OWLClass oc = (OWLClass) domains.iterator().next(); - String str = oc.getURI().toString(); - if(str.equals("http://www.w3.org/2002/07/owl#Thing")) { - return new Thing(); - } else { - return new NamedClass(str); - } + return getDescriptionFromReturnedDomain(set); } catch (OWLReasonerException e) { throw new Error(e); } @@ -680,43 +642,9 @@ public Description getDomainImpl(DatatypeProperty datatypeProperty) { OWLDataProperty prop = OWLAPIConverter.getOWLAPIDataProperty(datatypeProperty); try { - // TODO: look up why OWL API return a two dimensional set here - // instead of only one description (probably there can be several - // domain axiom for one property and the inner set is a conjunction - // of descriptions (?)) - // Answer: this function is just horribly broken in OWL API Set<Set<OWLDescription>> set = reasoner.getDomains(prop); - if(set.size()==0) - return new Thing(); - - Set<OWLDescription> union = new HashSet<OWLDescription>(); - Set<OWLDescription> domains = new HashSet<OWLDescription>(); - - for(Set<OWLDescription> descs : set){ - for(OWLDescription desc : descs){ - union.add(desc); - } - } - for(OWLDescription desc : union){ - boolean isSuperClass = false; - for(Description d : getClassHierarchy().getSubClasses(OWLAPIConverter.convertClass(desc.asOWLClass()))){ - if(union.contains(OWLAPIConverter.getOWLAPIDescription(d))){ - isSuperClass = true; - break; - } - } - if(!isSuperClass){ - domains.add(desc); - } - } - - OWLClass oc = (OWLClass) domains.iterator().next(); - String str = oc.getURI().toString(); - if(str.equals("http://www.w3.org/2002/07/owl#Thing")) { - return new Thing(); - } else { - return new NamedClass(str); - } + return getDescriptionFromReturnedDomain(set); + } catch (OWLReasonerException e) { throw new Error(e); } @@ -736,6 +664,40 @@ } } + private Description getDescriptionFromReturnedDomain(Set<Set<OWLDescription>> set) { + if(set.size()==0) + return new Thing(); + + Set<OWLDescription> union = new HashSet<OWLDescription>(); + Set<OWLDescription> domains = new HashSet<OWLDescription>(); + + for(Set<OWLDescription> descs : set){ + for(OWLDescription desc : descs){ + union.add(desc); + } + } + for(OWLDescription desc : union){ + boolean isSuperClass = false; + for(Description d : getClassHierarchy().getSubClasses(OWLAPIConverter.convertClass(desc.asOWLClass()))){ + if(union.contains(OWLAPIConverter.getOWLAPIDescription(d))){ + isSuperClass = true; + break; + } + } + if(!isSuperClass){ + domains.add(desc); + } + } + + OWLClass oc = (OWLClass) domains.iterator().next(); + String str = oc.getURI().toString(); + if(str.equals("http://www.w3.org/2002/07/owl#Thing")) { + return new Thing(); + } else { + return new NamedClass(str); + } + } + @Override public Map<Individual, SortedSet<Individual>> getPropertyMembersImpl(ObjectProperty atomicRole) { OWLObjectProperty prop = OWLAPIConverter.getOWLAPIObjectProperty(atomicRole); Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-04-08 14:00:46 UTC (rev 1688) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-04-08 14:18:01 UTC (rev 1689) @@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue; import java.io.File; -import java.io.IOException; import java.net.MalformedURLException; import java.util.LinkedList; import java.util.List; @@ -39,7 +38,6 @@ import org.dllearner.core.owl.KB; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.Thing; import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; import org.dllearner.parser.KBParser; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |