问题
I have following query:
# endpoint used: https://query.wikidata.org/
#
# PREFIX wd: <http://www.wikidata.org/entity/>
# PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/resource/>
SELECT DISTINCT ?musicianLabel
WHERE {
{
# *** dbpedia ***
SERVICE <http://dbpedia.org/sparql> {
#SERVICE <http://lod.openlinksw.com/sparql> {
?musician a dbo:Person .
{
# person, who has musical genre xy
?musician dbo:genre ?genre .
} UNION {
# the member (person) of a band, which has musical genre xy
?musician dbo:member|wdt:associatedBand ?band .
?band dbo:genre ?genre .
}
OPTIONAL {
?musician <http://www.w3.org/2000/01/rdf-schema#label> ?musicianLabel .
FILTER ( LANGMATCHES ( LANG ( ?musicianLabel ), 'en' ) )
}
FILTER ( ?genre IN (
dbp:Psychedelic_pop,
dbp:Psychedelic_rock,
#dbp:Psychedelic_Rock,
dbp:Acid_rock,
dbp:Psychedelic_folk,
dbp:Neo-psychedelia,
dbp:Space_rock,
dbp:Dream_pop
) )
}
} UNION {
# *** wikidata ***
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?musician wdt:P31 wd:Q5 ;
{
?musician wdt:P136 ?genre .
} UNION {
?musician wdt:P361|wdt:P463 ?band .
?band wdt:P136 ?genre .
}
FILTER ( ?genre IN (
wd:Q383982,
wd:Q206159,
wd:Q236932,
wd:Q1500364,
wd:Q703778,
wd:Q236913,
wd:Q592330
) )
}
}
GROUP BY ?musicianLabel
ORDER BY ASC(?musicianLabel)
My questions are:
How would I change the query to use http://lod.openlinksw.com/sparql instead of http://dbpedia.org/sparql in order to get more results?
even though I used DISTINCT and GROUP BY, there are still persons appearing more than once in the result list (i.e. "Anton Newcombe"). Why?
In dbpedia, a resource can have multiple URI's, some redirecting to the other. i.e.
dbp:Psychedelic_Rock
has resources attached, but redirects todbp:Psychedelic_rock
, which actually seems to be the URI one should use. How can I resolve this in the query, without having to manually look up withDESCRIBE dbp:Psychedelic_Rock
first? Probably something withdbo:wikiPageRedirects
or so?
来源:https://stackoverflow.com/questions/54220599/federated-sparql-query-in-dbpedia-and-wikidata-few-questions