Home > semantic, technology > Nepomuk filters in KDE Dolphin

Nepomuk filters in KDE Dolphin

February 2, 2014

Finally worked this out : how to use sparql queries against nepomuk to give a file list.

In the “places” tab of Dolphin you will see “Search For” section on the left hand side, with items like Documents, Images, Audio Files. Each of these contains a simple search query for Nepomuk. What do you do if you want something more complicated – a file type or file name regexp ? The former would cover not just file extensions, but anything that nepomuk regards as a file that “is a” something – eg “is a” archive type. The later needs to look at the filename label and filter.

After much messing about, trying to find the nepomuk log[1], looking at the ontology in Protege etc heres what I came up with. For each expression you want to use, right click on “Search For” and choose “add entry”. Now give your expression a name, then in the Location field add the sparql query, using the nepomuk query protocol prefix. For example –

Search for filenames that contain the word “dog” – in the Location field add the expression : nepomuksearch:/?sparql=select ?r where {?r nfo:fileName ?fname . ?fname bif:contains 'dog' . }

Search for Archive file types – in the Location field add the expression : nepomuksearch:/?sparql=select ?r where { ?r a nfo:Archive}

Search for files ending with “pdf” – in the Location field add the expression : nepomuksearch:/?sparql=select ?r where {?r nfo:fileName ?fname . FILTER regex(?fname, '.*[.]pdf', 'i') }.

This last one took a while to work out because of the wildcard and the literal dot and basic regexp syntax is easy to forget if you don’t use it everyday 😉 Haven’t tried this with the bif syntax, but it should work if virtuoso is doing its thing.

The nepomuk ontology is not too complicated to once you remember the basics of sparql and regex, but it would also be good to have a Nepomuk sparql console in KDE to help set these things up and get feedback. I found one Nepomuk log (~/.kde/share/apps/nepomuk/repository/main/data/virtuosobackend/soprano-virtuoso.log), but I’m not sure its what would be needed in this case – it seemed to contain some syntax error messages that would have helped me, but also didnt seem to update in real time.

Another good reference is the KDE Nepomuk Manual blog : http://kdenepomukmanual.wordpress.com/. This explains Nepomuk integration in KDE and how it can be used, including the tag:/ protocol. Check out the Nepomuk tag manager at http://techbase.kde.org/Projects/Nepomuk/Repositories#Tag_Manager as well. (Further browsing here reveals a sparql console as well – the Nepomuk Shell).

Speaking of protocols, you can also use timeline:/ to get an historical inventory view of changes in Dolphin. (http://www.chakra-project.org/wiki/index.php?title=Nepomuk). For a list of protocols, expand the downarrow control to the very left of Dolphins search bar (when you clear the search bar that is) – timeline:/ and nepomuksearch:/ are listed under “other”.

Advertisements
Categories: semantic, technology Tags: , , ,
%d bloggers like this: