0

Trying to query for the most referenced SKOS concept in an RDF/XML file.

So if a concept looks like this in the file:

<rdf:Description   rdf:about="http://foo.bar.biz/Processes/151">
    <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
    <skos:prefLabel xml:lang="en">Part</skos:prefLabel>
    <skos:related rdf:resource="http://foo.bar.biz/Processes/150"/>
</rdf:Description>

How can I construct a SPARQL query that targets the skos:related tag ? I'm looking into RDFLib in Python right now, which has SPARQL compatibility. Seems like a query would be more appropriate than parsing the entire file - just not familiar enough with SPARQL syntax I suppose.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
ramenhood
  • 48
  • 5
  • 3
    I don't think it really helps your understanding of SPARQL if you just ask "please write this query for me". Try reading one of the many available SPARQL tutorials, they teach you the basics of the language, after which you should be able to figure this out quite easily. Or just have a look at some of the questions here on SO, there's plenty of good examples. – Jeen Broekstra Feb 18 '16 at 03:00

1 Answers1

2

As Jeen suggests, finding out more about SPARQL is a good idea. As an initial reference, this is pretty easy:

SELECT ?related
WHERE {
    ?s skos:related ?related
}

A more useful suggestion may be to view the data in any RDF text serialization other than RDF/XML, which is difficult for humans to parse out the triples, and hence understand how to query it. For example, the equivalent snippet in the Turtle text serialization is:

<http://foo.bar.biz/Processes/151> 
    rdf:type skos:Concept ;
    skos:prefLabel "Part"@en ;
    skos:related <http://foo.bar.biz/Processes/150>
.

...and you may find that more compatible with understanding how RDF is structured and how SPARQL can be used to query it.

scotthenninger
  • 3,921
  • 1
  • 15
  • 24