Search code examples
sparqldbpedia

Sparql dbpedia query


I want to make a query ( SPARQL) to select from dbpedia DB:

  • the purpose of my query is to get the definition of any given name :

Example : i want to find the definition of name Victor

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
CONSTRUCT { <http://example.org/person#Alice> foaf:description ?x }
FROM <http://example.org/foaf/people>
WHERE { ?x foaf:name ?name }
ORDER BY desc(?name)
LIMIT 10

I Think there's no foaf property called description , so i need the query which return this property


Solution

  • The DBpedia dataset has meanings of names. Here is one way of querying them with SPARQL:

    PREFIX  dbpedia-owl:  <http://dbpedia.org/ontology/>
    PREFIX      dbpprop:  <http://dbpedia.org/property/>
    SELECT  ?name 
            ?meaning
      WHERE 
        {
          ?s                a  dbpedia-owl:Name
           ;     dbpprop:name  ?name 
           ;  dbpprop:meaning  ?meaning 
           .  FILTER (str(?name) = "Victor")
        }
    

    Or, if you want RDF triples, use a CONSTRUCT query:

    PREFIX  dbpedia-owl:  <http://dbpedia.org/ontology/>
    PREFIX      dbpprop:  <http://dbpedia.org/property/>
    CONSTRUCT { ?s  dbpprop:meaning  ?meaning }
    WHERE 
      {
        ?s                a  dbpedia-owl:Name 
         ;     dbpprop:name  ?name 
         ;  dbpprop:meaning  ?meaning 
         .  FILTER (str(?name) = "Victor")
      }
    

    I think that the FOAF vocabulary is mostly suitable for describing individual persons, organizations, documents, and so on, rather than more abstract concepts like meanings of names, so this is just using the original DBpedia vocabularies.