Package org.apache.jena.reasoner
The Jena2 reasoner subsystem is designed to allow a range of inference
engines to be plugged into Jena. Such reasoners are primarily used to derive
additional RDF assertions which are entailed from some base RDF together
with any optional ontology information and the axioms and rules associated
with the reasoner. In addition, they can be used to test global properties
of an RDF graph such as consistency.
This machinery, and the rest of this description, are appropriate for
developers working with Graphs and Nodes at the SPI level. Application developers
using Models should see the convenience methods built into ModelFactory.
Each available reasoner is represented by an factory object which is an
instance of a ReasonerFactory.
It is also given a URI through which it can be identified. This URI
is used both as the base of a set of RDF assertions which describe the reasoner
capabilitiesand as an identifier for registering the reasoner with a central
registry. If you only need to access a specific built-in reasoner you can
use the factory class directly or the convenience methods built into ModelFactory
[TODO: ref]. However, if you need to dynamically check what reasoners are
registered with the Jena2 installation and examine their capabilities use
the machinery in ReasonerRegistry.
Once you have an appropriate factory you can create a reasoner instance. The instance can then be bound to a set of RDF data for processing. The result of such binding is an InfGraph , this is a specialization of the standard Graph interface - all the RDF assertions entailed from the base data via the reasoner appear as "virtual" triples within this InfGraph. Some additional methods on InfGraph offer access to the reasoner, the raw data and some additional capabilities.
For example, using the SPI all of the steps involved in generated an RDFS closure of
a graph are:
ReasonerFactory rf = RDFSReasonerFactory.theInstance(); Reasoner reasoner = rf.create(null); InfGraph graph = reasoner.bindSchema(tbox) // optional .bind(data); Model model = new ModelMem(graph);
For application developers working with the API then this code is accessible through the convenience methods in ModelFactory.
If the resulting graph or model are queried using find/listStatements
they contain the sum of all the assertions in the tbox graph, the data graph
and the triples entailed from them via RDF+RDFS entailment.
The ability to separately bind rule or ontology information (tbox
in the example) and raw assertional information (data in the example)
is optional. Some reasoners may require a strict separation of terminology
and instance data, others may allow both binds but be lax about the allowed
contents of each, others may not support the bindSchema stage.
The existing built-in reasoners allow a single tbox together with a single data bind but the tbox is optional and unrestricted. In the case of the RDFSReasoner in the example, some work is done at bindSchema time to cache information on property and class lattices that may be reused across multiple data sets but the extent of that reuse is lessened if the data graph also contains such schema assertions.
-
Interface Summary Interface Description Derivation Derivation records are used to determine how an inferred triple was derived from a set of source triples and a reasoner.Finder Minimal interface for preforming simple pattern find operations.InfGraph Extends the Graph interface to give additional means to query an inferred graph.Reasoner The minimal interface to which all reasoners (or reasoner adaptors) conform.ReasonerFactory The interface through which a reasoner (inference engine) can be instantiated.ValidityReport Data structure used to report the results of validation or consistency checking operations. -
Class Summary Class Description BaseInfGraph A base level implementation of the InfGraph interface.BaseInfGraph.InfCapabilities An InfCapabilities notes that size may not be accurate.BaseInfGraph.InfFindSafeCapabilities An InfCapabilities notes that size may not be accurate.BaseInfGraph.InfTransactionHandler FGraph Wrapper round a Graph to implement the slightly modified Finder interface.FinderUtil Some simple helper methods used when working with Finders, particularly to compose them into cascade sequences.ReasonerRegistry A global registry of known reasoner modules.StandardValidityReport Default implementation of ValidityReport which simply stores a list of precomputed Report records.TriplePattern Datastructure which defines a triple pattern as used in simple rules and in find interfaces.ValidityReport.Report -
Exception Summary Exception Description IllegalParameterException Exception used to signal that a configuration parameter was used (typically in a setParameter call) that was not understood - either because it was not a recognized parameter URI or its value range was incorrect.ReasonerException Exception signalling some generic problem with the reasoning subsystem.