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

List:       kde-commits
Subject:    KDE/kdebase/runtime/nepomuk/strigibackend
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-03-08 11:50:15
Message-ID: 1268049015.824829.12703.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1100708 by trueg:

* Added support for nie:isPartOf as used by recent Strigi trunk for video files.
  This way backlinks are properly handled.
* Store extracted metadata in nrl:DiscardableInstanceBase graphs.


 M  +5 -0      CMakeLists.txt  
 M  +45 -30    nepomukindexwriter.cpp  


--- trunk/KDE/kdebase/runtime/nepomuk/strigibackend/CMakeLists.txt #1100707:1100708
@@ -15,6 +15,11 @@
 )
 
 soprano_add_ontology(strigi_nepomuk_indexer_SRCS
+  ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nrl.trig
+  "NRL"
+  "Nepomuk::Vocabulary"
+  "trig")
+soprano_add_ontology(strigi_nepomuk_indexer_SRCS
   ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nfo.trig
   "NFO"
   "Nepomuk::Vocabulary"
--- trunk/KDE/kdebase/runtime/nepomuk/strigibackend/nepomukindexwriter.cpp \
#1100707:1100708 @@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
+  Copyright (C) 2007-2010 Sebastian Trueg <trueg@kde.org>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
@@ -21,6 +21,7 @@
 #include "util.h"
 #include "nfo.h"
 #include "nie.h"
+#include "nrl.h"
 
 #include <Soprano/Soprano>
 #include <Soprano/Vocabulary/RDF>
@@ -128,11 +129,14 @@
     class FileMetaData
     {
     public:
-        FileMetaData( const KUrl& url );
+        FileMetaData( const Strigi::AnalysisResult* idx );
 
         /// stores basic data including the nie:url and the nrl:GraphMetadata in \p \
model  void storeBasicData( Soprano::Model* model );
 
+        /// map a blank node to a resource
+        QUrl mapNode( const std::string& s );
+
         /// The resource URI
         QUrl resourceUri;
 
@@ -148,8 +152,12 @@
         /// a buffer for all plain-text content generated by strigi
         std::string content;
 
+    private:
+        /// The Strigi result
+        const Strigi::AnalysisResult* m_analysisResult;
+
         /// mapping from blank nodes used in addTriplet to our urns
-        QMap<std::string, QUrl> blankNodeMap;
+        QMap<std::string, QUrl> m_blankNodeMap;
     };
 
     class RegisteredFieldData
@@ -171,10 +179,12 @@
         bool isRdfType;
     };
 
-    FileMetaData::FileMetaData( const KUrl& url )
-        : fileUrl( url ),
-          fileInfo( url.toLocalFile() )
+    FileMetaData::FileMetaData( const Strigi::AnalysisResult* idx )
+        : m_analysisResult( idx )
     {
+        fileUrl = createFileUrl( idx );
+        fileInfo = fileUrl.toLocalFile();
+
         // determine the resource URI by using Nepomuk::Resource's power
         // this will automatically find previous uses of the file in question
         // with backwards compatibility
@@ -184,6 +194,27 @@
         context = Nepomuk::ResourceManager::instance()->generateUniqueUri( "ctx" );
     }
 
+    QUrl FileMetaData::mapNode( const std::string& s )
+    {
+        if ( s[0] == ':' ) {
+            if( m_blankNodeMap.contains( s ) ) {
+                return m_blankNodeMap[s];
+            }
+            else {
+                QUrl urn = Nepomuk::ResourceManager::instance()->generateUniqueUri( \
QString() ); +                m_blankNodeMap.insert( s, urn );
+                return urn;
+            }
+        }
+        // special case to properly handle nie:isPartOf relations created for \
containers +        else if ( s == m_analysisResult->path() ) {
+            return resourceUri;
+        }
+        else {
+            return QUrl::fromEncoded( s.c_str() );
+        }
+    }
+
     void FileMetaData::storeBasicData( Soprano::Model* model )
     {
         model->addStatement( resourceUri, Nepomuk::Vocabulary::NIE::url(), fileUrl, \
context ); @@ -207,7 +238,7 @@
         QUrl metaDataContext = \
Nepomuk::ResourceManager::instance()->generateUniqueUri( "ctx" );  \
model->addStatement( context,  Vocabulary::RDF::type(),
-                             Vocabulary::NRL::InstanceBase(),
+                             Nepomuk::Vocabulary::NRL::DiscardableInstanceBase(),
                              metaDataContext );
         model->addStatement( context,
                              Vocabulary::NAO::created(),
@@ -219,10 +250,10 @@
                              metaDataContext );
         model->addStatement( metaDataContext,
                              Vocabulary::RDF::type(),
-                             Vocabulary::NRL::GraphMetadata(),
+                             Nepomuk::Vocabulary::NRL::GraphMetadata(),
                              metaDataContext );
         model->addStatement( metaDataContext,
-                             Vocabulary::NRL::coreGraphMetadataFor(),
+                             Nepomuk::Vocabulary::NRL::coreGraphMetadataFor(),
                              context,
                              metaDataContext );
     }
@@ -273,22 +304,6 @@
         }
     }
 
-    QUrl mapNode( FileMetaData* fmd, const std::string& s ) {
-        if ( s[0] == ':' ) {
-            if( fmd->blankNodeMap.contains( s ) ) {
-                return fmd->blankNodeMap[s];
-            }
-            else {
-                QUrl urn = Nepomuk::ResourceManager::instance()->generateUniqueUri( \
                QString() );
-                fmd->blankNodeMap.insert( s, urn );
-                return urn;
-            }
-        }
-        else {
-            return QUrl::fromEncoded( s.c_str() );
-        }
-    }
-
     Soprano::Model* repository;
 
     //
@@ -356,7 +371,7 @@
     }
 
     // create the file data used during the analysis
-    FileMetaData* data = new FileMetaData( createFileUrl( idx ) );
+    FileMetaData* data = new FileMetaData( idx );
 
     // remove previously indexed data
     removeIndexedData( data->resourceUri, true );
@@ -450,7 +465,7 @@
             if ( value[0] == ':' ) {
                 Nepomuk::Types::Property property( rfd->property );
                 if ( property.range().isValid() ) {
-                    statement.setObject( d->mapNode( md, value ) );
+                    statement.setObject( md->mapNode( value ) );
                 }
             }
         }
@@ -546,11 +561,11 @@
 
     FileMetaData* md = fileDataForResult( d->currentResultStack.top() );
 
-    QUrl subject = d->mapNode( md, s );
-    Nepomuk::Types::Property property( d->mapNode( md, p ) );
+    QUrl subject = md->mapNode( s );
+    Nepomuk::Types::Property property( md->mapNode( p ) );
     Soprano::Node object;
     if ( property.range().isValid() )
-        object = d->mapNode( md, o );
+        object = md->mapNode( o );
     else
         object = Soprano::LiteralValue::fromString( QString::fromUtf8( o.c_str() ), \
property.literalRangeType().dataTypeUri() );  


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

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