get latitude and longitude of a place dbpedia

You can use Jena’s ARQ to execute queries against remote SPARQL endpoints. The process is described in ARQ — Querying Remote SPARQL Services. Using ParameterizedSparqlStrings in SELECT queries To do this for different places that you might not know until it is time to execute the query, you can use a ParameterizedSparqlString to hold the query and … Read more

Exclude results from DBpedia SPARQL query based on URI prefix

It might seem a little awkward, but your comment about casting to a string and doing some string-based checks is probably on the right track. You can do it a little bit more efficiently using the SPARQL 1.1 function strstarts: SELECT DISTINCT ?concept WHERE { ?x a ?concept FILTER ( !strstarts(str(?concept), “http://dbpedia.org/class/yago/”) ) } LIMIT … Read more

Some cities aren’t instances of city or big city? Odd behaviour of Wikidata

These missing statements are not truthy: SELECT ?statement ?valueLabel ?rank ?best WHERE { wd:Q1733 p:P31 ?statement. ?statement ps:P31 ?value . ?statement wikibase:rank ?rank . OPTIONAL { ?statement a ?best . } SERVICE wikibase:label { bd:serviceParam wikibase:language “en”. } } Try it! They are normal-rank statements, but there is a preferred-rank statement. Truthy statements represent statements … Read more

Exploratory SPARQL queries?

Well, the obvious first start is to look at the classes and properties present in the data. Here is how to see what classes are being used: SELECT DISTINCT ?class WHERE { ?s a ?class . } LIMIT 25 OFFSET 0 (LIMIT and OFFSET are there for paging. It is worth getting used to these … Read more

wikidata get all properties with labels and values of an item

Useful links on the Wikidata data model: RDF dump format Wikidata qualifiers, references and ranks Help:qualifiers Your query should be of this kind: SELECT ?wdLabel ?ps_Label ?wdpqLabel ?pq_Label { VALUES (?company) {(wd:Q95)} ?company ?p ?statement . ?statement ?ps ?ps_ . ?wd wikibase:claim ?p. ?wd wikibase:statementProperty ?ps. OPTIONAL { ?statement ?pq ?pq_ . ?wdpq wikibase:qualifier ?pq … Read more

Why does my SPARQL query return the URI of a resource instead of its name?

Non-anonymous resources in RDF and OWL are identified by IRIs. Your ontology clearly says that http://www.w3.org/2002/07/owl#aqua is class. If you ask for the class, that’s what you should get. It might be that Protege strips off the http://www.w3.org/2002/07/owl# part when it displays the result, but the result is still actually the IRI. Note: you really … Read more

DBpedia Jena Query returning null

that is so embarassing, there is space problem in the query: String service = “http://dbpedia.org/sparql”; String queryString = “”; queryString = “PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label ” + “WHERE {” + “<http://dbpedia.org/resource/Quatre_Bornes> <http://dbpedia.org/ontology/country> ?y .”+ “?y rdfs:label ?label .”+ “FILTER (LANG(?label) = ‘en’)”+ “}”;

Finding all steps in property path

While there are some limitations in what property paths can do, depending on your exact requirements, you may be able to get what you need here. Consider this data: @prefix : <urn:ex:>. :a :relatedTo :b . :b :relatedTo :c . :c :relatedTo :d . :a :relatedTo :e . :e :relatedTo :f . :f :relatedTo :g … Read more

tech