Running Reasoner...Explaining Inconsistency

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Running Reasoner...Explaining Inconsistency

OntoBLW
Hi,
Please, I need (for my protege plugin) to:
-run the reasoner
- and explaining inconsistency if the ontology is inconsistent.
This functionality surely could be got by clicking the "start reasoner"
submenu, but, I want to implement it in the code of my protege plugin.
Thanks for giving me even some hints.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running Reasoner...Explaining Inconsistency

Lorenz Buehmann
And why don't you look into the source code? That's what I also did when
implementing my first plugin. Protege is open source

* Explanation handling code is here [1]

* the current reasoner can be used by

OWLReasoner reasoner = editorKit.getModelManager().getReasoner();

and then call

reasoner.isConisistent();

Details of OWLReasoner interface as usual in the Javadoc of the OWL API [2]


Lorenz


[1]
https://github.com/protegeproject/protege/tree/master/protege-editor-owl/src/main/java/org/protege/editor/owl/ui/explanation

[2]
https://owlcs.github.io/owlapi/apidocs_4/org/semanticweb/owlapi/reasoner/OWLReasoner.html


On 27.12.2017 21:18, OntoBLW wrote:

> Hi,
> Please, I need (for my protege plugin) to:
> -run the reasoner
> - and explaining inconsistency if the ontology is inconsistent.
> This functionality surely could be got by clicking the "start reasoner"
> submenu, but, I want to implement it in the code of my protege plugin.
> Thanks for giving me even some hints.
>
>
>
> --
> Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running Reasoner...Explaining Inconsistency

OntoBLW
Hi,
First, I thank you for your answer. Indeed, this what I have done. However,
I have some problems.
I reused the code of "PrecomputeAction" as follows:

 ReasonerPreferences  preferences =
modelManager.getOWLReasonerManager().getReasonerPreferences();
        Set<InferenceType> precompute;
        precompute = preferences.getPrecomputedInferences();
             reasoner.precomputeInferences(precompute.toArray(new
InferenceType[precompute.size()]));
       boolean b=
modelManager.getOWLReasonerManager().classifyAsynchronously(precompute);

 Then, I used this line:

            InconsistentOntologyManager.get(getOWLModelManager()).explain();

What I have obtained is:
two consecutive explanation dialogues are thrown to explain inconsistency:
-I think the first one is due to ( boolean b=
modelManager.getOWLReasonerManager().classifyAsynchronously(precompute);)
-I think the second one is due to (
InconsistentOntologyManager.get(getOWLModelManager()).explain();)

I hope to measure the execution time for finding explanations. This time
could only be displayed by adding the line (
InconsistentOntologyManager.get(getOWLModelManager()).explain();) and then
after the displaying of the second explanation dialogue window.

I hope it was clear.
I thank you very much for helping me.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running Reasoner...Explaining Inconsistency

Lorenz Buehmann
>  Then, I used this line:
>
>             InconsistentOntologyManager.get(getOWLModelManager()).explain();

I don't understand why you're calling Protege code hat obviously
triggers the popup of a dialog. Why don't you use the "core" explanation
code? You want to measure the time to compute an explanation, so you
should use the code that computes an explanation, i.e. use the
ExplanationService as done in the dialog class [1]

Moreover, what is the overall goal of your plugin?


[1]
https://github.com/protegeproject/protege/blob/master/protege-editor-owl/src/main/java/org/protege/editor/owl/ui/explanation/ExplanationDialog.java#L30-L33


On 28.12.2017 10:45, OntoBLW wrote:

> Hi,
> First, I thank you for your answer. Indeed, this what I have done. However,
> I have some problems.
> I reused the code of "PrecomputeAction" as follows:
>
>  ReasonerPreferences  preferences =
> modelManager.getOWLReasonerManager().getReasonerPreferences();
>         Set<InferenceType> precompute;
>         precompute = preferences.getPrecomputedInferences();
>              reasoner.precomputeInferences(precompute.toArray(new
> InferenceType[precompute.size()]));
>        boolean b=
> modelManager.getOWLReasonerManager().classifyAsynchronously(precompute);
>
>  Then, I used this line:
>
>             InconsistentOntologyManager.get(getOWLModelManager()).explain();
>
> What I have obtained is:
> two consecutive explanation dialogues are thrown to explain inconsistency:
> -I think the first one is due to ( boolean b=
> modelManager.getOWLReasonerManager().classifyAsynchronously(precompute);)
> -I think the second one is due to (
> InconsistentOntologyManager.get(getOWLModelManager()).explain();)
>
> I hope to measure the execution time for finding explanations. This time
> could only be displayed by adding the line (
> InconsistentOntologyManager.get(getOWLModelManager()).explain();) and then
> after the displaying of the second explanation dialogue window.
>
> I hope it was clear.
> I thank you very much for helping me.
>
>
>
> --
> Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running Reasoner...Explaining Inconsistency

Lorenz Buehmann
Or at least just the relevant part of the InconsistentOntologyManager
[1] without triggering the dialog.

[1]
https://github.com/protegeproject/protege/blob/master/protege-editor-owl/src/main/java/org/protege/editor/owl/ui/explanation/io/InconsistentOntologyManager.java#L43-L46


On 28.12.2017 11:21, Lorenz Buehmann wrote:

>>  Then, I used this line:
>>
>>             InconsistentOntologyManager.get(getOWLModelManager()).explain();
> I don't understand why you're calling Protege code hat obviously
> triggers the popup of a dialog. Why don't you use the "core" explanation
> code? You want to measure the time to compute an explanation, so you
> should use the code that computes an explanation, i.e. use the
> ExplanationService as done in the dialog class [1]
>
> Moreover, what is the overall goal of your plugin?
>
>
> [1]
> https://github.com/protegeproject/protege/blob/master/protege-editor-owl/src/main/java/org/protege/editor/owl/ui/explanation/ExplanationDialog.java#L30-L33
>
>
> On 28.12.2017 10:45, OntoBLW wrote:
>> Hi,
>> First, I thank you for your answer. Indeed, this what I have done. However,
>> I have some problems.
>> I reused the code of "PrecomputeAction" as follows:
>>
>>  ReasonerPreferences  preferences =
>> modelManager.getOWLReasonerManager().getReasonerPreferences();
>>         Set<InferenceType> precompute;
>>         precompute = preferences.getPrecomputedInferences();
>>              reasoner.precomputeInferences(precompute.toArray(new
>> InferenceType[precompute.size()]));
>>        boolean b=
>> modelManager.getOWLReasonerManager().classifyAsynchronously(precompute);
>>
>>  Then, I used this line:
>>
>>             InconsistentOntologyManager.get(getOWLModelManager()).explain();
>>
>> What I have obtained is:
>> two consecutive explanation dialogues are thrown to explain inconsistency:
>> -I think the first one is due to ( boolean b=
>> modelManager.getOWLReasonerManager().classifyAsynchronously(precompute);)
>> -I think the second one is due to (
>> InconsistentOntologyManager.get(getOWLModelManager()).explain();)
>>
>> I hope to measure the execution time for finding explanations. This time
>> could only be displayed by adding the line (
>> InconsistentOntologyManager.get(getOWLModelManager()).explain();) and then
>> after the displaying of the second explanation dialogue window.
>>
>> I hope it was clear.
>> I thank you very much for helping me.
>>
>>
>>
>> --
>> Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
>> _______________________________________________
>> protege-dev mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-dev
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running Reasoner...Explaining Inconsistency

OntoBLW
In reply to this post by Lorenz Buehmann
Hi again,
I have tried these snippets of code, but, I obtained the explanation
dialogue without axioms(empty), or with some exceptions. I also tried to
delete (          
InconsistentOntologyManager.get(getOWLModelManager()).explain();
). Unfortunately, the results were as I said before( the explanation
dialogue without axioms(empty),).

The best result was obtained by my code sent, however, I do not know why it
throws two consecutive explanation dialogues.
my objective is just to measure the time spent by (the reasoenr+the
explanation plugin) to check inconsistency and explain it.
Regards.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running Reasoner...Explaining Inconsistency

Lorenz Buehmann

Without seeing whole runnable code, It's impossible to help you.

i.explain

indeed triggers the popup of the explanation workbench. As I said earlier, you should better use the "core" explanation API, i.e. the

ExplanationService as created in ExplanationManager class with the following entailment

OWLModelManager owlModelManager = editorKit.getOWLModelManager();
OWLDataFactory df = owlModelManager.getOWLDataFactory();
OWLSubClassOfAxiom entailment = df.getOWLSubClassOfAxiom(df.getOWLThing(), df.getOWLNothing());


On 28.12.2017 17:14, OntoBLW wrote:
Hi again,
I have tried these snippets of code, but, I obtained the explanation
dialogue without axioms(empty), or with some exceptions. I also tried to
delete (           
InconsistentOntologyManager.get(getOWLModelManager()).explain();
). Unfortunately, the results were as I said before( the explanation
dialogue without axioms(empty),).

The best result was obtained by my code sent, however, I do not know why it
throws two consecutive explanation dialogues.
my objective is just to measure the time spent by (the reasoenr+the
explanation plugin) to check inconsistency and explain it.
Regards.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev


_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running Reasoner...Explaining Inconsistency

OntoBLW
This post was updated on .
Hi,
Here is my code attached
 InconsistencyCheck.java
<http://protege-project.136.n4.nabble.com/file/t375701/InconsistencyCheck.java>
 
AddClassAssertionAxiom.java
<http://protege-project.136.n4.nabble.com/file/t375701/AddClassAssertionAxiom.java
;
Indeed, when I click on the "(submenu from protege menu)", a window is
thrown and when I click on "OK", the classification and the inconsistency
checking and explanation process is executed. (Perhaps the names of classes
are not significitf).
My goal is to measure the time taken by the classification (by the reasoner)
and the explication algorithm (used by the explanation plugin).
Best regards.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
protege-dev@lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running Reasoner...Explaining Inconsistency

Lorenz Buehmann

Well, the entailment you're checking is obviously wrong and does **not** express inconsistency, see this line of your code:

if(modelManager.getExplanationManager().hasExplanation(modelManager.getOWLDataFactory().getOWLSubClassOfAxiom(modelManager.getOWLDataFactory().getOWLNothing(), modelManager.getOWLDataFactory().getOWLThing())))
              {

The axiom

owl:Nothing SubClassOf owl:Thing

is trivial, inconsistency is expressed by

owl:Thing SubClassOf owl:Nothing

I hope you understand this.


On 29.12.2017 11:28, OntoBLW wrote:
Hi,
Here is my code attached InconsistencyCheck.java
<http://protege-project.136.n4.nabble.com/file/t375701/InconsistencyCheck.java>  
AddClassAssertionAxiom.java
<http://protege-project.136.n4.nabble.com/file/t375701/AddClassAssertionAxiom.java> 
;
Indeed, when I click on the "(submenu from protege menu)", a window is
thrown and when I click on "OK", the classification and the inconsistency
checking and explanation process is executed. (Perhaps the names of classes
are not significitf).
My goal is to measure the time taken by the classification (by the reasoner)
and the explication algorithm (used by the explication plugin).
Best regards.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev


_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running Reasoner...Explaining Inconsistency

OntoBLW
Hi,
Yes, I understand, but it is not taken into consideration since it is
commented.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev