From: <jen...@us...> - 2009-04-14 07:10:51
|
Revision: 1696 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1696&view=rev Author: jenslehmann Date: 2009-04-14 07:10:46 +0000 (Tue, 14 Apr 2009) Log Message: ----------- small formatting fix Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/test/PelletBug.java Modified: trunk/src/dl-learner/org/dllearner/test/PelletBug.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/PelletBug.java 2009-04-14 07:01:50 UTC (rev 1695) +++ trunk/src/dl-learner/org/dllearner/test/PelletBug.java 2009-04-14 07:10:46 UTC (rev 1696) @@ -23,62 +23,64 @@ public class PelletBug { - public static void main(String[] args) throws OWLOntologyCreationException, OWLReasonerException, UnknownOWLOntologyException, OWLOntologyStorageException { - + public static void main(String[] args) throws OWLOntologyCreationException, + OWLReasonerException, UnknownOWLOntologyException, OWLOntologyStorageException { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); File f = new File("examples/family/father_oe.owl"); URI physicalURI = f.toURI(); OWLOntology ontology = manager.loadOntologyFromPhysicalURI(physicalURI); OWLDataFactory factory = manager.getOWLDataFactory(); - + // create a view class expressions and an axiom String ontologyURI = "http://example.com/father#"; OWLClass male = factory.getOWLClass(URI.create(ontologyURI + "male")); OWLClass female = factory.getOWLClass(URI.create(ontologyURI + "female")); OWLClass father = factory.getOWLClass(URI.create(ontologyURI + "father")); OWLDescription insat = factory.getOWLObjectIntersectionOf(male, female); - OWLDescription test = factory.getOWLObjectComplementOf(male); - OWLAxiom axiom = factory.getOWLEquivalentClassesAxiom(father, test); - - // load ontology - Set<OWLOntology> ontologies = new HashSet<OWLOntology>(); - ontologies.add(ontology); - OWLReasoner reasoner = new org.mindswap.pellet.owlapi.Reasoner(manager); - reasoner.loadOntologies(ontologies); - - // first subsumption check => everything runs smoothly - boolean result = reasoner.isSubClassOf(female, insat); - System.out.println("subsumption before: " + result); - - // add axiom causing the ontology to be inconsistent - try { + OWLDescription test = factory.getOWLObjectComplementOf(male); + OWLAxiom axiom = factory.getOWLEquivalentClassesAxiom(father, test); + + // load ontology + Set<OWLOntology> ontologies = new HashSet<OWLOntology>(); + ontologies.add(ontology); + OWLReasoner reasoner = new org.mindswap.pellet.owlapi.Reasoner(manager); + reasoner.loadOntologies(ontologies); + + // first subsumption check => everything runs smoothly + boolean result = reasoner.isSubClassOf(female, insat); + System.out.println("subsumption before: " + result); + + // add axiom causing the ontology to be inconsistent + try { manager.applyChange(new AddAxiom(ontology, axiom)); } catch (OWLOntologyChangeException e1) { e1.printStackTrace(); } - + // Pellet correctly detects the inconsistency - try { - System.out.println("consistent: " + reasoner.isConsistent(ontology)); - } catch (OWLReasonerException e) { - e.printStackTrace(); - } - - // remove axiom - try { + try { + System.out.println("consistent: " + reasoner.isConsistent(ontology)); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + + // remove axiom + try { manager.applyChange(new RemoveAxiom(ontology, axiom)); } catch (OWLOntologyChangeException e) { e.printStackTrace(); } - + // save file to verify that it remained unchanged (it is unchanged) - manager.saveOntology(ontology, new File("test.owl").toURI()); - - // perform subsumption check => Pellet now fails due to an inconsistency, - // although the ontology is unchanged from the point of view of the OWL API - result = reasoner.isSubClassOf(female, insat); - System.out.println("subsumption after: " + result); - + manager.saveOntology(ontology, new File("test.owl").toURI()); + + // perform subsumption check => Pellet now fails due to an + // inconsistency, although the ontology is unchanged from the + // point of view of the OWL API + result = reasoner.isSubClassOf(female, insat); + System.out.println("subsumption after: " + result); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |