0

I'm trying to extract some data from dbpedia using SERVICE function of SPARQL.

In fact I want to extract the names, the lat and lot of all New York theaters. To check if an instance is a theater I can use http://dbpedia.org/class/yago/Theater104417809​. One example of a theater could be http://dbpedia.org/resource/Grand_Theatre_(New_York_City).

How to use service function for getting what I need in SPARQL?

** EDIT **

The query that I'm trying is the following one, but is not returning any value.

PREFIX dbpedia: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geos: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX : <http://www.semanticweb.org/frubi/ontologies/2017/10/puntsWIFI#>

SELECT *
WHERE {
  SERVICE <http://dbpedia.org/sparql/> {
    SELECT ?teatreName ?lat ?long
    WHERE {
      ?teatre rdf:type dbpedia:Theatre .
      ?teatre foaf:name ?teatreName .
      ?teatre geo:lat ?lat .
      ?teatre geo:long ?long .
      ?teatre dbp:city ?ciutat .
      ?ciutat rdfs:label "New York City"@en
    }
  } 
}
Claps
  • 11
  • 6
  • 2
    And which SPARQL query did you try? Have you read the [SPARQL Federated Query W3C doc](https://www.w3.org/TR/sparql11-federated-query/)? I mean, everything is explained there... – UninformedUser Jun 11 '18 at 05:47
  • @AKSW, Sorry for not adding which query I was executing, It's added now. – Claps Jun 11 '18 at 18:14
  • Ok, thanks. But I'm a bit confused. Did you ever try the query in DBpedia directly??? I mean. it returns nothing, thus, the issue here is not related to federated querying... – UninformedUser Jun 12 '18 at 05:40

1 Answers1

1

It's not an issue with federated querying, but with your DBpedia query. dbp:city is not an object property but simply of type rdf:Property, thus it's untyped. In your case, it maps to literals which means, you have to use the literal directly. The weird thing here is, that for some reasons you have to use the datatype http://www.w3.org/1999/02/22-rdf-syntax-ns#langString explicitly instead of "New York City"@en - that's clearly not intuitive for any user. Not sure whether this happened due to the DBpedia extraction or is the expected behaviour of Virtuoso.

PREFIX dbpedia: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geos: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX : <http://www.semanticweb.org/frubi/ontologies/2017/10/puntsWIFI#>

SELECT *
WHERE {
  SERVICE <http://dbpedia.org/sparql/> {
    SELECT ?teatreName ?lat ?long
    WHERE {
      ?teatre rdf:type dbpedia:Theatre .
      ?teatre foaf:name ?teatreName .
      ?teatre geo:lat ?lat .
      ?teatre geo:long ?long .
      ?teatre dbp:city "New York City"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>
    }
  } 
}
UninformedUser
  • 8,397
  • 1
  • 14
  • 23
  • That's what I was looking for, I could not find which datatype to use. That worked, but I would like to know how did you proceed to get this solution. Thanks – Claps Jun 12 '18 at 20:18
  • I simply replaced `"New York City"@en` with a variable to see the type of the bindings of `dbp:city` related objects. – UninformedUser Jun 13 '18 at 07:33