dbpedia fetch entitites in language other than english

点点圈 提交于 2019-12-01 07:30:19

问题


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.


回答1:


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".




回答2:


You are looking for rdfs:label for a name, of course all the names are English, you are looking at the English dbpedia.

PREFIX owl: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>
SELECT distinct *
WHERE {
    ?person a owl:Person .
    ?person rdfs:label ?name . 
    FILTER(lang(?name) = "fr")
}

Again, for the second one, if you replace the name with the rdfs: label you can have:

    PREFIX owl: <http://dbpedia.org/ontology/>
    PREFIX dbpprop: <http://dbpedia.org/property/>
    SELECT distinct *
        WHERE {
    ?person a owl:Person .
    ?person rdfs:label ?name .
    ?person dbpprop:language <http://dbpedia.org/resource/English_language>.
}


来源:https://stackoverflow.com/questions/29069479/dbpedia-fetch-entitites-in-language-other-than-english

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!