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

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

Aggregating results from SPARQL query

You can GROUP BY by the variables that identify the tweet and then use GROUP_CONCAT to concatenate the hashtags into something like an array, but it will still be a string that you’ll need to parse afterward. For instance, given data like @prefix smo: <http://example.org/> . @prefix : <http://example.org/> . :tweet1 smo:tweeted_at “1” ; smo:has_hashtag … Read more

tech