Federated SPARQL query in dbpedia and wikidata: Few questions

让人想犯罪 __ 提交于 2019-12-25 00:28:24

问题


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 to dbp: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 with DESCRIBE dbp:Psychedelic_Rock first? Probably something with dbo:wikiPageRedirects or so?

来源:https://stackoverflow.com/questions/54220599/federated-sparql-query-in-dbpedia-and-wikidata-few-questions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!