org.topbraid.spin.inference
Class SPINInferences

java.lang.Object
  extended by org.topbraid.spin.inference.SPINInferences

public class SPINInferences
extends java.lang.Object

A service to execute inference rules based on the spin:rule property.

Author:
Holger Knublauch

Constructor Summary
SPINInferences()
           
 
Method Summary
static int run(Model queryModel, Model newTriples, java.util.Map<Resource,java.util.List<QueryWrapper>> class2Query, java.util.Map<QueryWrapper,java.util.Map<java.lang.String,RDFNode>> templateBindings, SPINExplanations explanations, java.util.List<SPINStatistics> statistics, boolean singlePass, Property rulePredicate, ProgressMonitor monitor)
          Iterates over a provided collection of SPIN rules and adds all constructed triples to a given Model (newTriples) until no further changes have been made within one iteration.
static int run(Model queryModel, Model newTriples, SPINExplanations explanations, java.util.List<SPINStatistics> statistics, boolean singlePass, ProgressMonitor monitor)
          See the other run method for help - this is using spin:rule as rulePredicate.
static int run(Model queryModel, Property rulePredicate, Model newTriples, SPINExplanations explanations, java.util.List<SPINStatistics> statistics, boolean singlePass, ProgressMonitor monitor)
          Iterates over all SPIN rules in a (query) Model and adds all constructed triples to a given Model (newTriples) until no further changes have been made within one iteration.
static boolean runQueryOnInstance(Query arq, Model queryModel, Model newTriples, Resource instance, boolean checkContains, java.util.Map<java.lang.String,RDFNode> initialBindings)
          Runs a given Jena Query on a given instance and adds the inferred triples to a given Model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SPINInferences

public SPINInferences()
Method Detail

run

public static int run(Model queryModel,
                      Model newTriples,
                      SPINExplanations explanations,
                      java.util.List<SPINStatistics> statistics,
                      boolean singlePass,
                      ProgressMonitor monitor)
See the other run method for help - this is using spin:rule as rulePredicate.

Parameters:
queryModel - the Model to query
newTriples - the Model to add the new triples to
explanations - an optional object to write explanations to
statistics - optional list to add statistics about which queries were slow
singlePass - true to just do a single pass (don't iterate)
monitor - an optional ProgressMonitor
Returns:
the number of iterations (1 with singlePass)
See Also:
run(Model, Property, Model, SPINExplanations, List, boolean, ProgressMonitor)

run

public static int run(Model queryModel,
                      Property rulePredicate,
                      Model newTriples,
                      SPINExplanations explanations,
                      java.util.List<SPINStatistics> statistics,
                      boolean singlePass,
                      ProgressMonitor monitor)
Iterates over all SPIN rules in a (query) Model and adds all constructed triples to a given Model (newTriples) until no further changes have been made within one iteration. Note that in order to iterate more than single pass, the newTriples Model must be a sub-model of the queryModel (which likely has to be an OntModel). The supplied rulePredicate is usually spin:rule, but can also be a sub- property of spin:rule to exercise finer control over which rules to fire.

Parameters:
queryModel - the Model to query
rulePredicate - the rule predicate (spin:rule or a sub-property thereof)
newTriples - the Model to add the new triples to
explanations - an optional object to write explanations to
statistics - optional list to add statistics about which queries were slow
singlePass - true to just do a single pass (don't iterate)
monitor - an optional ProgressMonitor
Returns:
the number of iterations (1 with singlePass)

run

public static int run(Model queryModel,
                      Model newTriples,
                      java.util.Map<Resource,java.util.List<QueryWrapper>> class2Query,
                      java.util.Map<QueryWrapper,java.util.Map<java.lang.String,RDFNode>> templateBindings,
                      SPINExplanations explanations,
                      java.util.List<SPINStatistics> statistics,
                      boolean singlePass,
                      Property rulePredicate,
                      ProgressMonitor monitor)
Iterates over a provided collection of SPIN rules and adds all constructed triples to a given Model (newTriples) until no further changes have been made within one iteration. Note that in order to iterate more than single pass, the newTriples Model must be a sub-model of the queryModel (which likely has to be an OntModel).

Parameters:
queryModel - the Model to query
newTriples - the Model to add the new triples to
class2Query - the map of queries to run (see SPINQueryFinder)
templateBindings - initial template bindings (see SPINQueryFinder)
explanations - an optional object to write explanations to
statistics - optional list to add statistics about which queries were slow
singlePass - true to just do a single pass (don't iterate)
rulePredicate - the predicate used (e.g. spin:rule)
monitor - an optional ProgressMonitor
Returns:
the number of iterations (1 with singlePass)

runQueryOnInstance

public static boolean runQueryOnInstance(Query arq,
                                         Model queryModel,
                                         Model newTriples,
                                         Resource instance,
                                         boolean checkContains,
                                         java.util.Map<java.lang.String,RDFNode> initialBindings)
Runs a given Jena Query on a given instance and adds the inferred triples to a given Model.

Parameters:
arq - the CONSTRUCT query to execute
queryModel - the query Model
newTriples - the Model to write the triples to
instance - the instance to run the inferences on
checkContains - true to only call add if a Triple wasn't there yet
initialBindings - the initial bindings for arq or null
Returns:
true if changes were done (only meaningful if checkContains == true)