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

List:       kde-commits
Subject:    playground/base/nepomuk-kde/annotation/plugins/dbpedia
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2011-02-24 16:26:12
Message-ID: 20110224162612.5D9A0AC8C0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1222520 by trueg:

Fixed DBPedia lookup - now we only need to do something with the results

 M  +20 -6     dbpediaannotationplugin.cpp  
 M  +1 -1      dbpediaannotationplugin.desktop  


--- trunk/playground/base/nepomuk-kde/annotation/plugins/dbpedia/dbpediaannotationplugin.cpp \
#1222519:1222520 @@ -32,13 +32,20 @@
 
 #include <KDebug>
 
+namespace {
+QString normalizedLanguageCode(const QString& language) {
+    QString lang, country, modifier, charset;
+    KGlobal::locale()->splitLocale(language, lang, country, modifier, charset);
+    return lang;
+}
+}
 
 Nepomuk::DbpediaAnnotationPlugin::DbpediaAnnotationPlugin( QObject* parent, const \
QVariantList& )  : AnnotationPlugin( parent ),
       m_currentResult( 0 )
 {
     kDebug();
-    m_dbpediaModel = new Soprano::Client::SparqlModel( "http://dbpedia.org/sparql" \
); +    m_dbpediaModel = new Soprano::Client::SparqlModel( "DBpedia.org" );
 }
 
 
@@ -67,14 +74,18 @@
     if ( m_currentResult )
         m_currentResult->disconnect( this );
 
-    QString query = QString( "prefix rdfs:<%1> "
+    QString query = QString("prefix rdfs:%1 "
                              "select * where { "
                              "?r a ?type . "
                              "?r rdfs:label ?label . "
-                             "OPTIONAL { ?r rdfs:comment ?comment . } . "
-                             "?label bif:contains '%2' . }" )
-                    .arg( Soprano::Node::resourceToN3( \
                Soprano::Vocabulary::RDFS::rdfsNamespace() ) )
-                    .arg( text );
+                            "?r rdfs:comment ?comment . "
+                            "FILTER(lang(?label)='%2') . "
+                            "FILTER(lang(?comment)='%2') . "
+                            "?label bif:contains \"'%3'\" . "
+                            "} LIMIT 10" )
+                    .arg(Soprano::Node::resourceToN3( \
Soprano::Vocabulary::RDFS::rdfsNamespace() ), +                         \
normalizedLanguageCode(KGlobal::locale()->language()), +                         text \
);  kDebug() << query;
     m_currentResult = m_dbpediaModel->executeQueryAsync( query );
 
@@ -85,10 +96,13 @@
 
 void Nepomuk::DbpediaAnnotationPlugin::slotQueryFinished( \
Soprano::Util::AsyncResult* result )  {
+    kDebug() << result->lastError();
+
     Soprano::QueryResultIterator it = result->queryResultIterator();
     while ( it.next() ) {
         kDebug() << it.current();
     }
+    emitFinished();
 }
 
 NEPOMUK_EXPORT_ANNOTATION_PLUGIN( Nepomuk::DbpediaAnnotationPlugin, \
                "nepomuk_dbpediaannotationplugin" )
--- trunk/playground/base/nepomuk-kde/annotation/plugins/dbpedia/dbpediaannotationplugin.desktop \
#1222519:1222520 @@ -30,7 +30,7 @@
 Comment[x-test]=xxNepomuk Annotation Plugin which searches DBpedia for related \
resourcesxx  X-KDE-ServiceTypes=Nepomuk/AnnotationPlugin
 Type=Service
-X-KDE-Library=nepomuk_dbpediannotationplugin
+X-KDE-Library=nepomuk_dbpediaannotationplugin
 
 # FIXME
 X-Nepomuk-ResourceTypes=*


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

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