From: <lor...@us...> - 2009-03-27 21:44:12
|
Revision: 1670 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1670&view=rev Author: lorenz_b Date: 2009-03-27 21:43:54 +0000 (Fri, 27 Mar 2009) Log Message: ----------- implemented method remainsSatisfiable(Axiom axiom) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-03-27 11:16:11 UTC (rev 1669) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-03-27 21:43:54 UTC (rev 1670) @@ -72,6 +72,7 @@ import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.inference.OWLReasoner; import org.semanticweb.owl.inference.OWLReasonerException; +import org.semanticweb.owl.model.AddAxiom; import org.semanticweb.owl.model.OWLAnnotation; import org.semanticweb.owl.model.OWLAxiom; import org.semanticweb.owl.model.OWLClass; @@ -87,12 +88,14 @@ import org.semanticweb.owl.model.OWLNamedObject; import org.semanticweb.owl.model.OWLObjectProperty; import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLOntologyChangeException; import org.semanticweb.owl.model.OWLOntologyCreationException; import org.semanticweb.owl.model.OWLOntologyFormat; import org.semanticweb.owl.model.OWLOntologyManager; import org.semanticweb.owl.model.OWLOntologyStorageException; import org.semanticweb.owl.model.OWLTypedConstant; import org.semanticweb.owl.model.OWLUntypedConstant; +import org.semanticweb.owl.model.RemoveAxiom; import org.semanticweb.owl.model.UnknownOWLOntologyException; import org.semanticweb.owl.util.SimpleURIMapper; import org.semanticweb.owl.vocab.NamespaceOWLOntologyFormat; @@ -119,6 +122,8 @@ } private OWLReasoner reasoner; + private OWLOntologyManager manager; + private OWLOntology ontology; // the data factory is used to generate OWL API objects private OWLDataFactory factory; // static factory @@ -188,7 +193,7 @@ individuals = new TreeSet<Individual>(); // create OWL API ontology manager - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + manager = OWLManager.createOWLOntologyManager(); // it is a bit cumbersome to obtain all classes, because there // are no reasoner queries to obtain them => hence we query them @@ -216,7 +221,7 @@ } try { - OWLOntology ontology; + if(source instanceof OWLAPIOntology) { ontology = ((OWLAPIOntology)source).getOWLOntolgy(); } else if (source instanceof SparqlKnowledgeSource) { @@ -996,7 +1001,7 @@ return reasoner.getInconsistentClasses(); } catch (OWLReasonerException e) { e.printStackTrace(); - throw new Error("Inconsistens classes check error in OWL API."); + throw new Error("Inconsistent classes check error in OWL API."); } } @@ -1019,10 +1024,22 @@ */ @Override public boolean remainsSatisfiableImpl(Axiom axiom) { + boolean consistent = true; OWLAxiom axiomOWLAPI = OWLAPIAxiomConvertVisitor.convertAxiom(axiom); + try { + manager.applyChange(new AddAxiom(ontology, axiomOWLAPI)); + consistent = reasoner.isConsistent(ontology); + manager.applyChange(new RemoveAxiom(ontology, axiomOWLAPI)); + + } catch (OWLOntologyChangeException e) { + + e.printStackTrace(); + } catch (OWLReasonerException e) { + + e.printStackTrace(); + } - // TODO Auto-generated method stub - return false; + return consistent; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |