简体   繁体   中英

SPARQL query for skos:related field?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM