我是语义网和 SPARQL 的新手。我正在制作音乐会的 RDFS。它有歌曲条目,如:
con:song04
rdfs:Class con:Repertoire;
rdfs:label "Deewani Mastani";
con:performedBy con:artist02.
con:performedBy con:artist05.
如果它们由同一位艺术家表演,我正在尝试获取歌曲列表及其数量。我一直在尝试一些来自 stackoverflow 的教程,但并没有达到我的目的。
我使用的查询可能完全错误,如果有人可以在这方面帮助我,这对学习很有帮助。我正在使用Apache Jena Fuseki进行查询。
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX co: <http://rhizomik.net/ontologies/copyrightonto.owl#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
prefix con: <http://www.example.com/paras/concert#>
#Use SPARQL to count and list the songs that two artists share.
SELECT ?songs (COUNT(?artist) AS ?count)
WHERE
{
?s rdfs:label ?songs .
?s rdf:type con:Repertoire.
?s con:performedBy ?artist.
?artist rdf:type con:Artist .
filter( ?count > 1 )
}