Author: buildbot
Date: Wed Jul 30 12:50:12 2014
New Revision: 917943
Log:
Staging update by buildbot for jena
Modified:
websites/staging/jena/trunk/content/ (props changed)
websites/staging/jena/trunk/content/documentation/inference/index.html
Propchange: websites/staging/jena/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Jul 30 12:50:12 2014
@@ -1 +1 @@
-1614636
+1614639
Modified: websites/staging/jena/trunk/content/documentation/inference/index.html
==============================================================================
--- websites/staging/jena/trunk/content/documentation/inference/index.html
(original)
+++ websites/staging/jena/trunk/content/documentation/inference/index.html Wed
Jul 30 12:50:12 2014
@@ -492,7 +492,7 @@
ontology is both valid (logically consistent) and generated no warnings (such
as inconsistent classes).</p>
-<h4 id="wzxhzdk340wzxhzdk341extended-list-statements"><a
name="extendedListStatements"></a>Extended list statements</h4>
+<h4 id="wzxhzdk363wzxhzdk364extended-list-statements"><a
name="extendedListStatements"></a>Extended list statements</h4>
<p><p>The default API supports accessing all entailed information at the level
of
individual triples. This is surprisingly flexible but there are queries which
cannot be easily supported this way. The first such is when the query needs
@@ -511,7 +511,7 @@
preloading your data with expressions you might need to query over. However,
for some external reasoners, especially description logic reasoners, we
anticipate
restricted uses of this form of listStatement will be important.</p></p>
-<h4 id="wzxhzdk352wzxhzdk353direct-and-indirect-relationships"><a
name="directRelations"></a>Direct and indirect relationships</h4>
+<h4 id="wzxhzdk375wzxhzdk376direct-and-indirect-relationships"><a
name="directRelations"></a>Direct and indirect relationships</h4>
<p><p>The second type of operation that is not obviously convenient at the
triple
level involves distinguishing between direct and indirect relationships. If
a relation is transitive, for example rdfs:subClassOf, then we can define the
@@ -532,7 +532,7 @@
<p>Typically the easiest way to work with such indirect and direct relations is
to use the <a href="../ontology/index.html">Ontology API</a> which hides the
grubby details of these property aliases.</p></p>
-<h4 id="wzxhzdk379wzxhzdk380derivations"><a
name="derivations"></a>Derivations</h4>
+<h4 id="wzxhzdk402wzxhzdk403derivations"><a
name="derivations"></a>Derivations</h4>
<p><p>It is sometimes useful to be able to trace where an inferred statement
was
generated from. This is achieved using the
<code>InfModel.getDerivation(Statement)</code>
method. This returns a iterator over a set <a
href="/documentation/javadoc/jena/com/hp/hpl/jena/reasoner/Derivation.html"><code>Derviation</code></a>
@@ -583,16 +583,15 @@
<p>Which generates the output:</p>
-<div class="codehilite"><pre><span class="nt"><i></span>Statement is
[urn:x-hp:eg/A, urn:x-hp:eg/p, urn:x-hp:eg/D]
-Rule rule1 concluded (eg:A eg:p eg:D) <span class="ni">&lt;</span>-
- Fact (eg:A eg:p eg:B)
- Rule rule1 concluded (eg:B eg:p eg:D) <span class="ni">&lt;</span>-
+<pre><i>Statement is [urn:x-hp:eg/A, urn:x-hp:eg/p, urn:x-hp:eg/D]
+ Rule rule1 concluded (eg:A eg:p eg:D) <-
+ Fact (eg:A eg:p eg:B)
+ Rule rule1 concluded (eg:B eg:p eg:D) <-
Fact (eg:B eg:p eg:C)
- Fact (eg:C eg:p eg:D)<span class="nt"></i></span>
-</pre></div>
-
+ Fact (eg:C eg:p eg:D)</i>
+</pre>
-<h4 id="wzxhzdk403wzxhzdk404accessing-raw-data-and-deductions"><a
name="rawAccess"></a>Accessing raw data and deductions</h4>
+<h4 id="wzxhzdk426wzxhzdk427accessing-raw-data-and-deductions"><a
name="rawAccess"></a>Accessing raw data and deductions</h4>
<p><p>From an <code>InfModel</code> it is easy to retrieve the original,
unchanged,
data over which the model has been computed using the
<code>getRawModel()</code>
call. This returns a model equivalent to the one used in the initial
<code>bind</code>
@@ -601,7 +600,7 @@ Rule rule1 concluded (eg:A eg:p eg:D) <s
<p>Some reasoners, notably the forward chaining rule engine, store the deduced
statements in a concrete form and this set of deductions can be obtained
separately
by using the <code>getDeductionsModel()</code> call. </p></p>
-<h4 id="wzxhzdk417wzxhzdk418processing-control"><a
name="processingControl"></a>Processing control</h4>
+<h4 id="wzxhzdk440wzxhzdk441processing-control"><a
name="processingControl"></a>Processing control</h4>
<p><p>Having bound a <code>Model</code> into an <code>InfModel</code> by using
a
<code>Reasoner</code> its content can still be changed by the normal
<code>add</code>
and <code>remove</code> calls to the <code>InfModel</code>. Any such change
@@ -628,7 +627,7 @@ Rule rule1 concluded (eg:A eg:p eg:D) <s
call. It there are any outstanding queries (i.e. StmtIterators which have not
been read to the end yet) then those will be aborted (the next hasNext() call
will return false).</p></p>
-<h4 id="wzxhzdk447wzxhzdk448tracing"><a name="tracing"></a>Tracing</h4>
+<h4 id="wzxhzdk470wzxhzdk471tracing"><a name="tracing"></a>Tracing</h4>
<p><p>When developing new reasoner configurations, especially new rule sets
for the
rule engines, it is sometimes useful to be able to trace the operations of
the
associated inference engine. Though, often this generates too much
information
@@ -643,14 +642,14 @@ Rule rule1 concluded (eg:A eg:p eg:D) <s
<p>[<a href="#api">API index</a>] [<a href="#index">main index</a>]</p>
-<h2 id="wzxhzdk455wzxhzdk456the-rdfs-reasoner"><a name="rdfs"></a>The RDFS
reasoner</h2>
+<h2 id="wzxhzdk478wzxhzdk479the-rdfs-reasoner"><a name="rdfs"></a>The RDFS
reasoner</h2>
<p><ol>
<li><a href="#RDFSintro">RDFS reasoner - introduction and coverage</a></li>
<li><a href="#RDFSconfiguration">RDFS Configuration</a></li>
<li><a href="#RDFSexamples">RDFS Example</a></li>
<li><a href="#RDFSnotes">RDFS implementation and performance notes</a></li>
</ol></p>
-<h3 id="wzxhzdk475wzxhzdk476rdfs-reasoner-intro-and-coverage"><a
name="RDFSintro"></a>RDFS reasoner - intro and coverage</h3>
+<h3 id="wzxhzdk498wzxhzdk499rdfs-reasoner-intro-and-coverage"><a
name="RDFSintro"></a>RDFS reasoner - intro and coverage</h3>
<p><p>Jena includes an RDFS reasoner (<code>RDFSRuleReasoner</code>) which
supports
almost all of the RDFS entailments described by the RDF Core working group
[<a href="http://www.w3.org/TR/rdf-mt/">RDF
Semantics</a>]. The only omissions are deliberate and are described
below.</p>
@@ -685,7 +684,7 @@ Rule rule1 concluded (eg:A eg:p eg:D) <s
<p>[<a href="#rdfs">RDFS index</a>] [<a href="#index">main index</a>]</p>
-<h3 id="wzxhzdk495wzxhzdk496rdfs-configuration"><a
name="RDFSconfiguration"></a>RDFS configuration</h3>
+<h3 id="wzxhzdk518wzxhzdk519rdfs-configuration"><a
name="RDFSconfiguration"></a>RDFS configuration</h3>
<p><p>The RDFSRuleReasoner can be configured to work at three different
compliance
levels: </p>
<dl>
@@ -778,22 +777,22 @@ Rule rule1 concluded (eg:A eg:p eg:D) <s
</tr>
</table>
<p>[<a href="#rdfs">RDFS index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk606wzxhzdk607rdfs-example"><a name="RDFSexamples"></a>RDFS
Example</h3>
+<h3 id="wzxhzdk629wzxhzdk630rdfs-example"><a name="RDFSexamples"></a>RDFS
Example</h3>
<p><p>As a complete worked example let us create a simple RDFS schema, some
instance
data and use an instance of the RDFS reasoner to query the two.</p>
<p>We shall use a trivial schema:</p></p>
-<div class="codehilite"><pre> <span class="o">&</span><span
class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span
class="n">lt</span><span class="p">;</span><span class="n">rdf</span><span
class="p">:</span><span class="n">Description</span> <span
class="n">rdf</span><span class="p">:</span><span class="n">about</span><span
class="p">=</span>"<span class="o">&</span><span
class="n">amp</span><span class="p">;</span><span class="n">eg</span><span
class="p">;</span><span class="n">mum</span>"<span
class="o">&</span><span class="n">gt</span><span class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">rdfs</span><span class="p">:</span><span
class="n">subPropertyOf</span> <span class="n">rdf</span><span
class="p">:</span><span class="n">resource</span><span
class="p">=</span>"<span class="o">&</span><span
class="n">amp</span><span class="p">;</span><span class="n">eg</span><span
class="p">;</span><span class="n">parent</span>"<span
class="o">/&</span><span class="n">gt</span><span class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="o">/</span><span class="n">rdf</span><span
class="p">:</span><span class="n">Description</span><span
class="o">&</span><span class="n">gt</span><span class="p">;</span>
-
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">rdf</span><span class="p">:</span><span
class="n">Description</span> <span class="n">rdf</span><span
class="p">:</span><span class="n">about</span><span
class="p">=</span>"<span class="o">&</span><span
class="n">amp</span><span class="p">;</span><span class="n">eg</span><span
class="p">;</span><span class="n">parent</span>"<span
class="o">&</span><span class="n">gt</span><span class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">rdfs</span><span class="p">:</span><span
class="n">range</span> <span class="o">&</span><span
class="n">nbsp</span><span class="p">;</span><span class="n">rdf</span><span
class="p">:</span><span class="n">resource</span><span
class="p">=</span>"<span class="o">&</span><span
class="n">amp</span><span class="p">;</span><span class="n">eg</span><span
class="p">;</span><span class="n">Person</span>"<span
class="o">/&</span><span class="n">gt</span><span class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">rdfs</span><span class="p">:</span><span
class="n">domain</span> <span class="n">rdf</span><span class="p">:</span><span
class="n">resource</span><span class="p">=</span>"<span
class="o">&</span><span class="n">amp</span><span class="p">;</span><span
class="n">eg</span><span class="p">;</span><span
class="n">Person</span>"<span class="o">/&</span><span
class="n">gt</span><span class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="o">/</span><span class="n">rdf</span><span
class="p">:</span><span class="n">Description</span><span
class="o">&</span><span class="n">gt</span><span class="p">;</span>
-
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">rdf</span><span class="p">:</span><span
class="n">Description</span> <span class="n">rdf</span><span
class="p">:</span><span class="n">about</span><span
class="p">=</span>"<span class="o">&</span><span
class="n">amp</span><span class="p">;</span><span class="n">eg</span><span
class="p">;</span><span class="n">age</span>"<span
class="o">&</span><span class="n">gt</span><span class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">rdfs</span><span class="p">:</span><span
class="n">range</span> <span class="n">rdf</span><span class="p">:</span><span
class="n">resource</span><span class="p">=</span>"<span
class="o">&</span><span class="n">amp</span><span class="p">;</span><span
class="n">xsd</span><span class="p">;</span><span
class="n">integer</span>" <span class="o">/&</span><span
class="n">gt</span><span class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="o">/</span><span class="n">rdf</span><span
class="p">:</span><span class="n">Description</span><span
class="o">&</span><span class="n">gt</span><span class="p">;</span>
+<div class="codehilite"><pre> <span class="nt"><rdf:Description</span>
<span class="na">rdf:about=</span><span
class="s">"&amp;eg;mum"</span><span class="nt">></span>
+ <span class="nt"><rdfs:subPropertyOf</span> <span
class="na">rdf:resource=</span><span
class="s">"&amp;eg;parent"</span><span class="nt">/></span>
+ <span class="nt"></rdf:Description></span>
+
+ <span class="nt"><rdf:Description</span> <span
class="na">rdf:about=</span><span
class="s">"&amp;eg;parent"</span><span class="nt">></span>
+ <span class="nt"><rdfs:range</span> <span
class="na">rdf:resource=</span><span
class="s">"&amp;eg;Person"</span><span class="nt">/></span>
+ <span class="nt"><rdfs:domain</span> <span
class="na">rdf:resource=</span><span
class="s">"&amp;eg;Person"</span><span class="nt">/></span>
+ <span class="nt"></rdf:Description></span>
+
+ <span class="nt"><rdf:Description</span> <span
class="na">rdf:about=</span><span
class="s">"&amp;eg;age"</span><span class="nt">></span>
+ <span class="nt"><rdfs:range</span> <span
class="na">rdf:resource=</span><span
class="s">"&amp;xsd;integer"</span> <span class="nt">/></span>
+ <span class="nt"></rdf:Description></span>
</pre></div>
@@ -803,10 +802,10 @@ Rule rule1 concluded (eg:A eg:p eg:D) <s
<p>We shall also use the even simpler instance file:</p>
-<div class="codehilite"><pre> <span class="o">&</span><span
class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span
class="n">lt</span><span class="p">;</span><span class="n">Teenager</span>
<span class="n">rdf</span><span class="p">:</span><span
class="n">about</span><span class="p">=</span>"<span
class="o">&</span><span class="n">amp</span><span class="p">;</span><span
class="n">eg</span><span class="p">;</span><span
class="n">colin</span>"<span class="o">&</span><span
class="n">gt</span><span class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">mum</span> <span class="n">rdf</span><span
class="p">:</span><span class="n">resource</span><span
class="p">=</span>"<span class="o">&</span><span
class="n">amp</span><span class="p">;</span><span class="n">eg</span><span
class="p">;</span><span class="n">rosy</span>" <span
class="o">/&</span><span class="n">gt</span><span class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">age</span><span class="o">&</span><span
class="n">gt</span><span class="p">;</span>13<span class="o">&</span><span
class="n">lt</span><span class="p">;</span><span class="o">/</span><span
class="n">age</span><span class="o">&</span><span class="n">gt</span><span
class="p">;</span>
- <span class="o">&</span><span class="n">nbsp</span><span
class="p">;</span><span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="o">/</span><span class="n">Teenager</span><span
class="o">&</span><span class="n">gt</span><span class="p">;</span>
+<div class="codehilite"><pre> <span class="o">&</span><span
class="n">lt</span><span class="p">;</span><span class="n">Teenager</span>
<span class="n">rdf</span><span class="p">:</span><span
class="n">about</span><span class="p">=</span>"<span
class="o">&</span><span class="n">amp</span><span class="p">;</span><span
class="n">eg</span><span class="p">;</span><span
class="n">colin</span>"<span class="o">></span>
+ <span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">mum</span> <span class="n">rdf</span><span
class="p">:</span><span class="n">resource</span><span
class="p">=</span>"<span class="o">&</span><span
class="n">amp</span><span class="p">;</span><span class="n">eg</span><span
class="p">;</span><span class="n">rosy</span>" <span class="o">/></span>
+ <span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="n">age</span><span class="o">></span>13<span
class="o">&</span><span class="n">lt</span><span class="p">;</span><span
class="o">/</span><span class="n">age</span><span class="o">></span>
+ <span class="o">&</span><span class="n">lt</span><span
class="p">;</span><span class="o">/</span><span class="n">Teenager</span><span
class="o">></span>
</pre></div>
@@ -818,11 +817,11 @@ Rule rule1 concluded (eg:A eg:p eg:D) <s
definitions, create an inference model and query it for information on the
<code>rdf:type</code>
of <code>colin</code> and the <code>rdf:type</code> of
<code>Person</code>:</p>
-<p>```
- Model schema = FileManager.get().loadModel("file:data/rdfsDemoSchema.rdf");
- Model data = FileManager.get().loadModel("file:data/rdfsDemoData.rdf");
- InfModel infmodel = ModelFactory.createRDFSModel(schema, data);</p>
-<div class="codehilite"><pre><span class="n">Resource</span> <span
class="n">colin</span> <span class="p">=</span> <span
class="n">infmodel</span><span class="p">.</span><span
class="n">getResource</span><span class="p">(</span>"<span
class="n">urn</span><span class="p">:</span><span class="n">x</span><span
class="o">-</span><span class="n">hp</span><span class="p">:</span><span
class="n">eg</span><span class="o">/</span><span
class="n">colin</span>"<span class="p">);</span>
+<div class="codehilite"><pre><span class="n">Model</span> <span
class="n">schema</span> <span class="p">=</span> <span
class="n">FileManager</span><span class="p">.</span><span
class="n">get</span><span class="p">().</span><span
class="n">loadModel</span><span class="p">(</span>"<span
class="n">file</span><span class="p">:</span><span class="n">data</span><span
class="o">/</span><span class="n">rdfsDemoSchema</span><span
class="p">.</span><span class="n">rdf</span>"<span class="p">);</span>
+<span class="n">Model</span> <span class="n">data</span> <span
class="p">=</span> <span class="n">FileManager</span><span
class="p">.</span><span class="n">get</span><span class="p">().</span><span
class="n">loadModel</span><span class="p">(</span>"<span
class="n">file</span><span class="p">:</span><span class="n">data</span><span
class="o">/</span><span class="n">rdfsDemoData</span><span
class="p">.</span><span class="n">rdf</span>"<span class="p">);</span>
+<span class="n">InfModel</span> <span class="n">infmodel</span> <span
class="p">=</span> <span class="n">ModelFactory</span><span
class="p">.</span><span class="n">createRDFSModel</span><span
class="p">(</span><span class="n">schema</span><span class="p">,</span> <span
class="n">data</span><span class="p">);</span>
+
+<span class="n">Resource</span> <span class="n">colin</span> <span
class="p">=</span> <span class="n">infmodel</span><span class="p">.</span><span
class="n">getResource</span><span class="p">(</span>"<span
class="n">urn</span><span class="p">:</span><span class="n">x</span><span
class="o">-</span><span class="n">hp</span><span class="p">:</span><span
class="n">eg</span><span class="o">/</span><span
class="n">colin</span>"<span class="p">);</span>
<span class="n">System</span><span class="p">.</span><span
class="n">out</span><span class="p">.</span><span class="n">println</span><span
class="p">(</span>"<span class="n">colin</span> <span class="n">has</span>
<span class="n">types</span><span class="p">:</span>"<span
class="p">);</span>
<span class="n">printStatements</span><span class="p">(</span><span
class="n">infmodel</span><span class="p">,</span> <span
class="n">colin</span><span class="p">,</span> <span class="n">RDF</span><span
class="p">.</span><span class="n">type</span><span class="p">,</span> <span
class="n">null</span><span class="p">);</span>
@@ -832,7 +831,6 @@ Rule rule1 concluded (eg:A eg:p eg:D) <s
</pre></div>
-<p>```</p>
<p>This produces the output:</p>
<pre><i>colin has types:
@@ -877,7 +875,7 @@ that is not compatible with 13</i></pre>
<p>[<a href="#rdfs">RDFS index</a>] [<a href="#index">main index</a>]</p>
-<h3 id="wzxhzdk612wzxhzdk613rdfs-implementation-and-performance-notes"><a
name="RDFSnotes"></a>RDFS implementation and performance notes</h3>
+<h3 id="wzxhzdk635wzxhzdk636rdfs-implementation-and-performance-notes"><a
name="RDFSnotes"></a>RDFS implementation and performance notes</h3>
<p><p>The RDFSRuleReasoner is a hybrid implementation. The subproperty and
subclass
lattices are eagerly computed and stored in a compact in-memory form using
the
TransitiveReasoner (see below). The identification of which container
membership
@@ -935,7 +933,7 @@ that is not compatible with 13</i></pre>
on adapting the rule engines to exploit the capabilities of the more
sophisticated
database backends will be considered.</p>
<p>[<a href="#rdfs">RDFS index</a>] [<a href="#index">main index</a>]</p></p>
-<h2 id="wzxhzdk700wzxhzdk701the-owl-reasoner"><a name="owl"></a>The OWL
reasoner</h2>
+<h2 id="wzxhzdk723wzxhzdk724the-owl-reasoner"><a name="owl"></a>The OWL
reasoner</h2>
<p><ol>
<li><a href="#OWLintro">OWL reasoner introduction</a></li>
<li><a href="#OWLcoverage">OWL coverage</a></li>
@@ -952,7 +950,7 @@ an external DL reasoner such as Pellet,
configuration still leaves something to be desired and will the subject of
future work - time permitting.</p>
<p>See also <a href="#OWLnotes">subsection 5</a> for notes on more specific
limitations
of the current implementation. </p></p>
-<h3 id="wzxhzdk734wzxhzdk735owl-coverage"><a name="OWLcoverage"></a>OWL
coverage</h3>
+<h3 id="wzxhzdk757wzxhzdk758owl-coverage"><a name="OWLcoverage"></a>OWL
coverage</h3>
<p><p>The Jena OWL reasoners could be described as instance-based reasoners.
That
is, they work by using rules to propagate the if- and only-if- implications
of
the OWL constructs on instance data. Reasoning about classes is done
indirectly
@@ -1171,7 +1169,7 @@ configuration still leaves something to
restriction.</li>
</ul>
<p>[<a href="#owl">OWL index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk984wzxhzdk985owl-configuration"><a
name="OWLconfiguration"></a>OWL Configuration</h3>
+<h3 id="wzxhzdk1007wzxhzdk1008owl-configuration"><a
name="OWLconfiguration"></a>OWL Configuration</h3>
<p><p>This reasoner is accessed using
<code>ModelFactory.createOntologyModel</code>
with the prebuilt <a
href="/documentation/javadoc/jena/com/hp/hpl/jena/ontology/OntModelSpec.html"><code>OntModelSpec</code></a>
<code>OWL_MEM_RULE_INF</code> or manually via
<code>ReasonerRegistery.getOWLReasoner()</code>.</p>
@@ -1208,7 +1206,7 @@ configuration still leaves something to
of the rule-based approach we imagine useful subsets of functionality
emerging
- like that that supported by the RDFS reasoner in the form of the level
settings.</p>
<p>[<a href="#owl">OWL index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk1050wzxhzdk1051owl-example"><a name="OWLexamples"></a>OWL
Example</h3>
+<h3 id="wzxhzdk1073wzxhzdk1074owl-example"><a name="OWLexamples"></a>OWL
Example</h3>
<p><p>As an example of using the OWL inference support, consider the sample
schema
and data file in the data directory - <a
href="data/owlDemoSchema.xml">owlDemoSchema.xml</a>
and <a href="data/owlDemoData.xml">owlDemoData.xml</a>. </p>
@@ -1219,27 +1217,39 @@ configuration still leaves something to
including two different descriptions of the configurations
"whiteBoxZX"
and "<code>bigName42</code>".</p>
<p>We can create an instance of the OWL reasoner, specialized to the demo
schema
- and then apply that to the demo data to obtain an inference model, as
follows:</p>
-<pre> Model schema =
FileManager.get().loadModel("file:data/owlDemoSchema.owl");
- Model data = FileManager.get().loadModel("file:data/owlDemoData.rdf");
- Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
- reasoner = reasoner.bindSchema(schema);
- InfModel infmodel = ModelFactory.createInfModel(reasoner, data);</pre>
+ and then apply that to the demo data to obtain an inference model, as
follows:</p></p>
+<div class="codehilite"><pre><span class="n">Model</span> <span
class="n">schema</span> <span class="p">=</span> <span
class="n">FileManager</span><span class="p">.</span><span
class="n">get</span><span class="p">().</span><span
class="n">loadModel</span><span class="p">(</span>"<span
class="n">file</span><span class="p">:</span><span class="n">data</span><span
class="o">/</span><span class="n">owlDemoSchema</span><span
class="p">.</span><span class="n">owl</span>"<span class="p">);</span>
+<span class="n">Model</span> <span class="n">data</span> <span
class="p">=</span> <span class="n">FileManager</span><span
class="p">.</span><span class="n">get</span><span class="p">().</span><span
class="n">loadModel</span><span class="p">(</span>"<span
class="n">file</span><span class="p">:</span><span class="n">data</span><span
class="o">/</span><span class="n">owlDemoData</span><span
class="p">.</span><span class="n">rdf</span>"<span class="p">);</span>
+<span class="n">Reasoner</span> <span class="n">reasoner</span> <span
class="p">=</span> <span class="n">ReasonerRegistry</span><span
class="p">.</span><span class="n">getOWLReasoner</span><span
class="p">();</span>
+<span class="n">reasoner</span> <span class="p">=</span> <span
class="n">reasoner</span><span class="p">.</span><span
class="n">bindSchema</span><span class="p">(</span><span
class="n">schema</span><span class="p">);</span>
+<span class="n">InfModel</span> <span class="n">infmodel</span> <span
class="p">=</span> <span class="n">ModelFactory</span><span
class="p">.</span><span class="n">createInfModel</span><span
class="p">(</span><span class="n">reasoner</span><span class="p">,</span> <span
class="n">data</span><span class="p">);</span>
+</pre></div>
+
+
<p>A typical example operation on such a model would be to find out all we know
about a specific instance, for example the <code>nForce</code> mother board.
This can be done using:</p>
-<pre> Resource nForce = infmodel.getResource("urn:x-hp:eg/nForce");
- System.out.println("nForce <em>:");
- printStatements(infmodel, nForce, null, null);<br></pre>
+
+<div class="codehilite"><pre><span class="n">Resource</span> <span
class="n">nForce</span> <span class="p">=</span> <span
class="n">infmodel</span><span class="p">.</span><span
class="n">getResource</span><span class="p">(</span>"<span
class="n">urn</span><span class="p">:</span><span class="n">x</span><span
class="o">-</span><span class="n">hp</span><span class="p">:</span><span
class="n">eg</span><span class="o">/</span><span
class="n">nForce</span>"<span class="p">);</span>
+<span class="n">System</span><span class="p">.</span><span
class="n">out</span><span class="p">.</span><span class="n">println</span><span
class="p">(</span>"<span class="n">nForce</span> <span
class="o">*</span><span class="p">:</span>"<span class="p">);</span>
+<span class="n">printStatements</span><span class="p">(</span><span
class="n">infmodel</span><span class="p">,</span> <span
class="n">nForce</span><span class="p">,</span> <span
class="n">null</span><span class="p">,</span> <span class="n">null</span><span
class="p">);</span>
+</pre></div>
+
+
<p> where <code>printStatements</code> is defined by: </p>
-<pre> public void printStatements(Model m, Resource s, Property p, Resource
o) {
- for (StmtIterator i = m.listStatements(s,p,o); i.hasNext(); ) {
- Statement stmt = i.nextStatement();
- System.out.println(" - " + PrintUtil.print(stmt));
- }
- }</pre>
+
+<div class="codehilite"><pre><span class="n">public</span> <span
class="n">void</span> <span class="n">printStatements</span><span
class="p">(</span><span class="n">Model</span> <span class="n">m</span><span
class="p">,</span> <span class="n">Resource</span> <span
class="n">s</span><span class="p">,</span> <span class="n">Property</span>
<span class="n">p</span><span class="p">,</span> <span
class="n">Resource</span> <span class="n">o</span><span class="p">)</span>
<span class="p">{</span>
+ <span class="k">for</span> <span class="p">(</span><span
class="n">StmtIterator</span> <span class="nb">i</span> <span
class="p">=</span> <span class="n">m</span><span class="p">.</span><span
class="n">listStatements</span><span class="p">(</span><span
class="n">s</span><span class="p">,</span><span class="n">p</span><span
class="p">,</span><span class="n">o</span><span class="p">);</span> <span
class="nb">i</span><span class="p">.</span><span class="n">hasNext</span><span
class="p">();</span> <span class="p">)</span> <span class="p">{</span>
+ <span class="n">Statement</span> <span class="n">stmt</span> <span
class="p">=</span> <span class="nb">i</span><span class="p">.</span><span
class="n">nextStatement</span><span class="p">();</span>
+ <span class="n">System</span><span class="p">.</span><span
class="n">out</span><span class="p">.</span><span class="n">println</span><span
class="p">(</span>" <span class="o">-</span> " <span
class="o">+</span> <span class="n">PrintUtil</span><span
class="p">.</span><span class="n">print</span><span class="p">(</span><span
class="n">stmt</span><span class="p">));</span>
+ <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
<p>This produces the output:</p>
-<pre><i>nForce </em>:
+
+<pre><i>nForce *:
- (eg:nForce rdf:type owl:Thing)
- (eg:nForce owl:sameAs eg:unknownMB)
- (eg:nForce owl:sameAs eg:nForce)
@@ -1248,6 +1258,7 @@ configuration still leaves something to
- (eg:nForce rdf:type a3b24:f7822755ad:-7ffd)
- (eg:nForce eg:hasGraphics eg:gamingGraphics)
- (eg:nForce eg:hasComponent eg:gamingGraphics)</i></pre>
+
<p>Note that this includes inferences based on subClass inheritance (being an
<code>eg:MotherBoard</code> implies it is an <code>owl:Thing</code> and an
<code>rdfs:Resource</code>),
property inheritance (<code>eg:hasComponent eg:gameGraphics</code> derives
from
@@ -1257,6 +1268,7 @@ configuration still leaves something to
of <code>whileBoxZX</code> use these two different terms for the mother
board).<i>
</i>The anonymous rdf:type statement referencesthe
<code>"hasValue(eg:hasComponent,
eg:gamingGraphics)" </code>restriction mentioned in the definition of
GamingComputer.</p>
+
<p>A second, typical operation is instance recognition. Testing if an
individual
is an instance of a class expression. In this case the
<code>whileBoxZX</code>
is identifiable as a <code>GamingComputer</code> because it is a
<code>Computer</code>,
@@ -1264,40 +1276,55 @@ configuration still leaves something to
have a <code>gamingGraphics</code> component from the combination of the
<code>nForce</code>
inferences we've already seen and the transitivity of
<code>hasComponent</code>.
We can test this using:</p>
-<pre> Resource gamingComputer =
infmodel.getResource("urn:x-hp:eg/GamingComputer");
- Resource whiteBox = infmodel.getResource("urn:x-hp:eg/whiteBoxZX");
- if (infmodel.contains(whiteBox, RDF.type, gamingComputer)) {
- System.out.println("White box recognized as gaming computer");
- } else {
- System.out.println("Failed to recognize white box correctly");
- }</pre>
+
+<div class="codehilite"><pre><span class="n">Resource</span> <span
class="n">gamingComputer</span> <span class="p">=</span> <span
class="n">infmodel</span><span class="p">.</span><span
class="n">getResource</span><span class="p">(</span>"<span
class="n">urn</span><span class="p">:</span><span class="n">x</span><span
class="o">-</span><span class="n">hp</span><span class="p">:</span><span
class="n">eg</span><span class="o">/</span><span
class="n">GamingComputer</span>"<span class="p">);</span>
+<span class="n">Resource</span> <span class="n">whiteBox</span> <span
class="p">=</span> <span class="n">infmodel</span><span class="p">.</span><span
class="n">getResource</span><span class="p">(</span>"<span
class="n">urn</span><span class="p">:</span><span class="n">x</span><span
class="o">-</span><span class="n">hp</span><span class="p">:</span><span
class="n">eg</span><span class="o">/</span><span
class="n">whiteBoxZX</span>"<span class="p">);</span>
+<span class="k">if</span> <span class="p">(</span><span
class="n">infmodel</span><span class="p">.</span><span
class="n">contains</span><span class="p">(</span><span
class="n">whiteBox</span><span class="p">,</span> <span
class="n">RDF</span><span class="p">.</span><span class="n">type</span><span
class="p">,</span> <span class="n">gamingComputer</span><span
class="p">))</span> <span class="p">{</span>
+ <span class="n">System</span><span class="p">.</span><span
class="n">out</span><span class="p">.</span><span class="n">println</span><span
class="p">(</span>"<span class="n">White</span> <span class="n">box</span>
<span class="n">recognized</span> <span class="n">as</span> <span
class="n">gaming</span> <span class="n">computer</span>"<span
class="p">);</span>
+<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+ <span class="n">System</span><span class="p">.</span><span
class="n">out</span><span class="p">.</span><span class="n">println</span><span
class="p">(</span>"<span class="n">Failed</span> <span class="n">to</span>
<span class="n">recognize</span> <span class="n">white</span> <span
class="n">box</span> <span class="n">correctly</span>"<span
class="p">);</span>
+<span class="p">}</span>
+</pre></div>
+
+
<p> Which gnerates the output:</p>
-<pre><i>White box recognized as gaming computer</i></pre>
+
+<pre> <i>White box recognized as gaming computer</i></pre>
+
<p>Finally, we can check for inconsistencies within the data by using the
validation
interface:</p>
-<pre> ValidityReport validity = infmodel.validate();
- if (validity.isValid()) {
- System.out.println("OK");
- } else {
- System.out.println("Conflicts");
- for (Iterator i = validity.getReports(); i.hasNext(); ) {
- ValidityReport.Report report = (ValidityReport.Report)i.next();
- System.out.println(" - " + report);
- }
- }</pre>
+
+<div class="codehilite"><pre><span class="n">ValidityReport</span> <span
class="n">validity</span> <span class="p">=</span> <span
class="n">infmodel</span><span class="p">.</span><span
class="n">validate</span><span class="p">();</span>
+<span class="k">if</span> <span class="p">(</span><span
class="n">validity</span><span class="p">.</span><span
class="n">isValid</span><span class="p">())</span> <span class="p">{</span>
+ <span class="n">System</span><span class="p">.</span><span
class="n">out</span><span class="p">.</span><span class="n">println</span><span
class="p">(</span>"<span class="n">OK</span>"<span class="p">);</span>
+<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+ <span class="n">System</span><span class="p">.</span><span
class="n">out</span><span class="p">.</span><span class="n">println</span><span
class="p">(</span>"<span class="n">Conflicts</span>"<span
class="p">);</span>
+ <span class="k">for</span> <span class="p">(</span><span
class="n">Iterator</span> <span class="nb">i</span> <span class="p">=</span>
<span class="n">validity</span><span class="p">.</span><span
class="n">getReports</span><span class="p">();</span> <span
class="nb">i</span><span class="p">.</span><span class="n">hasNext</span><span
class="p">();</span> <span class="p">)</span> <span class="p">{</span>
+ <span class="n">ValidityReport</span><span class="p">.</span><span
class="n">Report</span> <span class="n">report</span> <span class="p">=</span>
<span class="p">(</span><span class="n">ValidityReport</span><span
class="p">.</span><span class="n">Report</span><span class="p">)</span><span
class="nb">i</span><span class="p">.</span><span class="n">next</span><span
class="p">();</span>
+ <span class="n">System</span><span class="p">.</span><span
class="n">out</span><span class="p">.</span><span class="n">println</span><span
class="p">(</span>" <span class="o">-</span> " <span
class="o">+</span> <span class="n">report</span><span class="p">);</span>
+ <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
<p>Which generates the output:</p>
+
<pre><i>Conflicts
- Error (conflict): Two individuals both same and different, may be
due to disjoint classes or functional properties
Culprit = eg:nForce2
-Implicated node: eg:bigNameSpecialMB</i></p>
-<p>... + 3 other similar reports
+Implicated node: eg:bigNameSpecialMB</i>
+
+... + 3 other similar reports
</pre>
+
<p>This is due to the two records for the <code>bigName42</code> configuration
referencing two motherboards which are explicitly defined to be different
resources
and thus violate the FunctionProperty nature of
<code>hasMotherBoard</code>.</p>
-<p>[<a href="#owl">OWL index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk1159wzxhzdk1160owl-notes-and-limitations"><a
name="OWLnotes"></a>OWL notes and limitations</h3>
+
+<p>[<a href="#owl">OWL index</a>] [<a href="#index">main index</a>]</p>
+
+<h3 id="wzxhzdk1093wzxhzdk1094owl-notes-and-limitations"><a
name="OWLnotes"></a>OWL notes and limitations</h3>
<h4 id="comprehension-axioms">Comprehension axioms</h4>
<p><p>A critical implication of our variant of the instance-based approach is
that
the reasoner does not directly answer queries relating to dynamically
introduced
@@ -1368,7 +1395,7 @@ class B = cardinality(P,1)</pre>
should be valid) but not complete. </p></p>
<p>[<a href="#owl">OWL index</a>] [<a href="#index">main index</a>]</p>
-<h2 id="wzxhzdk1198wzxhzdk1199the-transitive-reasoner"><a
name="transitive"></a>The transitive reasoner</h2>
+<h2 id="wzxhzdk1132wzxhzdk1133the-transitive-reasoner"><a
name="transitive"></a>The transitive reasoner</h2>
<p><p>The TransitiveReasoner provides support for storing and traversing class
and
property lattices. This implements just the <i>transitive</i> and
<i>symmetric</i>
properties of <code>rdfs:subPropertyOf</code> and
<code>rdfs:subClassOf</code>.
@@ -1384,7 +1411,7 @@ class B = cardinality(P,1)</pre>
used in the default RDFS reasoner.</p>
<p>It has no configuration options.</p>
<p>[<a href="#index">Index</a>]</p></p>
-<h2 id="wzxhzdk1220wzxhzdk1221the-general-purpose-rule-engine"><a
name="rules"></a>The general purpose rule engine</h2>
+<h2 id="wzxhzdk1154wzxhzdk1155the-general-purpose-rule-engine"><a
name="rules"></a>The general purpose rule engine</h2>
<p><ol>
<li><a href="#RULEoverview">Overview of the rule engine(s)</a></li>
<li><a href="#RULEsyntax">Rule syntax and structure</a></li>
@@ -1398,7 +1425,7 @@ class B = cardinality(P,1)</pre>
<li><a href="#RULEnotes">Notes</a></li>
<li><a href="#RULEextensions">Extensions</a></li>
</ol></p>
-<h3 id="wzxhzdk1268wzxhzdk1269overview-of-the-rule-engines"><a
name="RULEoverview"></a>Overview of the rule engine(s)</h3>
+<h3 id="wzxhzdk1202wzxhzdk1203overview-of-the-rule-engines"><a
name="RULEoverview"></a>Overview of the rule engine(s)</h3>
<p><p>Jena includes a general purpose rule-based reasoner which is used to
implement
both the RDFS and OWL reasoners but is also available for general use. This
reasoner supports rule-based inference over RDF graphs and provides forward
@@ -1417,7 +1444,7 @@ class B = cardinality(P,1)</pre>
The current release includes a starting set of primitives which are
sufficient
for the RDFS and OWL implementations but is easily extensible.</p>
<p>[<a href="#rules">rule index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk1290wzxhzdk1291rule-syntax-and-structure"><a
name="RULEsyntax"></a>Rule syntax and structure</h3>
+<h3 id="wzxhzdk1224wzxhzdk1225rule-syntax-and-structure"><a
name="RULEsyntax"></a>Rule syntax and structure</h3>
<p><p>A rule for the rule-based reasoner is defined by a Java <code><a
href="/documentation/javadoc/jena/com/hp/hpl/jena/reasoner/rulesys/Rule.html">Rule</a></code>
object with a list of body terms (premises), a list of head terms
(conclusions)
and an optional name and optional direction. Each term or <a
href="/documentation/javadoc/jena/com/hp/hpl/jena/reasoner/rulesys/ClauseEntry.html"><code>ClauseEntry</code></a>
@@ -1527,7 +1554,7 @@ a single extra rule is:
<p>[<a href="#rules">Rule index</a>] [<a href="#index">main index</a>]</p>
-<h3 id="wzxhzdk1469wzxhzdk1470forward-chaining-engine"><a
name="RULEforward"></a>Forward chaining engine</h3>
+<h3 id="wzxhzdk1403wzxhzdk1404forward-chaining-engine"><a
name="RULEforward"></a>Forward chaining engine</h3>
<p><p>If the rule reasoner is configured to run in forward mode then only the
forward
chaining engine will be used. The first time the inference Model is queried
(or when an explicit <code>prepare()</code> call is made, see <a
href="#processingControl">above</a>)
@@ -1566,7 +1593,7 @@ a single extra rule is:
done to the default RETE engine.</p></p>
<p>[<a href="#rules">Rule index</a>] [<a href="#index">main index</a>]</p>
-<h3 id="wzxhzdk1502wzxhzdk1503backward-chaining-engine"><a
name="RULEbackward"></a>Backward chaining engine</h3>
+<h3 id="wzxhzdk1436wzxhzdk1437backward-chaining-engine"><a
name="RULEbackward"></a>Backward chaining engine</h3>
<p><p>If the rule reasoner is run in backward chaining mode it uses a logic
programming
(LP) engine with a similar execution strategy to Prolog engines. When the
inference
Model is queried then the query is translated into a goal and the engine
attempts
@@ -1632,7 +1659,7 @@ triple(s1, p1, o1) :- triple(sb1, pb1, o
might be run in either backward or forward mode then they should be limited to
a single consequent each.
</p>
<p>[<a href="#rules">Rule index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk1566wzxhzdk1567hybrid-rule-engine"><a
name="RULEhybrid"></a>Hybrid rule engine</h3>
+<h3 id="wzxhzdk1500wzxhzdk1501hybrid-rule-engine"><a
name="RULEhybrid"></a>Hybrid rule engine</h3>
<p><p>The rule reasoner has the option of employing both of the individual
rule engines
in conjunction. When run in this <i>hybrid</i> mode the data flows look
something
like this: </p>
@@ -1673,7 +1700,7 @@ might be run in either backward or forwa
removing backward rules in response to the data changes.</p></p>
<p>[<a href="#rules">Rule index</a>] [<a href="#index">main index</a>]</p>
-<h3 id="wzxhzdk1598wzxhzdk1599genericrulereasoner-configuration"><a
name="RULEconfiguration"></a>GenericRuleReasoner configuration</h3>
+<h3 id="wzxhzdk1532wzxhzdk1533genericrulereasoner-configuration"><a
name="RULEconfiguration"></a>GenericRuleReasoner configuration</h3>
<p><p>As with the other reasoners there are a set of parameters, identified by
RDF
properties, to control behaviour of the <code>GenericRuleReasoner</code>.
These
parameters can be set using the <code>Reasoner.setParameter</code> call or
passed
@@ -1774,7 +1801,7 @@ Reasoner reasoner = new GenericRuleReaso
</tr>
</table>
<p>[<a href="#rules">Rule index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk1736wzxhzdk1737builtin-primitives"><a
name="RULEbuiltins"></a>Builtin primitives</h3>
+<h3 id="wzxhzdk1670wzxhzdk1671builtin-primitives"><a
name="RULEbuiltins"></a>Builtin primitives</h3>
<p><p>The procedural primitives which can be called by the rules are each
implemented
by a Java object stored in a registry. Additional primitives can be created
and registered - see below for more details.</p>
@@ -1991,7 +2018,7 @@ do not "pollute" the inference results.<
</tr>
</table>
<p>[<a href="#rules">Rule index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk1977wzxhzdk1978example"><a name="RULEexamples"></a>Example</h3>
+<h3 id="wzxhzdk1911wzxhzdk1912example"><a name="RULEexamples"></a>Example</h3>
<p><p>As a simple illustration suppose we wish to create a simple ontology
language
in which we can declare one property as being the concatenation of two others
and to build a rule reasoner to implement this.</p>
@@ -2084,7 +2111,7 @@ while (i.hasNext()) {
[ (?A ?P ?C) <- (?A ?P ?B), (?B ?P ?C) ]
] </pre>
<p>[<a href="#rules">rule index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk2054wzxhzdk2055combining-rdfsowl-with-custom-rules"><a
name="RDFSPlusRules"></a>Combining RDFS/OWL with custom rules</h3>
+<h3 id="wzxhzdk1988wzxhzdk1989combining-rdfsowl-with-custom-rules"><a
name="RDFSPlusRules"></a>Combining RDFS/OWL with custom rules</h3>
<p><p>Sometimes one wishes to write generic inference rules but combine them
with some RDFS or OWL infernece. With the current Jena architecture limited
forms of this
is possible but you need to be aware of the limitations.</p>
@@ -2112,36 +2139,43 @@ while (i.hasNext()) {
have finer grain control - all your inferences you want the RDFS/OWL rules to
see
should be forward, all the inferences which need all of the results of the
RDFS/OWL rules
should be backward. Note that the RDFS and OWL rulesets assume certain
settings
- for the GenericRuleReasoner so a typical configuration is:</p>
-<pre>
- Model data = FileManager.get().loadModel("file:data.n3");</p>
-<p>List rules = Rule.rulesFromURL("myrules.rules");</p>
-<p>GenericRuleReasoner reasoner = new GenericRuleReasoner(rules);
- reasoner.setOWLTranslation(true); // not needed in RDFS case
- reasoner.setTransitiveClosureCaching(true);</p>
-<p>InfModel inf = ModelFactory.createInfModel(reasoner, data);
-</pre>
+ for the GenericRuleReasoner so a typical configuration is:</p></p>
+<div class="codehilite"><pre><span class="n">Model</span> <span
class="n">data</span> <span class="p">=</span> <span
class="n">FileManager</span><span class="p">.</span><span
class="n">get</span><span class="p">().</span><span
class="n">loadModel</span><span class="p">(</span>"<span
class="n">file</span><span class="p">:</span><span class="n">data</span><span
class="p">.</span><span class="n">n3</span>"<span class="p">);</span>
+<span class="n">List</span> <span class="n">rules</span> <span
class="p">=</span> <span class="n">Rule</span><span class="p">.</span><span
class="n">rulesFromURL</span><span class="p">(</span>"<span
class="n">myrules</span><span class="p">.</span><span
class="n">rules</span>"<span class="p">);</span>
+
+<span class="n">GenericRuleReasoner</span> <span class="n">reasoner</span>
<span class="p">=</span> <span class="n">new</span> <span
class="n">GenericRuleReasoner</span><span class="p">(</span><span
class="n">rules</span><span class="p">);</span>
+<span class="n">reasoner</span><span class="p">.</span><span
class="n">setOWLTranslation</span><span class="p">(</span><span
class="n">true</span><span class="p">);</span> <span
class="o">//</span> <span class="n">not</span> <span class="n">needed</span>
<span class="n">in</span> <span class="n">RDFS</span> <span
class="k">case</span>
+<span class="n">reasoner</span><span class="p">.</span><span
class="n">setTransitiveClosureCaching</span><span class="p">(</span><span
class="n">true</span><span class="p">);</span>
+
+<span class="n">InfModel</span> <span class="nb">inf</span> <span
class="p">=</span> <span class="n">ModelFactory</span><span
class="p">.</span><span class="n">createInfModel</span><span
class="p">(</span><span class="n">reasoner</span><span class="p">,</span> <span
class="n">data</span><span class="p">);</span>
+</pre></div>
+
+
<p>Where the <code>myrules.rules</code> file will use <code>@include</code> to
include
one of the RDFS or OWL rule sets.</p>
+
<p>One useful variant on this option, at least in simple cases, is
to manually include a pure (non-hybrid) ruleset for the RDFS/OWL fragment
you want so that there is no layering problem. [The reason the default
rulesets use the hybrid mode is a performance tradeoff - trying to
balance the better performance of forward reasoning with the cost of
computing all possible answers when an application might only want a few.]</p>
+
<p>
A simple example of this is that the <em>interesting</em> bits of RDFS
can be captured by enabled TranstiveClosureCaching and including just the
four core rules:</p>
+
<pre>
[rdfs2: (?x ?p ?y), (?p rdfs:domain ?c) -> (?x rdf:type ?c)]
[rdfs3: (?x ?p ?y), (?p rdfs:range ?c) -> (?y rdf:type ?c)]
[rdfs6: (?a ?p ?b), (?p rdfs:subPropertyOf ?q) -> (?a ?q ?b)]
[rdfs9: (?x rdfs:subClassOf ?y), (?a rdf:type ?x) -> (?a rdf:type ?y)]
-</pre></p>
+</pre>
+
<p>[<a href="#rules">rule index</a>] [<a href="#index">main index</a>]</p>
-<h3 id="wzxhzdk2084wzxhzdk2085notes"><a name="RULEnotes"></a>Notes</h3>
+<h3 id="wzxhzdk1998wzxhzdk1999notes"><a name="RULEnotes"></a>Notes</h3>
<p><p>One final aspect of the general rule engine to mention is that of
validation
rules. We described earlier how reasoners can implement a
<code>validate</code>
call which returns a set of error reports and warnings about inconsistencies
@@ -2171,7 +2205,7 @@ while (i.hasNext()) {
<p>Future extensions will improve the formatting capabilities and flexibility
of this mechanism. </p>
<p>[<a href="#rules">Rule index</a>] [<a href="#index">main index</a>]</p></p>
-<h3 id="wzxhzdk2128wzxhzdk2129extensions"><a
name="RULEextensions"></a>Extensions</h3>
+<h3 id="wzxhzdk2042wzxhzdk2043extensions"><a
name="RULEextensions"></a>Extensions</h3>
<p><p>There are several places at which the rule system can be extended by
application
code.</p></p>
<h4 id="rule-syntax">Rule syntax</h4>
@@ -2203,7 +2237,7 @@ while (i.hasNext()) {
and the <a
href="/documentation/javadoc/jena/com/hp/hpl/jena/reasoner/rulesys/RulePreprocessHook.html"><code>RulePreprocessHook</code></a>
class for more details.</p>
<p>[<a href="#index">Index</a>]</p></p>
-<h2 id="wzxhzdk2180wzxhzdk2181extending-the-inference-support"><a
name="extensions"></a>Extending the inference support</h2>
+<h2 id="wzxhzdk2094wzxhzdk2095extending-the-inference-support"><a
name="extensions"></a>Extending the inference support</h2>
<p><p>Apart from the extension points in the rule reasoner discussed above,
the intention
is that it should be possible to plug external inference engines into Jena.
The core interfaces of <code>InfGraph</code> and <code>Reasoner</code> are
kept
@@ -2214,7 +2248,7 @@ while (i.hasNext()) {
freely available, reasoner to both validate the machinery and to provide an
example of how this extension can be done.</p>
<p>[<a href="#index">Index</a>]</p></p>
-<h2 id="wzxhzdk2196wzxhzdk2197futures"><a name="futures"></a>Futures</h2>
+<h2 id="wzxhzdk2110wzxhzdk2111futures"><a name="futures"></a>Futures</h2>
<p><p>Whilst we can make no firm commitments, at the time of writing we intend
to
continue work on the Jena reasoning support. The key activities on the
drawing
board are:</p>