Java Code Examples for org.semanticweb.owlapi.model.OWLOntologyManager#createOntology()

The following examples show how to use org.semanticweb.owlapi.model.OWLOntologyManager#createOntology() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OboOntologyReleaseRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void createModule(String ontologyId, String moduleName, Set<OWLEntity> signature)
		throws OWLOntologyCreationException, IOException, OWLOntologyStorageException 
{
	// create a new manager, avoid unnecessary change events
	final OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	
	// extract module
	SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, mooncat.getOntology(), ModuleType.BOT);
	Set<OWLAxiom> moduleAxioms = sme.extract(signature);
	
	OWLOntology module = m.createOntology(IRI.generateDocumentIRI());
	m.addAxioms(module, moduleAxioms);
	
	// save module
	OutputStream moduleOutputStream = null;
	try {
		moduleOutputStream = getOutputSteam(getModuleFileName(ontologyId, moduleName));
		m.saveOntology(module, moduleOutputStream);
	}
	finally {
		IOUtils.closeQuietly(moduleOutputStream);
	}
}
 
Example 2
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 6 votes vote down vote up
@Test
public void inconsistentIndividual() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLNamedIndividual ind = factory
			.getOWLNamedIndividual(IRI.create("http://example.org/i"));
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	// ind instance of bottom => inconsistent
	owlManager.addAxiom(ontology, factory
			.getOWLClassAssertionAxiom(factory.getOWLNothing(), ind));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(
					factory.getOWLObjectIntersectionOf(a, b),
					factory.getOWLNothing()));
}
 
Example 3
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 6 votes vote down vote up
@Test
public void inconsistentClass() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	// A subclass of bottom => A is inconsistent
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(a, factory.getOWLNothing()));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
}
 
Example 4
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 6 votes vote down vote up
@Test
public void emptyDisjointUnion() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	// DisjointUnion(A ) = EquivalentClasses(A owl:Nothing)
	owlManager.addAxiom(ontology, factory.getOWLDisjointUnionAxiom(a,
			Collections.<OWLClassExpression> emptySet()));
	owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(b, b));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
}
 
Example 5
Source File: DiffOperationTest.java    From robot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Compare one ontology to a modified copy.
 *
 * @throws IOException on file problem
 * @throws OWLOntologyCreationException on ontology problem
 */
@Test
public void testCompareModified() throws IOException, OWLOntologyCreationException {
  OWLOntology simple = loadOntology("/simple.owl");
  Set<OWLOntology> onts = new HashSet<>();
  onts.add(simple);
  OWLOntologyManager manager = simple.getOWLOntologyManager();
  OWLDataFactory df = manager.getOWLDataFactory();
  OWLOntology simple1 = manager.createOntology(IRI.create(base + "simple1.owl"), onts);
  IRI test1 = IRI.create(base + "simple.owl#test1");
  manager.addAxiom(
      simple1,
      df.getOWLAnnotationAssertionAxiom(df.getRDFSLabel(), test1, df.getOWLLiteral("TEST #1")));

  StringWriter writer = new StringWriter();
  boolean actual = DiffOperation.compare(simple, simple1, writer);
  System.out.println(writer.toString());
  assertFalse(actual);
  String expected = IOUtils.toString(this.getClass().getResourceAsStream("/simple1.diff"));
  assertEquals(expected, writer.toString());
}
 
Example 6
Source File: AbstractOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public OWLOntology cacheInformationContentInOntology() throws OWLOntologyCreationException, UnknownOWLClassException {
	OWLOntologyManager mgr = getSourceOntology().getOWLOntologyManager();
	OWLDataFactory df = mgr.getOWLDataFactory();
	OWLOntology o = mgr.createOntology();
	OWLAnnotationProperty p = df.getOWLAnnotationProperty(IRI.create(icIRIString));
	for (OWLClass c : getSourceOntology().getClassesInSignature()) {
		Double ic = getInformationContentForAttribute(c);
		if (ic != null) {
			mgr.addAxiom(o,
					df.getOWLAnnotationAssertionAxiom(p, 
							c.getIRI(), 
							df.getOWLLiteral(ic)));
		}

	}
	return o;
}
 
Example 7
Source File: ImportedXrefTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void test() throws Exception {
	// load the base ontology
	ParserWrapper pw = new ParserWrapper();
	OWLOntology direct = pw.parseOBO(getResourceIRIString("graph/xref_test.obo"));
	
	OWLGraphWrapper directGraph = new OWLGraphWrapper(direct);
	
	// check that the test class has the expected number of xrefs
	OWLClass c = directGraph.getOWLClassByIdentifier("FOO:0001");
	
	List<String> directDefXrefs = directGraph.getDefXref(c);
	assertEquals(2, directDefXrefs.size());

	List<String> directXrefs = directGraph.getXref(c);
	assertEquals(2, directXrefs.size());
	
	// create an ontology using an import
	OWLOntologyManager manager = pw.getManager();
	OWLDataFactory factory = manager.getOWLDataFactory();
	OWLOntology importer = manager.createOntology();
	OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(direct.getOntologyID().getOntologyIRI().orNull());
	manager.applyChange(new AddImport(importer, importDeclaration));
	
	OWLGraphWrapper importerGraph = new OWLGraphWrapper(importer);
	
	// check that the wrapper uses also imports for lookups of xrefs
	List<String> importedDefXrefs = importerGraph.getDefXref(c);
	assertEquals(2, importedDefXrefs.size());

	List<String> importedXrefs = importerGraph.getXref(c);
	assertEquals(2, importedXrefs.size());
}
 
Example 8
Source File: SavingInferredAxioms.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws OWLOntologyStorageException,
		OWLOntologyCreationException {
	OWLOntologyManager inputOntologyManager = OWLManager.createOWLOntologyManager();
	OWLOntologyManager outputOntologyManager = OWLManager.createOWLOntologyManager();

	// Load your ontology.
	OWLOntology ont = inputOntologyManager.loadOntologyFromOntologyDocument(new File("path-to-ontology"));

	// Create an ELK reasoner.
	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
	OWLReasoner reasoner = reasonerFactory.createReasoner(ont);

	// Classify the ontology.
	reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	// To generate an inferred ontology we use implementations of
	// inferred axiom generators
	List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
	gens.add(new InferredSubClassAxiomGenerator());
	gens.add(new InferredEquivalentClassAxiomGenerator());

	// Put the inferred axioms into a fresh empty ontology.
	OWLOntology infOnt = outputOntologyManager.createOntology();
	InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner,
			gens);
	iog.fillOntology(outputOntologyManager.getOWLDataFactory(), infOnt);

	// Save the inferred ontology.
	outputOntologyManager.saveOntology(infOnt,
			new FunctionalSyntaxDocumentFormat(),
			IRI.create((new File("path-to-output").toURI())));

	// Terminate the worker threads used by the reasoner.
	reasoner.dispose();
}
 
Example 9
Source File: QuerySubsetGeneratorTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private OWLGraphWrapper getTargetGraph() throws Exception {
	OWLOntologyManager targetManager = OWLManager.createOWLOntologyManager();
	OWLOntologyID ontologyID  = new OWLOntologyID(Optional.of(IRI.create("http://test.owltools.org/dynamic")), Optional.absent());
	OWLOntology targetOntology = targetManager.createOntology(ontologyID);
	OWLGraphWrapper targetGraph = new OWLGraphWrapper(targetOntology);
	return targetGraph;
}
 
Example 10
Source File: InferenceBuilderTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Test that the {@link InferenceBuilder} does not report the trivial fact
 * that OWL:Nothing is a subclass of of every class.
 * 
 * @throws Exception 
 */
@Test
public void testIgnoreIgnoreOwlNothingInNewInferences() throws Exception {
	// create a test ontology which declares owl:Nothing and one term
	
	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
	
	OWLOntology ontology = manager.createOntology();
	OWLDataFactory factory = manager.getOWLDataFactory();
	
	// declare class
	
	OWLClass owlEntity = factory.getOWLClass(IRI.create("http://foo.bar/1"));
	manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(owlEntity));
	
	// declare owl:Nothing
	manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(factory.getOWLNothing()));
	
	OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
	
	// check that the inference builder does not report a new inferred axiom
	InferenceBuilder builder = new InferenceBuilder(graph);
	try {
		List<OWLAxiom> inferences = builder.buildInferences();
		if (!inferences.isEmpty()) {
			fail("Do not expect any new inferences, but was: "+inferences);
		}
	}
	finally {
		builder.dispose();
	}
}
 
Example 11
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Generate a OboGraphs JSON ontology blob for the local axioms for an object.
 * 
 * This will include
 * 
 *  - all logical axioms about the object
 *  - all annotations for all entities in the signature
 *  
 * In other words, direct parents plus labels and other metadata on all entities
 * 
 * @param obj
 * @return JSON string
 * @throws JsonProcessingException
 * @throws OWLOntologyCreationException
 */
public String getOboGraphJSONString(OWLObject obj) throws JsonProcessingException, OWLOntologyCreationException {
	FromOwl fromOwl = new FromOwl();
	OWLOntologyManager m = sourceOntology.getOWLOntologyManager();
	if (obj instanceof OWLNamedObject) {
		OWLNamedObject nobj = (OWLNamedObject)obj;
		OWLOntology ont = m.createOntology(nobj.getIRI());
		Set<OWLAxiom> axioms = new HashSet<>();
		if (nobj instanceof OWLClass) {
			axioms.addAll(sourceOntology.getAxioms((OWLClass)nobj, Imports.INCLUDED));
		}
		else if (nobj instanceof OWLObjectProperty) {
			axioms.addAll(sourceOntology.getAxioms((OWLObjectProperty)nobj, Imports.INCLUDED));
		}
		m.addAxioms(ont, axioms);
		axioms = new HashSet<>();
		for (OWLEntity e : ont.getSignature()) {
			axioms.addAll(sourceOntology.getAnnotationAssertionAxioms(e.getIRI()));
		}
		axioms.addAll(sourceOntology.getAnnotationAssertionAxioms(nobj.getIRI()));
		m.addAxioms(ont, axioms);

		GraphDocument gd = fromOwl.generateGraphDocument(ont);
		return OgJsonGenerator.render(gd);
	}
	else {
		return "{}";
	}

}
 
Example 12
Source File: ProvenanceReasonerWrapper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void reasonLeavingOneOut(OWLOntology leaveOutOntology) throws OWLOntologyCreationException {
	OWLOntologyManager m = getManager();
	OWLOntology ont2 = m.createOntology();
	
	LOG.info("LEAVE ONE OUT: "+leaveOutOntology);
	for (OWLOntology io : ontology.getImportsClosure()) {
		if (io.equals(leaveOutOntology)) {
			LOG.info("SKIPPING:"+io);
			continue;
		}
		m.addAxioms(ont2, io.getAxioms());
		
	}
	
	OWLReasoner reasoner = rf.createReasoner(ont2);
	for (OWLEdge e : edges) {
		if (!e.isJustified) {
			// there is no point checking unjustified edges;
			// these are edges that when removed cannot be re-inferred using the entire ontology set.
			// as reasoning is monotonic, removing imports cannot bring it back.
			continue;
		}
		//LOG.info("Testing "+e); 
		if (!isEdgeEntailed(e, ont2, reasoner)) {
			IRI req = leaveOutOntology.getOntologyID().getOntologyIRI().orNull();
			LOG.info(e + " requires "+req);
			e.requires.add(req);
			
		}
	}
	reasoner.dispose();
}
 
Example 13
Source File: DLQueryTool.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Execute the DL query on the given ontology graph. Uses the factory to create 
 * the {@link OWLReasoner} for an internal query ontology.
 * 
 * @param dlQuery
 * @param graph
 * @param reasonerFactory
 * @return set of {@link OWLClass} which 
 * @throws OWLParserException
 * @throws OWLOntologyCreationException
 */
public static Set<OWLClass> executeDLQuery(String dlQuery, OWLGraphWrapper graph, 
		OWLReasonerFactory reasonerFactory) throws OWLParserException, OWLOntologyCreationException 
{
	// create parser and parse DL query string
	ManchesterSyntaxTool parser = null;
	
	OWLClassExpression ce;
	try {
		parser = new ManchesterSyntaxTool(graph.getSourceOntology(), graph.getSupportOntologySet());
		ce = parser.parseManchesterExpression(dlQuery);
	} finally {
		// always dispose parser to avoid a memory leak
		if (parser != null) {
			parser.dispose();
		}
	}
	
	// create query ontology
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	OWLOntology queryOntology = m.createOntology(IRI.generateDocumentIRI(), graph.getAllOntologies());
	OWLDataFactory f = m.getOWLDataFactory();
	OWLClass qc = f.getOWLClass(IRI.create("http://owltools.org/Q"));
	OWLEquivalentClassesAxiom ax = f.getOWLEquivalentClassesAxiom(ce, qc);
	m.addAxiom(queryOntology, ax);
	
	Set<OWLClass> subset = executeQuery(ce, queryOntology, reasonerFactory);
	if(subset.isEmpty()) {
		LOG.warn("No classes found for query subclass of:"+dlQuery);
	}
	return subset;
}
 
Example 14
Source File: OCUtils.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
public static OWLOntology load(File... inputFiles) throws OWLOntologyCreationException {
	OWLOntologyManager manager= OWLManager.createOWLOntologyManager();
	OWLOntology ont = manager.createOntology();
	for (File f:inputFiles) {
		manager= OWLManager.createOWLOntologyManager();
		manager.setSilentMissingImportsHandling(false);
		IRI documentIRI = IRI.create(f);
		OWLOntology ontology = manager.loadOntologyFromOntologyDocument(documentIRI);
		ont.getOWLOntologyManager().addAxioms(ont, ontology.getAxioms());
	}
	return ont;		
}
 
Example 15
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Test
public void emptyEnumeration() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	// ObjectOneOf() = owl:Nothing
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(a, factory.getOWLObjectOneOf()));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(b, factory.getOWLNothing()));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(factory.getOWLObjectOneOf(), c));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, a));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, c));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, c));
}
 
Example 16
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Test
public void emptyDisjunction() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	// ObjectUnionOf() = owl:Nothing
	owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(a,
			factory.getOWLObjectUnionOf()));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(b, factory.getOWLNothing()));
	owlManager.addAxiom(ontology, factory
			.getOWLSubClassOfAxiom(factory.getOWLObjectUnionOf(), c));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, a));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, c));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, c));
}
 
Example 17
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Test
public void emptyConjunction() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	OWLClass d = factory.getOWLClass(IRI.create("http://example.org/D"));
	// ObjectInteresectionOf() = owl:Thing
	owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(a,
			factory.getOWLObjectIntersectionOf()));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(b, factory.getOWLThing()));
	owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(
			factory.getOWLObjectIntersectionOf(), c));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(factory.getOWLThing(), d));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, c));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, d));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, c));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, d));
}
 
Example 18
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Test
public void proofListener() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	OWLObjectProperty r = factory
			.getOWLObjectProperty(IRI.create("http://example.org/R"));
	OWLObjectProperty s = factory
			.getOWLObjectProperty(IRI.create("http://example.org/S"));
	OWLAxiom ax1 = factory.getOWLSubClassOfAxiom(a, c);
	OWLAxiom ax2 = factory.getOWLSubClassOfAxiom(c, b);
	OWLAxiom ax3 = factory.getOWLSubClassOfAxiom(a,
			factory.getOWLObjectSomeValuesFrom(r, c));
	OWLAxiom ax4 = factory.getOWLSubClassOfAxiom(
			factory.getOWLObjectSomeValuesFrom(s, c), b);
	OWLAxiom ax5 = factory.getOWLSubObjectPropertyOfAxiom(r, s);

	boolean changed = false; // means entailment has changed

	for (boolean bufferringMode : Arrays.asList(true, false)) {
		// creating an ontology
		final OWLOntology ontology = owlManager.createOntology();

		final OWLProver prover = OWLAPITestUtils.createProver(
				OWLAPITestUtils.createReasoner(ontology, bufferringMode));
		OWLSubClassOfAxiom entailment = factory.getOWLSubClassOfAxiom(a, b);
		DynamicProof<? extends Inference<OWLAxiom>> proof = prover
				.getProof(entailment);
		ProofChangeTracker tracker = new ProofChangeTracker();
		proof.addListener(tracker);

		assertFalse(Proofs.isDerivable(proof, entailment));

		// add ax1 and ax2 => ENTAIL
		owlManager.applyChanges(Arrays.asList(new AddAxiom(ontology, ax1),
				new AddAxiom(ontology, ax2)));

		// derivable only in non-buffering mode
		changed = tracker.changed();
		assertEquals(!bufferringMode, changed);
		assertEquals(!bufferringMode,
				Proofs.isDerivable(proof, entailment));
		// but always derivable after flush
		prover.flush();
		changed |= tracker.changed();
		assertTrue(changed);
		assertTrue(Proofs.isDerivable(proof, entailment));

		// remove ax1, add ax3, ax4 => NOT ENTAIL
		owlManager.applyChanges(Arrays.asList(
				new RemoveAxiom(ontology, ax1), new AddAxiom(ontology, ax3),
				new AddAxiom(ontology, ax4)));

		// still derivable only in bufferring mode
		changed = tracker.changed();
		assertEquals(!bufferringMode, changed);
		assertEquals(bufferringMode, Proofs.isDerivable(proof, entailment));
		// always non derivable after flush
		prover.flush();
		changed |= tracker.changed();
		assertTrue(changed);
		assertFalse(Proofs.isDerivable(proof, entailment));

		// add ax5 => ENTAIL
		owlManager.applyChanges(Arrays.asList(new AddAxiom(ontology, ax5)));

		// derivable only in non-buffering mode
		changed = tracker.changed();
		assertEquals(!bufferringMode, changed);
		assertEquals(!bufferringMode,
				Proofs.isDerivable(proof, entailment));
		// but always derivable after flush
		prover.flush();
		changed |= tracker.changed();
		assertTrue(changed);
		assertTrue(Proofs.isDerivable(proof, entailment));

	}

}
 
Example 19
Source File: OWLGraphWrapperBasic.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected OWLGraphWrapperBasic(String iri) throws OWLOntologyCreationException {
	super();
	ParserWrapper pw = new ParserWrapper();
	OWLOntologyManager manager = pw.getManager();
	sourceOntology = manager.createOntology(IRI.create(iri));
}
 
Example 20
Source File: OWLGraphWrapperBasic.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void remakeOntologiesFromImportsClosure(IRI ontologyIRI) throws OWLOntologyCreationException {
	addSupportOntologiesFromImportsClosure();
	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
	sourceOntology = manager.createOntology(sourceOntology.getAxioms(), ontologyIRI);
}