sparqlowlwikipediadbpediafoaf

dbpedia fetch entitites in language other than english


I'm trying to extract entity dictionary contains person name etc. from dbpedia using sparql.

PREFIX owl: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>
SELECT ?name
WHERE {
    ?person a owl:Person .

    ?person dbpprop:name ?name . FILTER(lang(?name) = "en")
}

The query above did succeed, but when I change the language name to fr, there is nothing to fetch.

How can I fetch names in other languages?

Moreover, why can't I filter language using query below?

SELECT ?name
WHERE {
    ?person a owl:Person .
    ?person dbpprop:language "English"
    ?person dbpprop:name ?name . 
}
// this query returns nothing

I tried to fetch all languages using

SELECT DISTINCT ?lanName
WHERE {
    ?person a owl:Person .
    ?person dbpprop:language ?lanName .
}

and the result set contains English.


Solution

  • You need to filter based on the language of the value of the property. Not every property will have values in different languages, but some properties will. It seems, from your example, that dbpprop:name doesn't have values in every language. You may find more values in other languages if you look on the other language specific DBpediae.

    However, for something like a name, you'll probably get multi-language results if you use the rdfs:label property. For instance, to get the names of Barack Obama, Daniel Webster, and Johnny Cash in Russian, you could do:

    select ?label {
      values ?person { dbpedia:Johnny_Cash dbpedia:Barack_Obama dbpedia:Daniel_Webster }
      ?person rdfs:label ?label .
      filter langMatches(lang(?label),"ru")
    }
    

    SPARQL results

    As an aside, note the use of langMatches rather than equality for matching language tags. This is usually a better approach, because it will correctly handle the different language tags within a language For example (from the SPARQL specification), you can find both of the French literals:

    "Cette Série des Années Soixante-dix"@fr .
    "Cette Série des Années Septante"@fr-BE .
    

    with langMatches(lang(?title),"fr"), but only the first one with lang(?title) = "fr".