Search code examples
sparqldbpedia

Can not get all properties for a DBpedia class


I use Sparql to get all property for a specific class with this code.

PREFIX db: <http://dbpedia.org/resource/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX onto: <http://dbpedia.org/ontology/>
select ?property ?value 
where { db:Thin-film-transistor_liquid-crystal_display ?property ?value . }

However, the output result is missing some properties as:

is dbpprop:display of   dbpedia:IPhone_4S
                        dbpedia:IPhone_5S
is dbpprop:industry of  dbpedia:InnoLux_Corporation
is dbpprop:paneltype of dbpedia:Dell_monitors
is dbpprop:products of  dbpedia:Zalman

How can I get those properties?


Solution

  • The properties that you have mentioned have one important bit in common, "OF". This means that the item you are looking for is the "object" and not the "subject" and you are searching for the "objects". Therefore, if you swap your subject and object in the query, you will find them:

    PREFIX db: <http://dbpedia.org/resource/>
    PREFIX prop: <http://dbpedia.org/property/>
    PREFIX onto: <http://dbpedia.org/ontology/>
    select ?property ?value 
    where { 
        ?value ?property db:Thin-film-transistor_liquid-crystal_display. 
    }
    

    So, if you want to get everything out, one way is to a union:

    PREFIX db: <http://dbpedia.org/resource/>
    PREFIX prop: <http://dbpedia.org/property/>
    PREFIX onto: <http://dbpedia.org/ontology/>
    select ?property ?value 
    where { 
    {
       db:Thin-film-transistor_liquid-crystal_display ?property ?value. 
    }
    union{
        ?value ?property db:Thin-film-transistor_liquid-crystal_display. 
    }
    }