# class Rule

###

Module | soprano
Namespace | Soprano::Inference
Class | Rule
Inherits |

\class Rule inferencerule.h Soprano/Inference/Rule

A rule used by the InferenceModel to generate inferenced statements.

Rules can be created manually by adding preconditions and the effect via addPrecondition() and setEffect() or from a rules file through the RuleParser.

Author Sebastian Trueg <trueg@kde.org>

### methods

- Rule ( )

  returns ctor

- Rule (other)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  other | Soprano.Inference.Rule |

- addPrecondition (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | Soprano.Inference.StatementPattern |

- bindEffect (bindings)

  returns Soprano.Statement

  Argument | Type | Default
  --- | --- | ---
  bindings | Soprano.BindingSet |

  Bind the rule's effect to a set of bindings as reveived from a query. If the bindings do not contain all variables the bound statement is used as backup.

  bindings - The bindings to apply to this rule.

  Returns The statement infered by this rule under the application of bindings.

  See also bindToStatement, bindPreconditions

- bindPreconditions (bindings)

  returns QList<Soprano::Statement>

  Argument | Type | Default
  --- | --- | ---
  bindings | Soprano.BindingSet |

  Bind the rule's preconditions to a set of bindings as reveived from a query. If the bindings do not contain all variables the bound statement is used as backup.

  bindings - The bindings to apply to this rule.

  Returns The statements that have to be valid in order for this rule to infer the statement returned by bindEffect under the same bindings.

  See also bindToStatement, bindEffect

- bindToStatement (statement)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  statement | Soprano.Statement |

  Bind this rule to a specific Statement.

  The purpose of this method is to allow retricting the application of a rule to one statement, i.e. a newly added one.

  statement - The Statement to bind this rule to.

  See also createSparqlQuery, bindEffect, bindPreconditions

- createSparqlQuery (bindVariables)

  returns QString

  Argument | Type | Default
  --- | --- | ---
  bindVariables | bool | 0

  Create a SPARQL query that retrieves all resources matching this rule.

  bindVariables - If true and a valid binding statement is set the query will be bound to this statement resulting in a UNION query of all possible bindings.

  See also bindToStatement

- effect ( )

  returns Soprano.Inference.StatementPattern

  The effect of a rule is a pattern that repeats variables from the preconditions and thus, identifies the statements that are to be infered from the preconditions.

- match (statement)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  statement | Soprano.Statement |

  Check if a statement matches any of the statement patterns in this rule. Returns true if statement matches any of the patterns, false otherwise.

- preconditions ( )

  returns QList<Soprano::Inference::StatementPattern>

  The list of preconditions for the rule. Each condition is a StatementPattern which can contain variables. These variables are identified by their name and matched accordingly.

- setEffect (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | Soprano.Inference.StatementPattern |