Difference between revisions of "ProtegeReasonerAPI"

From Protege Wiki
Jump to: navigation, search
m
m
Line 10: Line 10:
  
 
<font color="red">
 
<font color="red">
'''''If you want to use the Reasoner API with a previous version of Protege than 3.4 beta 120 (from 2007/11/16), please refer to this [http://protege.stanford.edu/plugins/owl/api/ReasonerAPIExamples.html page].'''''
+
'''''If you want to use the Reasoner API with a previous version of Protege than 3.4 beta 120 (from 2007/11/17), please refer to this [http://protege.stanford.edu/plugins/owl/api/ReasonerAPIExamples.html page].'''''
 
</font>
 
</font>
 
<br /><br /><br />
 
<br /><br /><br />
Line 31: Line 31:
 
In general, the first step when using the reasoning API is to obtain an instance of <code> ProtegeReasoner </code> for an OWL model. This instance of the reasoner can then be used to obtain inferred information about the model such as inferred superclasses, inferred equivalent classes, and inferred types for individuals. The <code>ProtegeReasoner</code> manages communication with the direct or DIG reasoner, ensuring that it is always properly synchronized with the internal Protégé-OWL model.
 
In general, the first step when using the reasoning API is to obtain an instance of <code> ProtegeReasoner </code> for an OWL model. This instance of the reasoner can then be used to obtain inferred information about the model such as inferred superclasses, inferred equivalent classes, and inferred types for individuals. The <code>ProtegeReasoner</code> manages communication with the direct or DIG reasoner, ensuring that it is always properly synchronized with the internal Protégé-OWL model.
  
In order to get an instance of <code> ProtegeReasoner </code> for an OWL model, the ReasonerManager, which is found in the edu.stanford.smi.protegex.owl.inference.protegeowl package, must be used. The ReasonerManager is a singleton class (a class with only one instance), whose instance can be obtained by using the static method getInstance().
+
In order to get an instance of <code> ProtegeReasoner </code> for an OWL model, the <code>ReasonerManager</code>, which is found in the <code> edu.stanford.smi.protegex.owl.inference.protegeowl </code> package, must be used. The <code> ReasonerManager </code> is a singleton class (a class with only one instance), whose instance can be obtained by using the static method <code> getInstance() </code>.
The getReasoner(OWLModel kb) method on the ReasonerManager can be used to obtain the reasoner for the specified OWLModel. This method will return the same instance of ProtegeOWLReasoner for a given model each time it is called. An alternative method getReasoner(OWLModel kb, boolean createNew) may be used to obtain a reasoner for a knowledge base. If the createNew flag is set to true, then this method will create a brand new instance of ProtegeOWLReasoner for the specified knowledge base. In general, the former method is preferred since the default implementation of ProtegeOWLReasoner only synchronizes the external DIG reasoner with the Protégé-OWL model when necessary (when changes have occurred to the OWL model) - creating a new reasoner every time will cause the external DIG reasoner to be resynchronised every time, which could be costly in terms of time for large ontologies. The code snippet below shows how to obtain a ProtegeOWLReasoner for an OWLModel:
+
 
 +
To obtain an instance of a reasoner, the method <code> createProtegeReasoner(OWLModel owlModel, Class reasonerJavaClass)</code> should be used. The second argument, <code>reasonerJavaCode</code>, is the Java class of the reasoner for which you would like to obtain an instance.
 +
 
 +
 
 +
The Protege full installation comes with three reasoner implementations:
 +
 
 +
* '''<code>DefaultProtegeDIGReasoner</code>''' : provides a connection to an external DIG compliant reasoner
 +
* '''<code>ProtegePelletJenaReasoner</code>''':  provides a direct connection to the [http://pellet.owldl.com/ Pellet reasoner] accessed through the [http://jena.sourceforge.net/ Jena API]
 +
* '''<code>ProtegePelletOWLAPIReasoner</code>''': provides a direct connection to the [http://pellet.owldl.com/ Pellet reasoner] accessed through the [http://owlapi.sourceforge.net/ OWL-API]
 +
 
 +
 
 +
Each of the above reasoner implement the <code>ProtegeReasoner</code> interface. If you would like to use a direct connection to Pellet in your application, it is recommended that you use the <code>ProtegePelletOWLAPIReasoner</code>.
 +
 
 +
 
 +
In the following we will provide some code snippets that show how to obtain reasoner instances for the reasoners mentioned above.
 +
 
 +
 
 +
 
 +
 
  
  
 
''' <nowiki>---</nowiki> TO BE CONTINUED <nowiki>---</nowiki> '''
 
''' <nowiki>---</nowiki> TO BE CONTINUED <nowiki>---</nowiki> '''

Revision as of 12:24, November 17, 2007

Protege-OWL Reasoning API

This page describes the Protege-OWL Reasoner API that provides programmatic access to a direct or a DIG-compliant reasoner. It provides methods for consistency checking, classification, etc. of an ontology as well as methods for getting the inferred information for a particular OWL entity.

A new plugin type, the reasoner plugin, has been added that allows the integration of other reasoners into Protege. A reasoner implementing the reasoner plugin interface will be accessible through the Protege user interface the same way that the built-in reasoners are.

This Reasoner API is available since Protege 3.4 beta 120. The old Reasoner API described here has been deprecated and should not be used anymore.


If you want to use the Reasoner API with a previous version of Protege than 3.4 beta 120 (from 2007/11/17), please refer to this page.



The Reasoning API

The following sections provide a rough outline of how to use the Protégé-OWL reasoning API. The examples use an ontology that describes pizzas, which can be downloaded from here.


The inference Package

The reasoning API is encapsulated in the edu.stanford.smi.protegex.owl.inference package. The main classes that will be used are the ReasonerManager (used to obtain a reasoner) and ProtegeReasoner (an interface to the direct or DIG reasoner).

The Reasoner Manager

In general, the first step when using the reasoning API is to obtain an instance of ProtegeReasoner for an OWL model. This instance of the reasoner can then be used to obtain inferred information about the model such as inferred superclasses, inferred equivalent classes, and inferred types for individuals. The ProtegeReasoner manages communication with the direct or DIG reasoner, ensuring that it is always properly synchronized with the internal Protégé-OWL model.

In order to get an instance of ProtegeReasoner for an OWL model, the ReasonerManager, which is found in the edu.stanford.smi.protegex.owl.inference.protegeowl package, must be used. The ReasonerManager is a singleton class (a class with only one instance), whose instance can be obtained by using the static method getInstance() .

To obtain an instance of a reasoner, the method createProtegeReasoner(OWLModel owlModel, Class reasonerJavaClass) should be used. The second argument, reasonerJavaCode, is the Java class of the reasoner for which you would like to obtain an instance.


The Protege full installation comes with three reasoner implementations:

  • DefaultProtegeDIGReasoner : provides a connection to an external DIG compliant reasoner
  • ProtegePelletJenaReasoner: provides a direct connection to the Pellet reasoner accessed through the Jena API
  • ProtegePelletOWLAPIReasoner: provides a direct connection to the Pellet reasoner accessed through the OWL-API


Each of the above reasoner implement the ProtegeReasoner interface. If you would like to use a direct connection to Pellet in your application, it is recommended that you use the ProtegePelletOWLAPIReasoner.


In the following we will provide some code snippets that show how to obtain reasoner instances for the reasoners mentioned above.




--- TO BE CONTINUED ---