theud
theud

Reputation: 11

SPARQL: Get all properties we see in some DBpedia entity

I basically try to recover with sparql all the properties of the company entity "Apple_Inc." looking at http://dbpedia.org/page/Apple_Inc. I see for example the properties "is dbo:developer of", and "is dbo:cpu of".

But with this code

select distinct ?property where {
  ?instance a <http://dbpedia.org/ontology/Company> . 
  ?instance rdfs:label ?name.
  filter(regex(?name, "Apple Inc")).
  ?instance ?property ?obj .
}

I recover only a part of properties, and none of the two examples.

Upvotes: 1

Views: 1217

Answers (1)

Bierbarbar
Bierbarbar

Reputation: 1479

Hey simple solution of your problem. When in the DBpedia frontend is <something> of is shown it indicates that the entity that is described on the page you are looking for is the object of for the property not the subject.

For example the triple (dbr:IOS_8,dbo:developer,dbr:Apple_Inc.) will be shown in the frontend as is developer of because apple is the object not the subject oft the triple.

The following query should do the job:

  select distinct ?prop where {
  {?apple a <http://dbpedia.org/ontology/Company> . 
  ?apple rdfs:label ?name.
  filter(regex(?name, "Apple Inc"))}.

  {{?x ?prop ?apple} union {?apple ?prop ?y}}}

Upvotes: 2

Related Questions