From: <jen...@us...> - 2008-08-06 17:54:33
|
Revision: 1056 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1056&view=rev Author: jenslehmann Date: 2008-08-06 17:54:29 +0000 (Wed, 06 Aug 2008) Log Message: ----------- EL refinement operator continued Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-08-06 09:53:31 UTC (rev 1055) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-08-06 17:54:29 UTC (rev 1056) @@ -94,6 +94,35 @@ subsumptionHierarchyUp = hierarchyUpNew; } + /** + * Implements a subsumption check using the hierarchy (no further + * reasoning checks are used). + * @param subClass The (supposedly) more special class. + * @param superClass The (supposedly) more general class. + * @return True if <code>subClass</code> is a subclass of <code>superclass</code>. + */ + public boolean isSubclassOf(NamedClass subClass, NamedClass superClass) { + if(subClass.equals(superClass)) { + return true; + } else { + for(Description moreGeneralClass : subsumptionHierarchyUp.get(subClass)) { + // search the upper classes of the subclass + if(moreGeneralClass instanceof NamedClass) { + if(isSubclassOf((NamedClass)moreGeneralClass, superClass)) { + return true; + } + // we reached top, so we can return false (if top is a direct upper + // class, then no other upper classes can exist) + } else { + return false; + } + } + // we cannot reach the class via any of the upper classes, + // so it is not a super class + return false; + } + } + @Override public String toString() { return toString(false); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2008-08-06 09:53:31 UTC (rev 1055) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2008-08-06 17:54:29 UTC (rev 1056) @@ -29,8 +29,12 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; 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.ObjectProperty; +import org.dllearner.core.owl.SubsumptionHierarchy; +import org.dllearner.core.owl.Thing; import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptComparator; @@ -97,6 +101,27 @@ return Helper.intersection(rs.getMostGeneralRoles(), applicableObjectProperties); } + public Set<NamedClass> getClassCandidates(Description index, Set<NamedClass> existingClasses) { + return getClassCandidatesRecursive(index, existingClasses, Thing.instance); + } + + private Set<NamedClass> getClassCandidatesRecursive(Description index, Set<NamedClass> existingClasses, Description upperClass) { + Set<NamedClass> candidates = new TreeSet<NamedClass>(); + SubsumptionHierarchy sh = rs.getSubsumptionHierarchy(); + for(Description d : sh.getMoreSpecialConcepts(upperClass)) { + // check disjointness with index + if(isDisjoint(d,index)) { + // check whether the class is meaningful, i.e. adds something to the index + // to do this, we need to make sure that the class is not a superclass of the + // index (otherwise we get nothing new) + if(isDisjoint(new Negation(d),index)) { + // TODO further checks + } + } + } + return candidates; + } + private boolean isDisjoint(Description d1, Description d2) { // check whether we have cached this query Map<Description,Boolean> tmp = cachedDisjoints.get(d1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |