简体   繁体   中英

DBPedia SPARQL query should return results but is empty

I want to get all pages which have a specified category and a specified key. My query:

PREFIX dbpedia: <http://dbpedia.org/>
PREFIX dbpedia2: <http://dbpedia.org/property/> 
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://dublincore.org/2010/10/11/dcterms.rdf#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX grs: <http://www.georss.org/georss/point>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?page ?cat ?key ?value (lang(?value) as ?language) WHERE {

  ?page dcterms:subject ?cat .
  ?page ?key ?value .

  FILTER(
    regex(?cat, "category:Amusement_parks_in_the_Netherlands") &&
    ?key = foaf:depiction
  )

}

But it return zero results. See here: SNORQL query

It should at least return this page: http://dbpedia.org/page/Duinrell (because it matches the criteria).

Any ideas?

There's a couple of things wrong with your query. First of all, don't use a regex when comparing URIs. Instead of:

regex(?cat, "category:Amusement_parks_in_the_Netherlands")

use:

?cat = <http://dbpedia.org/resource/category:Amusement_parks_in_the_Netherlands>

Second: your namespace prefix for dublin core seems wrong. You are querying the property dcterms:subject , and in your query, the prefix dcterms is mapped to the namespace http://dublincore.org/2010/10/11/dcterms.rdf# . However, the actual property in DBPedia is http://purl.org/dc/terms/subject , so your namespace prefix should map to http://purl.org/dc/terms/ instead.

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