Soprano  2.9.3
Public Slots | Public Member Functions | List of all members
Soprano::Inference::InferenceModel Class Reference

The Soprano Inference Model provides a simple forward chaining inference engine which uses the underlying parent model itself to store status information. More...

#include <Soprano/Inference/InferenceModel>

+ Inheritance diagram for Soprano::Inference::InferenceModel:

Public Slots

void performInference ()
 
void clearInference ()
 
void setCompressedSourceStatements (bool b)
 
void setOptimizedQueriesEnabled (bool b)
 

Public Member Functions

 InferenceModel (Model *parent)
 
 ~InferenceModel ()
 
Error::ErrorCode addStatement (const Statement &)
 
Error::ErrorCode removeStatement (const Statement &)
 
Error::ErrorCode removeAllStatements (const Statement &)
 
void addRule (const Rule &)
 
void setRules (const QList< Rule > &rules)
 
- Public Member Functions inherited from Soprano::FilterModel
virtual ~FilterModel ()
 
virtual void setParentModel (Model *model)
 
virtual ModelparentModel () const
 
Error::ErrorCode addStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
Error::ErrorCode removeStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
Error::ErrorCode removeAllStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
virtual StatementIterator listStatements (const Statement &partial) const
 
StatementIterator listStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
virtual NodeIterator listContexts () const
 
virtual QueryResultIterator executeQuery (const QString &query, Query::QueryLanguage language, const QString &userQueryLanguage=QString()) const
 
virtual bool containsStatement (const Statement &statement) const
 
bool containsStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
virtual bool containsAnyStatement (const Statement &statement) const
 
bool containsAnyStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
virtual bool isEmpty () const
 
virtual int statementCount () const
 
virtual Error::ErrorCode write (QTextStream &os) const
 
virtual Node createBlankNode ()
 
- Public Member Functions inherited from Soprano::Model
virtual ~Model ()
 
Error::ErrorCode addStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
Error::ErrorCode addStatements (const QList< Statement > &statements)
 
Error::ErrorCode removeStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
Error::ErrorCode removeAllStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
Error::ErrorCode removeStatements (const QList< Statement > &statements)
 
Error::ErrorCode removeContext (const Node &)
 
Error::ErrorCode removeAllStatements ()
 
StatementIterator listStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
StatementIterator listStatements () const
 
StatementIterator listStatementsInContext (const Node &context) const
 
bool containsAnyStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
bool containsStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
bool containsContext (const Node &context) const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent=0)
 
 blockSignals (bool block)
 
 childEvent (QChildEvent *event)
 
 children ()
 
 connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type=Qt::AutoCompatConnection)
 
 connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type=Qt::AutoCompatConnection)
 
 connectNotify (const char *signal)
 
 customEvent (QEvent *event)
 
 deleteLater ()
 
 destroyed (QObject *obj=0)
 
 disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
 disconnect (const char *signal=0, const QObject *receiver=0, const char *method=0)
 
 disconnect (const QObject *receiver, const char *method=0)
 
 disconnectNotify (const char *signal)
 
 dumpObjectInfo ()
 
 dumpObjectTree ()
 
 dynamicPropertyNames ()
 
 event (QEvent *e)
 
 eventFilter (QObject *watched, QEvent *event)
 
 findChild (const QString &name=QString()
 
 findChildren (const QString &name=QString()
 
 findChildren (const QRegExp &regExp)
 
 inherits (const char *className)
 
 installEventFilter (QObject *filterObj)
 
 isWidgetType ()
 
 killTimer (int id)
 
 metaObject ()
 
 moveToThread (QThread *targetThread)
 
 parent ()
 
 property (const char *name)
 
 receivers (const char *signal)
 
 removeEventFilter (QObject *obj)
 
 sender ()
 
 setParent (QObject *parent)
 
 setProperty (const char *name, const QVariant &value)
 
 signalsBlocked ()
 
 startTimer (int interval)
 
 thread ()
 
 timerEvent (QTimerEvent *event)
 
 tr (const char *sourceText, const char *comment=0, int n=-1)
 
 trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
 staticMetaObject
 
 QObject (QObject *parent, const char *name)
 
 checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
 child (const char *objName, const char *inheritsClass=0, bool recursiveSearch=true)
 
 className ()
 
 insertChild (QObject *object)
 
 isA (const char *className)
 
 name ()
 
 name (const char *defaultName)
 
 normalizeSignalSlot (const char *signalSlot)
 
 removeChild (QObject *object)
 
 setName (const char *name)
 
- Public Member Functions inherited from Soprano::Error::ErrorCache
virtual ~ErrorCache ()
 
virtual Error lastError () const
 

Additional Inherited Members

- Signals inherited from Soprano::Model
void statementsAdded ()
 
void statementsRemoved ()
 
void statementAdded (const Soprano::Statement &statement)
 
void statementRemoved (const Soprano::Statement &statement)
 
- Protected Member Functions inherited from Soprano::FilterModel
 FilterModel ()
 
 FilterModel (Model *parent)
 
virtual void parentStatementsAdded ()
 
virtual void parentStatementsRemoved ()
 
virtual void parentStatementAdded (const Statement &)
 
virtual void parentStatementRemoved (const Statement &)
 

Detailed Description

The Soprano Inference Model provides a simple forward chaining inference engine which uses the underlying parent model itself to store status information.

The InferenceModel does perfect inference which means that removing of statements is supported and results in a perfect update of the infered statements. There is only one exception: If a model contains two statements in different named graphs that both have the same subject, predicate, and object and trigger one rule then if one of these statements is removed the infered statements are removed, too, although the second statement would still make the infered one valid. This situation gets resolved once the same rule is triggered again by some other added statement or performInference gets called.

The inference is performed based on rules which are stored in Rule instances. Rules can be created manually or parsed using a RuleParser.

The inference engine works roughly as follows:

Whenever a new statement is added it is compared to each rule to check if it could trigger this rule. Then if it could trigger a rule this rule is applied to the whole model.

If a rule produces a new infered statement the following data is created:

Thus, when removing a statement it can easily be checked if this statement had been used to infer another one by querying all named graphs that have this statement as a source statement.

Author
Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org

Definition at line 71 of file inferencemodel.h.

Constructor & Destructor Documentation

Soprano::Inference::InferenceModel::InferenceModel ( Model parent)
Soprano::Inference::InferenceModel::~InferenceModel ( )

Member Function Documentation

Error::ErrorCode Soprano::Inference::InferenceModel::addStatement ( const Statement )
virtual

Add a new statement to the model. Inferencing will be done directly. Inferenced statements are stored in additional named graphs.

Reimplemented from Soprano::FilterModel.

Error::ErrorCode Soprano::Inference::InferenceModel::removeStatement ( const Statement )
virtual

Remove one statement from the model.

Reimplemented from Soprano::FilterModel.

Error::ErrorCode Soprano::Inference::InferenceModel::removeAllStatements ( const Statement )
virtual

Remove statements from the model.

Reimplemented from Soprano::FilterModel.

void Soprano::Inference::InferenceModel::addRule ( const Rule )

Add an inference rule to the set of rules. This method will not trigger any inference action. If inference is necessary call performInference() after adding the new rules.

void Soprano::Inference::InferenceModel::setRules ( const QList< Rule > &  rules)

Set the inference rules to be used. This method will not trigger any inference action. If inference is necessary call performInference() after adding the new rules.

void Soprano::Inference::InferenceModel::performInference ( )
slot

Normally inferencing is done once new statements are added to the model or statements are removed. This method performs inferencing on the whole model. It is useful for initializing a model that already contains statements or update the model if it has been modified bypassing this filter model.

Tha latter can easily be done by connecting the Model::statementsAdded and Model::statementsRemoved signals to this slot.

void Soprano::Inference::InferenceModel::clearInference ( )
slot

Removes all statements infered by this model. This can be useful if the parent model has been changed without informing the inference model and statements have been removed.

void Soprano::Inference::InferenceModel::setCompressedSourceStatements ( bool  b)
slot

If compressed statements are enabled source statements are stored compressed in one literal value. Otherwise source statements are stored using rdf:subject, rdf:predicate, rdf:object, and sil:context. Non-compressed statements are much cleaner from an ontology design point of view while compressed statements take much less space.

By default comressed source statements are enabled.

This method exists mainly for historical reasons and there normally is no need to call it. Compressed statements should work well for most users.

Parameters
bIf true compressed source statements are enabled (the default).
void Soprano::Inference::InferenceModel::setOptimizedQueriesEnabled ( bool  b)
slot

If the storage backend supports joined SPARQL queries via UNION it makes sense to enable this.

Parameters
bIf true InferenceModel will use optimized queries for the inference during addStatement. This will speed up the process quite a lot as matching rules are only applied to the new statement. This flag has no influcence on performInference() though.

The default is to disable the optimized queries since the default soprano redland backend does not support UNION.


The documentation for this class was generated from the following file: