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: <> 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

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 is class. If you ask for the class, that’s what you should get. It might be that Protege strips off the 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

SPARQL: is there any path between two nodes?

While you can’t use variables in property paths, you can use a wildcard by taking advantage of the fact that for any URI, every property either is that property or isn’t. E.g., (<>|!<>) matches any property, since every property either is <> or isn’t. You can make a wildcard that goes in either direction by … 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: <> . @prefix : <> . :tweet1 smo:tweeted_at “1” ; smo:has_hashtag … Read more