[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdesupport/soprano/soprano/inference
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2008-07-09 8:58:17
Message-ID: 1215593897.678195.10472.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 829832 by trueg:

Never try to insert invalid statements to avoid infinite loops

 M  +38 -33    inferencemodel.cpp  


--- trunk/kdesupport/soprano/soprano/inference/inferencemodel.cpp #829831:829832
@@ -349,48 +349,53 @@
         Statement inferedStatement = rule.bindEffect( *it );
 
         // we only add infered statements if they are not already present (in any \
                named graph, aka. context)
-        if ( !parentModel()->containsAnyStatement( inferedStatement ) ) {
-            ++inferedStatementsCount;
+        if ( inferedStatement.isValid() ) {
+            if( !parentModel()->containsAnyStatement( inferedStatement ) ) {
+                ++inferedStatementsCount;
 
-            QUrl inferenceGraphUrl = createRandomUri();
+                QUrl inferenceGraphUrl = createRandomUri();
 
-            // write the actual infered statement
-            inferedStatement.setContext( inferenceGraphUrl );
-            parentModel()->addStatement( inferedStatement );
+                // write the actual infered statement
+                inferedStatement.setContext( inferenceGraphUrl );
+                parentModel()->addStatement( inferedStatement );
 
-            // write the metadata about the new inference graph into the inference \
                metadata graph
-            // type of the new graph is sil:InferenceGraph
-            parentModel()->addStatement( Statement( inferenceGraphUrl,
-                                                    Vocabulary::RDF::type(),
-                                                    \
                Vocabulary::SIL::InferenceGraph(),
-                                                    \
Vocabulary::SIL::InferenceMetaData() ) ); +                // write the metadata \
about the new inference graph into the inference metadata graph +                // \
type of the new graph is sil:InferenceGraph +                \
parentModel()->addStatement( Statement( inferenceGraphUrl, +                          \
Vocabulary::RDF::type(), +                                                        \
Vocabulary::SIL::InferenceGraph(), +                                                  \
Vocabulary::SIL::InferenceMetaData() ) );  
-            // add sourceStatements
-            QList<Statement> sourceStatements = rule.bindPreconditions( *it );
-            for ( QList<Statement>::const_iterator it = \
                sourceStatements.constBegin();
-                  it != sourceStatements.constEnd(); ++it ) {
-                const Statement& sourceStatement = *it;
+                // add sourceStatements
+                QList<Statement> sourceStatements = rule.bindPreconditions( *it );
+                for ( QList<Statement>::const_iterator it = \
sourceStatements.constBegin(); +                      it != \
sourceStatements.constEnd(); ++it ) { +                    const Statement& \
sourceStatement = *it;  
-                if ( d->compressedStatements ) {
-                    // remember the statement through a checksum (well, not really a \
                checksum for now ;)
-                    parentModel()->addStatement( Statement( inferenceGraphUrl,
-                                                            \
                Vocabulary::SIL::sourceStatement(),
-                                                            compressStatement( \
                sourceStatement ),
-                                                            \
Vocabulary::SIL::InferenceMetaData() ) ); +                    if ( \
d->compressedStatements ) { +                        // remember the statement \
through a checksum (well, not really a checksum for now ;) +                        \
parentModel()->addStatement( Statement( inferenceGraphUrl, +                          \
Vocabulary::SIL::sourceStatement(), +                                                 \
compressStatement( sourceStatement ), +                                               \
Vocabulary::SIL::InferenceMetaData() ) ); +                    }
+                    else {
+                        // remember the source statement as a source for our graph
+                        parentModel()->addStatement( Statement( inferenceGraphUrl,
+                                                                \
Vocabulary::SIL::sourceStatement(), +                                                 \
storeUncompressedSourceStatement( sourceStatement ), +                                \
Vocabulary::SIL::InferenceMetaData() ) ); +                    }
                 }
-                else {
-                    // remember the source statement as a source for our graph
-                    parentModel()->addStatement( Statement( inferenceGraphUrl,
-                                                            \
                Vocabulary::SIL::sourceStatement(),
-                                                            \
                storeUncompressedSourceStatement( sourceStatement ),
-                                                            \
Vocabulary::SIL::InferenceMetaData() ) ); +
+                if ( recurse ) {
+                    inferedStatementsCount += inferStatement( inferedStatement, true \
);  }
             }
-
-            if ( recurse ) {
-                inferedStatementsCount += inferStatement( inferedStatement, true );
-            }
         }
+        else {
+            qDebug() << "Inferred statement is invalid (this is no error):" << \
inferedStatement; +        }
     }
 
     return inferedStatementsCount;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic