From: <jen...@us...> - 2009-03-27 11:16:23
|
Revision: 1669 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1669&view=rev Author: jenslehmann Date: 2009-03-27 11:16:11 +0000 (Fri, 27 Mar 2009) Log Message: ----------- started implementing consistency check for added axiom Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/BaseReasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/core/BaseReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/BaseReasoner.java 2009-03-27 10:53:47 UTC (rev 1668) +++ trunk/src/dl-learner/org/dllearner/core/BaseReasoner.java 2009-03-27 11:16:11 UTC (rev 1669) @@ -23,6 +23,7 @@ import java.util.Set; import java.util.SortedSet; +import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Entity; @@ -51,6 +52,13 @@ public boolean isSatisfiable(); /** + * Checks whether adding the specified axiom leads to an inconsistency. + * @param axiom The axiom to be added to the knowledge base. + * @return True of the knowledge base including the axiom is satisfiable. False otherwise. + */ + public boolean remainsSatisfiable(Axiom axiom); + + /** * Gets all named classes in the knowledge base, e.g. Person, City, Car. * @return All named classes in KB. */ Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2009-03-27 10:53:47 UTC (rev 1668) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2009-03-27 11:16:11 UTC (rev 1669) @@ -30,6 +30,7 @@ import java.util.Map.Entry; import org.apache.log4j.Logger; +import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; @@ -398,6 +399,26 @@ } @Override + public final boolean remainsSatisfiable(Axiom axiom) { + reasoningStartTimeTmp = System.nanoTime(); + boolean result; + try { + result = remainsSatisfiableImpl(axiom); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return false; + } + reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; + otherReasoningTimeNs += reasoningDurationTmp; + overallReasoningTimeNs += reasoningDurationTmp; + return result; + } + + protected boolean remainsSatisfiableImpl(Axiom axiom) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + @Override public final Map<ObjectProperty,Set<Individual>> getObjectPropertyRelationships(Individual individual) { try { return getObjectPropertyRelationshipsImpl(individual); Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-03-27 10:53:47 UTC (rev 1668) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-03-27 11:16:11 UTC (rev 1669) @@ -33,9 +33,12 @@ import org.dllearner.core.configurators.ClassLearningProblemConfigurator; import org.dllearner.core.options.ConfigOption; import org.dllearner.core.options.StringConfigOption; +import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.EquivalentClassesAxiom; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.SubClassAxiom; /** * The problem of learning the description of an existing class @@ -150,8 +153,9 @@ double coverage = coveredInstances.size()/(double)classInstances.size(); double protusion = (additionalInstances.size() + coveredInstances.size() == 0) ? 0 : coveredInstances.size()/(double)(coveredInstances.size()+additionalInstances.size()); + boolean isConsistent = isConsistent(description); - return new ClassScore(coveredInstances, coverage, additionalInstances, protusion, getAccuracy(coverage, protusion)); + return new ClassScore(coveredInstances, coverage, additionalInstances, protusion, getAccuracy(coverage, protusion), isConsistent); } public boolean isEquivalenceProblem() { @@ -367,4 +371,17 @@ ClassScore score = computeScore(description); return new EvaluatedDescriptionClass(description, score); } + + /** + * @return the isConsistent + */ + public boolean isConsistent(Description description) { + Axiom axiom; + if(equivalence) { + axiom = new EquivalentClassesAxiom(classToDescribe, description); + } else { + axiom = new SubClassAxiom(classToDescribe, description); + } + return reasoner.remainsSatisfiable(axiom); + } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-03-27 10:53:47 UTC (rev 1668) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-03-27 11:16:11 UTC (rev 1669) @@ -39,12 +39,15 @@ private double addition; private double accuracy; - public ClassScore(Set<Individual> coveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy) { + private boolean isConsistent; + + public ClassScore(Set<Individual> coveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy, boolean isConsistent) { this.coveredInstances = coveredInstances; this.additionalInstances = additionalInstances; this.coverage = coverage; this.addition = protusion; this.accuracy = accuracy; + this.isConsistent = isConsistent; } /** @@ -85,6 +88,13 @@ */ public Set<Individual> getAdditionalInstances() { return additionalInstances; + } + + /** + * @return the isConsistent + */ + public boolean isConsistent() { + return isConsistent; } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java 2009-03-27 10:53:47 UTC (rev 1668) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java 2009-03-27 11:16:11 UTC (rev 1669) @@ -78,5 +78,13 @@ public Set<Individual> getCoveredInstances() { return classScore.getCoveredInstances(); } + + /** + * + * @return True if adding the axiom to the knowledge base leads to an inconsistent knowledge base. False otherwise. + */ + public boolean isConsistent() { + return classScore.isConsistent(); + } } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-03-27 10:53:47 UTC (rev 1668) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-03-27 11:16:11 UTC (rev 1669) @@ -43,6 +43,7 @@ import org.dllearner.core.options.ConfigOption; import org.dllearner.core.options.InvalidConfigOptionValueException; import org.dllearner.core.options.StringConfigOption; +import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.BooleanValueRestriction; import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DataRange; @@ -1002,4 +1003,12 @@ return rc.getTypesImpl(individual); } + /* (non-Javadoc) + * @see org.dllearner.core.BaseReasoner#remainsSatisfiable(org.dllearner.core.owl.Axiom) + */ + @Override + public boolean remainsSatisfiableImpl(Axiom axiom) { + return rc.remainsSatisfiableImpl(axiom); + } + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2009-03-27 10:53:47 UTC (rev 1668) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2009-03-27 11:16:11 UTC (rev 1669) @@ -208,6 +208,7 @@ rc.releaseKB(); } + // @Override // public boolean hasDatatypeSupport() { // return true; Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-03-27 10:53:47 UTC (rev 1668) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-03-27 11:16:11 UTC (rev 1669) @@ -47,6 +47,7 @@ import org.dllearner.core.options.ConfigOption; import org.dllearner.core.options.InvalidConfigOptionValueException; import org.dllearner.core.options.StringConfigOption; +import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypeProperty; @@ -72,6 +73,7 @@ import org.semanticweb.owl.inference.OWLReasoner; import org.semanticweb.owl.inference.OWLReasonerException; import org.semanticweb.owl.model.OWLAnnotation; +import org.semanticweb.owl.model.OWLAxiom; import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLConstant; import org.semanticweb.owl.model.OWLDataFactory; @@ -1011,6 +1013,17 @@ } return annotations; } + + /* (non-Javadoc) + * @see org.dllearner.core.BaseReasoner#remainsSatisfiable(org.dllearner.core.owl.Axiom) + */ + @Override + public boolean remainsSatisfiableImpl(Axiom axiom) { + OWLAxiom axiomOWLAPI = OWLAPIAxiomConvertVisitor.convertAxiom(axiom); + + // TODO Auto-generated method stub + return false; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |