1

I am beginner in SPARQL, and I want to make query on DBpedia to use the result then in Java-Programm as a JSON file . I use this simple SPARQL query on http://dbpedia.org/snorql or https://dbpedia.org/sparql

PREFIX owl: <http://www.w3.org/2002/07/owl#>    
PREFIX : <http://dbpedia.org/resource/>

SELECT ?a    
WHERE {    
 :Berlin owl:sameAs ?a .    
}

And I get this result, but I want to extract these words, which are highlighted in yellow, and exclude everything else. Is it doable, or should I continue this part in Java?

UninformedUser
  • 8,397
  • 1
  • 14
  • 23
Eddi
  • 55
  • 5
  • 1
    Was asked here dozens of time. You have to get the label (`rdfs:label`) of the resources. Indeed, only the URIs are shown as RDF resources are identified by URIs – UninformedUser Dec 13 '17 at 10:51
  • If there is no such label - `owl:sameAs` might link to external datasets, you can try to get what you're after by String functions of the SPARQL 1.1 language – UninformedUser Dec 13 '17 at 11:01
  • `BIND(REPLACE(STR(?a), '(http://[a-z][a-z].dbpedia.org/resource/)', '') AS ?label)` – UninformedUser Dec 13 '17 at 11:13
  • 1
    Possible duplicate of [Why does my SPARQL query return the URI of a resource instead of its name?](https://stackoverflow.com/questions/28479394/why-does-my-sparql-query-return-the-uri-of-a-resource-instead-of-its-name) – Jeen Broekstra Dec 14 '17 at 05:35

0 Answers0