From: <jen...@us...> - 2008-10-24 06:21:50
|
Revision: 1421 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1421&view=rev Author: jenslehmann Date: 2008-10-24 06:21:43 +0000 (Fri, 24 Oct 2008) Log Message: ----------- added reasoning methods getRelatedIndividuals + getRelatedValues 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/ReasoningService.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-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -75,6 +75,10 @@ public SortedSet<Individual> retrieval(Description concept) throws ReasoningMethodUnsupportedException; + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; + + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) throws ReasoningMethodUnsupportedException; public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -104,6 +104,14 @@ throw new ReasoningMethodUnsupportedException(); } + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -28,6 +28,7 @@ import java.util.TreeSet; import org.apache.log4j.Logger; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypePropertyHierarchy; @@ -456,8 +457,24 @@ return result; } - // gibt zu einer Rolle alle Elemente zur�ck - // private, da es keine Standardoperation ist + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { + try { + return reasoner.getRelatedIndividuals(individual, objectProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + try { + return reasoner.getRelatedValues(individual, datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) { reasoningStartTimeTmp = System.nanoTime(); Map<Individual, SortedSet<Individual>> result; Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -43,6 +43,7 @@ import org.dllearner.core.configurators.ComponentFactory; import org.dllearner.core.configurators.FastInstanceCheckerConfigurator; import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypePropertyHierarchy; @@ -666,6 +667,16 @@ return opPos.get(atomicRole); } + @Override + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { + return rc.getRelatedIndividuals(individual, objectProperty); + } + + @Override + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + return rc.getRelatedValues(individual, datatypeProperty); + } + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -705,6 +705,55 @@ return map; } + @Override + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) { + OWLIndividual ind = factory.getOWLIndividual(URI.create(individual.getName())); + OWLObjectProperty prop = getOWLAPIDescription(objectProperty); + Set<OWLIndividual> inds = null; + try { + inds = reasoner.getRelatedIndividuals(ind, prop); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + // convert data back to DL-Learner structures + SortedSet<Individual> is = new TreeSet<Individual>(); + for(OWLIndividual oi : inds) { + is.add(new Individual(oi.getURI().toString())); + } + return is; + } + + @Override + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) { + OWLIndividual ind = factory.getOWLIndividual(URI.create(individual.getName())); + OWLDataProperty prop = getOWLAPIDescription(datatypeProperty); + Set<OWLConstant> constants = null; + try { + constants = reasoner.getRelatedValues(ind, prop); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + // convert data back to DL-Learner structures + SortedSet<Constant> is = new TreeSet<Constant>(); + for(OWLConstant oi : constants) { + // for typed constants we have to figure out the correct + // data type and value + if(oi instanceof OWLTypedConstant) { + Datatype dt = convertDatatype(((OWLTypedConstant)oi).getDataType()); + is.add(new TypedConstant(oi.getLiteral(),dt)); + // for untyped constants we have to figure out the value + // and language tag (if any) + } else { + OWLUntypedConstant ouc = (OWLUntypedConstant) oi; + if(ouc.hasLang()) + is.add(new UntypedConstant(ouc.getLiteral(), ouc.getLang())); + else + is.add(new UntypedConstant(ouc.getLiteral())); + } + } + return is; + } + public Map<Individual, SortedSet<Double>> getDoubleValues(DatatypeProperty datatypeProperty) { OWLDataProperty prop = getOWLAPIDescription(datatypeProperty); Map<Individual, SortedSet<Double>> map = new TreeMap<Individual, SortedSet<Double>>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |