Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get all attributes of a person in dpbedia, not just specific attributes queried

I know you can get a list of all of the attributes and a list of all people via the simple query:

select distinct ?property where {
         ?instance a <http://dbpedia.org/ontology/Person> . 
         ?instance ?property ?obj . }

but how do I get all information of a person available without having to enter in each of those quantities? Select * doesn't extract all variables as it would in SQL.

SELECT * WHERE
{ ?p a <http://dbpedia.org/ontology/Person> .
?p <http://dbpedia.org/ontology/knownFor> ?knownFor . }
LIMIT 10

This only gives me the person and the knownfor attribute. I thought select * gives all quantities? In any case, I want not just the person or their knownfor attribute, but all values possible for each person.

like image 407
Griff Avatar asked Dec 26 '22 14:12

Griff


2 Answers

You cant't get the attributes as columns, but still it's possible to get al properties/values as rows.

This query gets all properties for all the resources of type Person:

SELECT ?person ?prop ?value WHERE 
{
    ?person a <http://dbpedia.org/ontology/Person> .
    ?person ?prop ?value .
    FILTER ( langMatches(lang(?value), "en") )   
}
LIMIT 100

Hope it helps!

like image 182
conca Avatar answered Feb 01 '23 23:02

conca


@conca already gave you a simple SELECT query that returns the data you want.

As an alternative, you could look at a CONSTRUCT or DESCRIBE query, the result of which will not be a table-like structure, but an actual RDF graph. For broad "tell me everything you know about a particular topic"-type queries, these are often easier to work with:

CONSTRUCT 
WHERE { ?person a <http://dbpedia.org/ontology/Person> ; 
                ?prop ?value . 
} 
LIMIT 100

or

DESCRIBE 
WHERE { ?person a <http://dbpedia.org/ontology/Person> } 
LIMIT 100 
like image 27
Jeen Broekstra Avatar answered Feb 02 '23 01:02

Jeen Broekstra