0

I use OWLAPI with HermiT and it works unless I try to modify the ontology after the reasoner has been created.

Should the reasoner be notified of modifications of the ontology? Or do I need to recreate the reasoner, or can I notify the reasoner that it should "synchronize" with the changes? (like the menu item in Protege)

Edit: what "does not work": I am adding an axiom that makes the ontology inconsistent, and if I add it after creating the reasoner, the reasoner still reports it is consistent.

peschü
  • 1,299
  • 12
  • 21

1 Answers1

1

The reasoner can be created in buffering or non buffering mode. In non buffering mode, ontology changes will be immediately synchronized.

You are likely using buffering mode. To synchronize, call the flush() method.

Ignazio
  • 10,504
  • 1
  • 14
  • 25
  • I tried that, but it did not help. My idea was the following: I have one ontology manager with one ontology and multiple times I copy with another manager the ontology and modify it there for reasoning. My new idea (which works) is as follows: Use only one manager, one ontology, and apply OWLOntologyChange objects, then do reasoning, then apply their reverse to get back the original ontology. – peschü Feb 09 '20 at 18:56
  • Creating changes and then reversing them is exactly the same as adding and removing an axiom (behind the scenes, `addAxiom()` calls `applyChanges()`). If calling `flush()` did not work, I suspect there was something else missing in the code. If you add the code you were using to the question, we could investigate that route. – Ignazio Feb 09 '20 at 23:09
  • The last attempt can be found here: https://preview.tinyurl.com/vpxcc7n where you can see the main part of the code that probably causes the problem: `modifiedCopy` first calls the copy constructor where `copyOntology` happens, then `apply` just adds one axiom and then `reasoner()` is used to get the reasoner. Maybe there is a problem reusing/not reusing managers or the data factory? – peschü Feb 12 '20 at 15:00