SPARQL query to get all parent of a node

Your data can be represented in RDF as data.n3: @prefix : <http://example.org/> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . :Network rdfs:subClassOf :Main . :ATM rdfs:subClassOf :Network . :ARPANET rdfs:subClassOf :Network . :Software rdfs:subClassOf :Main . :Linux rdfs:subClassOf :Software . :Windows rdfs:subClassOf :Software . :XP rdfs:subClassOf :Windows . :Win7 rdfs:subClassOf :Windows . :Win8 rdfs:subClassOf :Windows . From here, … Read more

How to get all companies from DBPedia?

You’re right that your query isn’t returning all the companies. The pattern is correct, though. Notice that this query which only counts the companies returns 88054: prefix dbpedia-owl: <http://dbpedia.org/ontology/> select (count(distinct ?company) as ?count) where { ?company a dbpedia-owl:Company } SPARQL results I think this is a limit imposed by the DBpedia SPARQL endpoint for … Read more

SPARQL functions in CONSTRUCT/WHERE

Yes this is possible You can’t use expressions directly in a CONSTRUCT template but you can assign the variable in the WHERE clause either via a SELECT expression in a sub-query or using BIND. In your case as GROUP_CONCAT is an aggregate it can only be a SELECT expression so you just need to put … 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

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

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