Soprano 2.9.4
|
A rule used by the InferenceModel to generate inferenced statements. More...
#include <Soprano/Inference/Rule>
Public Member Functions | |
Rule () | |
Rule (const Rule &other) | |
~Rule () | |
Rule & | operator= (const Rule &other) |
QList< StatementPattern > | preconditions () const |
void | addPrecondition (const StatementPattern &) |
StatementPattern | effect () const |
void | setEffect (const StatementPattern &) |
bool | match (const Statement &statement) const |
void | bindToStatement (const Statement &statement) |
Statement | boundToStatement () const |
QString | createSparqlQuery (bool bindVariables=false) const |
Statement | bindEffect (const BindingSet &bindings) const |
QList< Statement > | bindPreconditions (const BindingSet &bindings) const |
bool | isValid () const |
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.
Definition at line 49 of file inferencerule.h.
Soprano::Inference::Rule::Rule | ( | ) |
Constructs an invalid rule
Soprano::Inference::Rule::Rule | ( | const Rule & | other | ) |
Copy constructor. Creates a shallow copy of other
.
Soprano::Inference::Rule::~Rule | ( | ) |
Destructor
Assignment operator. Creates a shallow copy of other
.
QList< StatementPattern > Soprano::Inference::Rule::preconditions | ( | ) | const |
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.
void Soprano::Inference::Rule::addPrecondition | ( | const StatementPattern & | ) |
Add a precondition
StatementPattern Soprano::Inference::Rule::effect | ( | ) | const |
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.
void Soprano::Inference::Rule::setEffect | ( | const StatementPattern & | ) |
Set the effect of the rule.
bool Soprano::Inference::Rule::match | ( | const Statement & | statement | ) | const |
Check if a statement matches any of the statement patterns in this rule.
void Soprano::Inference::Rule::bindToStatement | ( | const Statement & | 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. |
Statement Soprano::Inference::Rule::boundToStatement | ( | ) | const |
QString Soprano::Inference::Rule::createSparqlQuery | ( | bool | bindVariables = false | ) | const |
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. |
Statement Soprano::Inference::Rule::bindEffect | ( | const BindingSet & | bindings | ) | const |
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. |
QList< Statement > Soprano::Inference::Rule::bindPreconditions | ( | const BindingSet & | bindings | ) | const |
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. |
bool Soprano::Inference::Rule::isValid | ( | ) | const |
Check if a rule is valid.
true
if the rule is valid and can be used with the InferenceModel, false
otherwise.