APR
29
2008

Nepomuk Virtual Folders - The Next Level

Well, maybe "The Next Level" is overstating it but I improved the query API a lot. Not only can we now properly handle all sorts of literal comparisons but we can also use plain SPARQL queries. The latter allow some nice stuff like "Recent Files".

For anyone interested the "Recent Files" virtual folder is coded using the folloing SPARQL query:

select ?r where { 
    ?r a <http://freedesktop.org/standards/xesam/1.0/core#File> . 
    ?r <http://freedesktop.org/standards/xesam/1.0/core#sourceModified> ?date . 
} ORDER BY DESC(?date) LIMIT 10

A very simple query that just selects the 10 most recent files.

Also nice are the folders listing all files modified today or yesterday. Anyway, time for a little screenshot and for me to code some query creation GUI (and maybe nested virtual folders).

[image:3442 size=preview]

Comments

That's really nice.

I see you have these searches stored somewhere, since they are displayed in nepomuksearch:/

Can we, for example, take those searches and make some new ones? Keeping the SQL-like theme:

select ?r
from {
    "nepomuksearch:/All Music Files/"
}
GROUP BY http://some/Musical/DTD#genre .

PS: have no idea how to write SPARQL, gotta learn that.


By renrutal at Tue, 04/29/2008 - 23:38

It is not that easy. You cannot group stuff using SPARQL that way. You would have to do that in a client. As I mentioned in my previous blog I think it would be best to hide the nepomuksearch:/ protocol from the user. Thus, a music application would just create one virtual folder for each genre. Something like this:

foreach( const QString& genre, genres ) {
   listFolder( "nepomuksearch:/type:Music AND genre:" + genre );
}

(BTW: You can also enter this directly in Dolphin or Konqueror as presented in my last blog.)

This is the simplest way. It would be slightly faster when using the query API which is still in playground:

foreach( const QString& genre, genres ) {
   Term musicTerm( Soprano::Vocabulary::RDF::type(), Soprano::Vocabulary::Xesam::Music() );
   Term genreTerm( Soprano::Vocabulary::Xesam::genre(), genre );
   Term andTerm;
   andTerm.setType( Term::AndTerm );
   andTerm.addSubTerm( musicTerm );
   andTerm.addSubTerm( genreTerm );
   createVirtualFolder( Query( andTerm ) );
}

As you can see there is no need for an advanced SPARQL query to group files by genre. All you need it a basic virtual folder (I still need to create a GUI that allows to put together these queries instead of just inserting them).

Of course one thing still missing for this to work: Strigi does not extract the genre from mp3 files yet. :(


By Sebastian Trüg at Wed, 04/30/2008 - 06:18