W3C home > Mailing lists > Public > public-esw-thes@w3.org > October 2010

Re: SKOS query in SPARQL 1.1

From: Bob DuCharme <bob@snee.com>
Date: Sat, 16 Oct 2010 09:52:04 -0400
Message-ID: <4CB9AE04.7030307@snee.com>
To: danbri@danbri.org, public-esw-thes@w3.org
  The blog posting Dan mentions covers property paths as one set of new 
SPARQL 1.1 features. I covered other new features at 
http://www.snee.com/bobdc.blog/2010/08/trying-sparql-11-new-query-fea.html.

For using property paths with SKOS, here are a few queries off the top 
of my head with the International Virtual  Observatory Alliance SKOS 
thesaurus available at 
http://www.ivoa.net/rdf/Vocabularies/vocabularies-20091007/IAUT93/ . (If 
I brought over my neighbor who knows a lot more about astronomy than I 
do, that would probably make these better.)

All queries assume @prefix i: 
<http://www.ivoa.net/rdf/Vocabularies/IAUT93#> and @prefix skos: 
<http://www.w3.org/2004/02/skos/core#> .

1. Get all data in the subtree under the top level concept i:VariableStars:

SELECT *
WHERE {
   ?c skos:broader* i:VariableStars .
   ?c ?p ?o .
}


2. What concepts are skos:related to the same concepts that i:BlackHoles 
is related to?

SELECT DISTINCT ?c
WHERE {
   i:BlackHoles skos:related^skos:related ?c .
   FILTER (?c != i:BlackHoles)
}


3. Working in some of SPARQL 1.1's aggregate functions 
(http://www.w3.org/TR/sparql11-query/#aggregates) can help to analyze a 
particular vocabulary. For example: how many nodes are there six levels 
down?

SELECT (COUNT(?b) as ?sixDeep)
WHERE {
   ?c skos:broader{6} ?b .
}


Bob


-----Original Message-----

From: Dan Brickley [mailto:danbri@danbri.org]
Sent: Saturday, October 16, 2010 6:04 AM
To: SKOS

Subject: SKOS query in SPARQL 1.1

Hello SKOS people,

http://www.snee.com/bobdc.blog/2010/10/playing-more-with-sparql-11-pr.html
from Bob DuCharme might be of interest.

"Playing more with SPARQL 1.1 property paths"

It describes some new language features in SPARQL (along with their
implementation in ARQ, Jena's query engine; Java software).

The new SPARQL draft includes a 'property paths' feature,
http://www.w3.org/TR/2010/WD-sparql11-query-20101014/#propertypaths

"A property path is a possible route through a graph between two graph
nodes. A trivial case is a property path of length exactly 1, which is
a triple pattern. Property paths allow for more concise expression of
some SPARQL basic graph patterns and also add the ability to match
arbitrary length paths. The ends of the path may be RDF terms or
variables. Variables can not be used as part of the path itself, only
the ends. Query evaluation determines all matches of a path expression
and binds subject or object as appropriate."

This should lend itself to SKOS (and Bob reports some success there),
since we often have hierarchies of skos:broader to traverse. If anyone
experiments with this, I'm sure everyone here would be happy to see
some summary and sample queries. The SPARQL Working Group might
appreciate feedback too.

cheers,

Dan
Received on Saturday, 16 October 2010 13:51:08 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 2 March 2016 13:32:14 UTC