Re: How to do twice reasoning
Posted by
Jiba on
URL: http://owlready.306.s1.nabble.com/How-to-do-twice-reasoning-tp1741p1748.html
Hi,
The problem is related to the use of close_world(). Calling close_world() creates new restrictions. Since you call it twice, 2 sets of restrictions are created.
In particular, the first call to close_world() creates a restriction on drug1 : it must have for active principle only acetaminophen.
Then, you add a second active principle to drug1, and call close_world() again. It now creates a second restriction : drug1 must have for active principle only acetaminophen and test_acid. But the previous restriction remains, and make the individual (and thus the ontology) inconsistent.
You can see the restrictions as follow:
>>> drug1.is_a
[onto.has_for_active_principle.only(OneOf([onto.acetaminophen])), onto.SingleActivePrincipleDrug, onto.has_for_active_principle.only(OneOf([onto.acetaminophen, onto.test_acid]))]
The solution is to add the restrictions created by close_world() in a separate ontology, and to destroy this ontology before calling close_world() a second time:
restr_onto = get_ontology("
http://test.org/restr_onto1.owl")
with restr_onto: close_world(Drug) # First call
[...]
restr_onto.destroy()
restr_onto = get_ontology("
http://test.org/restr_onto2.owl")
with restr_onto: close_world(Drug) # Second call
As mentioned by Carlos, you'll also need to destroy the ontology containing the inferences ("
http://inferrences/" by default).
Jiba